collapse

Author Topic: Faceting machine head assembly.  (Read 22840 times)

Alaskan

  • ALF'er Silver Member
  • *
  • Posts: 54
  • Will AI have curiosity and a sense of humor?
Re: Faceting machine head assembly.
« Reply #120 on: July 08, 2024, 03:41:52 AM »
Hi Frank, my shop is getting a new roof which was getting worse wi annoying leaks & buckets and such catching drips so my faceting is taking a backseat. My Supernova is currently stopped at the table just above the meets @#5 Diamond - going to #14 then #50 as soon as roof is done... lots of mistakes but beautiful - patience of pushing on too soon is my biggest shortcoming - this winter when snow and rain going sideways is my time to build the hardware and box then coding Arduino which will be me begging for help. Thank you all!

RoughCreations

  • Administrator
  • ALF'er Platinum
  • *****
  • Posts: 409
    • Rough Creations homepage
Re: Faceting machine head assembly.
« Reply #121 on: July 08, 2024, 10:54:34 AM »

 Anyway, I know the numbers on the top line on my screen will be badly affected by any lap flutter. So, I was thinking of using the 20 step encoder I have to create a set of millisecond delays in the millis function. Having the top line print out to suit the dialled in delay the 20 step encoder is set at to suit the lap rotation.
Sounds good, but need to look at more vids on how to make it work.


My LCD screen code (you should already have a copy) has a section that addresses lap flutter, worth a look for some ideas.
Anywhere the variable padTime appears is relevant, and particularly the snippet below that uses a 7-value moving average (and an array) to reduce or smooth the output by only displaying an averaged value to the screen every padTime milliseconds:

Code: [Select]

 //========================================================================================
  // Display averaged angle info.
  //========================================================================================
                                     
  sumArray = 0;
       
  for (int k = 0; k < 7; k++) {
    sumArray = sumArray + liveAng[k];
    liveAng[k] = liveAng[k+1];                            // shift all array elements to the left one place
  }
  liveAng[6] = theAng;

  u8g2.setCursor(2, 52);
  u8g2.setFont(u8g2_font_helvR08_tr);
  u8g2.print("Averaging mS: ");

  if (millis() - lastTimeRun > padTime) {
lastTimeRun = millis();
    movingA = sumArray / 7;                               // calculate the (moving) average   
}
 
  if ((changeRotVal != padTime) && (millis() - enc_change_time < 1500)) {
    u8g2.print(changeRotVal);
  } else {
    u8g2.print(padTime);
  }


I have a little rotating encoder to dial in the amount of smoothing, then the encoder is pressed (my rotary_onButtonClick() function) to save the desired value to the flash memory.

RC
Rough Creations - Beauty from rough beginnings

Faceting Frank

  • Global Moderator
  • ALF'er VIP
  • *****
  • Posts: 583
Re: Faceting machine head assembly.
« Reply #122 on: July 09, 2024, 07:51:36 PM »
The way I see your code RC, is it taking an average of several loop readings and printing that on the screen, which will take away the flutter and give you an average over the swing across the lap as well. Not that I understand the code but that is what I think it does.
 I can’t test any type of delay function at the moment till I fit the encoder to the machine.

RoughCreations

  • Administrator
  • ALF'er Platinum
  • *****
  • Posts: 409
    • Rough Creations homepage
Re: Faceting machine head assembly.
« Reply #123 on: July 11, 2024, 09:50:59 AM »
The way I see your code RC, is it taking an average of several loop readings and printing that on the screen, which will take away the flutter and give you an average over the swing across the lap as well. Not that I understand the code but that is what I think it does.
 I can’t test any type of delay function at the moment till I fit the encoder to the machine.

Almost.

The important bit, particularly the first line, is:
Code: [Select]
 
if (millis() - lastTimeRun > padTime) {
    lastTimeRun = millis();
    movingA = sumArray / 7;                               // calculate the (moving) average   
}

The 7 value moving average is calculated only every 'padTime' interval.
For example, if I set my smoothing to, say, 200mS (a fifth of a second) with my rotating knob, every 200mS the moving average is instantly calculated (the third line), and then the value is sent to the screen to be displayed (further in the main code).
If no smoothing algorithm is used with a fast controller like the ESP32, you get a screen refresh every few milliseconds (each loop) making for massive electronic/lap flutter.
The use of smoothing code gives you total control over what is sent to the screen, and how often. You could have a 10 value (or more) moving average if you wanted, but I find 7 works for me. I select the interval between discrete calculations/screen displaying events (with the knob) instead, a greater interval for a coarse, uneven lap, a smaller interval for a fine, even lap.

RC
« Last Edit: July 11, 2024, 10:03:32 AM by RoughCreations »
Rough Creations - Beauty from rough beginnings

RoughCreations

  • Administrator
  • ALF'er Platinum
  • *****
  • Posts: 409
    • Rough Creations homepage
