Tips for Arduno software for Rotary Table Controllers

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
I downloaded your code, Rod, and it will not compile. Many errors. Are you using the libraries that came with the Arduino IDE, or new ones?.
First error is " 'LCD' does not name a type."

Chuck
 
Hi guys, I've attached an update for my faithful beta testers. The code has been changed quite a lot so beware any bugs!

We now have the following features:
1. Menu has changed to make it flatter. To open a menu procedure, press the up or down arrows
2. Pressing Select exits a procedure.
3. Divide feature entering # of divisions
4. Divide feature by entering Degrees, Minutes, Seconds. Cursor left and right along the field and change digits with the up and down buttons. Press Select to move to operation
5. Jog function. Rotary Table operates continuously while the left or right button is held down. Up and down button moves stepper NUMBER_JOG_STEPS each button press. This should let you get a perfect setup if say you wanted to drill holes in the side of a hex bar.

The other feature I want to add is the ability to remember a home position and be able to return to that position by simply pressing a button. That needs a bit of thought as the distance from home needs to be maintained within the ISR procedure.

It works on my arduino, but I dont have a stepper motor to try it with. I LOVE the menu, and the method of entering numbers, its just what I was planning. GREAT JOB

A couple of issues I found...

After program set and running, the display shuts off after 30 seconds. This would happen while cutting a gear tooth and appears to be power saving feature that may have been copied from another sketch?

The user must hit a key to reactivate the display, then hit right button to advance the rotary table. I'd prefer to have the display remain active. I doubt anyone is using battery power so power conservation not an issue.

Issue two, when setting degrees if you mistakenly enter a value in the 100's of degrees column (say 100 00' 00") there is no way to clear the 100's integer value back to zero, you are stuck with either 1, 2 or 3. The only option is to reset the arduino and start over. This could be fixed to allow zero as a valid input

Question, would it be easy to change the ratio and math to make this work to control a non rotary table indexing head with 5 to 1 ratio with the obvious limitation on step resolution to 0.36 deg per step?

photo.jpg
 
Hi Rod

Very nice work !
I had a few minutes at lunch time to try it, Everything works great. I also agree with TB about the screensaver. But I just increased the wait time to 3 minutes, which I think will be fine for now. A lot will depend on what has to be done when you get to the indexed position.

Thank you so much for all of your hard work, it is appreciated very much !

Scott
 
I thought I'd try to make a quick change to see how easy this sketch would be to adapt to a more basic indexing head.

I changed the step resolution to 1000 to reflect 200 full steps per motor x 5 for the 5 to 1 gear ratio. Then I programmed in 6 deg per step... but the math converted to 62 steps when the result should have been 60 teeth...

see image 1

I then tried 1200 steps per revolution and got a good result for that one gear setting at least...

see image 2

anyway I'll have to play with this more to understand the math and rounding the sketch is doing.

photo (1).jpg


photo (2).jpg
 
The timer library link shows 2 libraries. Which one do I need?
I have the Sainsmart LCD. I will try it with that.

Chuck
 
The timer library link shows 2 libraries. Which one do I need?
I have the Sainsmart LCD. I will try it with that.

Chuck

The newest one... check the dates. I had no trouble with my sainsmart lcd display and keypad.
 
Thanks to these threads on the arduino and rotary tables I have finally gotten the motivation to dig out my hemingway rotary table kit.

Sadly I'm still not up and running on my lathe thanks to the utter incompetence of the busybee tools recommended delivery stooge.
 
I can't get Rod's sketch to work. It loads, I can set divisions, but the stepper doesn't move, and successive steps give a garbled display.
I'm back to using Chuck F's sketch, and will give my poor brain a rest.

Chuck
 
I can't get Rod's sketch to work. It loads, I can set divisions, but the stepper doesn't move, and successive steps give a garbled display.

Try :

#define stepPin 1
#define dirPin 2

replace:

#define stepPin 2
#define DirPin 1


Or if you are using some other pins.
 
Wow guys, 2 pages of comments while I was sleeping!

I have edited post #1 to point to the posts with the latest code and will maintain that over time As I add new versions.

A couple of things:

All parameters you need # steps, stepper pins etc are all configurable in the #defines and global variables at the top of the sketch. I had to change the pins because of a conflict with the freetronics board.

To change a value from say 100 degrees to 90 degrees, position the cursor in the tens column, not the hundreds, and the down button will let you change the hundreds. This code is in the degreefield files that are part of the LCD library. I wrote this new class based on tbe existing time field datdata type. I did not want the cursor to be left hanging. Maybe I can change how this works.

