Project of the Month built by driller1432

Help Support Home Model Engine Machinist by donating using the link above or becoming a Supporting Member.
Home Model Engine Machinist > The Tools and Tips > Machine Modifications > Arduino Rotary Table for Dummies

Reply
 
Thread Tools
Old 11-18-2017, 06:42 PM   #81
Stieglitz
 
Join Date: Aug 2012
Posts: 49
Liked 9 Times on 9 Posts
Likes Given: 10

Default

Hi bmac2, Thank you for producing a great explanation,I was considering trying out a rotary indexer but balked at the electronics side of it.
Will try it.
Allen


Stieglitz is offline  
 
Reply With Quote
Old 11-19-2017, 05:20 AM   #82
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

Hi Allen, I’m glad you like it. I’ve just been running it with the original sketch though Foozer, rodw, tjwal and others have put a lot of work into rounding errors. My setup is a little too dodgy to worry about getting to 9 decimal places.



__________________
Bob
Alberta, Canada
bmac2 is offline  
 
Reply With Quote
Old 11-19-2017, 07:25 PM   #83
tjwal
 
Join Date: Sep 2013
Posts: 21
Liked 4 Times on 3 Posts

Default

Bob
Your original code declared Multiplier as an integer
const int Multiplier = (StepsPerRotation * TableRatio)/360;

Depending on the values for Steps and Table this can result in a significant error. In my case I am using a TableRatio of 4. With 800 steps, Multiplier should be 8.888... truncating it to an integer gives you 8, which is in error by over 10%. I believe you have a TableRatio of 36, which does not result in any truncation so you wouldn’t have noticed an error.

Changing Multiplier to a float as per billanygard’s post#70 fixes the Multiplier truncation error.

After that, you’re correct, most of the changes just add precision which might not even be noticeable. I believe my version of the code is like Chuck F’s code in that it distributes errors as they accumulate. In theory this should be more accurate but without a side by side comparison I don’t know whether it is noticeable.

I do like the keypad interface of your version over Chucks button interface.

Thanks again for the great construction tutorial.

John
Ps. My table ratio is actually 4.2, but knowing how the calculation works, I can enter it as 42 and my steps as 80
tjwal is offline  
 
Reply With Quote
Old 12-05-2017, 03:08 AM   #84
driller1432
Project of the Month Winner!!!
 
driller1432's Avatar
 
Join Date: Dec 2011
Location: Gallup, NM
Posts: 68
Liked 139 Times on 33 Posts

Default

Hi Bob
First thanks for this thread. Ok so I got all the parts put everything together the lcd display works, keypad works able to scroll and enter degrees etc and direction but nothing happening on the step output it flashes “moving” for a split second put scope on direction it changes state but no step pulses.
I’ve tried 2 Arduino boards still nothing also reloaded program several times. Any ideas
driller1432 is offline  
 
Reply With Quote
Old 12-05-2017, 05:25 AM   #85
driller1432
Project of the Month Winner!!!
 
driller1432's Avatar
 
Join Date: Dec 2011
Location: Gallup, NM
Posts: 68
Liked 139 Times on 33 Posts

Default

Quote:
Originally Posted by driller1432 View Post
Hi Bob
First thanks for this thread. Ok so I got all the parts put everything together the lcd display works, keypad works able to scroll and enter degrees etc and direction but nothing happening on the step output it flashes “moving” for a split second put scope on direction it changes state but no step pulses.
I’ve tried 2 Arduino boards still nothing also reloaded program several times. Any ideas


Figured it out won’t work if you put 400 steps per rotation for some reason
driller1432 is offline  
 
Reply With Quote
Old 12-05-2017, 09:28 AM   #86
rodw
 
Join Date: Dec 2012
Posts: 1,046
Liked 311 Times on 242 Posts
Likes Given: 161

Default

Quote:
Originally Posted by driller1432 View Post
Figured it out won’t work if you put 400 steps per rotation for some reason
I'm not really familiar with this software or your hardware but most stepper motors are 200 steps per rev. If you set the software up to be 400 steps, that could be double the speed which might be more than the stepper can handle (most of them peak out at about 400-450 rpm). After this point, they do nothing (except maybe make some high frequency noise)
__________________
RodW
Brisbane, Australia
vehiclemods.net.au
rodw is offline  
 
Reply With Quote
Old 12-05-2017, 12:56 PM   #87
driller1432
Project of the Month Winner!!!
 
driller1432's Avatar
 