Re: Faceting machine head assembly.
« Reply #124 on: July 12, 2024, 10:00:48 AM »
Also, the smoothing code is important to designate at what point you have actually reached the Target Angle. With an uneven lap, changing pressure applied to the stone during cutting (by your fingers) causing flex in different parts of your machine including the platen and lap assembly - when have you actually reached your angle? Is it the very first time the angle is reached, or after the 7-value moving average says so, or some other condition you choose? You can control this and you can fire off a visible and audible signal when the trigger conditions are met. Incidentally I even think there is some wander in the readings due to thermal expansion of the metal dop and quill during cutting from the warmth of your fingers and hand, small in scale I know - but it can all add up.

RC
« Last Edit: July 12, 2024, 10:09:27 AM by RoughCreations »
Rough Creations - Beauty from rough beginnings

Faceting Frank

  • Global Moderator
  • ALF'er VIP
  • *****
  • Posts: 583
Re: Faceting machine head assembly.
« Reply #125 on: July 12, 2024, 12:40:55 PM »
My faceting machine has a 1/6hp 3 phase motor on it, running through a lenze controller and a separate control box with on/off and dial speed control.
The Lenze box has a digital display of the % of the maximum speed the motor is running at and the motor will quit happily run at 6-7% speed and still have enough grunt to lightly cut with a 1200 grit lap. My theory is that I can have a number of millis() delays to suit different motor speeds by using the 20 step encoder. Currently I put an ink mark in the center of the 1200 lap while its dry and finish cutting the facet at that point, using the dial gauge as a stop. That cuts out any side to side sweep variations on the dial gauge. That should work the same with the encoder as well, the difference being the angle will be accurate.

Faceting Frank

  • Global Moderator
  • ALF'er VIP
  • *****
  • Posts: 583
Re: Faceting machine head assembly.
« Reply #126 on: July 12, 2024, 07:43:51 PM »
Took me all afternoon to get the preferences code working, kept coming up with old saved angles and I couldn't work out what the eenc90 did. But it works ok now and this is it.

#include<Preferences.h>
Preferences preferences;

Void setup()
.
.
preferences.begin("encoder", false);
eStoredAngle = preferences.getFloat("eStoredAngle", 0.0);
preferences.end();

void loop()
.
.
references.begin("encoder", false);
preferences.putFloat("eStoredAngle",eStoredAngle);// Write stored target angle to Flash memory
preferences.end();


Faceting Frank

  • Global Moderator
  • ALF'er VIP
  • *****
  • Posts: 583
Re: Faceting machine head assembly.
« Reply #127 on: July 14, 2024, 11:24:50 AM »
Have marked the 0-90-210deg positions on the plastic knob I have fitted to the encoder. 210deg being the quill rest position which is 30deg past vertical. Have kept that 0-210deg area away from the 0-20,000 changeover point on the encoder, as the angle goes all over the place if you go back and forth through that point.
As I understand it from Tom’s book, you change the number on line 29 of Tom’s code to initially set the 90deg position of the quill, as shown on page 413 of his book. This would mean downloading code to the encoder setup every time you want to change the setting.  I know that any changes on the faceting machine will mess that setting up.
I don’t see anything in Tom’s code to shows that that number on line 29 can be changed by pressing a button, as on the UltraTech machine. I was thinking of adding a pushbutton setting in the code to do that.
The code I have for storing the target angle with a push button is shown below.

// My button pin setup
 {buttonRead=digitalRead(buttonPin);
 Serial.println(buttonRead);
 
 if (buttonRead==1) {
  digitalWrite(GREEN_pin,LOW);
 }
 if(buttonRead==0){
 digitalWrite(GREEN_pin,HIGH);
 }
if (buttonRead==0){
 (eStoredAngle=(90+ (1.0*encPos-enc90)*degPerStep));
 }
 }
eStoredAngle being the variable name for the target angle and is printed on the screen.
That is then stored in what I think is called the flash memory with the preferences function, so it stays on the screen till it’s changed to a new angle.

Got a lot of trial end error stuff to do with the push button idea for setting the 90deg, but if the number on line 29 was saved as a variable called “90degset” for example.
 (My line 29 number is 10911 for where I want the 90deg position to be on the encoder.)
 You could store it with the preferences function and change it at any time with a pushbutton if needed.



Faceting Frank

  • Global Moderator
  • ALF'er VIP
  • *****
  • Posts: 583
Re: Faceting machine head assembly.
« Reply #128 on: July 19, 2024, 03:13:31 PM »
Just started working on your varying millis() delay code RC. I just noticed a couple of days ago there is a 100ms delay running in Tom's code. I knew there was a millis() statement at the start of the loop with some other bits with it but didn't realize he had a variable set to 100ms in the top part of the code.

RoughCreations

  • Administrator
  • ALF'er Platinum
  • *****
  • Posts: 409
    • Rough Creations homepage