The maths looks convoluted. It got confusing. Initially, I was simply calculating the number of stepper steps per division. Then when we wanted to enter an arbitrary angle, I changed it so that the stepper steps is calculated from the angle. The angle is maintained internally in seconds so it does not need to muck about with odd data types. Eg 1 degree is internally stored as 3600 seconds. The number of seconds in a circle is WAY more than any conceiveable number of stepper steps in a circle so the conversion maths seems to still be accurate so I settled on this for all divisions. The code that uses float data type basically simply calculates the ratio for the entered angle vs 360*60*60 seconds in a circle then multiplies that by the number of steps in a circle. If I did not use a float, we got rounding errors.

If the Screen saver triggers, the stepper dividing functions won't be affected as the interrupt routine still runs in the background. The keystroke that enables the display and it gets eaten so it does not affect anything. Eg. does not trigger another division! You can comment out the call in the setup () function.

So a question. Should the number of divisions be entered as an arbitrary number like the angles are entered? Currently it starts at 1 and goes up or down 1 step at a time.
 
I can't get Rod's sketch to work. It loads, I can set divisions, but the stepper doesn't move, and successive steps give a garbled display.
I'm back to using Chuck F's sketch, and will give my poor brain a rest.

Chuck

Chuck just modify these two entries:
#define stepPin 1
#define dirPin 2

changing to this:

#define stepPin 3 //Digital Pin 3 outputs Step Execution
#define dirPin 2 //Digital Pin 2 outputs Step Direction

assuming your system kept Chuck Fellow's program unmodified.

Always try to change software before hardware...
 
So a question. Should the number of divisions be entered as an arbitrary number like the angles are entered? Currently it starts at 1 and goes up or down 1 step at a time.

divisions shud be entered as arbitrary number like angles are entered if possible... entering 60 sucks at present.

Not sure I followed how to comment out the screen saver...

Do I change this code:
lcd.enableScreenSaver(30);

to this:
lcd.enableScreenSaver();
 
I thought I'd try to make a quick change to see how easy this sketch would be to adapt to a more basic indexing head.

I changed the step resolution to 1000 to reflect 200 full steps per motor x 5 for the 5 to 1 gear ratio. Then I programmed in 6 deg per step... but the math converted to 62 steps when the result should have been 60 teeth...

see image 1

I then tried 1200 steps per revolution and got a good result for that one gear setting at least...

see image 2

anyway I'll have to play with this more to understand the math and rounding the sketch is doing.

When stepping by degrees, the number of steps (62) is meaningless as it is the number of steps per stepper movement that counts. You'd need to check that the stepper is actually moving 6 degrees. I am pretty sure it will be. I reused the same procedure to save code space, maybe the "of 62" should not be displayed in this case. If you think about it, if you set a movement of 300 degrees, it is not an equal division of a circle.

Hopefully the error you observed has on affect on the code.
 
When stepping by degrees, the number of steps (62) is meaningless as it is the number of steps per stepper movement that counts. You'd need to check that the stepper is actually moving 6 degrees. I am pretty sure it will be. I reused the same procedure to save code space, maybe the "of 62" should not be displayed in this case. If you think about it, if you set a movement of 300 degrees, it is not an equal division of a circle.

Hopefully the error you observed has on affect on the code.

I think the "of 62 error" error is here
on line 214 in enterDegrees()
Code:
divisions = STEPS_PER_REV /  stepsPerDiv;
this should be linked to degrees for greater acuracy

I have not tried it, but I think it should be like
Code:
divisions = (long)((float) MINUTES_IN_CIRCLE / (float) angleField.value());
 
I think the "of 62 error" error is here
on line 214 in enterDegrees()
Code:
divisions = STEPS_PER_REV /  stepsPerDiv;
this should be linked to degrees for greater acuracy

I have not tried it, but I think it should be like
Code:
divisions = (long)((float) MINUTES_IN_CIRCLE / (float) angleField.value());

I am sure that it doesnt help that 6 degrees isnt equally divisible by the 0.36 deg /step if I change div /rotation to 1000
 
divisions shud be entered as arbitrary number like angles are entered if possible... entering 60 sucks at present.

Not sure I followed how to comment out the screen saver...

Do I change this code:
lcd.enableScreenSaver(30);

to this:
lcd.enableScreenSaver();
Change it to
Code:
  //lcd.enableScreenSaver(30);
to ignore this line of code (turn into a comment).

To change the input so it does not suck, try changing Line 57 to
Code:
GetIntField divfField(divideForm, "Divisions", 1, 1000, 1, 3, " ");

Working hours now so not playing with the script. if you get syntax errors, check the form example script for how to use it. I don't think there will be any flow on changes required.
NOte this code sets the maxiimum divisions to 1000.
 

Latest posts

Back
Top