Join Date: Dec 2011
Location: Gallup, NM
Posts: 68
Liked 139 Times on 33 Posts

Default

Quote:
Originally Posted by rodw View Post
I'm not really familiar with this software or your hardware but most stepper motors are 200 steps per rev. If you set the software up to be 400 steps, that could be double the speed which might be more than the stepper can handle (most of them peak out at about 400-450 rpm). After this point, they do nothing (except maybe make some high frequency noise)


Installed the sketch that tjwal modified and everything works perfectly’ I have a 90 to 1 table so the calculations would not work with original sketch set to 400 steps. I’m an old guy learning new things. Thank you
driller1432 is offline  
 
Reply With Quote
Old 12-05-2017, 04:44 PM   #88
tjwal
 
Join Date: Sep 2013
Posts: 21
Liked 4 Times on 3 Posts

Default

Quote:
Originally Posted by driller1432 View Post
Installed the sketch that tjwal modified and everything works perfectly’ I have a 90 to 1 table so the calculations would not work with original sketch set to 400 steps. I’m an old guy learning new things. Thank you


Did 400 steps work with my version?

With the original sketch 400 steps with a 90:1 table ratio will likely have an issue with integer overflow. I used double integers so overflow shouldn’t be an issue.

How fast is it with your 90:1 table? I didn’t implement accelerations so by default the stepping speed is fairly slow.

Cheers
John
tjwal is offline  
 
Reply With Quote
Old 12-05-2017, 09:34 PM   #89
rodw
 
Join Date: Dec 2012
Posts: 1,046
Liked 311 Times on 242 Posts
Likes Given: 161

Default

Quote:
Originally Posted by tjwal View Post
Did 400 steps work with my version?

Cheers
John
I had a look at the code. there are a number of undefined type conversion which could catch you out. eg as one example

Code:
ToMove=(bob/360) * Multiplier + 0.5 - cumSteps;
Should be more like
Code:
ToMove=(long) ((bob/360.0) * (float) Multiplier + 0.5 - cumSteps);
If the compiler sees 360 it will probably think its a long or int but if its 360.0, it knows its a float as it has a decimal point. Also you are doing float maths but assigning the result to a long at the end plus Multiplier is a long used in a float formula. You must program defensively. I've been caught so many times with odd results due to incorrect type conversions.

Probably Multiplier should be defined as a float as thats how it is used.

In some languages, type conversion is automatic but in C it isn't. Don't depend on the compiler to do it for you. It might not get it right every time. Treat every compiler warning as if its a bug and eliminate it.
__________________
RodW
Brisbane, Australia
vehiclemods.net.au
rodw is offline  
 
Reply With Quote
Old 12-07-2017, 02:52 AM   #90
driller1432
Project of the Month Winner!!!
 
driller1432's Avatar
 
Join Date: Dec 2011
Location: Gallup, NM
Posts: 68
Liked 139 Times on 33 Posts

Default

Quote:
Originally Posted by rodw View Post
I had a look at the code. there are a number of undefined type conversion which could catch you out. eg as one example



Code:
ToMove=(bob/360) * Multiplier + 0.5 - cumSteps;


Should be more like

Code:
ToMove=(long) ((bob/360.0) * (float) Multiplier + 0.5 - cumSteps);


If the compiler sees 360 it will probably think its a long or int but if its 360.0, it knows its a float as it has a decimal point. Also you are doing float maths but assigning the result to a long at the end plus Multiplier is a long used in a float formula. You must program defensively. I've been caught so many times with odd results due to incorrect type conversions.



Probably Multiplier should be defined as a float as thats how it is used.



In some languages, type conversion is automatic but in C it isn't. Don't depend on the compiler to do it for you. It might not get it right every time. Treat every compiler warning as if its a bug and eliminate it.


Controller not mounted to table yet, that’s up next.

IMG_1512614970.327171.jpg


Hey if I don’t have turn a crank it’s fast enough!


driller1432 is offline  
 
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Arduino control for a 3” rotary table bmac2 Machine Modifications 101 04-23-2017 01:17 AM
Rotary table Coomba General Engine Discussion 64 08-22-2016 04:34 PM
wtb rotary table toolroom Buy / Sell / Trade / eBay 5 01-04-2016 03:31 PM
My Second Rotary Table,80 mm table. gus Introduction 75 07-29-2014 08:36 PM
Using a rotary table. radfordc General Engine Discussion 10 03-10-2009 12:58 PM



Newest Threads






- Top - Member List