Re: Faceting machine head assembly.
« Reply #129 on: July 19, 2024, 04:31:21 PM »
Just started working on your varying millis() delay code RC. I just noticed a couple of days ago there is a 100ms delay running in Tom's code. I knew there was a millis() statement at the start of the loop with some other bits with it but didn't realize he had a variable set to 100ms in the top part of the code.

Yes, you're right, just had a look at Tom's code again - hadn't noticed that before. It looks like you have developed a good understanding of it all.

RC
Rough Creations - Beauty from rough beginnings

MakkyBrown

  • Administrator
  • ALF'er VIP
  • *****
  • Posts: 1813
    • Andrew Brown Faceting Designs
Re: Faceting machine head assembly.
« Reply #130 on: July 20, 2024, 01:46:01 AM »
millis() is not a delay it is a timer. Delays are bad, far better to use timers like micros()and millis()
MB

Faceting Frank

  • Global Moderator
  • ALF'er VIP
  • *****
  • Posts: 583
Re: Faceting machine head assembly.
« Reply #131 on: July 20, 2024, 11:35:56 AM »
I know the difference between millis and delay MB. Delay will stop the loop from running for the delayed time, as millis will continue till a specified millisecond time has been reached and then do something. For example, you can have two LED lights blink, one at 500ms and the other at 200ms, as well as carry on with other functions.
Both the buttons I have display their on-off state on the PC screen 1 for off and 0 for pressed. If I press one it will display 1-0-1-0 etc. and if I press both 0-0-0-0 will be displayed. This also shows the speed of the loop by how fast these numbers go up the screen.
On Toms code line 52 is the variable “rate” of 100ms, that is used in line 134. That “rate” number effects the entire loop, I know that by the fact it will change the speed of the button number display speed.
On my LED screen I have the “rate” displayed as well as the number the 20 step encoder is set at. The step encoder has no memory so will always display 0 at startup regardless of position. That number variable is called “counter”, so I want to add a line to the loop, rate=rate*counter;. I think that would be the correct maths to change rate to 200-300-400 etc. by turning the encoder dial. The original number on line 52 will have to be smaller. The theory being I could dial in a screen delay to suit the lap speed.





Faceting Frank

  • Global Moderator
  • ALF'er VIP
  • *****
  • Posts: 583
Re: Faceting machine head assembly.
« Reply #132 on: July 20, 2024, 02:37:26 PM »
Got that wrong about the 100ms affecting the buttons, the 0 or 1 from a button races up the screen when pressed. But is significantly slowed down if I change it to 1000ms.

MakkyBrown

  • Administrator
  • ALF'er VIP
  • *****
  • Posts: 1813
    • Andrew Brown Faceting Designs
Re: Faceting machine head assembly.
« Reply #133 on: July 21, 2024, 01:27:33 AM »
Your serial prints also slow down the code looping liked a delay. Comment them out on your final version. You could swap to making buttons on the TFT touch screen then you don't need any physical buttons as you can put them on the touch screen.
MB

Faceting Frank

  • Global Moderator
  • ALF'er VIP
  • *****
  • Posts: 583
Re: Faceting machine head assembly.
« Reply #134 on: July 21, 2024, 08:15:06 AM »
I don’t see me learning how to use a touch screen MB till after I have this fitted and working on my faceting machine. The YouTube vids I look at on how to use certain functions like millis() for example use LED screens. I think because they are so simple to use and a beginner like me can easily learn how to use one. 

 

Recent Activities

Recently cut gems (AB Facet Designs) by mehoose
[Today at 03:40:59 PM]


Magnetic Encoders by MakkyBrown
[Today at 01:18:03 PM]


rock or stone by Jimnyjerry
[February 08, 2025, 02:07:53 PM]


Hi Back again by Butts
[February 03, 2025, 02:51:19 PM]


Pendant findings by Faceting Frank
[February 01, 2025, 09:54:45 AM]


Castlemaine Victoria by Rusted
[January 29, 2025, 09:43:25 AM]


Faceting machine encoder by RoughCreations
[January 24, 2025, 10:57:36 AM]


Good vs Bad cutting by RoughCreations
[January 21, 2025, 09:52:33 PM]


Save the Gemfields. by pc bowe
[January 21, 2025, 06:48:25 AM]


Question re tumbling with 80 grit for more than one week by Rock gal
[January 21, 2025, 12:39:30 AM]


Tooraweenah opal by ann3244
[January 19, 2025, 05:34:50 PM]


Cutting Oregon Sunstones: A Step-by-Step Guide by Azard_faza
[January 16, 2025, 08:37:53 PM]


Tolmie / toombullup by swirly
[January 16, 2025, 03:09:28 PM]


Mount Eliza quarry Mornington Peninsula by RufusD
[January 15, 2025, 10:29:11 PM]


Tumbled and polished Chinchilla petrified wood by MakkyBrown
[January 12, 2025, 01:36:23 PM]

SimplePortal 2.3.7 © 2008-2025, SimplePortal