# Arduino Rotary Table for Dummies



## bmac2

Ive had a few people tell me that they like the project (http://www.homemodelenginemachinist.com/showthread.php?t=25783) but dont feel comfortable with the electronics. Ive been playing around to simplify it down to where I feel anyone who wants to could comfortably build the controller. With the right hardware this can all be done with point to point wiring and screw terminals. Sooo. . . .


----------



## bmac2

I stressed tested this by asked my wife if she would try building the controller using these instructions and she got it up and running. 
  And Yes, I will soon be spending some quality time standing in the Mall holding her purse.
*CAUTION!*​ *Messing around with Arduinos and stepper motors can be very addictive so do so at your own risk.*​ Tools Required  A small screwdriver . . . .  and depending on the hardware you choose a multimeter.
The Hardware
  An Arduino UNO
  I2C 20x4 LCD display 
  4x4 keypad 
  TB6560 based Stepper Controller
  Some wire for jumpers. Male to Male and Male to Female
  DC to DC (bump) convertor 
  Power supply


----------



## bmac2

[FONT=&quot]Any Arduino should work. You can get an UNO clone in the $5 - $10 range from EBay, Amazon, Aliexpress, Banggood etc. From here on in Im going to assume an Arduino UNO.      [/FONT]


----------



## bmac2

The I2C 20x4 LCD display gives you 4 line 20 character LCD module that uses none of the Arduino digital pins which is good because we only have 13 and the keypad is going to chew up 8 of them. You can get these as low as $5 to $10 from China.


----------



## bmac2

The 4x4 key pad can be found almost anywhere on the internet just dont pay more than $2 or$ 3 for one. I have seen them for as high as $20.00.


----------



## bmac2

Any stepper controller that can handle the current of the stepper motor will work but Im going to concentrate on the TB6560 based driver. The TB6560 shown below go from $8 or $9 dollars. It has screw terminals for the wire connections and the setup is simple, using the dip switches on the board. They are also rated for 3 amps so it can handle larger stepper motors.


----------



## bmac2

The DuPont jumper wires (Male to Male And Male to Female) are not necessary but do make things easier and keep the wiring neat. Just dont get them too short and again pay more than $2 or$ 3 for them.


----------



## bmac2

The power supply I used was from an old laptop with an 18 volt 4.5 amp output but you can use any DC supply that will work with your stepper motor. Stepper motors have a rated voltage and current. The stepper motor I used is a high torque NEMA 17 rated at 10 volts and a maximum current of 0.64 amps.  This basically means if you hook it up to 10 volts it will draw 0.64 amps.  If you try to run it at a higher voltage it will draw more current and get very hot.  The stepper motor drivers regulate the current.  If you hook it up to 18V, for example, the motor will attempt to draw 1.1 amps, but the motor driver will not allow that to happen and use high frequency pulses to limit the average current to the set maximum value. Stepper motors are designed to work this way and it is safe to run some motors at up to 20 times the rated voltage.

  DC to DC convertor (Optional). The Arduino has a built in 5v regulator but If you are using a power supply greater than 12 volts you will need a DC to DC convertor to safely power the Arduino. Online they go for $2 or $3 and a couple bucks more, you will get you one with a display.
  Thats it. The total bill for the electronics should be under $35 Canadian pesos.


----------



## bmac2

The stepper motor will have to be sized for your application. I used a small 3 rotary table and  dont plan on using it for anything other than indexing so a high torque NEMA17 did the job. If youre working with a larger rotary table or want to be able to use it as a 4th axis in the mill you will want at least a NEMA23 size motor. You will have to reach out to the forum for help with selection. 
  The controller is going to have to survive swath and other nasty stuff so it will need to be in a box.  You can use one like I did in my build http://www.homemodelenginemachinist.com/showthread.php?t=25783&page=2 or something as simple as a wooden box. Just keep in mind the environment that it will be being used in.
  Ok get out the anti-identity thief, pre-paid Visa card and order all the bits, wait for a month and a half for Canada Customs/Canada Post to figure out it isnt anything nasty and youre ready to begin.
  Youll have to install the Arduino software (IDE) on your computer. Spark Fun has a good step by step tutorial for completing the install. https://learn.sparkfun.com/tutorials/installing-arduino-ide


----------



## bmac2

Lets make sure your Arduino is working. Plug it into a USB port on your computer and open the Arduino IDE program. On the menu bar at the top click on Tools, Board: and select Arduino/Genuino Uno then Tools, Port, and your com port. This will usually be on the highest number.


----------



## bmac2

Ready to load your first program? Click on File, Examples, Basic and Blink then click on the upload arrow (the arrow pointing to the right) in the top left of the window. Once loaded one of the LEDs on the Arduino will be blinking on and off, at a one second cycle. 

  Scroll down to the bottom and you can see where the code reads
    digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(1000);              // wait for a second
    digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
    delay(1000);              // wait for a second

What this does is turn digital pin 13 on, wait for 1000 milliseconds then turn it off for 1000 milliseconds. Mess around with the delay to get a feel of what going on you cant break anything just be careful not to remove the brackets. 
Congratulations youre a programmer!


----------



## bmac2

Libraries are simply programs someone smarter than me has written that our program can reference making everyone&#8217;s life a lot easier and you need the 2 attached below. Download the zip files and make sure you know where they are saved. 
  To install the libraries open the Arduino IDE program and click on &#8220;Sketch&#8221;, &#8220;Include Library&#8221; and &#8220;Add .ZIP Library&#8221;. Navigate to where you saved LiquidCrystal_I2C-master.zip, select it and click &#8220;Open&#8221;. Do this again and select the Keypad.zip file. You need to close the Arduino IDE and open it again for the libraries to be recognised. 

View attachment keypad.zip







View attachment LiquidCrystal_I2C-master.zip


----------



## bmac2

*Rule #1 *NEVER CONECT OR DISCONECT ANYTHING WHILE THE ARDUINO IS POWERED UP Always unplug the USB Cable and turn off any connected power supply.

  We are going to take a step by step approach to this and are going to start with the display. 
The display has 4 connectors on the back labeled GND, VCC, SDA, and SCL. If you are using the DuPont jumper peel 4 of the Male to Female jumpers off the ribbon and connect them the Arduino as below. At this point the only way you can damage anything is to hook the power up backwards so check that connection twice. 

  Display Pin GND  to  Arduino pin Gnd
  Display Pin VCC  to - Arduino pin 5v
  Display Pin SDA  to - Arduino pin A4
  Display Pin SCL  to - Arduino pin A5

  [FONT=&quot]If you plug the USB cable into the Arduino now you can adjust the contrast using the blue pot near the connector. For now just adjust it so that the white boxes on the display are just showing up.[/FONT]


----------



## bmac2

Download I2C_Scanner and unzip it to your My Documents\Arduino folder. In the program open the sketch My Documents\Arduino\I2C_Scanner\I2c_Scanner.ino. Upload the sketch to the Arduino (click on the arrow in the top left) and once its loaded click on Tools, Serial Monitor. Check that the monitor is set to 9600 baud in the lower right of the window and in a couple of seconds it should show the address for your display. If not check your wiring and run it again. Make note of the address and close the window. 






View attachment I2C_Scanner.zip


----------



## bmac2

To test the display click File, Examples, LiquidCrystal_I2C, then HelloWorld. Check that the address matches what you got from the scan, edit it if necessary and upload it to the Arduino. Your display should light up with Hello World as below. If the display is just blank check that the small jumper on the back of the display is in place, without it the back light will not come on.


----------



## bmac2

With the display working the next step is to add the keypad. I dont have a 4x4 keypad just a 3x4 so I had to add the forth column and were going to pretend that it looks like yours. If you are using the DuPont jumper peel 8 of the Male to Male jumpers off the ribbon and connect them to the Arduino as below.

  Remember Rule #1?

Keypad Pin 1  to  Arduino Pin D11
  Keypad Pin 2  to  Arduino Pin D10
  Keypad Pin 3  to  Arduino Pin D9
  Keypad Pin 4  to  Arduino Pin D8
  Keypad Pin 5  to  Arduino Pin D7
  Keypad Pin 6  to  Arduino Pin D6
  Keypad Pin 7  to  Arduino Pin D5
  Keypad Pin 8  to  Arduino Pin D4
  [FONT=&quot]
On the one I have pin 1 is marked with a number 1 about .05 high black on black. If you cant find any markings dont worry about it everything here is at a data level and if you hook it up backwards the Arduino will just not understand it. Sort of like when you show your wife that picture of a really cool milling setup.[/FONT]


----------



## bmac2

Time to load the controller sketch (program). Download the Arduino_Rotary_Table_Control_2016.zip and unzip it to your my Documents\Arduino folder. Open the program  My Documents\Arduino\ Arduino_Rotary_Table_Control_2016\Arduino_Rotary_Table_Control_2016.ino. For now just check I2c address and change it like you did for the Hello World test then upload the sketch to the Arduino by clicking on that arrow in the top left. 






View attachment Arduino_Rotary_Table_Control_2016.zip


----------



## bmac2

With the sketch loaded check that the keypad is working and that the correct numbers are showing up on the display. The main menu is self-explanatory. Once you enter the sub menus there is no way out so just enter a number and press # button. In the next menu you have A for forward, B for reverse and C exits back to the main menu. If not check your wiring and try it again you dont have to reload the sketch.


----------



## bmac2

Almost done. On the TB6560 we have 3 connections to the Arduino.  Step, Gnd, Direction, and a short jumper between &#8220;CLK -&#8220; and &#8220;CW -&#8220;. Peel 3 of the DuPont Male to Male jumpers off the ribbon and connect them as follows.

  TB6560 terminal CLK + to Arduino pin D2 
  TB6560 terminal CW + to Arduino pin D3
  TB6560 terminal CW - to Arduino pin GND
  A Jumper between terminal CLK- and terminal CW- on the TB6560

At this point you can run the program again by just plugging the Arduino back into the USB port and go through the keypad to make sure nothing came loose. If you really want to get your nerd on, you can look at the steps on an oscilloscope but honestly if you own a scope you stopped reading after the first page.


----------



## bmac2

Hooking up the stepper motor to the controller is straight forward. Connect the power supply positive (+) to the &#8220;+24&#8221; terminal on the controller.  It&#8217;s labeled +24 but I&#8217;ve found that it works fine as low as 9 volts. Connect the power supply negative (&#8211 to the &#8220;GND&#8221; terminal. Connect the stepper A and B leads as per the data sheet that hopefully came with it. 
For initial testing set the current as low as you can by setting the switches as shown.

We left the &#8220;StepsPerRotation&#8221; in the sketch set to 400 assuming a 200 step per revolution motor, and for now setting the controller to 2 or half step. 

Plug in the USB cable and turn on the stepper power supply. 

If your motor runs backwards, [FONT=&quot]counter clockwise [/FONT] when you press &#8220;A&#8221; for forward just reverse the stepper connections at the controller.


----------



## bmac2

[FONT=&quot]How can you tell if your controller is a Chinese clone? On mine I set the Running Cunent.  scratch.gif[/FONT]


----------



## bmac2

The Arduino runs on 5vdc and if your stepper is running on 12 volts or less you can power it by connecting the power supply positive (+) to the VIN pin on the Arduino and the negative (-)  to the Arduino GND. 
If you are using a supply greater than 12 volts the easiest way to power the Arduino is to use a DC to DC (Bump) convertor. Most of the ones I have seen on the internet have a maximum input voltage of 35 volts DC. The output can be adjusted to anything from 1.5 volts up to the same as the input.

  Connect the power supply positive (+) to the IN + terminal on the convertor. Connect the power supply negative () to the IN -on the convertor. Turn on the supply and adjust the OUT to read around 6 volts. If youre Buck doesnt have a display use a DC meter to set this. It has to be above 5 volts or the Arduino internal regulator would drop it to 4. 

  Peel off 2 of the DuPont Male to Male jumper and connect them to the OUT + and OUT - terminals. (the power supply is turned off now, right? just asking.) Then connect OUT -  terminal to the GND on the Arduino. Next Then connect OUT + terminal to the VIN on the Arduino.
*
Check this connection twice! This is about the only step where you can smoke the Arduino*.


----------



## bmac2

You will notice that if you now ask the controller to turn the stepper motor 45 degrees it will spin around a half a dozen times before it comes to a stop. This is because the software is calculating the reduction of the rotary table.  
  We are down to the last edit that is needs to complete the project. Open the sketch in the Arduino IDE (program) you need to edit 2 lines. 

Line 30, &#8220;const int StepsPerRotation = 400;&#8221; 

Change this to reflect the number of steps of your stepper motor multiplied by the step resolution set on the controller. For example if you have a 200 step motor (most common) and you set the controller to ½ step (2) then the StepsPerRotation = 400, for 1/8 step (8) it will be 1600 etc.

Line 31, &#8220;const int TableRatio = 36;&#8221; 

This is the ratio of rotary table and my table has a 1:36 reduction. If your table is 1:72 then the line will have to be changed to read 

&#8220;const int TableRatio = 72;&#8221;

 Upload the sketch to the Arduino and you are done.


----------



## blighty

awesome post. will have to wait till lunch to read it all :-(


----------



## kadora

The best tutorial I have ever read.
Thank you


----------



## MRA

That looks great!  Well, the rotary table I have 'borrowed' (see my dividing plate thread) came from a cupboard full of a university project a fellow postgrad completed about 20 years ago, and untouched since.  In the same cupboard were (the last time I looked) a pair of stepper motors, one of which was once attached to the rotary table, and a fairly big rack of control gear which (given when it was) must have hooked up to a 486 PC.  The rats nest of a controller was the reason I borrowed the table and left the motors, but...maybe I ought to find a reason to go back! .  Oh, in the boot of my car are some large-ish regulated DC PSUs scavenged from a scrapped flight simulator for no better reason than I couldn't leave them in the bin.  

Thanks for this tutorial - I used to program in Fortran and Matlab but I've kind of left that world behind.  Perhaps I should have another play.


----------



## stragenmitsuko

Great writeup . 

Maybe worth mentioning that for a chinese arduino clone , a diffferent driver needs to be loaded , the one that come with the arduino software do not work . 

Wel , at least mine didn't  , but the driver is easy to find if you google for chinese arduino driver . 

Pat


----------



## crankshafter

Great writeup Bob. I will be ordering components needed to build the controller, and a 100 mm RT dedicated for the Arduino-controller.

CS


----------



## dnalot

Hi

How many decimal places can the input be?

Mark T


----------



## dnalot

Hi

Looking more closely to the photos I see two decimal places. 

So here is my root question. I want to drive an indexer using a 4 to 1 reduction with a timing belt. Will that ratio provide sufficient resolution for cutting gears?

Mark T


----------



## John S

Doubt it.

At only 4:1 the cutting forces may be too great that they will force the table to jump steps.


----------



## dnalot

> At only 4:1 the cutting forces may be too great that they will force the table to jump steps



That is a given. For gear cutting the indexer would be locked mechanically after each move. I am leaning towards a stepper with a planetary gear reduction.

Mark T


----------



## bmac2

stragenmitsuko said:


> Great writeup .
> 
> Maybe worth mentioning that for a chinese arduino clone , a diffferent driver needs to be loaded , the one that come with the arduino software do not work .
> 
> Wel , at least mine didn't  , but the driver is easy to find if you google for chinese arduino driver .
> 
> Pat



 Thanks guys. The hard part was convincing my wife to do the build. 



  Pat good call. :thumbup: Ive never ran into that with an UNO only with the NANO clones but that said I got some NANO clones pretty early on so I would never have noticed it.


----------



## bmac2

dnalot said:


> That is a given. For gear cutting the indexer would be locked mechanically after each move. I am leaning towards a stepper with a planetary gear reduction.
> 
> Mark T



 Mark, John
  For gear cutting the stepper is just indexing and providing holding torque but I still lock the table when making a cut. Maybe have a look at the BAZMAKs A dedicated indexing head for the Sieg mill http://www.homemodelenginemachinist.com/showthread.php?t=25980


  If you are using a 200 step per revolution motor with a 1:4 reduction, with the driver to 1/8 step you would have 6400 steps per revolution or 17.7 steps per degree. With a 42 tooth gear the teeth are something 8.5 degrees apart (I think) so 1:4 might not leave enough wiggle room. Sneak in a second belt with an idler shaft?


----------



## dnalot

Hi

Thanks bmac2 your numbers match mine. I suspected a simple 4 to 1 belt drive would be to rough. 

Mark T


----------



## dnalot

Hi

So I'm not as swift as bmac2's wife. 

When I got to the part 

To test the display click File, Examples, LiquidCrystal_I2C, then Hello, World. Check that the address matches what you got from the scan, edit it if necessary and upload it to the Arduino. Your display should light up with Hello World as below. If the display is just blank check that the small jumper on the back of the display is in place, without it the back light will not come on.

I am not getting the simple example liquidCrystal_12C . Instead I get Arduino-LiquidCrystal-12C-Librarymaster When loaded I do not get the 4 line output, I only get one line that reads Hello, World.  

And if I go on to the next step and load the control sketch I get an error

'class LiquidCrystal_12C' has no member named 'initc'


I must be doing something wrong, any ideas?


----------



## Foozer

dnalot said:


> Hi
> 
> So I'm not as swift as bmac2's wife.
> 
> 
> 
> 'class LiquidCrystal_12C' has no member named 'initc'
> 
> 
> I must be doing something wrong, any ideas?



Try changing lcd.init to 
 lcd.begin(20, 4);                   // Start the LCD library


----------



## dnalot

Tried that and it just bumped the error to another line that started with    lcd.init

I see that text in three lines

line 41    lcd.init () ;       //  initialize the lcd

line 53    lcd.init () ;

And then the line that caused the error

line 114   lcd.init () ;


Thanks for the effort

Mark T


----------



## bmac2

It looks like I uploaded the wrong library:wall:. I just checked and I dont have the Arduino-LiquidCrystal-I2C-library-master installed. 
I have it in my Arduino ZIP Files directory but never installed it. You need the Marco Schwartz "LiquidCrystal_I2C-master" library for the DFRobot I2C LCD displays from GitHub. 
Hope this works and I have to apologize for the confusion. 

View attachment LiquidCrystal_I2C-master.zip


----------



## dnalot

Hi

Thanks bmac2, the sketch now loads so its off to the next step. 

Mark T


----------



## dnalot

OK

Well the number one mark on my keypad when wired to the number 11 terminal on the arduino did not work so I reversed all 8 wires and the unit now responds correctly.


----------



## dnalot

OK, powered up and the motor is moving. Now I just need to calibrate my setup. 

I have mounted a group 17 stepper motor with a 27-1 reduction that turns a 2.5 - 1 belt drive reduction that turns my indexer.  To make it a bit more difficult its not an even 27 to 1 on the gearbox, but 26 with a fraction of 103 over 121 to 1

The drive system has .4 degree of backlash but that should not be a problem as I can manually press on the belt before locking the indexer with its locking screw. 

I still have the current set to its minim value at 12 V without losing steps so the motor should easily be able to do  the job.    

Next step will have to wait till tomorrow as today is my 67th birthday and I have to party with friends and family.  

Mark T


----------



## bmac2

Well happy birthday Mark! :thumbup:
Glad it worked out.


----------



## dnalot

OK. I have a small problem in that my geared stepper motor does not give me a whole number for the reduction and the sketch does not accept numbers with a decimal place. My reduction comes out to 67.1281. To overcome this problem I lied and entered 404 steps per revolution of the motor in place of the actual 400 steps. This gets me very very close to a full 360 at the indexer when I command a 360 degree movement. I think the system will work as long as I don't make more than one revolution of the indexer. I will need to cut a gear to find out. 

I will post photos when I get the electronics mounted in a box.

Mark T


----------



## bmac2

Ive corrected post #12 so it has the correct library.


----------



## Maxmekker50

Hi everyone here is my version Of rotary table in small box All honor to bob. Had some issues along the way. With programming problems, etc. Seeing there are several who have had problems researching it a bit and just looking like it may have been awkward in some wires. But now happy and everything seems as it should. And again big thanks to bob

Link for CHINA ARDUINO DRIVER ; http://0xcf.com/2015/03/13/chinese-arduinos-with-ch340-ch341-serial-usb-chip-on-os-x-yosemite/


link to box: https://www.aliexpress.com/item/Fre...32717034004.html?spm=2114.13010608.0.0.hjyaKH


----------



## bmac2

Looks good Max. I like that project box and good call on not getting the white one . 

How do you find Aliexpress? When I first heard of them I couldnt believe the prices and placed a small test order (4 items in 4 different categories) to try them out. The fastest arrived in 63 days and the last one took 4 months. That was back in March and I havent used them since.

Here in Canada something changed back in November and anything coming from China is taking 1 to 2 months to clear Canada Post.


----------



## Maxmekker50

HI  bob   I have used Import from china last 15 years  When i ordere i ordere 10 pcs ore more and i collect all in one store and use dhl  And get in 5 to 6 days 
Some time i use the e shipping that take 14 days . 

If bigger i use the seway on my lathe  and mill i used seway take 39 days to norway . More pictures comming up now i convert the uno card and driver to wire up all in the box then pictures comming.


----------



## chucketn

I have a 3d printer coming in the mail. I'd like to print an enclosure for my setup(I built the same RT Controller and love it). 

Chuck


----------



## grapegro

Hello Chuck,
                 I got mine in the post yesterday in kit form. It is an Anet A8 . It seems a very sound unit and am looking forward to using it. Norm


----------



## bmac2

Oh the 3D printer. Now theres a sirens call that keeps niggling at the back of my brain.


----------



## rodw

I thought I'd  just poke my nose in after reading about concerns regarding accuracy when dividing. You should not be using floating point maths anywhere because you will end up with accumulated rounding errors. It like using a micrometer with a coarse scale. Accuracy can not be better than 0.5 of the smallest division as I was taught and we had to accumulate the error +- the measuring unit when doing maths with such readings. It is far better to reduce everything to the smallest discrete unit you can measure. So if you measure divisions in seconds rather than the much coarser degree, a lot of problems go away. Others will appear though as you need to present the angle to the user. I chose to  do this in degrees minutes and seconds.

So by working in smaller units you may only be one step out per division and if you want to go one step further to improve accuracy, you can add and subtract a step or two every alternate division to make the error go away by the time you get round the circle.

Finally, let me just say if you are old enough to remember programming on an 8 bit PC, using floating point maths was fraught with danger due to ongoing errors accumulated from converting to and from decimal numbers and hexadecimal numbers used internally in the machine architecture. 16 bit is not as bad but the issue is still there. Most accounting programs will use a binary coded decimal as the numerical unit to ensure accurate results. Regrettably, few programming languages support such a data type.


----------



## dnalot

Hi

Well after trying to fudge the numbers to get my indexer to work with an odd reduction without success,  I gave up the idea of using a stepper motor with a gear box. Digging through my odds and ends box I came up with a 36 to 1 worm gear set. Coupled with the existing 2.5 to 1 timing belt reduction I came out with 90 to 1 reduction.

Note that when choosing a reduction your steps times your reduction must divide evenly by 360.  I am using 200 steps per rotation, 90 to 1 reduction so 200 * 90 / 360 = 50, and that works.  I tried using half steps 400 * 90 / 360 = 100 but that didn't work, 


The worm gear has about the same amount of backlash as the stepper with a gearbox. To eliminate that I am using a counter weight. Will need to cast a better weight, the one in the photo is just to test the idea. Will also need to provide a second idler wheel to hold the weight off when the table is cranked all the way back.   

The electronics as well as the 12 volt power supply were fitted inside a project box. The fitting for the 110 volt inlet also provided a fuse and an off on switch. To keep the box from heating up a 1.5 computer fan was installed in the backside of the box.

All and all I'm very pleased with the system. 

Mark T


----------



## chucketn

Nice job, Mark. Can you share the source and specs of the project box? Is it perchance, 3d printed?

Chuck


----------



## dnalot

Hi Chucketn

Here is a link to amazon. com for the box. Note it took a few weeks to get

https://www.amazon.com/gp/product/B06XSMK61Q/?tag=skimlinks_replacement-20

And here is the link for the power inlet

https://www.amazon.com/gp/product/B00ME5YAPK/?tag=skimlinks_replacement-20

And the power supply

https://www.amazon.com/gp/product/B00UHI3NGS/?tag=skimlinks_replacement-20

Mark T


----------



## chucketn

Thanks, Mark. I asked because I also built an Arduino based set up and need a box to finish it off. I also just built a 3d printer and would like to print same.

Chuck


----------



## Flopearedmule

Bob, that is awesome! thanks for the lesson and example.
is there a way to tell the Arduino you want a specific number of index? say for example, you want 48 teeth....can you just type 48 in the LCD and it will figure out the angle to move? (7.5degrees)
Also, I PM'd you on a question I have with my project. I don't want to hijack your thread with my project.
thanks


----------



## chucketn

dmh13433 said:


> is there a way to tell the Arduino you want a specific number of index? say for example, you want 48 teeth....can you just type 48 in the LCD and it will figure out the angle to move? (7.5degrees)


 
The sketch allows selecting divisions or degrees, then you enter the value via the keypad. I built the same setup for my rotary table, but it's still rough. I need to print an enclosure and add a connector for the power and the stepper.


----------



## billanygard

Hello all of you!
Sometimes when you see something it says clonk in the head "That should i build".
This was such a thing.
Ordered missed components, draw a nice box and 3d printed it, hooked it up and its working.
BUT!
I use it for my 4th axels thing to my cnc router. 200steps/rot, beltgear 1:3 and it is impossible to get the controller to give the right steps. I need 1200 and get 1040. Fiddeling with numbers in the script only change between 1040 and 1440steps.

Any tips?


----------



## Foozer

Quick and Dirty for 1200 steps . . .
change line   'for(int i = 0; i < tm; i++)'  to 'for(int i = 0; i < 1200; i++)'

steps [200] and table ratio [3:1] look to be too coarse for an accurate 'Multiplier' value.
Multiplier = (StepsPerRotation * TableRatio)/360;


----------



## billanygard

I did as been told, swap tm with 1200.
BUT!
Still 1040 steps for 360 degrees


----------



## Foozer

billanygard said:


> I did as been told, swap tm with 1200.
> BUT!
> Still 1040 steps for 360 degrees



if your steps are 200 per rev with table ratio of 3:1, 3 revolutions of the stepper is 1 turn [360] of the table or 600 steps. So thinking you wanted to step 1200 steps is 2 turns [720] of the table . Half stepping [400] will give you 1200 at 3:1 for 1 turn. 
  So whats off? steps per revolution or the table ratio?

const int StepsPerRotation = ?; // Set Steps per rotation of stepper 
 const int TableRatio = ?;        // ratio of rotary table


----------



## bmac2

Hi Olsson. I think Fooser has it. Check the settings on your stepper driver and remember to work that in for the StepsPerRotation


----------



## bmac2

billanygard said:


> Hello all of you!
> Sometimes when you see something it says clonk in the head "That should i build".
> This was such a thing.
> Ordered missed components, draw a nice box and 3d printed it, hooked it up and its working.
> BUT!
> I use it for my 4th axels thing to my cnc router. 200steps/rot, beltgear 1:3 and it is impossible to get the controller to give the right steps. I need 1200 and get 1040. Fiddeling with numbers in the script only change between 1040 and 1440steps.
> 
> Any tips?



 I know a few people around here have been asking about 3D printing a box for this project. I know Chuck (chucketn) would like to print one. Any chance you could post your STL file?


----------



## bmac2

dnalot said:


> Hi Chucketn
> 
> Here is a link to amazon. com for the box. Note it took a few weeks to get
> 
> https://www.amazon.com/gp/product/B06XSMK61Q/?tag=skimlinks_replacement-20
> 
> And here is the link for the power inlet
> 
> https://www.amazon.com/gp/product/B00ME5YAPK/?tag=skimlinks_replacement-20
> 
> And the power supply
> 
> https://www.amazon.com/gp/product/B00UHI3NGS/?tag=skimlinks_replacement-20
> 
> Mark T



 This is a little off topic but hey its my thread. ;D
  Mark I think I saw your avatar (http://www.homemodelenginemachinist.com/showthread.php?t=22722) or its cousin in the wild while we were on vacation in BC a couple of weeks ago. My wife takes pictures of the pretty things . . . Im always looking for the rust!


----------



## Foozer

const int Multiplier = (StepsPerRotation * TableRatio)/360;  
Only returns a whole number,

'member trying this script , my numbers were (400 *36)/360 
 for 40 steps per degree
  400 steps per rev @ 36 || 27 || 18 || 9 returns whole steps

i.e.   	 	 		 			400 			36 			14400 			40 		 		 			400 			35 			14000 			38.8888888889 		 		 			400 			34 			13600 			37.7777777778 		 		 			400 			33 			13200 			36.6666666667 		 		 			400 			32 			12800 			35.5555555556 		 		 			400 			31 			12400 			34.4444444444 		 		 			400 			30 			12000 			33.3333333333 		 		 			400 			29 			11600 			32.2222222222 		 		 			400 			28 			11200 			31.1111111111 		 		 			400 			27 			10800 			30 		 	  

The Bride loved the picture . . she wants one . .


----------



## dnalot

Hi



> Mark I think I saw your avatar



Nice, thanks for sharing 

Mark


----------



## billanygard

Hello again!
I was not clear enough in describing.
Steps/rev for motor = 200 set for halfsteps give 400steps/rev and with 1:3 gear need 1200 / rev.
I can see about those even numbers but dont understand yet how it rounds off in the end.
For now when ask for 360deg i get some 324 and hoping to get closer.

STL
Nema problema, would be happy if someone find them useful.
There are about 2x5hr printing time, print without cooling and with raft and support.
Let stay long on the buildplate for cooling, long things wrap easily.
I use som round 5mm alu pillars for the circuit mount and also for the two caseparts. 

View attachment top.stl


View attachment bottom.stl


----------



## chucketn

Thank you for sharing your enclosure, billanygard.


----------



## billanygard

I know what I have done, but do not know what I did!

I was not satisfied about the resulution I get with my 1:3 ratio so I set down and read the script up and down up and down
as I understand what i was reading.
The worst thing that could happen if i changed something would be that is not function so I changed some rows.

032 const int Multiplier = (StepsPerRotation * TableRatio)/360;  // 200*90=18000/360 = 50
to
032  float Multiplier = (StepsPerRotation * TableRatio)/3.6;  // 200*90=18000/360 = 50

102 ToMove = (Degrees*Multiplier);
to
102 ToMove = (Degrees*(Multiplier/100));

109 ToMove = (Degrees*Multiplier);
to
109 ToMove = (Degrees*(Multiplier/100));

This was an huge change with just a few steps at worst eg 36x10°=1198 instead of correct 1200.

I have read a little in an "sidethread" about another solution but for now that is to heavy for me.

//Olsson


----------



## chucketn

I am printing Olsson's  case for my RT controller. I have the bottom half printed, took over 9 hours. Had a problem printing the top half. The external mosfet in the heat bed circuit failed in the on condition. Luckily, I noticed the bed temp climbing and disconnected the wires to the bed. Shortly thereafter, the Y axis hung, causing many missed steps, which and caused a large level shift, ruining the print at 8 hours + . I will attempt the top half again when the replacement mosfet comes in.
For ChuckF, I can't remember now, but was your code based on Bob Pratl's code?


----------



## Foozer

Never Mind - Try it again after some sleep  . .


----------



## rodw

billanygard said:


> I have read a little in an "sidethread" about another solution but for now that is to heavy for me.
> 
> //Olsson



The problem is that no matter what you do you end up with a required division that includes a fraction of a step under some circumstances and stepper motors can only move whole steps. You will get errors if your script simply calculates a fixed number of steps per division.

Imagine a rotary table doing 36 divisions around the complete circle and the required number of divisions is 100.333333333 steps per division. So if you just round this to 100 steps, by the time you get right round the circle, you have missed 36 x 0.3333 = 12 steps.

The only way to fix this is to work out a way of distributing those missing steps around the circle. In our imaginary example, if you moved 101 steps every third division, your problem is solved.

Work out how to code that and your problem will go away.


----------



## Foozer

float Multiplier = (StepsPerRotation * TableRatio)/360.00;

From: ToMove = (Degrees*Multiplier);
to: ToMove = round(Degrees * Multiplier);

Should get you close . . . At least
Serial.print("ToMove # Steps = ");
  ToMove = round(Degrees * Multiplier),
   Serial.println(ToMove);
   Degrees = Degrees + 1;
  if(Degrees==361)Degrees=0;
  delay(500);
shows 360 degrees as 1200 steps . . .


----------



## tjwal

Foozer said:


> float Multiplier = (StepsPerRotation * TableRatio)/360.00;
> 
> From: ToMove = (Degrees*Multiplier);
> to: ToMove = round(Degrees * Multiplier);
> 
> Should get you close . . . At least
> Serial.print("ToMove # Steps = ");
> ToMove = round(Degrees * Multiplier),
> Serial.println(ToMove);
> Degrees = Degrees + 1;
> if(Degrees==361)Degrees=0;
> delay(500);
> shows 360 degrees as 1200 steps . . .



Im in the process of adding a routine that will allow the steps and table ratio to be input rather than embedded in the code.

While I was going through the code I noticed the issue with Multiplier as well.  Unless the steps and table ratio give an integer number of steps per degree the controller wont be accurate.  It likely works with most RTs but likely wont with a timing belt pulley arrangement.  There are a number of fixes for this.  Changing Multipler to a float is the easiest.  Im going to test a couple things of other methods.  I think one of them will also adjust for steps that have been lost through rounding.  Ill post my results and code when Im done.


----------



## rodw

tjwal said:


> There are a number of fixes for this.  Changing Multipler to a float is the easiest.



Unfortunately, this will not work becasue the float has to be converted back to an integer to determine the number of steps to move. So either you will end up truncating or incrementing the integer value. This will lead to errors if the number of steps per division does not end up being a whole number. You cannot move a fraction of a step.

Consider a mythical example that requires 36 divisions per 360 degrees and each division requires exactly 100.33 steps. to move around a circle, you will need 100.33 * 36 = 3612 steps. But truncating to 100 will result in 100 x 36 = 3600 steps meaning you will be 12 steps short at the end of a 360 degree move. This is a significant error and will be noticeable.

So you must work out a way to distribute the 12 step error across the 36 divisions. The solution is to move 100 steps per division and every third division, move 101 steps. How you code that is up to you but two alternative approaches have been documented in other threads on this forum.


----------



## tjwal

I agree, changing Multiplier to float only addresses one of the issues.  It does not fix the accumulated truncation error that you describe.  Ill have to find the other threads you. 

If Im correct, my method will have less than ½ step error at each division.  Ill have to find the discussions you refer to, perhaps its the same solution.

In any case my original intent was to allow for steps and table ratios to be an input.  At the same time Im changing to long integers so I can use 16th steps with my 90:1 RT.


----------



## rodw

The approach I took on this thread 
http://www.homemodelenginemachinist.com/showthread.php?t=25091&page=3
was to accumulate the fractional error and add a step when it was > 1.0 add another step.

Chuck Fellowes followed another approach. For the start of each division, he tracked how far around the circle he was and calculated how far around the circle he would be after the division, take the difference and move that number of steps.

Ultimately the result is identical. The adjustment algorithm depends a bit on the complete methodology you use to do your divisions.

As far as the data structure goes, using int or long will make no difference unless the number of steps moved exceeds the resolution of the data type. When I did this, I wanted to avoid the use of floats and inevitable rounding errors so I measured angles in the number of seconds of a degree using an unsigned long as there are 1,296,000 seconds in a circle. I wrote routines to input and display this value for angles in degrees, minutes and seconds but internally worked with seconds. Then when actually moving the rotary axis, I  implemented a trapezoidal acceleration/deceleration algorithm to maximise torque on startup and overshoot at the end of the move. (You can't do instantaneous accelleration to maximum speed due to the laws of physics).

So what on the surface looks like a simple application becomes amazingly complex, particularly if you use interrupt driven step generation.


----------



## tjwal

Rod
I havent examined Chucks code but from your description its the same method as what Im incorporating.  So far it appears to be an almost trivial change to the code.  I have more debug print statements than actual new code.

Ive just completed my controller and dont have it connected to a spindle so I cant directly test the accuracy.  The numbers look good though.

It will be a while before I build the spindle so Ill clean up my code and post it.  Perhaps someone can test it out.

Ive downloaded your code and when I get time will examine your approach.

Cheers
John


----------



## tjwal

I have finished modifying the code so it now allows for finer microstepping and high ratio rotary tables.  I've changed it to accumulate steps so there should never be more than 1/2 step error.  I can't physically check this as I don't have it connected to an RT, but  I've included a debug macro in the code that when enabled prints values to the serial monitor.  As best I can tell the code is working.  I've included the code and a text file noting the changes I have made.  For installation follow the excellent instructions posted by bmac2 at the start of this thread. 

View attachment Dummies_Rotary_Table_Control_2017_beta.zip


----------



## Stieglitz

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


----------



## bmac2

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.

[ame="https://www.youtube.com/watch?v=65NOxiFHoQI"]https://www.youtube.com/watch?v=65NOxiFHoQI[/ame]


----------



## tjwal

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


----------



## driller1432

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

driller1432 said:


> 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


----------



## rodw

driller1432 said:


> 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)


----------



## driller1432

rodw said:


> 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


----------



## tjwal

driller1432 said:


> 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


----------



## rodw

tjwal said:


> 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.


----------



## driller1432

rodw said:


> 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.

View attachment IMG_1512614970.327171.jpg



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


----------



## piwiron

I built this and had trouble getting the steps right. In the end I // some of the code so it is closer to steps per degree.

This was an awesome starting point for me just needs more tweaks.
Les


----------



## kquiggle

Just want to thank you for an awesome write-up. I've been wanting to learn more about stepper motors, and I am also interested in building an indexer, so your post hit every target.


----------



## driller1432

kquiggle said:


> Just want to thank you for an awesome write-up. I've been wanting to learn more about stepper motors, and I am also interested in building an indexer, so your post hit every target.





View attachment IMG_1180.jpg


Finished my mount the thing works perfectly thanks again for sharing this SWEET!


----------



## Stieglitz

Hi Driller1432,Thanks for the photo.
Alen


----------



## clifwst

I have a question,would a 250 watt 12 volt ATX power supply have enough amps to power the electronics package and a nema 23 57BYGH310 stepper?

ATX:

Dell HP-P2507F3B

120v 6a input
5v 22a output
3.3v 18a output
12v 14a output

*24.0 kg-cm (333.2 oz-in) 4 Wire NEMA 23 Stepping Motor;*



Step angle: 1.8°
Voltage (V): 8.6
Current (A): 2.0
Resistance (Ohms): 4.3
Inductance (mH): 16.2
L0 Dimension (mm): 76
L1 Dimension (mm): 21
Holding Torque (kg.cm): 24.0


I'm thinking it would, but then again I've made the magic blue smoke more than I care to.


I want to use an ATX power supply because it has the 3.3, 5 and 12 volt rails, and the purple wire that is 5v always on if plugged in, I connect it to a usb and use is as a usb phone charger, when ever I use one of these.  I have lots of these lying around cause I pick up discarded computers for them.


----------



## rodw

In my experience, even 24 volts is not enough. Go 48 volt if your controller can handle it!


----------



## tjwal

It will work but your torque will drop off dramatically as your rpm goes up.  With every step the current in each phase has to go from maximum in one direction to maximum in the other direction.  Higher voltages are needed for this to happen quickly.  If you&#8217;re using an Arduino the pololu drivers are supposedly good up to 2 amps and are rated for 36 volts.  They have current limiting so won&#8217;t supply any current above their set point.  You can adjust it to a lower value if you don&#8217;t require full torque.  At the higher current levels they do run extremely hot.  If you need full torque you&#8217;re better off with a separate high voltage driver like Rod suggests.


----------



## clifwst

I'm not using pololu drivers, I'm using the  stepper driver based on the  Toshiba TB6560 chip. 

The data sheet says voltages above 24 volt isn't recommended.

 The ATX would give me 24 volts across the +12 and -12 volt rails, unless I can't do that with an ATX power supply.


----------



## tjwal

clifwst said:


> I'm not using pololu drivers, I'm using the  stepper driver based on the  Toshiba TB6560 chip.
> 
> The data sheet says voltages above 24 volt isn't recommended.
> 
> The ATX would give me 24 volts across the +12 and -12 volt rails, unless I can't do that with an ATX power supply.



A couple of problems come to mind

First the -12v typically has a low current rating.  I looked at one of mine and the -ve rail is only good for 0.8 amps.  Thats not enough to adequately drive your stepper.

The second issue is that the ground of your driver board will be at -12v.  The +5 from the supply is now +17 v when referenced to the driver.  If youre using the +5 to power an Arduino or something else connected to the driver then unless the grounds are kept separate you will be shorting out the -12v rail.


----------



## bmac2

Hi clifwst. 
would a 250 watt 12 volt ATX power supply have enough amps to power the electronics package and a nema 23 57BYGH310 stepper 

Yes of course it will. The _Manufacturer _of your stepper rates it to operate at 2amps, 8.6Vdc. Limit the current to 2 amps and it will run all day on the 12 volt output from the AT Supply.

Upping the voltage is preferred _IF_ you are going to be using micro stepping, but if you are planning to use a rotary table I personally dont see any need to go below quarter step. 

Microstepping increases the resolution at the stepper and is advantageous with an indexer with a low mechanical reduction but comes at a cost of a reduction in torque and speed. 

https://www.micromo.com/technical-library/stepper-motor-tutorials/microstepping-myths-and-realities

If I remember correctly Dillers rotary table is 90 to 1. Set to quarter step he would be sitting at 72,000 steps per revolution with tons of torque.

Im using a high torque Nema 17 stepper set to quarter step with a 36 to 1 table ratio. The stepper is running off 12 volts with the current limited to .6 amps. This gives me 28,800 steps per revolution. Ive cut dozens of gears (and they work) and find myself using it more and more for milling so long as the piece will fit on the little 3 inch table. And yes lite cuts 5 or 10 thou max.

Sorry to any one I may offend but with 80 steps per degree of rotation if it drops a couple through rounding errors I just dont care. It cost less to build than buying a single dividing plate, I dont have to turn the crank and it doesnt lose track of the number of holes.


----------



## clifwst

> The second issue is that the ground of your driver board will be at  -12v.  The +5 from the supply is now +17 v when referenced to the  driver.  If you&#8217;re using the +5 to power an Arduino or something else  connected to the driver then unless the grounds are kept separate you  will be shorting out the -12v rail.


I had planned on using +12v on the + rail and -12v on the - rail,  done this before to get 24v.  But bmac2 is correct only 1 amp on the -12v rail. Given the stepper specs this still might work.

PS original usage was to build live steam parts.


----------



## Wizard69

The voltage that is ideal for a specific stepper motor is based on its inductance.   On the Gecko drives site there is an explanation as to how you calculate that voltage.   You then need drivers that can handle that voltage to get maximum performance.   

In any event this highlights a couple of things.   One it is possible to match motor inductance to the power supply available.  Second you don't always need max performance out of the motor.   If you are hell bent on using a PC power supplies 12 VDC rail make sure you have a low inductance motor that will run well on 12 VDC. 

This highlights another issue, sometimes you can get better performance out of a smaller motor if your power supply is less than optimal.  

A related problem that i see in the reprap and CNC forums is that people  tend to set the current settings on their drives often because they believe the motor is running too hot.   This can completely trash stepper performance.   You want the motor driver to run the motor at its rated current to get full performance.   In a nut shell current impacts torque and voltage allows you to over come inductance faster, proper values for the stepper in question leads to the best possible performance. 

Now on a worm driven rotary table you have significant gearing advantages so maybe you don't need max performance.  That is possible but you never know what you may be doing in the future and end up with a drive failure due to the lack of torque.  

So what is all this gibberish?   Simply a suggestion to make sure you are getting maximum performance for when you need it.


----------



## clifwst

> On the Gecko drives site there is an explanation as to how you  calculate that voltage.


Did that;

32 x sqrt16.2 = 128.7975  but at what amps?  

Because remember my motor is rated 8.6v at 2 amps.  

So would that mean 0.1335 amps at 128.7975 volts?

I'm asking this because I am willing to change both the driver and power supply, but need to know what would be both relatively safe for the motor as well as cost effective for me.


Would some thing like this work, or is it too small voltage wise if I keep to the recommended input voltage?



> Input voltage 9-42 V (24 V recommended)
> Ouput Current 0.5-4.0 A
> Maxium frequency: 20KHz



Is this driver better?




> Input voltage: 20 - 40 VDC
> Output current: 7 selections of 0.30 - 2.20A
> Maximum frequency: 75KHz



I'm guessing it might be for my stepper.


----------



## rodw

Don't overcomplicate things. 

If you are going to upgrade hardware, don't stuff around and go with 48 volts.  It is common to send much higher voltages to the drive than what the spec says.

I can recommend 2 quality drivers but the Gecko is the smallest so it might be easy to fit in an enclosure.
Gecko g251x http://www.geckodrive.com/g251x.html

Longs Motors DM542a https://www.ebay.com/itm/High-1pcs-...VDC-CNC-New-/131184809631?hash=item1e8b39569f
Make sure you get one with an elephant on it. I have 5 of these driving my 1200mm x 1200mm plasma table and they fairly scream!

The main thing is to limit the current on the driver so it does not exceed the drive rating so if yours is 2 amps, set the current to 2 amps. Gecko uses a resistor, Longs Motor uses a DIP switch


----------



## Wizard69

clifwst said:


> Did that;
> 
> 32 x sqrt16.2 = 128.7975  but at what amps?


You run stepper motors at their rated current, nothing more and nothing less.  It is the responsibility of the stepper driver to regulate the current to the motor.  It will do this if the driver is set up properly.  


> Because remember my motor is rated 8.6v at 2 amps.


Doesn't matter, a properly set up drive regulates the current.   The big issue here is that the stepper requires a fairly high voltage to get max performance.   Id strongky suggest sourcing a stepper with a lower inductance that can operate successfully on a lower voltage and thus more commonly available drives.  


> So would that mean 0.1335 amps at 128.7975 volts?


No!   Steppers are current based devices, best performance comes at the rated value for the stepper.  


> I'm asking this because I am willing to change both the driver and power supply, but need to know what would be both relatively safe for the motor as well as cost effective for me.


Buy a stepper motor with a lower inductance that can operate off lower voltage power supplies.  

You can try running this stepper off a supply of less than 80VDC and see what happens but you wont get max performance.  .  It might be good enough if ultimate speed isn't important.    In the end though the right answer is to buy a drive/stepper/power supply combo that work well together.  


> Would some thing like this work, or is it too small voltage wise if I keep to the recommended input voltage?


That doesn't even translate into something that makes sense to me.   So a quick stepper primmer. 

Current affects torque, you always want your driver set up to run the stepper at its rated current otherwise torque is compromised.  

Second inductance impacts the rate of change to current flow in a circuit.   In the case of steppers high inductance means a slow motor for a given power supply.  

Applying a higher voltage to a high inductance stepper will change the current through the windings faster.  The little bit of math that we use finds what that max voltage should be.  

Now modern drives regulate the current in the motors by rapidly switching the voltage to the windings thus the motor never sees the power supply voltage for any length if time.  So the concern about voltage has to do with the speed at which the drive can saturate the windings and thus the ultimate speed of the stepper.    So max performance demands a power supply close to your calculated value.  

Now your problem is that the vast majority of low cost solutions operate at less than 80 volts DC.  This means you either need a new stepper or a high voltage drive to get max performance out of your stepper.   It is one or the other if you need max performance.  

In a nut shell you would be far better off with a different stepper that can run off commonly available power supplies.   Commonly available supplies have voltages of 5, 12, 24, 28 and 48 VDC.   With a bit of searching you can also find supplies in the 72-80 volt range for servo or stepper use.  

The trick is to fit all of your electronics into a suitable panel bos, ideally one that isn't huge.  In this regard you really want to think carefully about the voltage you settle upon


> Is this driver better?
> 
> 
> 
> I'm guessing it might be for my stepper.



Don't guess!   Really that will lead to excessive frustration.    Post questions here but more importantly look for stepper motor tutorials on the net and spend some time learning about the tech.  This will allow you to make wise decisions about the parts you buy.  In a nut shell a little bit of engineering up front goes a long way.


----------



## HarrisCreekCentral

You may also like to refer to Chuck Fellows series on the Arduino Controlled Dividing head.
https://www.youtube.com/playlist?list=PLA-7ZG9vM-3JP6OIPQ5TtIawvOqDMD05j

I have found these very interesting.  This link is to his total series. Check them out one by one as you have the time.

Harvey
In Kelowna, B.C.


----------



## rodw

Wizard69 said:


> Buy a stepper motor with a lower inductance that can operate off lower voltage power supplies.



Or just get a higher voltage power supply. 

Lower inductance generally means higher cost so choose your options carefully to stay in budget. Regardless of the inductance, doubling the voltage more than quadruples the torque.


----------



## jkcab

Ok, I ordered the stuff, waited three months, then followed the instructions and made it to post 19. Bob says if you own a scope you probably stop reading? Not me LOL. I finished the project but the stepper will not move? Every thing seems to work and I tried two different stepper drives. The first was a Pokeys 25-32 which I had never used before and purchased for another project. I suspected it might be the issue so I connected a TB6600 which is wired like the one Bob used. No go.

 Having an O scope and some limited knowledge I attached it to the Arduino pin 2 to see if I could find a trace of the step signal and I get nothing? I went back to post 19 to look at the photo of Bob's scope to see what he had set it to. I have a Tec 2232 and set it to the same as Bob's and then set the controller to do 60 degrees, pressed A and waited to see something and there was nothing but noise?

The only changes I made to the code were 1600 steps, as I am using a nema 17 200 step motor and eighth steps on the controller. I also changed the ratio to 72 as I am using a Sherline rotary table. I am confused as to what I am doing wrong? 

Any direction here would be most appreciated as I have no experience with programming an Ardunio. I have done a little with VB in Mach3 and that is about the extent of my programming.

Apparently Bob's wife is smarter then me and I am dummer then the dummies this tutorial was intended for?

Thanks,

Jeff K.


----------



## bmac2

Hi Jeff
If your seeing nothing but noise on your scope check that the ground lead on the scope probe is connected to the Arduinos GND. You could start with the Blink sketch and the delays set to 100 or so and have a look at pin 13 with your scope. If the LED on the board is flashing you will have a square wave on the scope.
Id suggest stepping back a bit and start by loading the stock sketch as is and run it with the controller   disconnected. If you can see the step signal on the Arduino then connect the controller. It looks like on the TB6600 ENA-should be connected to the Arduino GND. Then connect the scope probe ground clip to the - terminal of the stepper supply and check that you have something on the stepper output. If thats working connect your stepper and once its up and running then tweak the software.


----------



## Cogsy

I second the advice to start with an example sketch (like "Blink"). I recently received a Chinese clone Arduino with a simple robotic car kit and although it powers on, it refuses to communicate with the Arduino environment, so it's very possible to get dodgy boards. Some day, when all the other things I have on the to-do list have been achieved, I'm going to build one of these rotary table controllers as well...


----------



## bmac2

Hi Cogsy I see on the news that you are definitely in The Heat of Summer down under. We were at a high one day last week of -31 and then today +3. Got to love winter in Canada.

  For your Arduine, stragenmitsuko (Pat) mentioned that a lot of the Chinese cloned use a CH340 uart. You just have to download/install the driver. Easy peasy.
https://sparks.gogo.co.nz/ch340.html


----------



## rodw

Cogsy said:


> I recently received a Chinese clone Arduino with a simple robotic car kit and although it powers on, it refuses to communicate with the Arduino environment, so it's very possible to get dodgy boards.



Its not uncommon to have problems with setting up USB serial ports on a Windows machine regardless of who made the chipset. If you have  a poke around using Device Manager, you can often find the correct COM port in the Arduino IDE. Sometimes though you will need to install the correct device driver and then Device Manager may give you a clue on what to look for.


----------



## jkcab

Thanks for the reply. I did disconnect the driver and power supply prior to making the check with the scope. As for the 6600 I have one on the bench connected to my other project I was working on prior to getting the components for this one. It is attached to a rotary tool changer I built to go on the sherline cnc lathe. It is connected to a breakout board and I can jog the axis with Mach3 but am having trouble with the VB script program. That aside it works without attaching anything to the enable pin. I am charging my camera up so I can provide a photo of my setup for you. I am not very experienced with the scope and bought it to work out some problems with a Pokeys57cnc board I am using for a cnc conversion at work.

I will re-flash the arduino with the original sketch and try that. What do you suggest I set the scope for in divisions and period? I am using a 10x probe and had the div at 10 and the period at 1 ms.

By the way I did check to make sure I had a good ground. I was using the ground pin that went to the controller per your instructions. I was thinking maybe I should have the wife or my daughter do it for me!!! Hopefully I will have some photos and results for you before church this morning. If not it will need to wait till after lunch.

Thanks again,

Jeff k.


----------



## jkcab

Here are some pics!


----------



## Foozer

Using original sketch 

1600 steps and 72 ratio returns '-1320 steps' . . . Knock it back down to 400 steps [half step]

Rod is by far better with code as to why it returns a minus @ 1600 than I . . .


----------



## jkcab

I put it back to the original 400 and 36  and got a good scope reading. I did set the driver to half step and then hooked it up and it worked. I need to change the ratio to 72 and see if it will still works?

Thanks,

Jeff K.


----------



## bmac2

Excellent this will stop you having to get your wife's help. Believe me it will save you HOURS is standing in the mall, holding her purse, and looking at shoes that all look the same


----------



## Foozer

Should be good at 72
Just stripped out from the sketch all that wasn't needed to get a step value 


// int yields a range of -32,768 to 32,767
// const int good for 400 [half step]

 const int StepsPerRotation = 400; // Set Steps per rotation of stepper NOTE the driver is set to Half step
 const int TableRatio = 72;        // ratio of rotary table
 const int Multiplier = (StepsPerRotation * TableRatio)/360;  // 200*90=18000/360 = 50
// const long StepsPerRotation = 800; // Set Steps per rotation of stepper NOTE the driver is set to Half step
//const long TableRatio = 72;        // ratio of rotary table
// const long Multiplier = (StepsPerRotation * TableRatio) / 360; // 200*90=18000/360 = 50

float Degrees = 180;                // Degrees from Serial input
float ToMove = (Degrees*Multiplier);                // Steps to move


void setup()
{
  Serial.begin(9600);
  Serial.println((StepsPerRotation * TableRatio) / 360);
  Serial.println(ToMove);
}

void loop()      // MAIN LOOP
{
}

Something about 'int' being limited which my minimal skills sparked as a red flag . . .- anywho const int works with the numbers even at 360 degree rotation


----------



## jkcab

Bob,

That is why I was going to ask my 16 year old daughter first! dodged the bullet there. Anyway here are the results ....it will not work with anything but 400 steps (1/2 step)? I would really like to take better advantage of micro stepping as it has a lot of resonance at 1/2 step. Do you have any suggestions as to how to make that happen? I am using a 20V 3A power supply and a nema 17 84 ozin stepper with 3mh inductance @ 1 khz and 2A rating.

Thanks,

Jeff K.


----------



## rodw

You guys are getting caught up with overflow of the datatype. As said an int can count from -32767 to +32767 so if you add 1 to 32767, you get -32767.

400 * 72 = 28,800 which is getting up near 32767 so you can't go past 400 steps per rev.

If you use const unsigned int, you get to count from 0 to 65,534 which may help but really the code needs a bit of cleaning up at this point. Personally, I would use a #define to set the rotation parameters. This is a preprocessor directive that generates no code but when the compiler sees a #define it blindly substitutes what is on the #define statement. Convention says #defines are shown in capital letters to designate its a #define not a variable.

You are also probably getting problems from type mismatches when calculating the steps per degree for the variable ToMove as you are mixing data types. When assigning a value to a float, ALWAYS ensure the value has a decimal point like this:

float Degrees = 180.0;  // Makes it unambiguous to the compiler that you are assigning a float data type  

So I would start like this:



		Code:
	

#define STEPS_PER_ROTATION 400
#define TABLE_RATIO 72
float Multiplier = ((float) STEPS_PER_ROTATION * (float) TABLE_RATIO) / 360.0  
float Degrees = 180.0; // Degrees from Serial input
float ToMove = (Degrees*Multiplier); // Steps to move

void setup()
{
Serial.begin(9600);
Serial.println(Multiplier);
Serial.println(ToMove);
}

void loop() // MAIN LOOP
{
}


This is still not really clean code as the variable multiplier never changes so you could use another #define instead



		Code:
	

#define MULTIPLIER ((float) STEPS_PER_ROTATION * (float) TABLE_RATIO) / 360.0


Once compiled, the compiler will do the maths and only store the result. 
This might be a bit hard to print as per the example as the print statement will expect a type so you might have to do


		Code:
	

Serial.println((float)MULTIPLIER);


So in summary guys, you have been set up to fail by poor coding practices in the original script. Whilst it worked for the author, it is not universal code and full of gotchas that could bite the inexperienced coder who needs to change the values to suit his hardware.

Please take the time to  learn about C compiler preprocessor directives (like #define) and C data types. Just Google these phrases.


----------



## tjwal

jkcab said:


> I put it back to the original 400 and 36  and got a good scope reading. I did set the driver to half step and then hooked it up and it worked. I need to change the ratio to 72 and see if it will still works?
> 
> Thanks,
> 
> Jeff K.



The version I posted in message #80 uses long integers so it will handle micro-stepping up to where steps * table ratio > 2 million.

My code does rely on the compiler to take care of the conversion rodw refers to.  I plan on fixing that but am still waiting on parts for my spindle.
IIRC there are either 1000 or 500 steps per second so a a setup with a large Multiplier will take several minutes per rotation.


----------



## jkcab

That is pretty funny! I was coming here to ask that question. I read Rods reply which was a bit over my head so I did some research. I was wondering if I would be able to use long integers? I am not sure I understand about the compiler conversion though? I guess I need to do more reading.

Thanks,

Jeff K.


----------



## Cogsy

jkcab said:


> I am not sure I understand about the compiler conversion though?


 
Type conversions are when a variable type is changed to a different type. For example an integer is a whole number (1, 2, 3, etc.) and a float is a floating point number (basically a decimal 1.23, 10.5, etc.) and they are different things. Now if you let the compiler decide which type you wanted to use it can have unwanted consequences. For example, using floats, 3.0 divided by 2.0 gives a result of 1.5 as a float. If we mix our types though, and divide a float of 3.0 by an integer of 2, without specifying what we want the answer in, we will still most likely get a float of 1.5 but it's not guaranteed and is decided by the compiler - the answer may well be given as exactly 1. 

What about if we don't mix types and divide the integer 3 by the integer 2? The result is the integer 1, so 3/2 = 1!! This is how integer division works, where remainders are discarded. In this example, if we let the compiler decide the type of the result, it will return an integer of 1, rather than a float of 1.5 (most likely anyway). From our example above, 3.0/2 is possibly going to return an integer of 1 as well, even though at first glance it looks like we are performing float division rather than integer division. So because of all this potential for problems, we must make sure we don't have any ambiguity by either not mixing variable types, or specifying the types used for calculations and results (it's called type casting).

Lastly, if we take a returned value (let's say a float of 2.99) and attempt to use it where the program is expecting a different type (we'll say an integer) the compiler will do the typecasting for us and likely convert the float from 2.99 to an integer of 2, so we just lost over 30% of the value of our variable. You can see how many problems can arise from this.

When a program is written with typecasting issues like this, it may function perfectly due to the values being used (eg 10/2 = 5, etc.) but then small changes are made, such as needing a ratio change from 10/2 to 11/2 using integer values, and we hit conversion issues.

This was supposed to be a quick explanation but I'm not sure I succeeded...let me know if it's not clear.


----------



## rodw

I think Cogsy has given a fairly good explanation of consequences of getting types wrong. The term is not "type conversion" but "type cast".

eg :

float f:
int i = 13:
f = ((float) i /2.0);  // adding brackets around stuff like this is always a good idea.

Mixing types should generate a warning at compile time. You should treat every warning as an error and try and work out why they are happening and change your code to eliminate the warnings totally.

C is very tightly integrated to the CPU and its seen iterations from 8 bit, 16 bit, 32 bit and 64 bit processors so today we can manipulate larger data types than we could and it is quite possible that an int on one CPU is a different size on another.

Now try changing the above to
f = i / 2;
and see what value ends up in f and if you get a compiler warning.


----------



## jkcab

Thanks Guys, That was a great explanation and very easy to follow. Rod's sketch is working for me because the only change I made was to double the ratio for the gearing. His was 36 and mine is 72. I am going to do some more reading and attempt some changes on my own. I will try tjwal's sketch from post #80 also and see how that goes. I will report my results after.

Thanks again for taking the time to explain. I find the tutorials to be a bit confusing. They do not take the time to explain the nomenclature.

Jeff K.


----------



## tjwal

I've quickly gone through the sketch I posted in message #80.
I found 3 instances where there were type conversions that depended on the compiler to resolve.  The compiler with Arduino IDE 1.8.2 does resolve these correctly however there is no guarantee that another compiler would do so.
line 152 should be  ToMove=(long)((bob/360.0) *(float)( Multiplier + 0.5 - cumSteps));
line 164 should be  ToMove=(long)((float)(cumSteps+0.5 -  (bob * Multiplier)/360.0));
and line 251 should be Degrees = (float)360/num;

I haven't tested these changes other than making sure the code compiles.  When I have an opportunity to do a full test  I will re upload it.


----------



## jkcab

tjwal,

In the beginning of your sketch you have user defined variables. I used pin assignments from Rod's original sketch. So I changed those and also the ones for the key pad to what Rod had for rows and columns. I then downloaded the sketch but the key pad was not responsive. What might I be doing incorrectly?

Jeff K.


----------



## tjwal

Without looking at Rods sketch I imagine that my sketch is using one the pins for something else.  First thing to do though is test the keypad with his assignments.  I'm attaching a short sketch for testing the keypad.  It uses the same pin assignments as my indexer sketch.  Make your changes to it and see if the keypad works. 

View attachment keypad_test.zip


----------



## tjwal

Can you point me to Rod's sketch that you are using?  The one I found doesn't use a keypad.

Thanks
John


----------



## jkcab

John,

I,m sorry I was referring to Bob's sketch in this tutorial!

 I also made the changes you listed and I got this error for line 164 change "Long was not declared in this scope"?

Thanks for your patience,

Jeff


----------



## tjwal

jkcab said:


> John,
> 
> I,m sorry I was referring to Bob's sketch in this tutorial!
> 
> I also made the changes you listed and I got this error for line 164 change "Long was not declared in this scope"?
> 
> Thanks for your patience,
> 
> Jeff



is "long" all lower case?

I didn't make many changes to the keypad input part of Bob's code, but I do recall having a bit of difficulty getting my keypad to work.  As I recall Bob's original keypad was 3x4 and the column-row pinout seemed to be reverse of what mine is.  I wrote the keypad_test sketch so I could figure out what was going on.  When I pressed the 1 key the sketch was detecting the keypress but reporting a different result to the serial monitor.  Then it was just a matter of adjusting the pin assignments to get it to work.


----------



## Foozer

Code from post 17 Arduino_Rotary_Table   Rows 11,10,9,8  Col 7,6,5,4
...     from post 80 Dummies_Rotary_Table   Rows 9,10,11,12 Col 5,6,7,8

Tested 4x4 keypad 
byte rowPins[ROWS] = {9,10,11,12};
byte colPins[COLS] = {5,6,7,8};

Reports correct button pushes . .


----------



## jkcab

John,

I typed long with an upper case L and am assuming we are case sensitive? As for the keypad pin out fozzer's description is accurate. I renumbered your sketch to match Bob's as I had already wired it and it was working correctly under Bob's sketch. When trying yours with the numbers changed I got no response to the keypad at all. I then uploaded Bob;s sketch back in and all worked. I will need to take another look to make sure it was typed correctly?

Jeff


----------



## Foozer

While watching Rick & Morty played around with the sketch
Sketch from post 80 has listed

const int stp = 8;               // connect pin D8 to step
 const int dir = 9; 

8 & 9 are used by the keypad, haven't looked thru all the post to see if that was caught, changed them to 3 & 4
Also and this may just be the keypad library on my machine, changed all instances of 'Keypad kpd'  to 'Keypad keypad'

To clean up screen
char key = keypad.getKey();
  lcd.clear();   <---- added 
   lcd.print("Enter Selection:"); 

Buttons and screen working in harmony

Robert


----------



## rodw

jkcab said:


> John,
> 
> I typed long with an upper case L and am assuming we are case sensitive?
> 
> Jeff



C is a case sensitive language.


----------



## jkcab

Ok Guys here is my report. I fixed the case sensitive problems and I apparently transposed the numbers for rows and columns. I fixed that also. I am using an 84 ozin nema 17 motor to turn a Sherline rotary table that is 72:1. I changed the steps on the motor driver to 1/8 and in the sketch to 800 and all worked fine. I then tried 1/16 at 1600 and it worked also. The problem is with 1/16 it seams to lack enough torque and is really sloooow! In the end I put it back to 1/2 step and 400. I am using a 20v 3A power supply. I think the only thing else I could do is use a higher voltage supply in hopes that it will increase speed?

Thanks again for the help,

Jeff K.


----------



## jkcab

I have everything finished and hooked up. John's sketch dose some strange things with the maths. I typed in 17 divisions to test an odd number. It reports a move of 21.18 degrees and moves 1694 steps. The next time you hit the button it moves double the steps but reports the correct degrees 42.36. it goes on in odd steps from there. I then uploaded Bob's sketch since I am still at 400 and 1/2 stepping and performed the same test. The only thing wrong there is it dose not report the number of steps to move on the LCD? however it lands right back at the start when you travel the full 17 increments 3 times around.

Jeff K.


----------



## kquiggle

I've been working on a build based on the original post for this topic, and it has been a very useful learning experience. Of course there is a ton of info online about steppers (drinking from the fire-hose, anyone?), but a few things seem to be hard to find. Here are some things I think I learned, which may or may not be correct, so if anyone can confirm or correct these items I would appreciate it. Also, I have not been able to find a really good reference on controller settings (what they are and how best to set them), so if anyone has one please let me know.

Things I learned (?) about stepper motors :


Do NOT rotate the stepper motor by hand while connected to the controller  it will generate a voltage which may damage the controller.
NEMA motor sizes : These refer to the size of the motor faceplate, not the overall size of the motor. Motors with the same NEMA size can vary in length, rated current, maximum torque, etc.
Settings on the controller :
Running current  the current supplied to the motor by the controller. Increasing the running current increases the torque. Do NOT set the running current higher than the rated current for the motor.
Stop  amount of current to supply the motor when stopped; more current = more holding torque. [really not sure about this one]
Excitation  set the motor for stepping or microstepping.
Decay  controls how quickly the current to the motor drops off when stopping (its counterintuitive : fast decay = slow stop, quick decay = fast stop).
 
Microstepping  generally speaking, microstepping will reduce torque to about 71% of full stepping.


----------



## kquiggle

I've been working on an electronic indexer based on the original post on this topic, making what I call a "straight-through" design (see picture) with the motor driving an ER32 collet holder. I plan to use this on my mini-mill to make gears and other small items which can be held in an ER32 collet (or mounted on a mandrel in the collet). My goal is to build a simpler (cheaper!) indexer.

Initially I was concerned that the motor might not have enough torque to do the job, but it seems to be working. The design also includes a mechanical rotation lock, so I'm not counting on motor holding torque to keep things stationary while milling.

I'm running the motor at max rated current (1.4A) with microstepping set to 16. Since there is no reduction gearing the collet holder moves quite briskly. This give me a resolution of 0.1125 degrees/step, but I need to make the coding more complicated to make full use of this resolution (working on that).

Here's a link to the build in progress:

https://sites.google.com/site/lagad...ls-etc/build---electronic-indexing-head?pli=1


----------



## Foozer

inserting the change [line 152 should be ToMove=(long)((bob/360.0) *(float)( Multiplier + 0.5 - cumSteps));] from post 126 gives the error  - It seems to be adding tomove to itself 

'vert back to the original till the 'Why' is solved . .    Been punching the A - B with 17 divisions for a while and so far error free . .


----------



## tjwal

Foozer said:


> inserting the change [line 152 should be ToMove=(long)((bob/360.0) *(float)( Multiplier + 0.5 - cumSteps));] from post 126 gives the error  - It seems to be adding tomove to itself
> 
> 'vert back to the original till the 'Why' is solved . .    Been punching the A - B with 17 divisions for a while and so far error free . .



Thanks Foozer.  Error was caused by misplaced brackets.
This seems to work better.
ToMove=(long)((float)(bob/360 * Multiplier + 0.5 - cumSteps));


----------



## tjwal

jkcab said:


> Ok Guys here is my report. I fixed the case sensitive problems and I apparently transposed the numbers for rows and columns. I fixed that also. I am using an 84 ozin nema 17 motor to turn a Sherline rotary table that is 72:1. I changed the steps on the motor driver to 1/8 and in the sketch to 800 and all worked fine. I then tried 1/16 at 1600 and it worked also. The problem is with 1/16 it seams to lack enough torque and is really sloooow! In the end I put it back to 1/2 step and 400. I am using a 20v 3A power supply. I think the only thing else I could do is use a higher voltage supply in hopes that it will increase speed?
> 
> Thanks again for the help,
> 
> Jeff K.



Jeff
shouldn't 1/8 stepping be 1600 steps?  I'm assuming a 200 step/rev stepper.
Raising the voltage will not increase the speed but will increase the torque.
You can increase speed by reducing "stepdelay" on line  20 of my sketch.  I'm using 1000 microseconds.  Bob is using 1 millisecond.  If you're using Bob's sketch you will need to change the code in the rotation function to use "delayMicroseconds".  Increased speed will need higher torque so you likely will also have to raise the voltage.
John


----------



## tjwal

Foozer said:


> While watching Rick & Morty played around with the sketch
> Sketch from post 80 has listed
> 
> const int stp = 8;               // connect pin D8 to step
> const int dir = 9;
> 
> 8 & 9 are used by the keypad, haven't looked thru all the post to see if that was caught, changed them to 3 & 4
> Also and this may just be the keypad library on my machine, changed all instances of 'Keypad kpd'  to 'Keypad keypad'
> 
> To clean up screen
> char key = keypad.getKey();
> lcd.clear();   <---- added
> lcd.print("Enter Selection:");
> 
> Buttons and screen working in harmony
> 
> Robert


Good catch.  I'm using a pro micro and missed revising those two pins to reflect a UNO when I posted the code.
There must be some difference in the libraries we're using as I'm not having the keypad or lcd issue.
Cheers
John


----------



## Foozer

That fixed it, 17 divisions 1694 steps with the occasional spread the error out 1695 popped in

Also changed line in printadvance from lcd.setCursor(13, 0) to lcd.setCursor(14, 0) to wipe out the left over trailing digit by the padding that follows [lcd.print("      ");]

I like half steps, so the motor buzzes a bit, my little rotary is 36:1 and @ 1600 steps per rotation the torque is so dropped off that I can with little effort finger stop it, plus my gray beard will grow an inch waiting for the next position to come up, not so much @ 400 steps . . . 400 is a reasonable bank for the buck . . .

Robert


----------



## kquiggle

After reviewing the code from the original project  (Reference  #3 below), I decided to make some major changes. The revised code can  be downloaded here:

Arduino_Rotary_Table_Control_2017_Rev5.ino : https://drive.google.com/open?id=14_J0URvgsPYnLZ1EFZD2IRKg-7uJEYHN

The  code changes were made so that when stepper motor and rotary table  parameters are entered into the program, calculations will be made in  two ways:

[Note: In the explanation below, I  will use "steps" to mean either full steps or microsteps, which the  stepper motor is set for.]

First, the  program will calculate the exact ("theoretical") number of steps  required to move a specified number of degrees; this may be a fractional  number even though the stepper motor cannot move a fractional step. The  program also keeps track of the total number of theoretical steps  moved.

Second, the theoretical number of  steps are converted to "actual" (integer) steps. The program also keeps  tracks of the total number of actual steps moved.

The  determination of the required number of steps to move is in all cases  based on the theoretical steps, which are then converted to actual  steps. This method provides the best approximation (typically with an  error less than 0.01%), and enables the easy use of gear and table  ratios which do not divide exactly into 360.

Updates or corrections will be posted on my build log here:

https://sites.google.com/site/lagadoacademy/machining---lathes-mills-etc/build---electronic-indexing-head?pli=1


----------



## jkcab

Thank you John and Foozer,
I am not sure I follow where to make the changes you suggested in regards to the screen:
"To clean up screen
char key = keypad.getKey();
lcd.clear(); <---- added 
lcd.print("Enterction:"); "
However I made the bracket change to the "To Move" line and that worked great. Yes you were correct I miss typed 1/16 instead of 1/8, 1600 steps. I decided to try several delays along with different step resolutions. I ended up with 1/8 step at 200 milliseconds. It runs reasonably fast and I am unable to stall the rotation by hand. If However I wanted to mill a curved slot, with the table set horizontal, I think it would be a bit too fast. I found for milling I would need to reload the sketch at a delay of 500. 
This begs the question, can another menu item be added that allows the selection of that delay from the LCD screen. If so one would have the ability to adjust feed speed when milling. I assume that most people doing this is for indexing and would not require speed adjustment. I am hoping to extend the capabilities to include all the typical uses of the rotary table in addition to indexing.
On another note, I looked at kquiggle's sketch and to not understand how he is accounting for cumulative error? The sketch that John made keeps track and adjusts for it if I am reading it correctly?

Thanks again,

Jeff K.


----------



## tjwal

jkcab said:


> ...snip....
> 
> This begs the question, can another menu item be added that allows the selection of that delay from the LCD screen. If so one would have the ability to adjust feed speed when milling. I assume that most people doing this is for indexing and would not require speed adjustment. I am hoping to extend the capabilities to include all the typical uses of the rotary table in addition to indexing.
> 
> .....snip...
> 
> Thanks again,
> 
> Jeff K.



Jeff
I&#8217;m working on a version with a menu to change the table and stepper ratios.  It will be easy to include the delay.  The data is stored in EEPROM so it only has to be  done when a change is needed.  It&#8217;s a work in progress but I&#8217;ll upload a &#8220;working&#8221; version later today.

John


----------



## kquiggle

Jeff K.  -

My sketch avoids cumulative error by calculating the exact "theoretical" position for each move, and then converting that to an integer "step position". Subtracting the previous "step position" gives the required number of steps for each new increment.

Before writing the code I modeled this in a spreadsheet and tested different numbers of divisions. Here are the calculations for 7 divisions (note: 3200 steps per 360 degrees for my set-up, so 0 and 3200 are the same position). 


[FONT=DejaVu Sans Mono, monospace]Div Theoretical       Actual[/FONT]

 [FONT=DejaVu Sans Mono, monospace]0    0.000                            0    [/FONT]
 [FONT=DejaVu Sans Mono, monospace]1    457.143          457    [/FONT]
 [FONT=DejaVu Sans Mono, monospace]2    914.286          914    [/FONT]
 [FONT=DejaVu Sans Mono, monospace]3    1371.429         1371    [/FONT]
 [FONT=DejaVu Sans Mono, monospace]4    1828.571         1829    [/FONT]
 [FONT=DejaVu Sans Mono, monospace]5    2285.714         2286    [/FONT]
 [FONT=DejaVu Sans Mono, monospace]6    2742.857         2743    [/FONT]
 [FONT=DejaVu Sans Mono, monospace]7    3200.000         3200[/FONT]


----------



## tjwal

The attached file includes a menu system to change the settings of the indexer.  The included text file goes into detail.
I'm working with a pro micro but I have tried to save the pin setting for a UNO.  Check these to make sure they match your setup.
Comments and suggestions are requested.

Cheers
John 

View attachment Dummies_Rotary_Table_Eprom_2018uno_beta.ino.zip


----------



## Foozer

jkcab said:


> I am not sure I follow where to make the changes you suggested in regards to the screen: "To clean up screen Jeff K.


The post 80 script . . .

In the void printadvance()     section
From - lcd.print(ToMove);lcd.setCursor(13,0)
To     - lcd.print(ToMove);lcd.setCursor(14,0)

Was doing, say 17 divisions, 400 steps, 72:1 the 5th rotation advance reports 105.88 degrees- go back one rotation which should read 84.71, reads 84.718
Not a big thing.

"kquiggle's sketch and to not understand how he is accounting for cumulative error?"

It does, just doesn't show it on the screen - can check it by commenting out the stepper commands in void rotation(long tm, int d) and adding 
Serial.println(tm);

will show 1694 steps with each advance with the odd 1695 showing up when the error requires . .

I don't know seems like this new one should have a post of it's own, the original work which works fine for it's intended usage is kinda getting lost . .
Robert


----------



## kquiggle

As I do not want to detract from this post in any way, or risk making comments which are starting to veer off the main topic, I have started a new post on my related build (Electronic (Arduino) Rotary Indexer - Another One). If anyone is interested my build and related programming, I'll be posting updates there.

Thanks again to bmac2.


----------



## jkcab

Thank you John,

I loaded your sketch and it works great for speed adjustment. While playing with it I noticed I have .5 degrees of backlash. I adjusted out the lash and found that the 84 ozin motor dose not have enough torque to rotate the rotary table. It seems the highest torque motor I can find in nema 17 is 92ozin. I did find one that was 115 but way to pricey. I chose the nema 17 for clearance reasons and size of motor driver.  I am now in a quandary as I am not sure another 8ozin will make a difference or do I need lash adjustment in the sketch. I would hate to have to start over with a nema 23 and a larger driver? 
I feel like I am imposing to ask if you could add lash adjustment to the sketch? I am not even sure it is doable?

As for comments in regard to your latest sketch I have a few. It works great as is but you must turn it off and back on to change the settings. It might prove more convenient to be able to press the A key on the splash screen for changes without having to re-power the controller. I added an on off switch to my control box so that it would not be an issue for me. My other comment is when in the set up screen you need to put all the variables in every time even if you only want to change one. It would be convenient if the settings defaulted to the last one if you just hit the enter key without a change. 

I am grateful for the sketch as is but you asked for comments and I thought you would be interested in the observation. It feels like I am complaining about a gift!

Thanks so much for your efforts,

Jeff K.


----------



## tjwal

Jeff
Have you tried running with a longer stepdelay?  If that will work then increasing your supply voltage will also help.  For indexing, backlash usually isn&#8217;t a problem, you just need to approach your position from one side.  I think the same thing goes for milling but conceivably it could be a problem.  
I agree with you that having to enter all three variables is a pain.  I will try to fix that.  

If you&#8217;re in one of the moving menus, pressing &#8220;C&#8221; resets the Arduino and the splash screen comes up.  I&#8217;ve set the display time to be fairly short but if you&#8217;re quick should be able to press &#8220;A&#8221; and get to the settings.
Comments are welcome as they help me to improve the code.

John


----------



## jkcab

John,

If you power up the controller, go through set up and then run whatever. You then hit c and yes you do have time to hit the a but it will not take you to the settings screen? Maybe I am just not fast enough or I need to increase the splash screen time? 

I did lots of permutations with step delay and step resolution. I only changed 1 variable at a time. I did try a higher voltage supply in my earlier testing  and found it did not perform as well. I ended up with a 20v 4.5a dell power supply. I have a 24 volt adjustable supply but I did not think the extra 4 volts would make a great deal of difference. The other one I mentioned before was 32v but only 1.6a. The motor is 2a with low inductance so I opted for the lower voltage and higher amps.

As for the lash issue I was more concerned with a circular groove. You would have to exit the cut, go past the start, come back to the start and then re-enter the groove. You would also loose the ability to reverse direction to clean up the opposite side of the groove. You would always have one side climb milled and one side conventional.

It would also be a time consuming process something like the following: Say you wanted a 45 degree arc. You would set up for it and then plunge and cut. You would then lift the cutter exit and reverse say 50 degrees. You would exit again and then reset for 5 degrees forward. You would then exit again and rest for 45 degrees, plunge in and the run forward. This would be the process for each depth of cut. Sounds a bit tedious? I may be missing something I'm not sure?

Jeff K.


----------



## kquiggle

Jeff - Re torque problem: I'm new to stepper motors myself,but my understanding is that more power  (amps) = more torque, so you should set the running current on your controller to the setting that equals (or is just below) the rated current for your motor. Microstepping reduces torque slightly, so if you can get away without microstepping you should gain a bit of torque that way.

Another option (which I am considering for my own build) is to get a stepper motor with built in planetary gear reduction. I don't know what space limitations you are working with, but this might still fit your requirements (random ebay pick to show what I mean) : https://www.ebay.com/itm/Extruder-G...397028&hash=item4896881c77:g:tN8AAOSwM8ZZeZ9G

For your backlash issue, it would be possible to program in "backlash correction" but only if the backlash is constant. For example, if you had to advance exactly 8 steps every time to take out the backlash, this could be programmed in, but if it varied among 7,8,9 steps then I don't see how to correct for that. I'm assuming the backlash in your system is in the rotary table gears, so is maybe fairly constant. But it could also drift over time, so you might have to reset the backlash correction every time you use the table.


----------



## jkcab

OK I was missing something. If you have a known amount of lash it is easy to compensate for. Take my earlier example of a 45 degree arc. You would first set up for the 45 degrees, plunge in and then cut. You then exit out and set up for 45.5 degrees (.5 degrees of lash compensation) and reverse. You can now move forward and back as you will be compensated with each reversal. You would just need to keep track of your last move for your next operation to know which direction your lash is in.

Though increasing voltage and reducing micro-stepping will increase torque it appears it is not sufficient to overcome the friction of near zero lash with my current motor. That being said I would be dubious  of a planetary gear reduction as it would induce additional mechanical lash through the gear train. 

The reason I suggested programmable lash compensation is for the same reason you use it on a cnc with lead screws. Lead screws require a bit of clearance unlike ball-screws. Usually you try to remove as much mechanical lash as possible and then measure what remains. This is easy to do on a linear axis with a dial indicator. Once the amount is determined you just insert the dimension in the software like Mach 3. I suppose you could do the same with the rotational axis using trial and error until the indicator showed zero. Though lash will increase over time due to ware, It just requires occasional inspection and adjustment like any other system.

My real issue is the programming end! I am still trying to work out visual basic for the tool changer I built. In addition I have been reading about c and c++. It is a lot to learn. 

Jeff K.

Everything is easy once you know how!


----------



## rodw

Personally, I would not bother about backlash compensation for indexing on a rotary table.  Its easy to work around just by taking it up before you start machining and always move in the one direction just like we take up backlash on a manual machine. The only time it could possibly be an issue is if you are milling a slot on an arc but if it was too much to bear, you could just add a bit onto the angle you are cutting.

For the budding programmers out there I strongly recommend you skip Visual Basic and go straight to C or C++. If you have an environment that mandates Visual Basic, find another environment. Usually, you can interface to external DLLs etc with either language. C is just so much more efficient when you want to get things done!

If you need a scripting language, then consider Python which is used in LinuxCNC. Google has a week long recorded Python programming course to get you going. What might take 1000 lines in C, you can often get done n Python in under 100.


----------



## kquiggle

Jeff - 

I think my revised Sketch could be modified without too  much work to add backlash correction. With my mechanical set-up, I don't  have a good way to test, but if you are interested I can make the  modifications and share them with you for testing. Let me know if you  are interested.


----------



## tjwal

Attached is the latest version of my sketch.  The sketch allows the table ratio, steps per revolution and the step delay to be entered and stored in EEPROM.  I've added a selection to the first menu to select Settings.  The settings can be stepped through without changes by just pressing the "#" key.  Unless I've broken something, it should work on a UNO. 

View attachment EEPROM_2118-2.zip


----------



## johnstij

Hi.
I'm completly new to all this but thought I would have a go. I downloaded bmac2's sketch onto my Arduinno R3. If I change the steps per rev to 200 & Table ratio to 90 ( for my Vertex RT) it works OK. But when I change steps per rev to 400 ( for half stepping) and ratio to 90 I just get "moving " on the LCD for a fraction of a second  and Steps = 7380 but no pulses to the stepper motor driver (TB6560 set for 1/2)
 Has any one had it working for 400 steps 90 RT ratio?

Thank You
Ian

PS .
I tried tjwal's latest sketch which loads OK but does not respond to key pad.


----------



## tjwal

Bmac&#8217;s original sketch works only in steps*ratio is less than about 32000.  If you make the changes as per message #70 it will work.  There are some other issues but they are largely a matter of precision which might not even be noticeable.

My sketch uses the same keyboard coding as bmac&#8217;s but the keypad is connected to the pins differently.
John


----------



## johnstij

Thanks for that John.
I still could not get Bmac2's sketch to work. But after changing the key pad connections yours is good to go. What is a good value to enter for step delay ? I've set it at 1000. 
Thank you.
Ian


----------



## tjwal

A stepdelay of 1000 is equivalent to 500 steps per second which is what Bmac&#8217;s sketch used.  Decreasing stepdelay will increase the steps per second but will also decrease the stepper&#8217;s torque.


----------



## camm-1

Hi
In ordered all the **** at ebay and now trying to get something to work.
After a couple of ours I finally find a driver for this Arduino uno Clone that works.
And conect the Lcd display and downloded and uploaded the program
but it only lights up and nothing happens then I klick on serial monitor,
its only a empty window and the baud is on 9600.
Have put on other cables if it should be that but no.

Ove


----------



## camm-1

Im a dum dummie on this I know but I want to learn.
Somtimes I can load a unzipped file but most of the time it says invalid library.
And if I manage to load the 12c display it have a different adress and dont find the line bmac have on his photo to change it.
I maybe have to give up this


----------



## crankshafter

camm-1 said:


> Im a dum dummie on this I know but I want to learn.
> Somtimes I can load a unzipped file but most of the time it says invalid library.
> And if I manage to load the 12c display it have a different adress and dont find the line bmac have on his photo to change it.
> I maybe have to give up this


Hi Ove.

Don't give up buddy. It's only a matter of time and then the bulb will light up[emoji362]

CS


----------



## bmac2

Hi Ove, I just checked and its line #7 in the sketch that you will have to edit. Only change the address (underlined) with the address you got from the scan and click on the upload arrow (top left under Edit)





If you get a blank screen or the entire screen lights up first check that the LED jumper (circled on the left) is on the 2 pins and then try turning the contrast pot (circled on the right) with a small screwdriver.

Hang in there . . . Bob


----------



## NutNoxNut8

Firstly thank you for the clear build instructions very happy !- I have made 2 of these 1 for indexing on my milling machine -works perfect and 1 for my tig welding rotary table this i have a couple of problems with. 1) i need to control the rpm to adjust my travel speed before welding which varies with size and thickness of the aluminum tubing i am welding ( is it possible to hook up a potentiometer in your configuration ?) and the next is the fact that the high frequency of the tig machine ( welding mostly aluminum ) interferes with the control box - i suspect its the fact that i have not got a decent earth bushing construction on my rotary table or is it the high frequency that upsets things anyway ?.

Wonder if anybody has a simple solution for this or has had the same question ?

Many Thanks in advance 
Nick


----------



## tjwal

Attached are pictures of my controller.  I had an arduino Pro Micro so I used it.  A nano would work just as well.  Both of them have standard pin spacing which makes it easier to connect the keypad. I'm using as 18V lithium supply so I used an 8V regulator to drop the voltage to the arduino.   

I used a 330 oz-in stepper and a pololu driver.  The pulley ratio is 4.2 and I'm using 16 microsteps for 3200 steps per rev.  These have to be entered as integers but since they are multiplied together, I entered a table ratio of 42 and 320 steps.  With a step delay of 500 usecs, it has enough torque that it is difficult to hold the spin index wheel tight enough to get it to miss steps.  With a step delay of 250 usecs I'm pretty sure it missed an occasional step when starting to move.

I've also attached a picture of my 18V powerpack.  Originally I only intended to use it at our local "show and tell".  It works so well though, that its likely the only supply I will use with the indexer.  I found the 3D stl file for it at https://www.thingiverse.com/thing:352094

Kudos to bmac for writing up the assembly instructions. 





















View attachment EEPROM_2118-final.zip


----------



## scoopydo

tjwal,

I really like the way you've built your controller . Part 3D print and part aluminum. Would you happen to have a schematic? I've been working on your take on this but I can't get the keypad to work. Can't figure what I'm doing wrong, I've tried wiring the keyboard both ways to no avail? I know it's somthing simple but just can't get past that.

Thanks George


----------



## tjwal

George
I too had difficulty getting my keypad to work.  I finally wrote a sketch to test the keypad.  I posted it in message #128.  It echos the key presses to the serial monitor so you can see what is happening.  You adjust the row and column pin assignments until it works and then copy those over to the indexer sketch.

I didn't use a schematic when I put my controller together.  However, looking at the pictures and my code I came up with the attached.  It is for the pro-micro that I used.  It allows me to plug the keypad in without using jumpers.  I think a nano would be better choice than the pro-micro just because of the idiosyncrasies of uploading to a pro-micro.  I believe the nano pinout also allows for 8 consecutive pins to be used for the keypad.

John

I 

View attachment Index Controller.pdf


----------



## scoopydo

Thanks, John! I do have a Pro Mini but was trying to use a nano. It does support 8 consecutive pins for analog support. I'm using the same driver as bmac used, mainly because I've bought one or two whenever I found them on sale. I do have a Pololu driver in stock but I like the higher amperage.

Agin thanks! George


----------



## ramkitty82

I got mine working after some messing around. Default code threw a warning for variable overflow which for some reason prevented any stepper movement. Changing the multiplier formula to include a type cast as follows corrected my issue
 const int Multiplier = ((unsigned long)StepsPerRotation * TableRatio)/360;


----------



## tjwal

Be aware that  (StepsPerRotation*TableRatio) must be exactly divisible by 360 for the original sketch to be reasonably accurate.


----------



## tjwal

A follow up to my post #169, after using the indexer for about 20 minutes it started losing steps.  I assume the little stepper driver was over heating. I’ve rewired an external driver but haven’t got around to testing it.


----------



## harrzack

Here is a link to yet another take on creating an indexer with an arduino:   

The concept needs a bit of refinement for real accuracy on odd-tooth spacing but I have an idea for that... when I get my 'round-2-it' !


----------



## ramkitty82

tjwal said:


> Be aware that  (StepsPerRotation*TableRatio) must be exactly divisible by 360 for the original sketch to be reasonably accurate.


Good advice since that information is burried in depth of forums rather than front page. My 6" rotary table is just double the handle rotations maintaining the null modulus but this caused steps*ratio to be to large


----------



## scoopydo

harrzack said:


> Here is a link to yet another take on creating an indexer with an arduino:



Cool idea and simple menu system. I checked out your website but there doesn't seem to be much information there? And the video seems to be several years old. Are you going to have more information available? I'd like to build another rotary table and would like to try something different.

George


----------



## harrzack

scoopydo said:


> Cool idea and simple menu system. I checked out your website but there doesn't seem to be much information there? And the video seems to be several years old. Are you going to have more information available? I'd like to build another rotary table and would like to try something different.
> 
> George


Yes - the project is a tad old!  I've gotten off into a number of other things and had to put that on the back burner.
I can give you the Arduino source (but it may be a bit obscure!) If you are interested in giving it a go I'll be glad to help out as I can.

One of the big probs I see with this is the interpolation needed for odd step sizes. Which is what those 'plates' are for on a mechanical dividing head.  So - I've been thinking if I can get the degrees/step down to a fine enough level the error would be (largely) insignificant.   The rotary table gives 4 deg per rev which could then be divided down with stepper pulley ratios.  It would be slow moving - but so?   

If interested I'll dig out some of the calcss I did for this and pass them on.
Thanks for looking!

=Alan R.


----------



## scoopydo

harzzack, thanks for the reply. I think I'll have to give it a pass. The setup I have works great so I think it'll just get duplicated for the next one.

George


----------



## shopmate

Really appreciate your trouble to provide this information. Great work.


----------



## animal12

howdy folks , I finally have the parts in hand to get my build of this project going , thank you all for your hard work to get me to this point !!. I'm not sure where to start, with the link in post 145 , or the one in post 149 .
thanks in advance
animal


----------



## Jmccrack

I know I am butting in a bit but I was wondering if any has used one of these from Grizzly T1191


----------



## animal12

their pretty proud of that puppy .I have a old 4th axis from a MAXNC that I will be putting this project on hopefully . It's paid for already has the stepper & motor mount so I'm part way there already
animal


----------



## SmithDoor

Jmccrack said:


> I know I am butting in a bit but I was wondering if any has used one of these from Grizzly T1191
> 
> View attachment 102333


I look up the price over $600.00 for 4" table
I would look at shars. 
http://www.shars.com/products/workholding/rotary-machining-tables
I have seen 4" under $200 too
My self I found 8" is a better size
In I own 12", 10", 8" and 6" 
The was just to small and 12" weight to mush for hobby work.

Dave


----------



## Coolfox007

Thanks for making all this nice and clear ( just right for dummies ).
I have kinda question if you can help me to understand. 
Just for example: I have rotary table with total ratio 1000 pulses per one revolution and I need to divide circle say, for easiest,   on 3 equal segments how this code  deal with such task? 
Many thanks in advance
Ilia


----------



## SmithDoor

Coolfox007 said:


> Thanks for making all this nice and clear ( just right for dummies ).
> I have kinda question if you can help me to understand.
> Just for example: I have rotary table with total ratio 1000 pulses per one revolution and I need to divide circle say, for easiest,   on 3 equal segments how this code  deal with such task?
> Many thanks in advance
> Ilia



It simple if have 90 tooth worn and 1,000 pulses This make to a full turn of table is 90,000 pulses 
So 3 segment needs 30,000 pulses

So small may have 72 tooth worn or 72,000 1/3 = 26,000 pluses

Hope helps
Dave


----------



## Coolfox007

Hello Dave
Thank you for swift reply, I my phrase my question wrong , what I'm trying to establish is how adruino code handle odd numbers of devisions. 1000 pulses per revolution ( meaning rotary table revolutions, including steeper motor and gearbox - 1000 pulses give 1 revolution of the table. is hypothetical ). 
other way of saying would adruino code employ math with floating point of division or some other way  to compensate accumulating errors ?
Kind regards
Ilia


----------



## Cogsy

There has been much discussion of this in the past. I think what they settled on was error accumulation, i.e. keeping track of the error and adding/subtracting a step as required to maintain orientation. In your example, I'd guess first movement would be 333 steps, second 334 and third 333. So one revolution is exactly 1000 pulses and each graduation is off by no more than 1/3 of a pulse. I do think the resolution is quite  bit higher than that though, with gear reductions and micro-stepping, but even so an error rate of in the region of 0.4/1000 is pretty reasonable.


----------



## Wizard69

Jmccrack

One thing that becomes very important with rotary tables is table size and in that regard 4" is extremely small.  Based on manual table experiences i would look for something bigger.     The only people that should consider a table that small are users that know for absolute certainty that they will be able to setup all potential work properly.   You also need to consider machine size as you cant go much bigger on a Sherline.   On a Taig or the smaller Sieg mills id think long and hard about going larger.  On an X3 or larger id most certainly consider a 6" rotary table (greater than 4").  

The reason comes down to table area and ease of setup.  Consider a 2" flywheel would leave you about an inch on each side for clamping.   That may be fine but i hope that you see that you don't need to be making very large things before the table becomes very cramped.  Sometimes there are easy ways around the size limit sometimes not.  

By the way the electronic drive does give you the advantage of being able to drive the table easily with a large overhanging auxiliary table. The problem here is rigidity quickly going out the window on a small rotary table with a large auxiliary table. 

In any event i just wanted to point out that 4" rotary tables are very small and that they should fit your best estimate of your needs.  


Jmccrack said:


> I know I am butting in a bit but I was wondering if any has used one of these from Grizzly T1191


----------



## Coolfox007

Thank you Dave.
All clear now. I was trying to understand code ( sketch ) before getting in to building hardware ) Would be interesting to get in touch with author of this code or see the link to discussion how it was developed, if such exist .
Many thanks
Ilia


----------



## SmithDoor

You want to look at counters 
I works like a DRO but it rotary minor
Simple to program using the scaling on the counter .

I have use for coil / cut to lenth machine
It would cut 300" blank steel part to 1/64"
This is found foot food to steel manufacturing

Dave





Coolfox007 said:


> Thank you Dave.
> All clear now. I was trying to understand code ( sketch ) before getting in to building hardware ) Would be interesting to get in touch with author of this code or see the link to discussion how it was developed, if such exist .
> Many thanks
> Ilia


----------



## CristianLdna

Hello friends! I really liked this project, it works perfectly! I would like to add a relay contact output, in the button option (*) I'm totally newbie, I request help from you! Thank you!


----------



## animal12

which one did you use , the one from post 145 or the one from post 149 ?
tks
animal


----------



## CristianLdna

Hi Aniamal12! 
I used Post 145!


----------



## animal12

thank you


----------



## wce4

I wish to thank all who has contribute to this project I am going to have a go at this.


----------



## dembelneizbezen

Hi guys!
Great project!
I've been following the topic for a long time, and I've finally started doing it myself.
Basically, your project has taken.
driver:2dm860
Engine:nema 34

and faced the problem. It is necessary to make a smooth start of the engine.
Do not tell the command to adjust the speed?


----------



## fubuddy

so ive tried reading thru this and im more lost and confused than when i started. 
im pretty sure im having the end problem of 1200 steps per rotation.
i changed the ine change line 'for(int i = 0; i < tm; i++)' to 'for(int i = 0; i < 1200; i++)'  but... 
my problems are compounded by the driver im using requiring an extra wire for enable.
i had it all figured out and moving, but in the process of trying to fix the numbers i have lost the working sketch for movement.
the scrolling is killing my wrist and the constant walking in and out from pc to shop is pissing my wife off, frustrated to the point im about to cry  

china 4th axis from ebay, all the info i can get is....
Angle: 0.3 degrees / step
Reduction ratio: 6:1 (Synchronous belt deceleration mode)
Stepper motor: 2 phase nema23 stepper motor

tb6600 driver, uses enable, pulse and direction signals.
i have enable set to pin 12. enable low or high seems to do something but im not exactly sure how to use it.
if someone who actually understands this code could look at it and tell me what i did wrong i would be so happy. 
i currently have it to where it hums when i try to move it, when i put in 360 degrees it says steps 1080


----------



## tjwal

The original code only works when. Multiplier=(TableRatio *StepsperRevolution)/360 results in an integer number. In your code multiplier=1200/360 which is equal to 3.33...  this gets truncated to 3.

When in use the program determines how many degrees you want to move and then multiplies that by the variable Multiplier to get the steps required.  In your case a full revolution of 360 degrees calculates to 1080.

There are other versions of the code posted to this thread that fix this issue.
I’m currently travelling but can provide further info when I get home in a couple of days.

Cheers
John


----------



## fubuddy

lol, yes, i dont exactly understand it but thats what my math and conclusions came out to.
hoping someone has something new, i saw mention of a code that will just let me decide steps, which would be fine for me, i just need divisions of  2 4 5 and 6.
ill have the wife walk on my arm, then read thru this again to see if i can figure it out while i wait for you to get home.
i was hoping to accomplish this without having to learn the code  been about 10 years since i worked in code..... 
i still gotta figure out the driver control, enable thing again....

thanks for your time John.
Brandon


----------



## dwk

Hello all
having spent alarge number of hours reading through this thread my poor mind is now frazzled! So I hope that you good people could give me an uncomplicated answer to my problem as follows:-

I want to cut a clock wheel with 96 teeth using a stepper motor as a means of division. The mechanical side of it is no real problem but the code etc. is totally beyond me.
\\\hope someone can help.

I have an Arduino uno, an lcd keypad display, and a stepper motor driver


----------



## fubuddy

have you gone thru page 1 and gotten everything hooked up, the program installed on your pc, and the code installed to the arduino ?
does your stepper motor move ? and what are the specs of your stepper motor and driver ?


----------



## dwk

yes have gone through page 1 and hooked up pretty much as described. My problem is trying to figure out what code I need to use that will give me the possibility of cutting a 96 tooth wheel. The more I look at examples of what people have done the more confused I get!!


----------



## fubuddy

try the 1st one,  in comment 17. the step in 14 and 15 is really important to make sure its communicating to the right spot. if your numbers are entered right for steps per rotation and table raito, and your getting a propper 360 degrees when you enter 360 degrees, then you would be good to go. you would want to select divisions and enter 192, then for every notch you cut, you will move 2 divisions, 1 to skip a tooth and one to cut the notch between them.
if you need help with the math you will need to give more numbers, specifically steps per rotation and table ratio
 for the motor your using.


----------



## dwk

Ok more detail of my project. I have built a small dividing head (tony jeffree design). This initially was to be used with indexing plates. It has a 30.1 worm drive. My thoughts were to replace the indexing plates with a stepper motor. I have a nema 17 1.8deg. stepper. The final outcome hopefully will be the building of a skeleton clock.
http://www.jeffree.co.uk/images/divphoto1.gif


----------



## dwk

Ok more detail of my project. I have built a small dividing head (tony jeffree design). This initially was to be used with indexing plates. It has a 30.1 worm drive. My thoughts were to replace the indexing plates with a stepper motor. I have a nema 17 1.8deg. stepper. The final outcome hopefully will be the building of a skeleton 
clock.


----------



## fubuddy

so on your controller there is a selection switch for step multipliers ? hopefully   you also need to know that setting.
to get the steps per rotation you divide 360 by the stepper angle, and multiply it by the raito your driver is set to.
the code is written for 1.8 degree stepper with the driver set to 2  360 / 1.8 =200 x 2 = 400, so that part of the code stays the same if your driver is set to 2.
the ratio for the table is originally 72 or something, you change that to 30, 400 steps per rotation times 30 ..... and .... you end up with the same problem i have  12000 steps per rotation, 12000 divided by 360 is 33 and 1/3 or 33.333toinfinityandbeyond which gets rounded down to 33 and fucks our math all up.....
and pretty sure if you where just using steps to control instead of converting to degrees in the code, you could set your jog to 125 steps, and it would give you the 96 jogs you need to cut your teeth, not sure why i was thinking you need 2 jogs per tooth before.


----------



## dwk

I tried the maths and came up with the same as yourself 33.3, t was from this onwards that my confusion set in.
Not sure what you mean by 'set my jog to 125 steps'.


----------



## fubuddy

jog is when you hit the button once and it moves a set number of steps or degrees. what i mean is it would be nice to be able to just use steps in both of our situations instead of degrees. sense the math works out and we just need specific cuts
Tjwal / John said he should be back soon and he seems to actually understand better. hopefully he can help us both out, if not i will just have to learn the code better and do it for us


----------



## dwk

If I change my worm drive to a 36.1, am I correct in saying that this would solve the problem?


----------



## fubuddy

i believe so, it looks like that would come out to an even number.


----------



## anderi

Hi everybody,
just jumping in and I have not read all postings (but many). I am using a windows based program for clock wheel cutting. The program does some calculations and inserts extra steps at intervals to even out any "impossible" divisions. I did not write the program and do not know exactly how it is calculated but it is possible to divide any number of teeth with only very small deviations from the ideal division. Could the arduino be programmed to do the same? It should not be impossible with some programming.


----------



## dwk

is it possible to post details of the programme you refer to?


----------



## anderi

As I said it is not my program but there is an explanation of the technique at this adress and also the program itself
http://members.optusnet.com.au/swensenr/ToothCutting.html
It would be interesting to be able to replace the old PC with an arduino setup in the future but the program does more. It also moves the x-axis so I can drink coffee while the wheel is cut.
Hope this helps


----------



## Lamplighter

Okay I HELP ... I have been following the bmac2 Arduino Rotary Table for Dummies string for well over a year now, there is some great information throughout the 11 pages of this Forum. Many people have contributed some very useful information, thank you. A big thanks to bmac2 for starting off the string Arduino Rotary Table for Dummies*,* in my opinion a very nice solution for the home hobbyist.
However I am in the same boat as dwk and as it looks a few others who are trying to solve this automation puzzle. 
I am not a coder/programmer, I have never developed programs or control code of any form, I have no experience in this field..  All I would like is a Clean Sketch of the bmac2 Arduino code to run my 4" Rotary Table. 
My rotary table has a 72:1 table ratio, NEMA 17 1.8 degree stepper motor - 200 steps per rotation , a 5:1 reduction(not sure how to  factor the 5:1 reduction into the mix). If it has been determined that the 5:1 reduction is a problem, I will design a direct stepper motor mount to couple the rotary table worm gear shaft to the stepper motor shaft. I have completed my control console build using the components  listed by bmac2 and a enclosure offered by Maxmekker50 via aliexpress.
I have loaded bmac2's Arduino stretch successfully and everything works great electrically/mechanically. Except I can not get the table to rotate to the correct position. example with a 45 degree input the table only rotates about 10 degrees. 
My goal has been to use the bmac2 solution or some revised version to cut timing gears or index the table to predefined positions.


----------



## fubuddy

try multiplying your reduction ratios manually and entering that number for table ratio.
5 x 72 = 360 for table ratio.
or do your math for steps and enter that, stepper is 200 steps per rotation times 1 stepper driver setting, times 5 reduction ratio = 1000 steps per rotation.
or 200 steps, times 2 driver setting, times 5 ratio = 2000 steps per rotation
you did not mention the driver micro steps setting so i assume its on 1, but most people run 2.


----------



## fubuddy

for people in the future, if your having the 1/3 problem, or just an odd number problem in general where your total steps divided by 360 is not an even number.
what i did to fix mine is enter my steps per rotation as my total , did all my own math. 1200 steps per rotation total. enter that in steps per rotation.
then change table ratio to 1 
and in line 263 i changed the degrees math to steps by changing the code to this "for(int i = 0; i < 1200; i++)"
this lets me do my division math manually, sense all i need is simple divisions of 1 2 3 4 5 6 8 10 12 and so on, and enter the number of steps i want to move instead of degrees. 
1200 steps divided by 5 divisions = 240 steps per division in the degrees option when using the controller


----------



## tjwal

Lamplighter
I’m not sure bmacs original code will work for you.

Your setup takes 72000 steps for 1 revolution, bmacs cide uses integers so you run into trouble with numbers over 32000.  There are a number of posts about this issue.
I posted a revised version in post #149.  As far as I know it is bug free.  It also takes care of the ⅓ type of issue that fubuddy refers to.
There are many other solutions but I can assist if you’re using mine.

Cheers
John


----------



## anderi

Don't know if this helps or if I am just adding confusion but here is an explanation of what I tried to say in previous posts.
As I understood the problem is when you want to cut for example a wheel with 57 teeth and it is not divisible in your setup. As an example the rotary table need 8 turns on the handle to turn i complete turn. Then you may have a 1:3 ratio between the handle shaft and stepper motor.
This means the stepper has to make 24 turns for 1 complete turn of the rotary table. Assume the stepper has 200 steps and is run with 2 stepper driving.
This gives 24*400=9600 steps for a complete turn. For 57 teeth you get 9600/57=168 steps per tooth but with a remainder of 24 steps. To make a complete 360 degree turn they have to be added to the 57*168 steps. In the program I referred to he spreads the 24 extra steps by inserting them as evenly as possible during the cutting. There will be a small error on some teeth but it is so small it falls within the tolerances. 
The Arduino should be capable of making the calculation and to distribute the extra steps if someone who is familiar with the program could modify it.


----------



## Foozer

Lamplighter said:


> My rotary table has a 72:1 table ratio, NEMA 17 1.8 degree stepper motor - 200 steps per rotation , a 5:1 reduction... I can not get the table to rotate to the correct position. example with a 45 degree input the table only rotates about 10 degrees.



72 by 5 by 200 gives a number too large for the code to handle (72000) It'll choke on a full turn . 200 steps per degree have to change the setup a bit to handle the math


from
const int StepsPerRotation = 200;
const int TableRatio = 360;
to
unsigned long StepsPerRotation = 200;
unsigned long TableRatio = 360;

Might be more in the code that would have to be changed - BUT - your timing belt - It's going to bite you sooner of later. Chips will cut the belt eventually. Better off fabbing a direct mount - i.e.






Boo Boo in my direct mount - the open slot in the top lets chips in, piece of tape settles it.
Direct mount better, makes math easier . .


----------



## Lamplighter

Thanks for your reply.
I believe you are correct, change the mounting of the stepper motor to direct drive. Thought that may be the solution but I wanted to post the problem out to the community for comment and direction.


----------



## tjwal

[QUOTE="anderi, post: 316174, member: 37607"<ship>
This gives 24*400=9600 steps for a complete turn. For 57 teeth you get 9600/57=168 steps per tooth but with a remainder of 24 steps. To make a complete 360 degree turn they have to be added to the 57*168 steps. In the program I referred to he spreads the 24 extra steps by inserting them as evenly as possible during the cutting. There will be a small error on some teeth but it is so small it falls within the tolerances.
The Arduino should be capable of making the calculation and to distribute the extra steps if someone who is familiar with the program could modify it.[/QUOTE]
Anderi
The code I posted in message 149 distributes the error.
The original code does what you describe, it calculates the number of steps per division and uses that amount for each tooth.  As such the error adds up like you describe.
The approach I used was to calculate the total number of steps for each tooth.  For your example it would calculate and move 168 steps for the first tooth.  For the second tooth it would calculate 2*9600/57=336.8
This would be rounded to 337.  Since the first tooth is already at 168 steps the program would calculate that an additional 169 steps is required to get to the second tooth.  It continues to do this for all 57 teeth.  Assuming I’ve coded it correctly there should be no more than ½ step error at each tooth.
Sorry for the long explanation but talking code can get me excited.

Cheers
John


----------



## OldRon

Me thinks that the OP failed to post the edition where his wife told him to go pound sand. As is the case with mechanical indexers the gear ratio in the table will impose limitations. Therefore not all index patterns will be possible without cumulative error. The higher the resolution the less the error will be. All of my experience has been with closed loop drive systems so I know nothing about stepper motors other then that they typically have a very low resolution. Below is a program that I wrote for setting up a dividing head with an internal gear ratio of 40:1 which is the common gear ratio. Rotary tables have a 90:1 gear ratio. If interested then download the attached .TXT file and change the extension to .EXE

NOTE: Norton and other anti-virus programs now recognize Win 32 files as being a virus. I contacted Norton about the problem and the agent asked permission to take control of my computer. I agreed and the agent ran Norton Power Eraser on my computer. When my computer rebooted then I was advised that my computer was now safe. My desktop was missing a **** load of icons and that was when I figured out what the GEN 32 virus was because Norton Power Eraser deleted every one of my programs that I wrote for my needs. I gave that Norton AV agent a big piece of my redneck mind and I'm sure that I expanded his Indian vocabulary. Fortunately I had back up files on other computers.


----------



## Cogsy

I'm not sure the stepper motor resolution is much of a problem as long as the resolution errors are not cumulative, which can be accounted for in the code. Keeping track of accumulated error and accounting for it at each calculation should result in plus or minus one step (or one microstep) for any graduation. Even with a direct 1-to-1 drive (which I assume nobody is using direct drive), a 200 step stepper motor running microstepping to 800 steps-per-revolution equates to a maximum error of 0.225 degrees. Add in a 40:1 reduction and the maximum resolution error drops to less than 0.005 degrees.


----------



## dazz

Hi
Working out fractional steps to keep within tolerance should use of floating point multiplication included in the Aduino language.

For the rotary table problem, probably the best solution is to calculate the steps from a zero reference point to get to each division, 
then keep a cumulative total of the steps actually moved from the reference.
The next division would be calculated by taking the difference between the current position ( = steps taken from reference ) and the next division ( = steps from reference to next position).  
Then round solution to calculate the step count.

This is computationally inefficient because each step requires multiplications but it avoids having to account for cumulative errors.  Basing all calculations from a starting reference point prevents cumulative errors.


----------



## cfellows

The attached file contains the arduino sketch I wrote for my dividing head.  The math algorithm is written to assure that the 0 (zero) location always winds up at the same point of rotation.  As it moves, it recalculates the position from zero so no matter how many times it goes around or back and forth, it maintains positional integrity.  The algorithm should work for your rotary table as well.
Chuck


----------



## chucketn

Chuck, Thanks again for sharing your work with the forum. Back when you first posted it, I modified your code to work with my 4" rotary table. I used that setup for quite a while making gears.
Then I got the idea to add a 4x4 matrix keypad to enter data rather than the 5 button LCD setup. A fellow(no pun intended) named Bob Pratl posted a code using such a keypad. I played with the 2 versions until I had one that worked with my configuration. I really like it and use it often. Thanks again for providing the inspiration.


----------



## cfellows

You're welcome, Chuck.  I guess I just like to show off...


----------



## canadianhorsepower

rodw said:


> Don't overcomplicate things.
> 
> If you are going to upgrade hardware, d


 I did build my own driver , worth the work


----------



## tjwal

dazz said:


> Hi
> 
> For the rotary table problem, probably the best solution is to calculate the steps from a zero reference point to get to each division,
> then keep a cumulative total of the steps actually moved from the reference.
> .


That’s the method I use in the version I posted in message #149.

I modified the code posted by Bmac to get rid of the cumulative error.  While I was at it, I made a few other changes which I hope are improvements.

Many thanks to bmac and everyone else who were involved in the evolution of this code.


----------



## Nigel Moody

Hello bmac2,
Thought I would give your project a quick whirl.
bought the components but settled for a cheap stepper for testing purposes as my stepper motors did not match the driver board.
Had fun assembling and installing the program.
Fired it all up and hey presto it works.
Unfortunately I am not getting on with the build of my Locking lever frame, but heyho its cold outside.
Now to find a box, and maybe a decent stepper at the Ally Pally Model Engineering show London.
Keep up the good work.
Nigel
UK


----------



## Pauldg

I have been reading this post with huge personal interest since I have developed a 32 bits controller successor to the 8 bits Arduino controller. I will be posting my topic "Cheap 5 axis G-code controller" separately. So look out for my post. Enjoy!

Feedback question:
It would be really great to get some feedback from machinists why there is so little uptake in it despite a successful Kickstarter. I still see posts and videos with stepper solutions based on a PC with basic parallel port solution with no intelligence (240 Aussie pesos) and Mach3 (licence 600 bucks) which is way more expensive than my controller assembled and further Grbl Arduino's which are cheap but limited in functionality (32kB memory ceiling and 30kHz step freq.).

For those interested: I added 2 more axis (5 in total), a soft start spindle feature (pwm from 60Hz upto 80kHz), M6/Tn ATC support, onboard spindle motor drivers (150/750W), step sticks capable of driing 4 Amp stepper motors. All opto coupler based i/o for those with a plasma cutter.


----------



## Wizard69

Pauldg said:


> I have been reading this post with huge personal interest since I have developed a 32 bits controller successor to the 8 bits Arduino controller. I will be posting my topic "Cheap 5 axis G-code controller" separately. So look out for my post. Enjoy!
> 
> Feedback question:
> It would be really great to get some feedback from machinists why there is so little uptake in it despite a successful Kickstarter.


Often getting the word out is a big factor.   In some cases it represents a significant cost per device.   So in my case this is a relatively new device. 


> I still see posts and videos with stepper solutions based on a PC with basic parallel port solution with no intelligence (240 Aussie pesos) and Mach3 (licence 600 bucks) which is way more expensive than my controller assembled and further Grbl Arduino's which are cheap but limited in functionality (32kB memory ceiling and 30kHz step freq.).


Actually I have no idea what 240 would be in US dollars.  Here in the USA Centroid has a DIY solution that starts at $299 right now.    Centroid has been into CNC control for decades now so has a very robust CNC solution.  There are other GRBL ARM ports running on far cheaper hardware.   Beyond that it is uncertain where official GRBL is going as far as ARM support goes.  If one wants to remain in the GRBL community then that would mean staying with the official tree. 


> For those interested: I added 2 more axis (5 in total), a soft start spindle feature (pwm from 60Hz upto 80kHz), M6/Tn ATC support, onboard spindle motor drivers (150/750W),


I really have no idea why people would stick a motor controller on a logic board.    It seems to have become a thing of late but in my estimation it just reduces flexibility.   The same pretty much applies to steppercontrol too.  The last thing I’m looking for in a board is integrated motor control. 


> step sticks capable of driing 4 Amp stepper motors. All opto coupler based i/o for those with a plasma cutter./



In don’t want to appear unkind but that web site doesn’t inspire a lot of confidence.  Honestly it is a mess!   Of course this is personal preference but if I find a web site frustrating I don’t do business with that company if I can help it. 

In any event one of the biggest problems small companies have is product promotion.  That can mean many things but almost all of them cost money.   For example this weekend I braved blizzard to go to a model engineering expo.  While the trip was cut short due to the weather, I did spend a few minutes with some vendors handling DIY CNC hardware.  That is a very good way to get your name out there and converse with potential customers, it is however expensive.  A far cheaper alternative is to send out free samples to sites that will review your product.


----------



## Pauldg

> Actually I have no idea what 240 would be in US dollars.


  About $140-160 USD.



> In don’t want to appear unkind but that web site doesn’t inspire a lot of confidence.


 This is important feedback which I am after so I can action it. What is it: text, format, relevance, lack of photos/information?



> loose Flexibility


 This great to hear since the board provides that flexibility for drivers on board or just leave them out and use external drivers. All ports have been provided as breakout connections. The PWM for a VFD is 5/10V opto coupler. So will update the description.



> That is a very good way to get your name out there and converse with potential customers, it is however expensive.


 Yes, I am already doing so. Next Makerfaire in the USA is on my itinerary. My first product sold on the spot at the Bay Area Makerfaire 2017. Australia is just very small for this kind activity and we hardly have Makerfaires (23M people dispersed over a country as big as the USA).



> A far cheaper alternative is to send out free samples to sites that will review your product.


 Yes, we have contacted various Vloggers (never got a single reply) and I guess just mailing them a controller might be easier. They might throw it in the bin or review it...I guess it's worth it.
Thanks for your reply, I really appreciate it.


----------



## Pauldg

canadianhorsepower said:


> I did build my own driver , worth the work View attachment 106529
> View attachment 106530
> View attachment 106531
> View attachment 106533


You can even make the step drivers since the PCB factories provide you PCB trials for just $2. See here my instructable: https://www.instructables.com/id/Eagle-Hackstricks-Example-TB6600-CNC-Mill-Stepper-/
Enjoy!


----------



## SailplaneDriver

Chuck fellows made a RT stepper driver:

https://www.homemodelenginemachinist.com/threads/electronic-dividing-head-using-the-arduino.17896/

If I remember correctly, his sketch allowed for constant rotation.


----------



## lkrestorer

Good evening gentlemen. I'm jumping threads and I hope it's ethical. I started the thread "Servo Feed For A Lathe Compound". The replies overwhelmingly kept referring me to this thread and I became fascinated with the idea. I have temporarily abandoned the compound feed and turned my attention to fitting my 8" rotary table with a stepper motor. I have read and re-read these posts and several others and have purchased the components to modify the table.
By following bmac2's instructions I have been able to get the basics working but now I'm up to connecting the stepper driver and I ran into a snag. I'm using a "Longs Motor DM542A" driver and I'm confused about comparing the Arduino wiring connections between the TB6560 driver described in this thread to the connections on the DM542A.
This is the way that the TB6560 is supposed to be connected:





These are the corresponding connections on the DM542A:





The first shows nothing connected to the EN(able) terminals. I thought that they would get a 5-volt supply connection. What corresponds to what? I'm assuming that PUL means pulse and DIR means direction. How do they cross to CW and CLK? Do I jumper the DIR- and PUL- terminals and connect them to Arduino GND? And which ones do I connect to D2 and to D3 on the Arduino?
Hopefully this is a question that you are just shaking your heads at and it will have an obvious (to you) answer. I have gotten this far without letting the smoke out of anything and I figured it would just pay to ask.
I have built a mount for the motor with the flex coupling and moving parts enclosed in a piece of 4" x 1/2" wall aluminum tubing and it moves very smoothly and is ready for power to see what happens.


----------



## Pauldg

Hi,

 I'm assuming that PUL means pulse and DIR means direction. > Yes it does mean PULSE (stepper pulses) PUL=CLK
How do they cross to CW and CLK? > CW means Clock Wise or in other words direction. CW=DIR
Do I jumper the DIR- and PUL- terminals and connect them to Arduino GND?  > Yes these are the grounds. The stepper driver uses opto couplers which need a return path.
And which ones do I connect to D2 and to D3 on the Arduino?> These are the clock stepper pulses so they go to PUL+ (you need two drivers for two axis)
#define X_STEP_BIT 2 // Uno Digital Pin 2
#define Y_STEP_BIT 3 // Uno Digital Pin 3
Pin layouts are described here https://github.com/gnea/grbl/blob/master/grbl/cpu_map.h

I have written an article about the setpper driver which might give you some help too: https://www.instructables.com/id/Eagle-Hackstricks-Example-TB6600-CNC-Mill-Stepper-/

Also check out my other projects like Super Gerbil...


----------



## tjwal

I found a copy of the user manual here
https://images-na.ssl-images-amazon.com/images/I/718BBSVkxPL.pdf
Use the connections shown in figure 2, pul-, dir- and ena- are connected to ground.
The corresponding pulse and dir will be asigned to the Arduino pins in your code.
The driver I use in enabled when ena+ is either held to ground or is left open.  It appears 
Ena+ must be held high to enable the DM542.  You could try it both ways, it won’t hurt anything.

John


----------



## lkrestorer

Wow! It works! And it worked the first time and all the smoke stayed inside! It even turns very smoothly.

Now I have to wander into never-never land and modify the sketch to deal with my hardware.

Thanks for the help, guys.

Len


----------



## lkrestorer

Ok, I can assemble everything needed but when it comes to the software I hit a wall. I loaded the original sketch and everything "worked" - but it didn't work well. My first problem was with my keypad and that was simple to fix. At first it was sending what appeared to be random inputs so I totally reversed the connections (1 through 8 to 8 through 1) and the right stuff came out.
I was not getting the proper number of steps so I changed the TableRatio from 36 to 90 to match my table. The step count came out to -3690 and nothing moved. To troubleshoot it I entered 72 (as was mentioned in the original post) and it worked and the number of steps and the degrees-moved doubled. I read farther and found some (to me) obscure references about why this happened.
Next, I loaded the sketch in message 145 thinking that it might give me some way to fix this but my keypad was totally dead. No key selection did anything. I then loaded the sketch from message 149 with the same results. This gave me the setup screen but with a dead keypad it was the end of the line. (As a hardware test I then reloaded the original sketch and the keypad worked fine eliminating the possibility of disconnected wiring.)
Right now I'm stuck until I can program in the 90:1 ratio that my rotary table requires. I can follow directions but without spending considerable time learning this sketch language I am not going to get much farther.
Help?  Please?

Len


----------



## kquiggle

Len - 

You might want to try the (based on the original but very much revised) sketch I wrote, which is available at the link below (scroll down to Part 3: Coding - and look for Rev7). The revised sketch allows you to input all required values from the keypad, so you can easily experiment with various settings (option D on the Menu). 

https://sites.google.com/site/lagad...es-mills-etc/build---electronic-indexing-head


----------



## lkrestorer

kquiggle,

I will have a chance to get back in the shop tomorrow sometime so I will give it a try then. Will my keyboard work with your sketch as it works with bmac2's original sketch?

Len


----------



## kquiggle

If bmac2's original sketch works on your hardware, my sketch should also work; they both work on my set-up.

Please let me know how it works for you.


----------



## ignator

lkrestorer said:


> I can follow directions but without spending considerable time learning this sketch language I am not going to get much farther.
> Help? Please?


If you can leave your programming computer connected to the Arduino board, you can install some debugging code in your program, and use your computers monitor to display the Arduino IDE popup screen monitor. To get this serial monitor on your computer screen, you select "tools" on the IDE program window, and select "serial monitor" (or you can press CTRL+SHIFT+M on the computer keyboard).
In your code you will need to insert program text that writes to this monitor. And every time build and program the Arduino micro controller.

In the setup part you will need this line of code
  // Just whilst we debug, view output on serial monitor
  Serial.begin(115200); //found with China copy of DUE, could not run this faster

Then print statement related to the variables used in the program, example;
I pulled this from one of my sketches
      Serial.print("I"); // put out an I for interrupt
      Serial.println(InterruptTime_avg); //and print the average last 1000 interrupts
      // Write out to serial monitor the value and direction
      Serial.print("\t");
      Serial.println(virtualPosition);

lkrestorer, go to the Arduino web site and look up the Serial function to see how to use it for debug.
Here is a link,
file:///C:/Program%20Files%20(x86)/Arduino/reference/www.arduino.cc/en/Reference/Serial.html

The above link will have examples and such. But the idea is to "instrument" your code, to see where it is going wrong.
Strange you had it working and then it stopped, seems like a loose connection or something bad like ESD.
edit
OK, the serial.begin, I set up a very high speed baud rate of 115200 bits per second. You have to set the popup screen to this same baud rate. I was using a DUE board, as in my use, was decoding an quadrature encoder which was using interrupts of the Arduino. I was testing to see if some were being lost. So I used a very high speed baud rate as the program was writing to the popup screen often. And a slow baud rate would be buffered by the computer and cause all sorts of problems, with Serial.print putting out data faster then the default slow baud rate could be displayed on the virtual popup screen. I see I have a comment about the slow DUE board China copy I was using, as all this data has to flow through the USB port from the Arduino board to the connected computer, to the popup screen. I can't recall the default baud rate, but 4800 seems correct from memory.


----------



## seleveng

Hi All,

really appreciate this project - it brings me forward a lot!
With my little Nema17 stepper motor everythzing works just fine.
Now I also want to use a stronger Stepper motor size Nema34. 
But I'm having the same problem like* "dembelneizbezen" Post #198. *Smooth ramps are required.
Like many others here I'm not really familiar with programming the Arduino yet.
I know there is a stepper motor library and as far as I know you can specify ramps for accelaration and decelaration.

I also found an interesting video on youtube.. it also covers the "backlash topic".



Would be good if somebody can help!

Reagrds,
Sebastian
*https://www.homemodelenginemachinist.com/members/dembelneizbezen.38870/*


----------



## bluejets

I for one find the input from #246 confusing and I am experienced with Arduino programming.
e.g. if one wants the serial monitor pop-up, there is a "radio-button" in the top right corner of the IDE screen. Run your cursor over it and it tells you "serial monitor".

Never really found the need for a stepper driven rotary table and all seems like a bit of a novelty thing to me really.
Unless of course one has full cnc.

The Op said he has problems with software so best would be to let him explain details of his problems as much as he possibly can.

Important to provide the problems in sequence and hardware used so a logical answer can be provided by others.


----------



## tjwal

Len
In message 128 I posted a sketch to debug the keypad.  You can monitor which key is pressed in the serial monitor. I’m sure there is a logical way to connect the keypad so it works but I used the trial and error approach.  Once you get the keypad working then if necessary copy the definitions into the indexing sketch.

John


----------



## seleveng

Does anyboday have an idea how to add smooth motion for the stepper motor?

Sebastian


----------



## elcid

seleveng said:


> Does anyboday have an idea how to add smooth motion for the stepper motor?
> 
> Sebastian


Hi
I purchased 4 of these, https://www.gearbest.com/3d-printer-parts/pp_1816577.html?wid=1433363, for my 3d printer. Made a  difference to the print quality and the stepper motors are smoother in operation and quieter too.

Cyril


----------



## kquiggle

Sebastian - keeping in mind that I am pretty new to all this stuff myself, here is my understanding: You can sort of smooth out the stepping using microstepping (smaller finer steps) , but the trade-off is you lose torque. You can also use gear or belt reduction to effectively reduce the step size at the business end. I think the requirements for 3D printing and indexing are similar but not the same. With 3D printing you want accuracy and smooth motion along the print path; with indexing you want accuracy, but it doesn't matter all that much of the motion between indexes is jerky as long as you end up in the right place.

I used a stepper motor with a built-in planetary gear reduction (~27:1) on my indexer, and this is working for me (link below). 

https://sites.google.com/site/lagad...es-mills-etc/build---electronic-indexing-head


----------



## seleveng

Thanks for your responses... but I'm still not sure, if I have explained my problem exactly enough. It is probably not that easy in German language, but even harder for me to do it in English  Let me try again... My stepper is a Nema 34 34HS1456 (3V, 5.6A, 840Ncm torque). The rotary table I'm using is a Knuth RT250 with a 200mm 6 jaw chuck mounted! I also want to use a planetary gear connected to the stepper motor (ratio 20:1) and a geared belt (HTD 5M, ratio 6:1). I will not use the integrated worm drive in hope to minimize backlash. With 1/4 microstepping (800 pulses per rotation) I will end up having 96000 pulses per rotation (800x20x6). On a disc with 500mm diametre that means about 0,016mm deviation per pulse along the perimeter... that's what I'm aiming for! But because the rotating mass will be at least 30kg, it is important to accelerate und decalerate smoothly! 

Regards,
Sebastian


----------



## kquiggle

Sebastian - I think I understand what you are looking for now (you're English is excellent by the way, so the confusion was on my end). Anyway, you may be interested in this:

http://www.airspayce.com/mikem/arduino/AccelStepper/

With 30kg of mass to move, acceleration may well be an issue but I would try it first without trying to compensate to see if controlling acceleration is really necessary.

Additional note - I think not using the integral worm drive may reduce backlash a bit, but you will still have backlash in the planetary gears and the belt system so I don't know that it will make a difference overall. My novice opinion is that the system should always be driven in one direction so that backlash is not an issue; also, I always drive my indexer one full 360° rotation before I start my actual indexing just to remove any slack in the system.


----------



## seleveng

Over the weekend I will read through the explenation of the AccelStepper library to get a better understanding... maybe I can find something helpful!
Thanks for the link!

Sebastian


----------



## weir-smith

Len

I can see that you are having a few problems with this project. I have made several of these units without difficulty however, if it is all new then its a case of plodding through all of the issues.

A quick fix for the sketch for 90:1 rotary tables is to edit the file by making the "Multiplier = 100" rather than "Multiplier = (StepsPerRotation* TableRatio)/360". Just scroll down to the "const int" and the fifth is the Multiplier. There is an issue with the code when you set the variables for 90:1 and while I am sure of the solution, I need to test it across a range of numbers to be sure. I will do that in the next couple of weeks. For 90:1, the multiplier needs to be 100 if you are using the setting on the stepper driver of "2". On the stepper controller module, you can set the max current and the stepping mode some times shown as excitation mode via dip switches. You can select 1, 2, 8, or 16 and you require 2.

So for a 90:1 rotary table, 4 deg is equal to 1 complete turn of the stepper or 200 steps for the standard stepper motor. So 4 deg x 100 = 400 and this is what you will read on your display. The stepper controller will divide the input steps by 2 e.g. 400 steps /2 = 200 or one revolution.

My fix is a quick one however is works without problems and as I said before, I will put in a correction which is easier to implement. I have two rotary tables of different ratios and I want to use the same controller so I will need an extra menu etc. I have also added an additional feature in my controller that provides continuous rotation with forward and reverse etc.

Also happy to answer any more of your questions.

Bruce


----------



## lkrestorer

kquiggle said:


> If bmac2's original sketch works on your hardware, my sketch should also work; they both work on my set-up.
> 
> Please let me know how it works for you.



kquiggle,

I followed your link and loaded the sketch (Rev.7). Everything worked according to schedule until it was loaded. The display reads:
Enter Selections
Degrees       = A
Divisions     = B
JOG              = C

And that's it. There is no "option D" on the menu and at that point I cannot do anything with it. None of the keys on my keypad register at all. The problem I had with the original bmac2 sketch was that the wrong keys sent the wrong information. I reversed the connections to the Arduino board and everything worked correctly - the order just had to be reversed. With each of the other sketches (including Rev7 that I just loaded) there is no response to any key stroke. Without changing any wiring connections I reloaded the original sketch and the keypad works fine.

You can see that I become stumped quite easily with this sketch language. I'm fairly good at building stuff but this is a foreign language to me. I can see some of the operation of the program but it doesn't take long for my eyes to cross and I have to walk away and make another pile of swarf to reset my senses.

Len


----------



## ignator

lkrestorer said:


> None of the keys on my keypad register at all.


This can be a problem jumping into a full system, and not playing with the piece parts.
So go to youtube, search for "arduino keypad tutorial", I found this one below that seems simple;

This youtube has a link to the software he's using, click the link, copy past the code into a new arduino sketch window. Then program your arduino with this code.
I copied this code below. You can leave all the other hardware connected for this test setup, but play with it, and verify you get the correct keys displayed on the arduino serial monitor.
You can find code for each piece part of what you are trying to debug. This also gives you some understanding of the piece parts of program operation, so you are not lost.
-------------
/*
 * Original sourse: https://playground.arduino.cc/Code/Keypad
 * This is the Arduino code for 4x4 keypad.
 * watch the video for details and demo 
 *  *
 * Written by Ahmad Nejrabi for Robojax Video channel www.Robojax.com
 * Date: Dec 18, 2017, in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purpose only.
 * this code has been downloaded from http://robojax.com/learn/arduino/
 *
 */
/* @file HelloKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact [email protected]
||
|| @description
|| | Demonstrates the simplest use of the matrix Keypad library.
|| #
*/
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6,7,8,9}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
}

void loop(){
  char key = keypad.getKey();
   // just print the pressed key
   if (key){
   Serial.println(key);
  }

  // this checkes if 4 is pressed, then do something. Here  we print the text but you can control something.
  if (key =='4'){
   Serial.println("Key 4 is pressed");
  }
}
---------------

I hope this helps.


----------



## lkrestorer

Bruce,

Yes, It is all new - but interesting. I don't know if I'll be willing to put in the time to become proficient at it but I would like to play around enough so that I have a little understanding of what's going on. There is a lot of excitement when something actually works, though. Like my first steam engine build when it actually rotated the way it was supposed to when I put air to it (a PM Research engine).

I made the changes to the sketch just as you suggested and my excitement rose dramatically when it traveled properly. When I put in 4 degrees it traveled 4 degrees and the display showed 400. I played with it quite a bit and it worked quite well until I tried 360 degrees - I had to disconnect the power after watching it go around three times. It works fine up to 320 degrees. 330 degrees and above runs constantly (I did not try each degree between 320 and 330 to see how it performed). If this is how it works I'm sure I can live with it.

I like the "continuous" feature on your controller but you may have just helped me build it into mine. (humor).

Len


----------



## lkrestorer

ignator,

Thank you. I will look at your keypad information in the near future. I don't want to sound like a complainer or excuse maker but it seems like my family doesn't understand the definition of the word "retirement" the same way that I do. The fact that I have finally made this rotary table work in a way that I had never even thought about a couple of months ago is encouraging so I will continue on.

Len


----------



## ignator

lkrestorer said:


> ignator,
> 
> Thank you. I will look at your keypad information in the near future. I don't want to sound like a complainer or excuse maker but it seems like my family doesn't understand the definition of the word "retirement" the same way that I do. The fact that I have finally made this rotary table work in a way that I had never even thought about a couple of months ago is encouraging so I will continue on.
> 
> Len


From your previous post, it appears you have the keypad working. You need to see what changes you did per  weir-smith suggestions, as to if this caused some program math error for it to spin continuously. You should not live with that. 
This is my whole point of "instrumenting" the code, to see what it is doing while running. The serial monitor is the easiest way to do this. Mainly printing out program variables that change during operation. There is no magic going on here. There may be bugs, but no magic.


----------



## weir-smith

Len

I only tested all of the values that I use and all worked well. However, 360 was not one of them and you are correct that anything over 329 deg causes the stepper to rotate continuously. I will need to brush up my C++ and have a look at what is happening however, my first thought is that it is not the code but the limitations of the Arduino for example, it only has a resolution of 10 bits. We shouldn't lose sight of the fact that this micro controller was developed as an entry level device primarily for academic applications however, it is still a very useful device without going to something more complex and they are cheap at $14. 

That been said, it doesn't mean that there is not a work around - just needs some thought. I have built three of these units with two being for other people so I need to get to the bottom of the problem. The thing to do first, is to decide what it is that you want from the controller and then solve the problem from there. I use mine primarily for drilling holes in a circle where I don't have to remember where I am in the degrees count. I also machine part circles on a job requiring that. I do not use it for cutting gears as I prefer to use indexing plates to avoid the accumulation error. There are program changes out there that go some way to correct this error. For continuous rotation, I use a seperate module $10 worth and a changeover switch to achieve it. The unit provides variable speed, CW and  CCW rotation and emergency stop - love Ebay.

I am providing my email address so if you would like the solution, I can send it to you directly and I am also happy to send you the information on the continuous rotation module. Just send me an email so that I can respond. I have been retired for seven years now and my family still think that they need to give me tasks to do, to keep me out of trouble. Little do they know so I can appreciate your comment.


[email protected]

Bruce


----------



## kquiggle

Len - 

It looks to me like the new sketch did not actually get loaded. If you look at the link below you will see pictures of what the display should look like. In particular, when you first power up you should see something like:

ROTARY TABLE CONTROL
Rev. 7.00 2019​
https://sites.google.com/site/lagad...es-mills-etc/build---electronic-indexing-head

Good luck - feel free to PM me if you wish.


----------



## ignator

weir-smith said:


> it only has a resolution of 10 bits


That is the resolution of the analog to digital converter. This is not used for this all digital rotary table controller.
I'm looking at the code for the first time, and it uses floating point variables for the stepper angle. These are 4 byte long, i.e. 32 bit. But I don't know the detail format of the math library. I see a divisor of 360.0 degrees,  but looking at the math to see if the motor exceeds 360 degrees, appears OK.  The code for the forward steps;
     if(key == 'A')            // FORWARD
       {
        TotalDegrees  = TotalDegrees + Degrees;
        if (TotalDegrees > 360.0) {                        // When making a full rotation, restart count at 360 degrees
          TotalDegrees = TotalDegrees - 360.0;
        } 
        if ( TotalStepsActual == (int) MicroStepsPerFullRotation)  {
          TotalStepsActual = 0;
          TotalStepsTheoretical = 0.0;
        }
        TotalStepsActualPrevious = TotalStepsActual;                      // Save current steps total as previous total
        TotalStepsTheoretical = TotalStepsTheoretical + StepsPerIncrementTheoretical;

        /* 
        Round up to integer actual total number of steps moved.
        If a fractional value is N.5 or greater, adding .5 will increase the interger portion to N+1.
        Conversion to int will truncate any fractional part. Result is that any number with a fractional
        part of >=.5 will be round up; <.5 will be rounded down.
        */
        TotalStepsActual = (int) (TotalStepsTheoretical + 0.5);

        StepsToMove = TotalStepsActual - TotalStepsActualPrevious;

        digitalWrite(dir, LOW);
        printadvance();
       }
The code to step the motor is;

     rotation(StepsToMove,0);* //this is the function call to 'rotation' that steps the motor located in the function printadvance*


..................|-------This should be int declaration
 void rotation(*float* tm, int d)* //tm is the passed variable of StepsToMove, the variable 'd' is not used. I'm guessing this was direction at one time*
   { 
     for(int i = 0; i < tm; i++)* //a simple loop counter, so what could cause this to overflow?*
       { 
       digitalWrite(stp, HIGH); 
       delay(stepdelay); 
       digitalWrite(stp, LOW); 
       delay(stepdelay); 
       }
   }
_______________
I can't see the problem, someone who has the setup can see what is going on in the rotation function with the tm variable. I'm confused that 'tm' is a float, and this might trip up the integer counter variable 'i' comparison for some values of 'tm'. In my mind this should cause a compiler flag as type mismatch.
edit;
StepsToMove is declared as a integer in line 88 of the program. I believe this is an error having tm declared as a float in the function 'rotation' which passes in an integer and then converted to a float.


----------



## Lina

It seems like the issue is fundamentally software.  Instead of adding hardware (arduino) to solve it, why not just use an integrated solution (Massimo, planetCNC, SuperGerbil) ?


----------



## weir-smith

Len

I did a quick test today and changed the multiplier to 50 rather than 100 which then requires a total count of 18,000 rather than 36,000. I also selected divide by 1 rather than divide by two on the stepper controller. The unit then worked to 640 deg before the problem returned. 

A review of the Arduino spec shows the upper count limit (integer) is 32,767 due to the 8 bit arithmetic which ties in with the above test. As pointed out, StepsToMove is an integer and if changed to float, it should overcome the overflow problem. I will have a play this afternoon.

Bruce


----------



## Cogsy

weir-smith said:


> Len
> 
> I did a quick test today and changed the multiplier to 50 rather than 100 which then requires a total count of 18,000 rather than 36,000. I also selected divide by 1 rather than divide by two on the stepper controller. The unit then worked to 640 deg before the problem returned.
> 
> A review of the Arduino spec shows the upper count limit (integer) is 32,767 due to the 8 bit arithmetic which ties in with the above test. As pointed out, StepsToMove is an integer and if changed to float, it should overcome the overflow problem. I will have a play this afternoon.
> 
> Bruce



As long as you don't require negative values (which I don't think you do) you could change your integer to an unsigned int which changes your upper limit to 65,535 while still being 16 bit. If you need more, you can change to a 32 bit unsigned long, which again won't give you negative values but will go all the way up to 4,294,967,295. Either should be a relatively simple alteration.


----------



## weir-smith

Al and Len

I just had a look at the code and there is a mix of integer and float in the steps counter as noted by Len. So just changing the "i" from int in the counter loop to float (line 12 from the bottom of the sketch) cures the problem and I tested it to well past 360 deg. Al, your suggestions would also work so thanks for your input. Just shows that you need to test the limits etc.

Bruce


----------



## kquiggle

For what it's worth, when I revised the code for my indexer, my general approach was to do all the preliminary calculations using floats and the actual steps with integers. To keep the steps integer from overflowing I reset to zero after a full rotation.

I'm still not entirely happy with my revisions. I started with bmac2's program (which I am not knocking - it's good code but needed revision to work with my stepper/planetary gear setup). I ended up making a lot of modifications some of them just stylistic, some of them to educate myself, and some of them to try a different approach. I believe my code works, but it's not as clean as I would like it to be and I am considering starting over again with a blank slate. Meanwhile I have successfully cut a couple of gears with it, so I'm happy for now.

Now some people will say you should avoid using floats with an Arduino because they take up more space than integers and take longer to calculate, but for an application like an indexer the differences are inconsequential.

If you're new to Arduino programming like me (I've done programming before, but just getting into Arduino), here's a good tutorial on data types:

https://learn.sparkfun.com/tutorials/data-types-in-arduino/all

My build:

https://www.homemodelenginemachinis...nic-arduino-rotary-indexer-another-one.27394/


----------



## ignator

kquiggle said:


> My build:
> 
> https://www.homemodelenginemachinis...nic-arduino-rotary-indexer-another-one.27394/


The code that I was commenting on is your version 7.0 I don't have the hardware setup on my Arduino so I can not see why the loop counter was going bonkers, all I could do is look at data types and such. I am not an Arduino or "C" program language expert. Most of my experience was assembly, Fortran, PL1, and an interpreter call ADATE (written in ADA). I really like how Arduino has simplified coding, as it hides the operating system, and hardware interfaces.


----------



## lkrestorer

kquiggle said:


> It looks to me like the new sketch did not actually get loaded. If you look at the link below you will see pictures of what the display should look like. In particular, when you first power up you should see something like:



It is very possible that I'm doing something basically wrong. My assumption was that loading one program into the Arduino and then by loading another into it would totally erase the first program and replace it with the second program. This appeared to be true with a couple of the things that I tried and this is what I did when trying to load and run your version 7. Am I doing it right or is there a purge-type process that has to be accomplished first? I had looked at your screen shots and the result that I was getting made me wonder if the two sketches had inter-scrambled in some fashion.

The question was raised "what is it going to be used for?". To recall, my part of this adventure started with trying to come up with a power feed for my lathe compound to achieve smoothness. When I heard about the Arduino and using it to control a rotary table my interest slightly shifted. I had looked quizzically at the Grizzly 4" rotary table but that seemed too small for my desires especially since I already have a Phase II 8" table. The idea of fitting that with a controller more precise than my fingers and eyesight woke up the interest in me. I would like to (more easily) use the table for machining a flywheel and possibly getting into gear making (I do have a manual indexing head that could be fitted this way also). And, as with any of these machining tools, once you have it you start dreaming up new ways to use it.

Len


----------



## lkrestorer

Lina said:


> It seems like the issue is fundamentally software. Instead of adding hardware (arduino) to solve it, why not just use an integrated solution (Massimo, planetCNC, SuperGerbil) ?



I had no idea what you were talking about when I first read your post so I did a search for the things you mentioned.  I found nothing on Massimo in relation to stepper motor controls. Planet CNC seems to have ready made controller boards to run anything but their boards are 4-axis and 9-axis - this is single axis stuff.  SuperGerbil sounds like they are a startup company trying to get pre-orders so they can gear up to build their boards.

Is any of this equipment such that it's closer to plug-and-play for the 'software challenged' hobbyist?


----------



## kquiggle

weir-smith and ignator - Thanks for the clarifications. You are right about that loop counter - needs to be fixed.  In fact I went back over the code and found a couple of nasty bugs, as well as some minor inconsequential ones. Hopefully I have now fixed them all in updated version 7.14 which is now available here:

https://sites.google.com/site/lagad...es-mills-etc/build---electronic-indexing-head

Some related comments: The old code worked OK for my set-up because the settings for my hardware do not lead to an integer overflow. However, when I experimentally changed the settings to a high micro-stepping number the bug emerged. While correcting the overflow bug (and running some additional tests to verify the fix) I uncovered another nasty bug (failure to recalculate micro-steps per full revolution correctly). 

An interesting observation I made while testing: If I experimentally set number of full steps per full revolution to 400, and micro-stepping to 16, with a planetary gear ratio of 26.85, then the total number of microsteps in a full revolution is 171848.  Since the step delay is set to 1 (millisecond) this is 172 seconds of delay total. On my setup, I find that the actual time is about double that, so this would be more than 5 minutes for a full revolution! I mention this because in testing these high number values, it can seem like nothing is happening when it's really just taking a long time. In actual use I don't experience this problem because I don't use microstepping at all and my motor is 200 full steps per full revolution (which is typical), so my indexer makes a full revolution in about 10 seconds. Since I'm using it for gear making I'm only moving small increments in actual use, so the move time is typically a second or less.

At this point I am running up against the limits of my knowledge on stepper motors. My understanding is that there has to be some delay between steps to allow the motor time to move, but whether the stepper motor controller handles this or the software (or both) is not clear to me. The code does include a delay parameter - which I have set to 1 (millisecond).


----------



## tjwal

kquiggle said:


> At this point I am running up against the limits of my knowledge on stepper motors. My understanding is that there has to be some delay between steps to allow the motor time to move, but whether the stepper motor controller handles this or the software (or both) is not clear to me. The code does include a delay parameter - which I have set to 1 (millisecond).



The driver has no control over the timing between steps, that is entirely set by your software.  If the steps are too close together the motor will lose steps.  You can usually hear this happening.

I’ve successfully run with a step delay of less than 500 microseconds before mine started losing steps.

John


----------



## kquiggle

John - that's good information, thank you.

I'll experiment with substituting delayMicroseconds() for delay(). I don't think it's a critical issue for this application, but it should be interesting to try it out.


----------



## bluejets

lkrestorer said:


> It is very possible that I'm doing something basically wrong.



Have you checked all your wiring. Using any "push in" connectors or breadboarding can create problems.
Reason I'm suspicious is when you quoted you had fitted the keypad backwards.



lkrestorer said:


> My assumption was that loading one program into the Arduino and then by loading another into it would totally erase the first program and replace it with the second program.


 Correct. Also any problems with loading will show at the bottom of the IDE screen. You may have to "lift" the bottom border of the text screen to see.

Do you have the correct board type selected when you do the programming...?


----------



## kquiggle

More programming bugs squashed! I have just uploaded version 7.23 of my indexer software (available at link below). This version fixes some bugs  when reversing rotation.  I should note that while the code allows for reversing rotation, it does not compensate for any backlash. For my indexer a full 360° rotation is 5,370 steps and the amount of backlash is approximately 75 steps (1.39%, even though the motor spec sheet says backlash is <1%).

For this version of the code, I also changed the delay option from milliseconds to microseconds. I tried setting the delay at 1,000 μsecs (works), 750 μsecs (seems to work), and 500 μsecs (stalls). To be on the safe side I'm running with a delay of 1000 μsecs (1 millisecond).

I have considered adding additional code to compensate for backlash, but for my purposes I do not see any real use for it. In practice, when using the indexer I think it is good practice to allow rotation in only one direction to ensure most accurate positioning. In addition, before use I always run the indexer through a full rotation to remove any slack from the system.

https://sites.google.com/site/lagad...es-mills-etc/build---electronic-indexing-head


----------



## V4dsXz329

Thanks kquiggle for your good work! 

I have two problems when i switched from bmac2 sketch to your sketch. First one was that my lcd keeps showing only blank charaters. After some researching i edited this line:


		Code:
	

LiquidCrystal_I2C lcd(0x3F,20,4);

to this:


		Code:
	

LiquidCrystal_I2C lcd(0x27,20,4);

And now everything works well!

Second problem comes when i updated to your latest sketch. Motor wont turn at all after updating. Solution is simple: setting step delay to 1000 (us) when old value was 1 (ms). 

I wrote these if they were helpful to other beginners like me. Now i got everything works well!


----------



## kquiggle

v4dsXz329 - 

Good to hear it is working for you. Some displays use 0x27 and some use 0x3F so your comment is very useful.  

If you used a previous version of my sketch it would have stored a value of 1 millisecond in EEPROM, which the updated sketch would interpret as 1 microsecond. If you were using my sketch for the first time, it would use hard-coded settings for my hardware, which are probably wrong for most everyone else. First time users should go through the settings first to make sure the values are correct for their hardware - once these have been updated they will be stored so they don't ever need to be reset unless you make a hardware change.

Both your comments raise good points. I am updating the program comments with notes for first time users to address these issues.

Thanks again.


----------



## lkrestorer

bluejets said:


> Have you checked all your wiring. Using any "push in" connectors or breadboarding can create problems.
> Reason I'm suspicious is when you quoted you had fitted the keypad backwards.
> 
> 
> Correct. Also any problems with loading will show at the bottom of the IDE screen. You may have to "lift" the bottom border of the text screen to see.
> 
> Do you have the correct board type selected when you do the programming...?



Yes, I had originally hooked up the keypad the way it was described at the beginning of this post. When I pushed the keys they came up in a random fashion so I just decided to reverse the order that they were connected. Everything worked great after that. When I have had a problem like I was describing I had gone back and reloaded the original bmac2 sketch and the keypad worked again - without touching any of the wiring. I have done this numerous times - it is not a wiring problem.

Yes, the correct board type is selected. The original sketch wouldn't run if it wasn't.

I'm getting back to the project today so I will check that bottom line on the IDE screen.


----------



## kquiggle

Hopefully the last update to my program for a while: I just finished version 7.25 of my indexer sketch, with the following changes:

added backlash compensation (optional)
added a beep function (optional)
fixed a minor bug when making a full 360° rotation in one move
In order to use the backlash compensation, you must determine the exact amount of backlash in your indexer and enter it into the program. In practice, I would not reverse rotation direction when actually using the indexer if it can be avoided. Note that the backlash compensation assumes that the amount of system backlash is repeatable and constant (possibly true in the short run; all bets are off in the long run).

The beep function requires the addition of a speaker or piezo buzzer to the system (wired to ground and pin 13). I added this because when I am using the indexer on my mill, I'm mostly not watching the LCD screen and the beep provides a nice confirmation that a rotation has completed.

Version 7.25 is available for download here:

https://sites.google.com/site/lagad...es-mills-etc/build---electronic-indexing-head


----------



## jabraham17

Mr. kquiggle,
I have been following your build and i appreciate your work. However I have a problem, I cannot get your sketch to load correctly on my arduino uno (clone).
It will load and run the original sketch (from the original poster) but when I try to load your code, my arduino simply does nothing, the IDE says that the upload is complete with no errors but when i power the arduino up all i get is bars across the screen. After trying several times with no success, I can go back to the original code it all functions work as it should again. 
Do you have any incite on things that I can try?
Thank You


----------



## V4dsXz329

jabraham17 said:


> Mr. kquiggle,
> I have been following your build and i appreciate your work. However I have a problem, I cannot get your sketch to load correctly on my arduino uno (clone).
> It will load and run the original sketch (from the original poster) but when I try to load your code, my arduino simply does nothing, the IDE says that the upload is complete with no errors but when i power the arduino up all i get is bars across the screen. After trying several times with no success, I can go back to the original code it all functions work as it should again.
> Do you have any incite on things that I can try?
> Thank You



I have exacyly same problem when i moved from bmac2 sketch to kquiggle sketch. (See my previous post)

To fix that, open sketch and find this line:


		Code:
	

LiquidCrystal_I2C lcd(0x3F,20,4);

And replace it by this:


		Code:
	

LiquidCrystal_I2C lcd(0x27,20,4);


----------



## jabraham17

V4dsXz329 said:


> I have exacyly same problem when i moved from bmac2 sketch to kquiggle sketch. (See my previous post)
> 
> To fix that, open sketch and find this line:
> 
> 
> Code:
> 
> 
> LiquidCrystal_I2C lcd(0x3F,20,4);
> 
> And replace it by this:
> 
> 
> Code:
> 
> 
> LiquidCrystal_I2C lcd(0x27,20,4);



This worked perfectly!! Thank You very much!


----------



## kquiggle

jabraham17  glad you got it working.  It's not a bug exactly -  some displays use 0x3F and some use 0x27 so you just have to find the one that works for you.  If you are using the latest version (7.25) I make note of this in the code comments (check out the NOTES ON FIRST USE at the beginning of the code listing for some useful tips).

The most recent version adds optional backlash compensation and optional "beep" after move (requires additional hardware).  If you don't have the latest version, you can get it here:

https://sites.google.com/site/lagad...es-mills-etc/build---electronic-indexing-head


----------



## bluejets

Best way to avoid the address problem with i2c is use the scanner program.
Load it, run it and it reports the address of whatever device back to the Serial Monitor.

One place for the scanner is here.....
https://playground.arduino.cc/Main/I2cScanner/


----------



## kquiggle

bluejets - thanks for the tip, that's a good one to know. I'm working on a new sketch using acceleration, and every day I am finding out how much I still have to learn about Arduinos and programming them, so I welcome all the advice I can get.

I've just started playing around with the AccelStepper library and I think I'm making some (slow) progress.  I'm glad I started with bmac2's approach first - it was an excellent learning tool, and having a working set-up makes testing a new version a lot easier.

As an aside, in the last version of my previous program I added a beep capability (you need to add a speaker or piezo buzzer to your hardware, of course), and I have found it to be very useful in de-bugging. I can throw a beep into the program and get an audible confirmation that something is sorta working even if the motor isn't moving.


----------



## lkrestorer

kquiggle,

I was able to load your version 7.25.  By changing to "LiquidCrystal_I2C 1cd(0x27),20,4);" my display looks fine and I can make entries just fine.

I then went into the settings and made these changes:
1) set the 'Full Steps in 360" to 400 (it only turned 1/2 of what I was entering in degrees when it was set for 200)
2) left Micro-stepping = 1
3) set Table Gear Ratio = 90 (because my RT is 90:1)
4) left Step Delay = 1000
5) left Backlash Correction = -1 (is it supposed to be a negative number?)
6) left Beep = 1 (because I might get a noise maker - I understand the value of this)

I doubt that I'll have any use for backlash control. There is some slop in the gear train but by running in one direction only and locking the table for each cut there shouldn't be any problem. I have always done this when running it manually, anyway. The micro-stepping idea is something I don't understand yet.

So far it seems to be right on the money but I still need to attach my original manual handle with it's scale so that I can see it in finer resolution.

Next I want to get some more information from Bruce about incorporating a continuous running option for making smooth curves. Then comes the project of putting this together with boxes and buttons so it will be safely useable. Maybe I'll even be able to convince some people that I knew what I was doing when "I" designed this thing.

I may not be done yet but I would like to thank everybody who has helped me muddle through this. It sure is fascinating!


----------



## kquiggle

lkrestorer -

Good to hear it is working for you. To address your points one at a time:

The "Full steps in 360" is the total number of "full" (no micro-stepping) steps your motor needs to turn a complete 360°. Typically this is 200, but for some motors it's 400. Make sure it is set properly for your stepper motor.
The micro-stepping setting should match whatever your stepper controller hardware is set for; 1 is correct if you are not doing any micro-stepping.
Sounds like you have the table gear ratio set correctly, assuming you are driving the table directly. However, if you were driving the table via a 2:1 belt reduction, you would need to set it for the reduction of the entire driving train (2x 90 = 180 in my example).
I think a step delay of 1000 (micro-seconds) is a good compromise. My stepper ran at 750 but stalled at 500, so I think 1000 gives a good safety margin. Of coursde ther is no way for the program to account for any missed steps,so you want to avoid that possibility.
Backlash correction should not be a negative number. If you used an earlier version of my program, you are probably picking up a random number from the EEPROM. IF you are not using backlash correction just set it to 0 (zero). I agree with you  on running in one direction only - that's the only way I would do gear cutting. However, it was easy to add backlash compensation, and I have some ideas for using it in a new program so I wanted to try it out. For what it's worth, it worked better than I expected.
Now that I have started using the beep I am really finding it useful. A piezo buzzer is only a buck (no need to use a resister), so it's a cheap and easy addition. 
About continuous running: I'm working on a program for this now, including acceleration/deceleration. Right now I am just at the point where I'm starting to understand the AccelStepper library, so it's going to be a few weeks before I have something to share, but I'll post something here when I do.


----------



## kquiggle

Adding a simple beeper to your indexer (I used a "piezo buzzer"like the one shown - actual size about 22mm diameter) is very easy; these cost around $1 or less.  Simply connect the two wires on the beeper as follows:

black: pin 13
   red: ground (GND)
Actually the beeper will work even if the two wires are reversed, but I found that mine worked better as above than when reversed. Sometimes it is suggested to add a 100 ohm resister, but this is really not necessary.

The indexing program I wrote includes the option to use a beeper. I also wrote a simple program ("beep-test" - available for download in the Coding section of the link below) which can be used to test beeper function and find the best frequency to use with your beeper. 

When I wrote my version 7.25 indexer program, I used a tiny speaker from my junk box as a beeper and found a frequency of 4000 worked best. With the piezo buzzer I found that a frequency of 3800 was a bit better. I suggest using the beep-test program to determine what works best for your beeper.


https://sites.google.com/site/lagad...es-mills-etc/build---electronic-indexing-head


----------



## tjwal

kquiggle
Rather than using the accel library I was considering just using an approximation. It would be something like this
First 5 steps use 5x stepdelay
Next 5 steps use 4x stepdelay
And so on
Similarly decelerate at the end.


----------



## kquiggle

tjwal -  That is essentially what the AccelStepper library does (but supposedly in a more sophisticated manner). 

I found the AccelStepper library a bit counter-intuitive at first, but now that I am starting to figure it out I can see the benefits.  For example, you can set acceleration and max motor speed and then with a single command you can move from A to B and the motor will automatically go from A to B by accelerating to top speed and then decelerating down to B (and if there is not enough time between A and B to reach top speed it will handle that too).

I think your proposed approach will work, and it may be the best approach depending on exactly what you want to do.  On the other hand, there are a lot of little details to address if you want to write your own acceleration code.  The advantage of the AccelStepper library is that those nasty little details have been addressed and de-bugged (there have been about 50 enhancements and bug fixes since the initial release).

Both approaches have advantages and disadvantages. If you write it yourself you will have a deeper understanding of how the program works, but it may be more limited. If you go with AccelStepper you will have to go through a learning curve and that may take more time and effort than necessary for what you need to do. 

The best part is: You can choose whatever you want.


----------



## kquiggle

As I mentioned earlier, I have been trying out the AccelStepper.h library for acceleration and deceleration of stepper motors. As I worked through the learning process I started accumulating notes, ideas, and observations so I decided to organize all the information on a web page. I have also written some small sample programs to show how the library can be used, and I am posting those programs also (with more on the way). Anyone who has built a bmac2 type hardware setup should be able to run these programs.

My ultimate goal is to write program for controlling a rotary index table using acceleration/deceleration with  these general capabilities:

Indexed moves (by degrees or number of sides/teeth)
Continuous rotation in both directions
Rotation in an arc, both one way and back and forth
Backlash compensation
If you are interested in writing your own programs with this library, you may find my web page useful:

https://sites.google.com/site/lagadoacademy/miscellaneous-projects/stepper-motor---accelstepper-h


----------



## tjwal

kquiggle
I took a look at your website.  You’ve been busy!!
I do have a couple of questions on your furnace controller.
How many watts is it?
What voltage is it?
What are the interior dimensions of the kiln?
I’m planning on a heat treat furnace but have been wondering how much power I should aim for.

The 100+ minutes of warm up time and maximum temps you are achieving has me leaning towards 240V, but my furnace will likely be smaller than yours so 120V might work.

Thanks for any info.

John


----------



## kquiggle

John - I don't want to get to far off-topic for this thread, but to give you a quick answer:

The furnace is fairly small; internal dimensions are 6.5" W x 4.25" H x 6"D. I do not know what the wattage is, but jewelry furnaces of similar size are around 1500 Watts so it is probably somewhere near that. I figured if it turned out to be too small I could make another furnace a bit larger and use the same controller, but for the small pieces I am doing it has worked out OK. If you have more questions feel free to PM me. For anybody wondering what the heck we are talking about: https://sites.google.com/site/lagadoacademy/machining---lathes-mills-etc/build---furnace-controller


----------



## kquiggle

For anyone interested in trying out a Rotary Table Controller program which uses acceleration and deceleration, I have an almost complete, partially tested Rotary Table Controller program. The program implements the following functions:

All user settings are stored in permanent memory
All user settings can be entered via keypad

All stepper motor moves use acceleration/deceleration
Maximum motor speed and acceleration are set by the user

Backlash compensation is implemented
Beep (audio) function is implemented

Move in indexed steps by setting degrees per move
Move in indexed steps by setting number of sides or (gear) teeth
Move in jog mode (small steps clockwise or counterclockwise)
Move in continuous rotation (clockwise or counterclockwise)
Not yet implemented: Move back and forth in a defined arc
The program is available for download here:
https://sites.google.com/site/lagadoacademy/miscellaneous-projects/stepper-motor---accelstepper-h

I'm interested in comments, suggestions, and bug finds from anyone who cares to try it out.

As noted above, everything in the program is working except the arc function, which I am just starting to design. The arc function will move the table back and forth in a defined arc. My current plan is something like this:

Use the jog function to move to the arc starting position (call it point A)
Define the arc ending position (call it point B) by one of these methods:
specify number of degrees from point A
use the jog function to move to point B and save the position

Move back and forth from A to B continuously (with keypad keys to start and stop)


----------



## seleveng

Hello kquiggle,

your last version looks promising... I'm really excited! I will give it a try hopefully later today.
One thing I can add as a suggestion... for permanent movement in either direction a speed-control-function would be nice, maybe by using a separate potentiometer.
This makes it possible to use the programm for a welding table function as well.

Regards,
Sebastian


----------



## Rhynardt1

Hi kquiggle

I have tried to load your Rory table 7.25 program but it keeps on faailing with this message:


Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"

In file included from C:\Users\Rhynardt\Documents\Arduino\Arduino_Rotary_Table_Control_2019_Rev7.25\Arduino_Rotary_Table_Control_2019_Rev7.25.ino:79:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:33:1: error: expected unqualified-id before 'class'

 class TwoWire : public Stream

 ^

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:33:1: error: expected constructor, destructor, or type conversion before 'class'

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


What can i do to fix this?


----------



## kquiggle

Sebastian - your potentiometer idea is a good one. However, now that I have started working on adding the arc movement functions I am starting to get "low memory" warnings when compiling; I I think I can make it fit but I will need to do some code optimization.  But I don't think I can fit in another speed control function. The current program does include an option for setting the continuous rotation speed. Another possibility would a separate program for rotary table applications which do not need to do indexing.

Rhynhardt1 - in answer to your problem with version 7.25 of the program: This sounds like the kind of error I see when there is a missing semi-colon or parenthesis. The first thing I would try is to download the program again and then try re0installing it. If that does not work, let me know. Just to be sure, I just re-downloaded and installed myself with no errors.


----------



## Rhynardt1

Hi kquiggle

Thanks for the prompt reply. Will try it today and give you feedback


----------



## Rhynardt1

Hi Kquiggle

I have downloaded the file again and its working perfectly thanks!


----------



## kquiggle

Rhynardt1: Thanks for the feedback.

FYI there is a bug in the V2-Rev4.00 program version that prevents backlash correction from being set to zero (turned off). I made a quick fix and uploaded the new program as V2-Rev4.01 - this is available now if this matters to you. 

A reminder to anyone reading this: This software is for testing only so there are probably more bugs lurking. I have received a report from another tester that his motor is stalling when he tries to run it in the continuous run mode.  I think he may have speed or acceleration set too high,but I could be wrong about this.

Here is what I do know right now: The program is working with my indexer. When I run in in constant run mode, I can hear the motor accelerating. I think this is correct behavior, as the idea is to give the motor time to move a heavy rotary table up to speed (and then decelerate slowly when stopping). However, I only have one indexer to test on, so I am very interested to see how the program works for others. 

For anyone testing the program, I would very much appreciate feedback as to whether it worked for you or not. Also, what did you like (or not like) about the program?

Download link:
https://sites.google.com/site/lagadoacademy/miscellaneous-projects/stepper-motor---accelstepper-h


----------



## kquiggle

Not long after my previous post, I found another bug: Setting the % of maximum speed for continuous running mode was not working. A corrected update has been posted.

As of this writing, the current posted version is 4.11

Download link:
https://sites.google.com/site/lagadoacademy/miscellaneous-projects/stepper-motor---accelstepper-h


----------



## SailplaneDriver

Downloaded and tried version 4.11. My stepper is not yet installed on the rotab but everything operates properly with the correct rotations for my setup. I had a bit of difficulty downloading the accelstepper.h library but finally found the link imbedded in the middle of the page - it's definitely not obvious.

I like the interface changes. I really like the accel/decel. I suspect that it will significantly decrease the likelyhood of missed steps. A bit more info on the stetting variables would be helpful, in particular the units. I am assuming they are percent unless otherwise noted. It also appears that the percent can be larger than 100. Are there limits to these values?

It looks like there is an interrelation between stepDelay and stepperMaximumSpeed.  A step delay of 1000 microsec implies a maxium output step frequency of 1kHz and a stepperMaximumSpeed of 500 gives 500Hz or a pulse cycle of 2000 microseconds. If I interpret it correctly, the stepDelay must be less than half 1000000/stepperMaximumSpeed assuming a 50% step duty cycle. Is that correct?

Great job so far. I'm looking forward to the next release.


----------



## kquiggle

SailplaneDrive -  I am glad it is working for you, but please keep in mind it's unfinished and not bug-free. I'm currently working on V2-Rev4.50 with a few improvements (but too many bugs yet to be released). With any luck I should have an update posted sometime next week.

I think you are right about stepDelay but I am far from an expert on this so I will defer to others who are more knowledgeable. The version I will be posting next does not use the stepDelay parameter at all, and all of the stepper movement is handled through AccelStepper.h

The program comments contain some useful information on the program but I will add more detail on parameter setting and program operation.  Eventually I will post some information on the web page (link below) but I will update the program comments first so that anyone with the program also has the instructions.

https://sites.google.com/site/lagadoacademy/miscellaneous-projects/stepper-motor---accelstepper-h


----------



## SailplaneDriver

I think I answered my own question, stepDelay is no longer used. Is that correct?


----------



## kquiggle

SailplaneDrive - you are correct. In the version you have, there is a setting option for it but it's not used. It's sort of like an appendix - I took it out of the next version.


----------



## kquiggle

An updated version (V2 - Rev.4.66) of my Rotary Table Control program with acceleration/deceleration is available at the link below. This is a fully working and tested program, but it should still be considered a "working beta" until it has undergone more extensive use and testing. The program is available at the link below. Please read the program comments for instructions and suggestion on use.

Also - many thanks to "VK" for helping to test this program and for many good comments and suggestions.

The program code includes extensive instructions on how to use the program, how to determine optimal speed and acceleration settings, how to determine required backlash corrections, etc.

The program implements the following functions:

All user settings are stored in permanent memory
All user settings can be entered via keypad

All stepper motor moves use acceleration/deceleration
Maximum motor speed and acceleration are set by the user

Backlash compensation is implemented (can be switched on or off)

Beep (audio) function is implemented (can be switched on or off)

Move in indexed steps by setting degrees per move
Move in indexed steps by setting number of sides or (gear) teeth
Move in jog mode (small steps clockwise or counterclockwise)
Move in continuous rotation (clockwise or counterclockwise)
speed and acceleration for this can be set
in particular, speed can be reduced for machining purposes

Move in arc mode: Move back and forth in a defined arc
https://sites.google.com/site/lagadoacademy/miscellaneous-projects/stepper-motor---accelstepper-h


----------



## kquiggle

I thought I would add an additional note here about a useful method I found to monitor rotary table position for the purposes of testing backlash compensation and indexer accuracy. It is quite simple: Just attach a laser pointer to the table and point it at a nearby wall. I then mark the position of the laser dot with a sticky note with a black dot on it (see the photo). 

Then, for example, if you rotate the table 360 and the dot does not return to the exact same position, you will know there is an error in your indexer somewhere. 

If you rotate the table a full 360 degrees in one direction, and then a full 360 degrees in the opposite direction you will see that the dot does not return to the original position due to backlash. In the comments written into my program linked to in my previous post, I explain how to use this method (along with program features) to determine (and compensate for) backlash.

I use a wall about 2 ft away for this purpose and find the dot is quite sensitive to motor stepping; I can easily detect movement of a 1/2-step. For even more sensitivity, just move farther from the wall.


----------



## kuhncw

Thanks for the laser suggestion.  Interesting application.

Chuck


----------



## kquiggle

People who have been following this thread may be interested in a video I just ran across on building an Electronic Lead Screw. Even if you are just thinking about building an electronic indexer, the video has a good overview of the different types of Arduinos and other microprocessors, and their pros and cons.


----------



## kquiggle

The final version Arduino_Rotary_Table_Control_2019_V2-Rev4.68.ino of my program which implements acceleration and deceleration is available at the link below. If you are trying this program for the first time (even if you tried an earlier version) you must use the Settings mode first to enter your stepper and rotary table parameters.

This is "final" in the sense that there will be no additional program features added, but if any bugs are reported to me I will post fixes as they become available; I will also note any issues on the page linked to below. Bugs can be reported by replying to this thread, or by sending an email to the address found at the link below. 

Additional note to anyone trying out this program: I would appreciate if you would let me know what program parameters (maximum speed, acceleration, etc.) worked for your indexer (as well as a brief description of your hardware) as I would like to get a general idea of what workable settings should be.

Finally, I would like to thank a couple of people (you know who you are!) who helped out with testing earlier versions of this program and who contributed many good comments and suggestions.

Program download and additional information here:

https://sites.google.com/site/lagadoacademy/miscellaneous-projects/stepper-motor---accelstepper-h


----------



## kquiggle

A couple of minor bug fixes to the final version (now Arduino_Rotary_Table_Control_2019_V2-Rev4.69.ino) of my program which implements acceleration and deceleration is available at the link below. If you are trying this program for the first time (even if you tried an earlier version) you must use the Settings mode first to enter your stepper and rotary table parameters.

These are the only bugs reported since the "final" version was published on April 17, 2019 so I believe the code is reasonably bug-free at this point. However, I will do my best to address any issues that may be reported in the future.

Program download and additional information here:

https://sites.google.com/site/lagadoacademy/miscellaneous-projects/stepper-motor---accelstepper-h


----------



## Imre karoly

Greetings,

I'm getting a bug during the test  (under verify), please help my.

                //decelerate to a stop
* stepper.stop();                                           //Reset target for deceleration  "*here is the error code*"*
        stepper.runToPosition();
        makeBeep(halt);

Regards, KIM


----------



## Coolfox007

Hi kquiggle
I have successfully tried your code and it work like a charm  I have come up with may be one more idea of upgrading it but not sure how to better change the code to activate electromagnetic breaks straight after indexing move with short "beep" and deactivate like 10 milliseconds before next indexing move begins. 
It my be useful to others who utilized small stepper motors in this project and it will make possible ( with right hardware) to make "direct driven" indexing table 
Thanks
Ilia


----------



## kquiggle

KIM - I don't think I understand what bug you are seeing - can you please clarify? 

Ilia - I'm guessing you want to implement some sort of automated table lock, which is the reason for your question.  In any case, the answer would be to write a simple function to activate/deactivate an IO pin, and then insert the function in the appropriate place in the code. My goal right now with the current version of the code is to finalize it with respect to adding any new features, and just make bug fixes. However, I would consider publishing a second experimental version with the function you described if you can give me some additional detail on what you plan to do in terms of hardware. As I said, I am assuming that you want to make a particular hardware IO pin go HIGH after indexing and LOW before indexing (or vice versa) in order to activate a relay. I can write the necessary code, but I would need someone to test it.


----------



## SailplaneDriver

kquiggle, can you add a button push to stop rotation? It would be used if there was a problem with either incorrect user entered data or a machine problem.


----------



## kquiggle

SailplaneDriver - I am looking into ways to wire in a stop button, but I am not optimistic about finding a good method. One option you might consider for a "panic stop" button is to wire a button to the reset switch. Pressing reset will result in a dead stop (no deceleration) and loss of current position information but is probably the best choice for an emergency stop, aside from just killing power to the motor (in fact a power on/off switch is another option).

Note also that a stop button cannot be used when moving in index mode because the AccelStepper.h function used is "blocking" - there is no option for the code to look for a stop button press. It may be that the use of an interrupt could work around this, but this needs further exploration (again, I am not optimistic). I could have used a non-blocking function for index moves but there are drawbacks to that as well, and since I thought that since most index moves are over fairly quickly (at least for me when making gears) that a stop option wouldn't add much benefit. There is a stop option in continuous move mode already and that seems to work reasonably well.


----------



## kquiggle

Update for anyone interested in operating a relay along with the stepper motor:

A program version Arduino_Rotary_Table_Control_2019_V2-Rev4.69B.ino has been posted which implements this function. The code was kindly supplied to me by VK; I have not tested it myself as I do not have a relay set up, but I see no reason why it should not work from a programming viewpoint. 

Program download and additional information here:

https://sites.google.com/site/lagadoacademy/miscellaneous-projects/stepper-motor---accelstepper-h


----------



## Noitoen

To program a quick stop, you can use the button press to change the "target" value to the current running value adding some extra steps to cope with safe deceleration. In this way, you can stop without losing position.


----------



## kquiggle

Noitoen - It's certainly possible to add a stop function from a programming point of view, but there are two problems with this.

The first problem is that the AccelStepper.h function which works best with stepper motors is a "blocking" function - there is no option to insert code to check for a stop button.

The second problem is that while there are other AccelStepper.h non-blocking functions which can be used in a while loop, inserting a check for a button press into the loop introduces a delay which adversely affects stepper motor function. This is especially true if checking for a keypad press because a keypad scan takes a long time (in computer terms). This option is implemented for the continuous run mode, but it results in greatly reduced maximum motor speed. 

It may be that using an interrupt would resolve this issue, but I have not had time to try this yet.

Finally, I suppose the main reason I did not implement a stop function for index mode is that I did not really see a need for it. This may be because my main use for the indexer is to cut gear teeth, so the index moves are relatively small and are generally completed before I would have time to hit a stop button anyway. IS there a need for a stop button in index mode that I am not seeing?


----------



## SailplaneDriver

kquiggle said:


> One option you might consider for a "panic stop" button is to wire a button to the reset switch.



I am implementing a separate emergency stop that will be wired directly into the stepper controller. In my case, the rotating table has a 90:1 gear ratio. It can take quite a while until the stepper stops depending on the number of divisions or angle input which is why I was asking for a stop button, preferably one of the keypad buttons. The intent would be to halt the current operation and go back to some prior menu level. When I was testing the unit for positional accuracy I found it easier to power down and reset the unit rather than wait for it to make 90 revoutions when I had input incorrect data and asked for 360 degrees. That is why I brought up the issue. It certainly is not a necessity and definitely should not be used for an emergency stop. E-stop should always be performed at as close a point to the driven load as practical.

Thanks again for posting such a useful program.


----------



## kquiggle

SailplaneDriver - thanks for the clarification. You said that you are wiring an emergency stop into the stepper controller - what is the benefit of this as opposed to just using a power off switch?


----------



## SailplaneDriver

kquiggle said:


> SailplaneDriver - thanks for the clarification. You said that you are wiring an emergency stop into the stepper controller - what is the benefit of this as opposed to just using a power off switch?



I plan on shutting off the stepper controller directly either by killing its power or logic input; the logic input is easier on the contacts. A general power shutoff can work depending upon where you do it. If at the input to the power supply you still have stored energy in the capacitors which will allow continued operation for some period. Contacts have to be suitably rated and any DC "kickback" has to be addressed.


----------



## weir-smith

If you require an emergency stop, then purchase a miniature emergency stop button and wire it between +5 volts and the other side to the +enable (EN) connection on the stepper controler board. The -EN needs to be commoned up with the -ELK and -DIR.

When operated, the stepper stops instantly and will restart once the stop button is released.

Bruce W-S


----------



## strannik2

Добрый день!
Нарисуйте пожалуйста полную схему подключения всех компонентов по версии (Arduino_Rotary_Table_Control_2019_V2-Rev4.69B.ino) и можно ли подключить Microstep Driver 8060 + Nema 34 8.6 Nm
(
Good day! 
Please draw the complete wiring diagram of all components at version (Arduino_Rotary_Table_Control_2019_v2-Rev4.69B.ino) and can I connect 8060 Microstep Driver + Nema 34 8,6 Nm)


----------



## animal12

my stepper motor is a 8 wire , will i work with this ?
tks
animal


----------



## weir-smith

To Strannik2 and Animal12

The connection of an emergency stop is very simple and can be tried easily by simply connecting the -EN to either 
- Clk or - Dir. Connect a wire to +5 volts then initiate the rotary table and while the stepper is moving, touch the five volts to the + EN and the stepper will instantly stop and remain stop until the +5 volts is removed.

 The enable control, is a logical gate that controls the clock and direction signals into the controler circuit.

The input signals to the stepper controller are independent of the output circuit that drives the stepper. Therefore, it doesn't matter if the controller is 4 wire, 6 wire or 8 wire.

I can post a diagram of how its wired  tomorrow if required.  The purpose of the emergency stop is to stop movement of the rotary table instantly because something seriously wrong has happened.

This happened to me about two weeks ago when machining the little end of a connecting rod, the tool started to extract itself from the collect. I had only tightened it by hand when I was interrupted, then when I went back to what I was doing proceeded without further tightening.

BruceWS


----------



## kquiggle

BruceWS - Am I correct in thinking that the while the emergency stop will stop the stepper motor from moving, the Arduino will continue to run it's program with the result that when the motor comes back on the Arduino will no longer "know" the correct table position?


----------



## SailplaneDriver

weir-smith said:


> If you require an emergency stop, then purchase a miniature emergency stop button and wire it between +5 volts and the other side to the +enable (EN) connection on the stepper controler board. The -EN needs to be commoned up with the -ELK and -DIR.
> 
> When operated, the stepper stops instantly and will restart once the stop button is released.
> 
> Bruce W-S



Sounds like you had the issue I was concerned about. I've got a mushroom head E-stop switch in hand. I'll locate it nest to the stepper motor for easy and quick access. Thanks for confirming the controller board pins, saves me looking them up.


----------



## SailplaneDriver

strannik2 said:


> Добрый день!
> Нарисуйте пожалуйста полную схему подключения всех компонентов по версии (Arduino_Rotary_Table_Control_2019_V2-Rev4.69B.ino) и можно ли подключить Microstep Driver 8060 + Nema 34 8.6 Nm
> (
> Good day!
> Please draw the complete wiring diagram of all components at version (Arduino_Rotary_Table_Control_2019_v2-Rev4.69B.ino) and can I connect 8060 Microstep Driver + Nema 34 8,6 Nm)



strannik2, go back to the beginning of this thread. There are complete instructions including pictures with wiring shown and materials list.


----------



## Dusty3v0

kquiggle said:


> BruceWS - Am I correct in thinking that the while the emergency stop will stop the stepper motor from moving, the Arduino will continue to run it's program with the result that when the motor comes back on the Arduino will no longer "know" the correct table position?


I have not read this thread of looked at the code.  Having said that:  One should have 2 stop buttons.   A true emergency stop with cuts the power and a switch connected to an arduino input which will cause the code to enter a loop waiting for the switch to be reset.  This 'should' not be difficult to code.    And perhaps it already exists.


----------



## strannik2

[QUOTE = "weir-smith, post: 323695, member: 20776"] Страннику2 и Животному12

Подключение аварийного останова очень просто, и его можно легко проверить, просто подключив -EN к
- Clk или - Dir. Подсоедините провод к +5 Вольт, затем запустите поворотный стол и, пока движущийся шагер, коснитесь пяти вольт до + EN, и шаговый двигатель мгновенно остановится и останется остановленным, пока не будет удалено +5 Вольт.

 Элемент управления разрешением - это логический элемент, который управляет тактовыми сигналами и сигналами направления в цепи контроллера.

Входные сигналы в контроллер шагового двигателя не зависят от выходной цепи, которая управляет шаговым двигателем. Следовательно, не имеет значения, является ли контроллер 4-проводным, 6-проводным или 8-проводным.

Я могу опубликовать диаграмму того, как это будет проводиться завтра, если потребуется. Целью аварийной остановки является немедленное прекращение движения поворотного стола, потому что произошло что-то серьезное.

Это случилось со мной около двух недель назад, когда обрабатывая маленький конец шатуна, инструмент начал извлекать себя из коллектора. Я затягивал его только рукой, когда меня прерывали, а затем, когда я вернулся к тому, что делал, продолжал без дальнейшего затягивания.

BruceWS [/ QUOTE]
Спасибо!
Скажите пожалуйста,а по такой схеме подключения драйвер будет работать? (
Thank you!
Tell please,and according to such scheme of connection the driver will work?)


----------



## weir-smith

I have attached the wiring diagram for fitting a Stop Switch for anyone who is interested. Further, I have had a discussion with a friend where it was pointed out that such a switch was not an Emergency Stop (poor use of words) rather it is a stop switch to which I concur. 
To answer a previous question, yes the program continues to run to complete the step. Therefore, you would need to start the machining from the last position. To holt the program as such, you would need to implement an interrupt which has been previously described. To my mind, the only time you would need to stop the machining process is when something has gone wrong and the most common thing is that the work piece has moved as a result of the cutting pressure or similar. This is particularly common when machining an odd shaped casting which is difficult to hold. If the job has moved, your back to resetting it up if it is practicable and starting again. I cut a keyway in the gear blank when cutting gears so that I always have a reliable reference. 
The only benefit of a stop switch, is that it is quick to operate rather than use the keypad to enter the required command. Just my thoughts.

Bruce W-S


----------



## strannik2

Спасибо!
Как с совместимостью драйверов?
(
Thank you!
How about driver compatibility?
)


----------



## weir-smith

All stepper drivers in terms of their digital input connections, are the same eg En, Cl and Dir. The microstep range can vary as can the output connections eg 4 wire, 6 wire and 8 wire.

Bruce


----------



## lmeb83

weir-smith said:


> Len
> 
> I can see that you are having a few problems with this project. I have made several of these units without difficulty however, if it is all new then its a case of plodding through all of the issues.
> 
> A quick fix for the sketch for 90:1 rotary tables is to edit the file by making the "Multiplier = 100" rather than "Multiplier = (StepsPerRotation* TableRatio)/360". Just scroll down to the "const int" and the fifth is the Multiplier. There is an issue with the code when you set the variables for 90:1 and while I am sure of the solution, I need to test it across a range of numbers to be sure. I will do that in the next couple of weeks. For 90:1, the multiplier needs to be 100 if you are using the setting on the stepper driver of "2". On the stepper controller module, you can set the max current and the stepping mode some times shown as excitation mode via dip switches. You can select 1, 2, 8, or 16 and you require 2.
> 
> So for a 90:1 rotary table, 4 deg is equal to 1 complete turn of the stepper or 200 steps for the standard stepper motor. So 4 deg x 100 = 400 and this is what you will read on your display. The stepper controller will divide the input steps by 2 e.g. 400 steps /2 = 200 or one revolution.
> 
> My fix is a quick one however is works without problems and as I said before, I will put in a correction which is easier to implement. I have two rotary tables of different ratios and I want to use the same controller so I will need an extra menu etc. I have also added an additional feature in my controller that provides continuous rotation with forward and reverse etc.
> 
> Also happy to answer any more of your questions.
> 
> Bruce
> 
> 
> View attachment 108104


----------



## lmeb83

Bruce,
I am using an HBS860H Hybrid servo drive and I am having issues with the rotation of the stepper. It rotates to the same direction. I am pretty sure I am not wiring it correctly.
I have tried different connections but haven't been successful. 
This is the code I am using.
Thank you,
Miguel


----------



## DzhusUA

Hi friends! I am new in this forum!
One Ukrainian gay makes version 2 of this module:




Make a video and ready to noncommercial seel them on world way!
I hope you describe to channel and liked his video: 
Best Regards!


----------



## weir-smith

lmeb83 said:


> Bruce,
> I am using an HBS860H Hybrid servo drive and I am having issues with the rotation of the stepper. It rotates to the same direction. I am pretty sure I am not wiring it correctly.
> I have tried different connections but haven't been successful.
> This is the code I am using.
> Thank you,
> Miguel



Miguel

I have had a look at what you are doing and one of us is confused however please note the following:-

The code you are using includes the use of the Arduino Nano so I will assume this is so. The output pins that have been declared in the Sketch pgm are digital outputs 12 for Step (Pul) and 13 for Direction (Dir) and you also need a ground connection to the Nano.

Your controller is the HBS860H which used Pul for Step (e.g. the pulses that drive the stepper) and Dir for direction.  If you look up the connections in the manual for PNP sourcing control and have some basic understanding of electronics, you will see that the interface on the HBS Driver are optical coupled. That is, current will only flow one way so reversing the connections has no effect except that nothing will happen.

The Pul or step is a series of pulses which the Nano counts. Each pulse drives the stepper forward (or reverse depending on the state of Dir signal ). Each step is equivalent to a micro step.

The Dir signal (pin 13 on the Nano) will be either + 5 volts (approx) or 0 volts. This signal simply instructs the controller as to the direction of the stepper motor. It simply phase shifts the stepper outputs that causes the stepper motor to reverse direction. 

So to get your stepper wired correctly,  do the following:-

        1. Connect pin 12 (Step) of the Nano to PUL + on the Driver.

        2. Connect pin 13 (Dir) of the Nano to DIR + on the Driver.

        3. Connect ground of the Nano to PUL -, Dir - on the Driver e.g. just loop between - Dir and - PUL and then back to the ground on the Nano. Note, there is only (I think) one ground connection on the Nano which you also need for the display, so you may need to join this wire.

So providing the Sketch works, your system should now work.

Bruce W-S


----------



## Jim Woodworth

Jen you have amazed at how much initiative and expertise you demonstrate and openly shared with this project. And now many more folks have the opportunity to proceed with similar projects and thanks for the rest that have chimed in to help clarify and such. A person can visit a lot of groups and never see this kind of comradery !
Jim


----------



## Jim Woodworth

So I'm on a small screen phone traveling and with further investigation it looks like this was originally started by bmac2
When it came up on my phone it looked like Jen had just done this... what I said is still true what an amazing group of people willing to share information like this. Internet keeps dropping me in the storms here in NC. Anyway cheers to all that are instrumental in this for dummies post


----------



## lmeb83

Bruce,

Thank you, for your help.

I had been reading, and trying different wirings, modifying the sketch.

I believe the sketch was not working because it was for a Pololu that only has one STEP and one DIR. Since I am using an HBS860H, I had to modified the sketch.
I don't know if I am going the right way, but this is what I have so far.

I can rotate the stepper CW and CCW now.

  I created one function for rotationCW and other for rotationCCW

I have some questions:
On line 31, if I put 51200 instead of 800. The sketch does not work. Even when I change the switches from the driver.
Or if I use 25600, the stepper  just works with 180 or 360 degrees. If I type 720, or 1080, it rotates infinitely.
Also, if I use 800 but change line 36 (stepdelay), to 0.5. The PWR/ALM light from the driver turns on and it the stepper does not rotate.
I had to change line 34 to float, so the rotation in more accurate. I need a resolution of 2 decimal places.

This is the wiring I am using:
1. Connect pin 12 (Step) of the UNO to PUL - on the Driver.
2. Connect pin 13 (Dir) of the UNO to DIR - on the Driver.
3. Connect PUL + and DIR + to 5V (I am using a breadboard)

Thank you,


----------



## weir-smith

Miguel

Clearly you are having all sorts of problems and getting some unusual outcomes. These problems are usually due to overflow issues and I would need to look carefully through the code however, I don't have the time at the moment.

I would suggest that you try code that is tried and tested. At this time I think you need something that is basic and the Sketch I use has been implemented on a number of rotary tables and it has worked out every time. Note, it is setup for a 90:1 rotary table. If yours is something different then a small change is required. If you can send me a personal message with your email address and rotary table ratio, I will send you the Sketch.

Regards

Bruce W-S


----------



## JPRI

Hi BMAC, where i can download  diagram for tHis proyect?


----------



## Clockiingin

Hi JPRI,

Have you seen this site:-

http://www.worldofward.com/rotarycontroller/

I have made a few of these and now don’t know what I would do without one.

Paul.


----------



## xpylonracer

DzhusUA said:


> Hello guys!
> Here new video from my bro with ready to sell rotary table electronic. Fully autonomous and protected. Any questions please mail me or bro!



Contact details please.


----------



## salzburg

Most people read and speak English, so English please.


----------



## OldRon

bmac2,

I NEED to motorize my Yuasa 8" HV rotary table. I have worked with servo motors and closed loop motion control but have never touched a stepper motor. However, my DSP motion control board is 3 axis so I cannot incorporate the table with the controller. Therefore, I would like to use an Arduino and a stepper motor. With CNC I don't need to use the table travel for machining. Out of necessity I do all of the repair and upgrades on my CNC machine tool controls but when it comes to design build electronics I'm totally ignorant. In the past I built indexing heads for the projects but motorizing my rotary table would eliminate the need to do that. If this is truly "Arduino Rotary Table for Dummies" then I would like to put it to the test. Will you assist me?

My current project is a centrifugal clutch for my motorcycle.







Multiple teeth were cut at each position on the Indexer below. That is why the divisions appear strange. The limiting factor was the cutter undercutting the first and last tooth or in other words shelving.


----------



## Joseph Comunale

Thank You BMac/Bob!   I got mine to work!   Now to put it in a nice enclosure and to hook it up to a rotary table!


----------



## Joseph Comunale

How is everyone mounting their hardware to make a robust system?


----------



## NickP

Joseph Comunale said:


> Thank You BMac/Bob!   I got mine to work!   Now to put it in a nice enclosure and to hook it up to a rotary table!


I’m at the same point. Thrilled to have the stepper behaving as expected thanks to the hard work and knowledge of others (I’m totally new to Arduino), I haven’t yet enclosed the tech bit or mounted mine to the dividing head or rotary table. 
Hopefully will get some good ideas if other users share what they’ve done in response to Joseph’s query above.


----------



## dnalot

Hi

See post 53. This setup with the counter weight to tame any backlash has worked out very well for me. I have used this rig a lot and tomorrow I will be using it to cut a camshaft for a 4 cylinder engine. 

Mark T


----------



## CNC-Joe

tjwal said:


> Attached are pictures of my controller.  I had an arduino Pro Micro so I used it.  A nano would work just as well.  Both of them have standard pin spacing which makes it easier to connect the keypad. I'm using as 18V lithium supply so I used an 8V regulator to drop the voltage to the arduino.
> 
> I used a 330 oz-in stepper and a pololu driver.  The pulley ratio is 4.2 and I'm using 16 microsteps for 3200 steps per rev.  These have to be entered as integers but since they are multiplied together, I entered a table ratio of 42 and 320 steps.  With a step delay of 500 usecs, it has enough torque that it is difficult to hold the spin index wheel tight enough to get it to miss steps.  With a step delay of 250 usecs I'm pretty sure it missed an occasional step when starting to move.
> 
> I've also attached a picture of my 18V powerpack.  Originally I only intended to use it at our local "show and tell".  It works so well though, that its likely the only supply I will use with the indexer.  I found the 3D stl file for it at https://www.thingiverse.com/thing:352094
> 
> Kudos to bmac for writing up the assembly instructions.
> 
> View attachment 94898
> 
> 
> View attachment 94899
> 
> 
> View attachment 94900
> 
> 
> View attachment 94901
> 
> 
> View attachment 94903


----------------------------------------------------------------------------------------
TJWal - very nice design on the hand held enclosure.  Would there be any chance of you posting your design?  The rest of us could use this as a basis for  3D printing one with the common (BMac2's) components?


----------



## animal12

thanks to all that have made this happen ! I have built this but my stepper driver is a different one , I thought I was ordering the same one , here is what I ordered & received https://www.amazon.com/gp/product/B0093Y88SK/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&th=1 .But mine has ST330-V3 in the bottom right of the board. Where I'm getting messed up is everything seems to work right , the screen, keypad,uno , but the driver I got has Step,Direction,Enable & 5V .the drawing for the project shows , Clock, Direction ,Enable & 5v /VCC. Are Clock & Step the same ? forgive me if this has already been addressed , I have scrolled & read this so many times it is starting to run together .Once I get this resolved hopefully all will be good . 
tks
animal


----------



## ignator

animal12 said:


> thanks to all that have made this happen ! I have built this but my stepper driver is a different one , I thought I was ordering the same one , here is what I ordered & received https://www.amazon.com/gp/product/B0093Y88SK/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&th=1 .But mine has ST330-V3 in the bottom right of the board. Where I'm getting messed up is everything seems to work right , the screen, keypad,uno , but the driver I got has Step,Direction,Enable & 5V .the drawing for the project shows , Clock, Direction ,Enable & 5v /VCC. Are Clock & Step the same ? forgive me if this has already been addressed , I have scrolled & read this so many times it is starting to run together .Once I get this resolved hopefully all will be good .
> tks
> animal


Yes, they are the same, i.e. Clock and Step.


----------



## tjwal

CNC-Joe said:


> ----------------------------------------------------------------------------------------
> TJWal - very nice design on the hand held enclosure.  Would there be any chance of you posting your design?  The rest of us could use this as a basis for  3D printing one with the common (BMac2's) components?




I didn’t really document my design (pics in post 169).  I lost the 3d design for the corners due to a hard drive crash.  I do have copies of the STL files though.  They work with the ⅛” material I had on hand so might not be of any value to anyone else.
I’ve made a couple changes since the pictures were taken.  I changed to an external stepper driver  and I added a hole in one side so I could slip in a programming cable.
I’m attaching an outline drawing that gives the key measurements.  The interior was 1.25” deep.
John


----------



## animal12

I'm back on this project . I have everything working until I plug in my stepper board , it freezes everything. I have to unplug the stepper board   & hit reset to get it to come up again but as soon as I plug the stepper board in it's frozen again. this is my stepper board https://www.amazon.com/gp/product/B0093Y88SK/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&th=1  . I know it is good . I just tested it tonite with this tutorial TB6560 Stepper Motor Driver with Arduino Tutorial (2 Examples)  & it worked fine as did the motor . I have clock hooked up to D2 on my UNO  & dir hooked to D3 . what do I do with enable ?
thanks
animal


----------



## tjwal

Enable is held either high or low.  One way turns the steppers on the other way is off.  The drivers I have worked with had them on by default.  I think I had to pull EN high to turn the motor off.

in any case with everything powered up if the stepper is enabled it will be hard to turn by hand.


----------



## animal12

thanks , I still must have missed something  , where does the enable on my stepper driver go on my arduino ?
thanks
animal


----------



## tjwal

If I remember correctly, I hope, the enable is not connected and relies on the driver having it on by default.


----------



## animal12

I don't know . my driver works & the motor spins doing a tutorial , but just sits there with this project .
for the tutorial it just uses step & direction like the project here 
animal


----------



## tjwal

is the stepper harder to turn by hand when it is powered up?


----------



## animal12

I'll give that a try tonite , so what would that mean ? that the stepper is gettin power ? could the micro stepping switches be off ? heres a copy of the driver board man . 
thanks
animal


----------



## tjwal

If the motor is powered and enabled it will be difficult to turn by hand.  This is true even without the Arduino connected.  If it’s still easy to turn you have a problem with the driver/motor/power supply.


----------



## Marcomac01

Hello, thanks a lot for the very detailed and easy to follow guide... i tried it and worked, the only issue i have is that i do not use a reducer. How should i edit the sketch to avoid it and have 0 reduction?
I am sorry for my bad english.
Thank you very much.


----------



## tjwal

Marcomac01 said:


> Hello, thanks a lot for the very detailed and easy to follow guide... i tried it and worked, the only issue i have is that i do not use a reducer. How should i edit the sketch to avoid it and have 0 reduction?
> I am sorry for my bad english.
> Thank you very much.


You will have to change the variable called “TableRatio”.  It is currently set for a 36:1 rotary table.
Are you driving a spindle directly from your stepper?  If so, there are some other things that need to be done.

John


----------



## Marcomac01

I have to directly connect the stepper motor to the rotation support... i have no rotation reduction


----------



## tjwal

Marcomac01 said:


> I have to directly connect the stepper motor to the rotation support... i have no rotation reduction


With no reduction (1:1) the original code will not work.
On the line after where Table Ratio is defined another variable is defined
const int Multiplier = (StepsPerRotation * TableRatio)/360

since it is defined as an integer, StepsPerRotation * TableRatio, must be evenly divisible by 360 to work.

I believe the quick fix was to change it to
const float Multiplier = (StepsPerRotation * TableRatio)/360
i never used this method so I don’t know if there were any other changes required.

a better approach would be to use the modified code posted by
Kquiggle in message 303.


----------



## Marcomac01

tjwal said:


> With no reduction (1:1) the original code will not work.
> On the line after where Table Ratio is defined another variable is defined
> const int Multiplier = (StepsPerRotation * TableRatio)/360
> 
> since it is defined as an integer, StepsPerRotation * TableRatio, must be evenly divisible by 360 to work.
> 
> I believe the quick fix was to change it to
> const float Multiplier = (StepsPerRotation * TableRatio)/360
> i never used this method so I don’t know if there were any other changes required.
> 
> a better approach would be to use the modified code posted by
> Kquiggle in message 303.


Ok, i was able to find a previeus version of the code, the version 5.5 (2018) and worked well for me.


----------



## SailplaneDriver

I got mine to work. Then I went to put the controls in a box like* Maxmekker50. * I used a 4-pin aircraft style plug so I could disconnect the stepper from the controller box. I tested it prior to connecting the motor and everything seemed to work fine. The "Run" led on the TB6560 flashed yellow when the Arduino sent the steps. Then I connected the motor and tried again - nothing. I looked at the 4-pin connector and found a solder bridge. I cleaned it up but nothing, and the "Run" led is now red. Does that mean I fried the board?


----------



## CNC-Joe

Has anybody put together a 3D Printed Case to house the electronics for this?


----------



## dazz

It depends on which pins were bridged and the design of the board. It should protect itself against shorts.
Start by checking the power supply voltages and currents.

Dazz


----------



## bluejets

Disconnecting steppers from driver board while powered will blow the driver every time.


----------



## dazz

Ouch, that is poor design.


----------



## bluejets

No, that's the way they are.


----------



## dazz

It is still poor design.


----------



## bluejets

No, it's quite simply something one does not do.
Bit like pulling the plug on a large running motor without first dropping the contactor control supply.


----------



## SailplaneDriver

bluejets said:


> Disconnecting steppers from driver board while powered will blow the driver every time.



Except that was not the case here. The system was not energized when the motor was disconnected. The stepper control board had been previously powered without a motor connected for testing purposes several times without issue and was still able to operate the motor afterwards. The only issue occurred after attempting to power the motor with a short in its leads.


----------



## SailplaneDriver

Does anyone know about the color codes for the "Run" led? I have seen it flash yellow when receiving data and stepping the motor and now solid red.


----------



## dazz

Hi
So if the motor outputs are not protected from a short, that is poor design.  There should at least be a fuse. A better solution would be current limiting.
You should first check that there isn't a blown fuse somewhere.

If you or someone you know has some electronics knowledge and test equipment, it should be relatively easy to fault find and fix.  Just compare the working outputs with the one(s) that don't work to pinpoint the faulty component.


----------



## weir-smith

Going back several posts, if you shorted out one pole of the motor, then it should survive as the driver is current limited. If you shorted adjacent poles the outcome could be problematic and to work it out would take a little time via vector anylises. I suppect that this is the case and you have exceeded the voltage ratings of the driver. Since the driver is probably dead, disconnect the motor, turn it on and measure the motor voltages which should be slightly lower than the supply voltage. Disconnecting a stepper while energized causes very high back EMF which could be hundreds of volts and will kill the driver output chips every time.

As for changing the ratio, I have modified the Sketch so that I can have three different ratios eg 90 to 1, 60 to 1 and 40 to 1 via menu selection. With my modified Sketch, you can have any ratio with in reason just by changing one number. I have made 5 of these controllers for different people who couldn't work it out for themselves.


Happy to share both Sketches with any one who wants them. p

Bruce
WESTERN AUSTRALIA


----------



## SailplaneDriver

I haven't seen any posts as to how to mount the stepper to the rotating table. I have a 6" Phase II and chose to use a clamping system on the shaft housing. Here are the drawings for what I did. An alternative is to make a solid plate instead of the mount on sheet 2 and attach it like you would index plates. I use a spiral aluminum coupling between the stepper and the rotating table. Here are the drawings if anyone wants some ideas of a mounting arrangement. You will need to adjust the dimensions to your particular rotating table and shaft coupler. It was done in Fusion360 if anyone wants the CAD files. I'll post some photos when I reattach the stepper motor after fixing the electronics.


----------



## SailplaneDriver

As promised, here are pictures of the finished product after I got the electronics sorted. It now works well. All the electronics in the case with the keyboard and display.


----------



## iamroyce

I have not done much yet but plan to set up and try the code for learning purposes but looks good so far.


----------



## iamroyce

weir-smith said:


> Going back several posts, if you shorted out one pole of the motor, then it should survive as the driver is current limited. If you shorted adjacent poles the outcome could be problematic and to work it out would take a little time via vector anylises. I suppect that this is the case and you have exceeded the voltage ratings of the driver. Since the driver is probably dead, disconnect the motor, turn it on and measure the motor voltages which should be slightly lower than the supply voltage. Disconnecting a stepper while energized causes very high back EMF which could be hundreds of volts and will kill the driver output chips every time.
> 
> As for changing the ratio, I have modified the Sketch so that I can have three different ratios eg 90 to 1, 60 to 1 and 40 to 1 via menu selection. With my modified Sketch, you can have any ratio with in reason just by changing one number. I have made 5 of these controllers for different people who couldn't work it out for themselves.
> 
> 
> Happy to share both Sketches with any one who wants them. p
> 
> Bruce
> WESTERN AUSTRALIA


Hi Bruce, I would love to get a copy of the sketches as I are retired and am interested in learning about the Arduino and steppers. It gives me something to fill in my spare time. I did 2 years in a tool making apprenticeship and moved up country and finished my apprenticeship in fitting and turning. My email is  
[email protected]    I have been working on using DC motors as steppers and ran an big old Cincinati mill with them for milling encoder disks.


----------



## CNC-Joe

SailplaneDriver said:


> As promised, here are pictures of the finished product after I got the electronics sorted. It now works well. All the electronics in the case with the keyboard and display.
> 
> View attachment 117693
> 
> 
> SailPlane Driver - where did you get the electronics box?


----------



## SailplaneDriver

CNC-Joe said:


> SailPlane Driver - where did you get the electronics box?



Aliexpress. Look for post #46 in this thread. 

Everything will fit but it is tight. I used industrial double stick tape to hole the boards to the bottom of the case. The display will center in the existing cutout if you modify the two top holes in the board to match the position of the screws that clamp the case together. You also have to cut off the four pins on the serial board and solder directly to the stubs since they interfere with the posts in the case. An alternative is to enlarge the cutout and shift the display down toward the keyboard.

I also wound up removing the headers and soldering directly to the Arduino for a better connection.


----------



## Antonio0022

Hi everyone, I'm an electronics student and I'm looking for a project for a rotating table and I came across this one, I congratulate you on the realization that seems to be really good, now I'm also replicating the same project, I use a nema  23, and as a driver a tb6600, I hope that in case of problems you can help me, further complements for the project


----------



## SmithDoor

I seen stepper motors used but best is encoders. Stepper motors and drift as you machine.

Dave 



Antonio0022 said:


> Hi everyone, I'm an electronics student and I'm looking for a project for a rotating table and I came across this one, I congratulate you on the realization that seems to be really good, now I'm also replicating the same project, I use a nema  23, and as a driver a tb6600, I hope that in case of problems you can help me, further complements for the project


----------



## animal12

so Dave , your talking a stepper with a encoder attached ? I'm interested to learn more 
thanks
animal


----------



## ignator

animal12 said:


> so Dave , your talking a stepper with a encoder attached ? I'm interested to learn more
> thanks
> animal


Most stepper motor systems are open loop. The idea is the stepper has enough torque to move when commanded, and not miss a step. If a step is missed, you don't know until the part being machined is trashed. With encoders, you count the movement of the stepper shaft, to ensure what was commanded occurred. The same processor that is driving the motor, can also read the encoder. But there needs to be some trickery in the code, like making the encoder edge triggered interupts, so no counts are lost.


----------



## L98fiero

ignator said:


> Most stepper motor systems are open loop.


Why couldn't hybrid steppers not be used? *Leadshine stepper motors *is one but there are several companies that make them and they self correct.


----------



## xpylonracer

There is no reason why standard steppers can't be used, but make sure you use a suitable power output to run the table without losing steps also a good controller with an adequate power supply, 24/36/48 v output.

The disadvantage of the std stepper are detailed in an earlier post and  may of course be better to use a closed loop system.


----------



## Antonio0022

hi everyone, I have a problem, I can't set the ratio, in my case I have a 1: 1 ratio but when I set 1 in the settings, the engine makes the wrong angles


----------



## BWMSBLDR1

Dave, let me thank you for such a clear and understandable explaination of how to set up controls for a rotary table. With these skills I expect you to have a great future in your chosen field!            Bill in Boulder CO USA


----------



## SmithDoor

I talk about a using encoder or a stepper motor.

A stepper motor can be used with a encoder but not need, a good DC motor will work too. 
The stepper with encoder would great on a lathe or mill. The stepper can give a wide range in speed. A dividing head and rotary table can use a DC as can be slow down.
You need to program for a brake too. If do not have have a the motor will work hard to stop drift.

When looking at encoder there two types.
1) reads single direction 
2) reads both directions this the one you want.

Dave 



animal12 said:


> so Dave , your talking a stepper with a encoder attached ? I'm interested to learn more
> thanks
> animal


----------



## awake

While it would be possible to use a DC motor and an encoder, I would not recommend it. A servo motor or stepper+encoder would be much less likely to overrun and would be much better at holding position.


----------



## SmithDoor

All motors can over heat. They need cooled and not under sized.
The programming of must include a a slow down at end to prevent over run.

The encoder will hole the exactl spot it does use electrical impulses just a mirror and set of two electric eyes.

The encoders take more programming than just simple using simple pulse.
On printer if lose one or two pulses you not see the error but gear it will make a difference.

Now try calculate the the pulses out for other errors.
The encoder off shelf I can  find 5,000 Resolution. The stepper motor off the shelf I found was 1.8 degrees or Resolution of 200.

If great precision use compound indexing. 

Dave



awake said:


> While it would be possible to use a DC motor and an encoder, I would not recommend it. A servo motor or stepper+encoder would be much less likely to overrun and would be much better at holding position.


----------



## xpylonracer

Dave, using micro-stepping from the controller will provide as many step pulses as needed to get a resolution of a few seconds of arc.


----------



## SmithDoor

xpylonracer said:


> Dave, using micro-stepping from the controller will provide as many step pulses as needed to get a resolution of a few seconds of arc.


The only ones I found was gear driven to give the few seconds. 

Do they make one that is not gear driven?

Dave


----------



## Eccentric

Yours looks like a great project.  I built an indexer for my mini lathe completly (almost) with 3D printed parts.  It works great and I have made three clocks with it (It is used to make the clock wheels (gears)).  It is also driven with an arduino.


----------



## SmithDoor

Eccentric said:


> Yours looks like a great project.  I built an indexer for my mini lathe completly (almost) with 3D printed parts.  It works great and I have made three clocks with it (It is used to make the clock wheels (gears)).  It is also driven with an arduino.
> 
> View attachment 122283
> 
> View attachment 122284
> View attachment 122285
> View attachment 122286
> View attachment 122287


Great job 
Dave


----------



## deeferdog

Well, here goes. I built a rotary table some time back, and by following all the excellent instructions here managed to get it to work quite well. A few weeks ago I decided to make a larger version and this is where it all came a gutzer. I purchased a NEMA 23 hybrid stepper motor and  57HS76ES controller, decided to make it closed loop for greater accuracy. Mounted the motor to the table ( 6 inch Vertex knock off, AU$215 delivered,  still can't believe it!). I connected it to the Arduino Uno, used the same connections as before but with the additional encoder as well. 24 volt supply. Nothing happened. 24 volt supply, 0.5 amps and the motor was locked solid.
Pulled everything apart, connected the old TB6560 driver but without the encoder wired in, worked perfectly. I decided that the 57 controller might be the problem. In my ratty box I had a new TB6600 Stepper driver, I think this is just a bigger version of the 6560 more current etc, but when I wired it in the same result, nothing. 24 volt supply, 0.17 amps, motor locked.
I have spent one of the most frustrating days of my life with this, I think that I have checked  everything I can think of. I don't pretend to be a genius at this stuff but I didn't think I was as stupid as I feel now. Photos that may help, please couch replies as you would to a four year old, right now I don't think I'm even at that level. Cheers, Peter.


----------



## weir-smith

Peter

You can make almost anything work and I am happy to help you. I have helped many people sucessfully with this project over the last couple of years. The original Arduino sketch would only work for 90 to 1. All other ratios were inaccurate because the sketch used integers rather than real's. This means that if the divider was 44.44444 everything past the decimal point was ignored and hence the errors.

Send me an email to   [email protected] and let's get it working for you.

Bruce


----------



## xpylonracer

I thought this point had been raised before and the original author answered the question with a satisfactory solution.


----------



## deeferdog

Bruce, many thanks for your offer to help, I will contact you later today. Xpylonracer, I would be grateful if you could point me in the right direction to the satisfactory solution in this post. I have read all 21 pages through at least twice and still cannot find the reason why the drivers behave differently. Thank you for your post. Cheers, Peter.


----------



## xpylonracer

Peter

Original article by the late Chuck Fellows here: 





						Electronic Dividing Head using the Arduino
					

I've made some strides on my Arduino powered dividing head the past few days. Here's a little background for what I am doing. First, the Arduino micro controller.     Available online for under $30, has 32K memory, numerous analog and digital inputs and outputs, including serial and PWM.  Next...




					www.homemodelenginemachinist.com
				




Rod's work added to the functions and made several options available but I'm sure I have read the problem you describe has been programmed out.


----------



## ajoeiam

deeferdog said:


> Well, here goes. I built a rotary table some time back, and by following all the excellent instructions here managed to get it to work quite well.
> snip
> Mounted the motor to the table ( 6 inch Vertex knock off, AU$215 delivered,  still can't believe it!).
> snip


Hmmmmmmmm - - - - I'd be curious as to where you found that 'table' - - - please?


----------



## xpylonracer

deeferdog said:


> Bruce, many thanks for your offer to help, I will contact you later today. Xpylonracer, I would be grateful if you could point me in the right direction to the satisfactory solution in this post. I have read all 21 pages through at least twice and still cannot find the reason why the drivers behave differently. Thank you for your post. Cheers, Peter.


Peter, read from here onwards: 
Electronic Dividing Head using the Arduino


----------



## deeferdog

Here is the link to the table: Rotary Table (Horizontal & vertical ) 150mm/6"  | eBay
The quality seems OK to me but I haven't stripped it down. I have a Vertex 4" (Taiwan) as well and this looks  just as good. One day I may just get to use it if ever I sort out these other problems. 
Peter.


----------



## ajoeiam

deeferdog said:


> Here is the link to the table: Rotary Table (Horizontal & vertical ) 150mm/6"  | eBay
> The quality seems OK to me but I haven't stripped it down. I have a Vertex 4" (Taiwan) as well and this looks  just as good. One day I may just get to use it if ever I sort out these other problems.
> Peter.


Went looking - - - - it seems that our Aussie friends have it much better than us here in the northern hemisphere. 
Looked like same product was well over $500 Canuckistani buckeroos and that was without shipping from our cousins south of us - - - - which has become incredibly pricey. 

Thanks for the link - - - - - gives me a starting point for looking!


----------



## ignator

ajoeiam said:


> Went looking - - - - it seems that our Aussie friends have it much better than us here in the northern hemisphere.
> Looked like same product was well over $500 Canuckistani buckeroos and that was without shipping from our cousins south of us - - - - which has become incredibly pricey.
> 
> Thanks for the link - - - - - gives me a starting point for looking!


If you do an eBay search with "rotary table HV6", I get the following link with the USA eBay site.








						Rotary Table HV6 for sale | eBay
					

Get the best deals for Rotary Table HV6 at eBay.com. We have a great online selection at the lowest prices with Fast & Free shipping on many items!



					www.ebay.com
				




So do you want a 4 slot or 3 slot (there are 6 slot tables available also). I sort on lowest price plus shipping. So you need to scroll down from the early hits (dividing plates and tailstocks), but you can find one from India for less then $200USD with free shipping.
Like this one;








						HV6 Rotary table 3 SLOTS Horizontal & Vertical Precision Quality.  | eBay
					

Find many great new & used options and get the best deals for HV6 Rotary table 3 SLOTS Horizontal & Vertical Precision Quality. at the best online prices at eBay! Free shipping for many products!



					www.ebay.com
				




However, I have a 4" table from India, and I do not like any part of it's poor quality. And my next purchase was a 6 inch that came from China, and again, substandard quality.


----------



## GarryIno

Hi....without basic literacy in Arduino you will find it hard to write a sketch to do much more than those examples.
Understand that you can lift sections from those sketches for your own, modify as needed but make sure that you know how they work and what they do which takes reading the lines, literacy. How much faster did grade school go for you once you could read books, write papers and do math? 

You don't have to know everything, just the basics. Variables and arrays, logic structures, how to use and make functions, the input/output functions for pins and serial and know to look things up starting with the Arduino Reference Page.


----------



## deeferdog

I have managed to sort out most of the frustrating problems that I posted about above, they were due to a faulty power supply. I would like to thank those who helped, in particular Bruce Weir-Smith whose knowledge of Arduino and Steppers greatly exceeds mine. Bruce was kind enough to spend his time emailing me circuit diagrams and instructions that helped track down the problem.
I have taken the advice of Rodw where he maintains that 48 volts is the way to go and I have ordered a Meanwell  500 watt 48VDC power supply, any heat issues I will address as they appear. Cheers, Peter.


----------



## OldRon

This is my prototype in C++. It features accumulated error management and regardless of the number of indexing divisions it goes 0 to 360º. My servo motor requires 2048 pulse per revolution so here's the logic:

Seconds in 360º: 1296000
My motor ppr: 2048
My gear ratio:  4:1 low backlash gear head * 90" rotary table gear ratio: 4 * 90  = 360:1
Motor ppr per rotary table revolution: 360 * 2048 ppr = 737280 pulse per rotary table revolution
1296000 / 737280 = 1.7578125 seconds per motor pulse (but we use degrees)
1 degree = 3600 seconds
3600 / 1.7578125 = 2048 The value of the variable, user in my code

(3600 / (1296000 / (motor ppr * gearing))) = user

degrees output are degrees = (degrees + (steps / user))
It does no good to compound (360º / divisions)
accumulated error output is error = (error +  ((360º /  divisions) - (steps / user)))

I moved up to the 32bit Arduino DUE so the double declaration is for real unlike the UNO that accepts double declaration but remains to  be 16 bit. As you can see in the picture this builds and extremely accurate indexer. Picking up the fractional value of the steps keeps the accumulated error down to next to nothing.



		C++:
	

// Visual Studio C++ 2019 w/round function

#include <process.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

int main()
{
    double error = 0;
    double steps = 0;
    double crumbs = 0;
    double divisor = 0;
    double degrees = 0;
    double index_L = 0;
    double user = 2048;

    std::cin >> divisor;

    index_L = (360.0 / divisor);

    std::ofstream myfile;
    myfile.open("Indexer.txt");

    std::cout << "\n";

    for (int n = 1; n <= divisor; n += 1)
    {
        steps = ((index_L * user) + crumbs);
        crumbs = (steps - round(steps));
        steps = round(steps);
        degrees = (degrees + (steps / user));
        error = (error + (index_L - (steps / user)));
        std::cout << std::fixed;
        std::cout << "Index: " << n << ": - " << "Degrees: " << degrees << char(167) << " - Accumulated Error: " << std::setprecision(8) << error << char(167) << "\n";
        myfile << std::fixed;
        myfile << "Index: " << n << ": - " << "Degrees: " << degrees << "º - Accumulated Error: " << std::setprecision(8) << error << "º\n";
    }
    myfile.close();
    std::cout << "\n";
    system("pause");
    return 0;
}


----------



## tjwal

Eccentric said:


> Yours looks like a great project.  I built an indexer for my mini lathe completly (almost) with 3D printed parts.  It works great and I have made three clocks with it (It is used to make the clock wheels (gears)).  It is also driven with an arduino.



Thats an interesting design.  Are the stl files available?  I doubt my printer would be able to print that worm accurately enough but I might give it a try just because.

Thanks John


----------



## awake

SmithDoor said:


> All motors can over heat. They need cooled and not under sized.
> The programming of must include a a slow down at end to prevent over run.
> 
> The encoder will hole the exactl spot it does use electrical impulses just a mirror and set of two electric eyes.
> 
> The encoders take more programming than just simple using simple pulse.
> On printer if lose one or two pulses you not see the error but gear it will make a difference.
> 
> Now try calculate the the pulses out for other errors.
> The encoder off shelf I can  find 5,000 Resolution. The stepper motor off the shelf I found was 1.8 degrees or Resolution of 200.
> 
> If great precision use compound indexing.
> 
> Dave



Dave, I hope you are talking about a servo motor. Yes, I suppose in theory a servo motor could be built using a plain old DC motor and a rotary encoder, but there would need to be some smarts somewhere in there!


----------



## skyline1

awake said:


> Dave, I hope you are talking about a servo motor. Yes, I suppose in theory a servo motor could be built using a plain old DC motor and a rotary encoder, but there would need to be some smarts somewhere in there!



Yes, In fact that is all many older servo motors are. The "Smarts" are in the servo Amplifier/Driver although newer servo motors have them built in as part of the motor


----------



## awake

Skyline, I understand your point. Earlier in the conversation, it sounded like the suggestion was just to put a DC motor on instead of a stepper, as though one could just slap any old DC motor in place. This is where I hope the DC motor in question is actually a servo motor! But let me be the first to say, I may have misunderstood the intent of that earlier post.


----------



## reloader

Hello,

I had a look at all 21 pages and I found a lot of different programs.
I would like to build a controller with 4*4 pad and the 4 row LCD display.
I am little bit confused, where to find the latest version of Bruces program together with the wiring plan.

best regards

Edgar


----------



## skyline1

awake said:


> Skyline, I understand your point. Earlier in the conversation, it sounded like the suggestion was just to put a DC motor on instead of a stepper, as though one could just slap any old DC motor in place. This is where I hope the DC motor in question is actually a servo motor! But let me be the first to say, I may have misunderstood the intent of that earlier post.



I agree completely, The "motor" in question would need to be either one  of the newer "self correcting" steppers with an internal position sensor and feedback loop to correct for missed steps or a true servo motor with a built in driver that could accept the same control signals (Step/Direction I assume). Both are pretty expensive components due to their complexity. 

The cheaper and most often adopted solution (even in some quite large and expensive machines) is good old fashioned open loop steppers provided they can develop sufficient torque to overcome the likely resistance. 

I have found the steppers on my machines are able to produce torques quite out of proportion to their tiny size and modest cost and rarely if ever "lose steps"
(and they are getting both smaller and more powerful all the time)

In a fault condition where for example an axis inadvertently hits a solid object that it shouldn't,  open loop steppers actually have a slight advantage, they will lose steps until the controller "thinks" they are at their final position and then stop.

In the case of a servo, due to the feedback the controller "Knows" that it is not in it's final position and may continue to drive the motor in an attempt to get there.

This is a generalization of course and not always true. In reality overload protection should protect both the motor and to a lesser extent the machine. (whatever it may be).  

So the choice is up to the individual both open and closed loop will work but for this particular application, I personally would stick with plain stepper motors.

Best Regards Mark


----------



## L98fiero

skyline1 said:


> In a fault condition where for example an axis inadvertently hits a solid object that it shouldn't,  open loop steppers actually have a slight advantage, they will lose steps until the controller "thinks" they are at their final position and then stop.


Are the stepper drives better now, I had a Summit-Dana Bandit control on a Bridgeport clone and the control _did _know when it hit something solid, it blew the power transistors on the axis drive?


----------



## reloader

Hallo,

today I got the 4*20 LCD Display. During lunch, I connected the display and a Keypad switch to my Arduino uno an installed the original program of Bob.

The keypad did not run as it should, so i changed the wiring as suggested. Now it works.
Later i will test the program with my rotary table. I also downloaded a program with Accelstepper from this thread. I will also test this version, because I like the Accelstepper library to run Stepper motors. Next step will be to search for a nice box. At the moment I am not sure if should put the power supply into the Arduino box.

best regards

Edgar


----------



## reloader

Hello,

I had to go back to the beginning of this thread to see, that kquiggle has two rotary table sketches.
So I loaded the version Table_Control_2019_7.25.
After making the setup, it works without any problems, but it has hard start and stops for the stepper.
After uploading the sketch Table_Control_2019_V2 4.69, the output of Pin 2  looks strange at the ozilloscope.
But I will connect the arduino to the stepper driver to see how it run.

best regards

Edgar


----------



## reloader

Hello,

just loaded the sketch with AccelStepper. It runs smooth without any problems.

So, special thanks to kquiggle for this sketch, I really like it.

best regards

Edgar


----------



## skyline1

L98fiero said:


> Are the stepper drives better now, I had a Summit-Dana Bandit control on a Bridgeport clone and the control _did _know when it hit something solid, it blew the power transistors on the axis drive?



Ouch, that sounds nasty !

Failures like this are  far less common with more modern drivers although not impossible.

The stepper drivers being used in this project are likely to be the plugin Arduino type (A4988 or similar) or the larger TB6600 type if the motor requires it

Both of these seem to be remarkably rugged and tolerant to accidental abuse

I have the plugin type on my 3d printers and I have had the occasional axis crash. None of them have resulted in blown driver yet or a burnt out stepper motor.
Usually just a failed print.

These crashes are almost always due to errors on my part (poor slicer settings or an incorrect configuration usually). not a fault in the machine itself

These little driver boards are remarkably inexpensive and easy to obtain. Being plugin they are also fairly easy to replace. I keep a couple of spares just in case a failure should happen but to date have not needed them.

One caveat to this is that  although they do have remarkably good overcurrent protection it is adjustable and needs to be set appropriately to the stepper motor being used.

The stepper drives on your Bridgeport were probably much larger and more powerful than these though and would probably need more sophisticated protection simply due to the larger amount of energy in the system.

Best Regards Mark


----------



## reloader

Hello,

the program is still working fine. The output of the Step Pin 2 is still looking strange. I have never seen such a signal duty cycle with AccelStepper.
Is there any PWM regulation of Pin 2 in this program?

best regards

Edgar


----------



## RM-MN

skyline1 said:


> The stepper drivers being used in this project are likely to be the plugin Arduino type (A4988 or similar) or the larger TB6600 type if the motor requires it
> 
> Both of these seem to be remarkably rugged and tolerant to accidental abuse


I have a mini mill with Arduino CNC control using DRV8825 drivers.  One was skipping steps so I increased the current.  It was still skipping so I increased the current.  Turned out it was skipping steps because it was overheating from the excess current.  I reduced the current and increased the voltage and the problem went away.


----------



## reloader

Hallo,

I finished my rotary table project today. Special thanks to kquiggle  who gave me the support I needed. I decided to use annother keyboard. I do not like these membran switch bords.

best regards 

Edgar


----------



## Muggs

tjwal, It doesn't look like you ever got your answer, so I'll jump in and say that it's probably this one:








						Hyperbolic Worm Gears by jsteuben
					

Worm gears find many uses in engineering applications due to their compact size and high gear reduction ratios. A disadvantage of this type of gear set is that only one tooth on the spur gear is engaged (or "in mesh") with the worm gear at any time. This causes high contact stresses which can...




					www.thingiverse.com
				



from Thingiverse.


----------



## SmithDoor

How many steps/PPR are the encoder ?

I have used for equipment a electronic counters

Dave


----------



## SmithDoor

After reading the program I found it using a stepper motor using StepsPerRotation = 400

*Does anyone use a encoder like they use on mill DRO?*

Dave


----------



## Cletus

Thanks for the idea and the code!
I built this over the last 5-days with stuff I had laying around the shop.
I used a 24V 5A laptop power supply, 7809 voltage regulator, Arduino Nano and one of these $11 Stepper Drivers



			https://www.amazon.com/gp/product/B07PQ5KNKR/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
		


3D printed a couple bezels for the display and keypad, an old PVC case has been repurposed and I must say, I am pleased with the way it turned out. Now I can use my CNC Rotary Table in a standalone fashion when needed.


----------



## Angler

Dear Sirs,
Could you please help me with a problem I came across while making my rotary table project. I bought all items mentioned at the beginning of this thread plus a simple buzzer. I just want my keyboard beep when pressed. I connected the buzzer to D13 pin and to GRD pin. Everything works fine but the buzzer. It beeps several times while Arduino is booting but doesn't beep when I press the keyboard. I am an absolute stupid in programming and my attempts to integrate buzzer sketch into Arduino Rotary Table Control 2016 sketch seem to fail. As far as I understad there is at least one error in my void loop section of the sketch - curly bracket is missing before buzzer loop. But when I put it there another errors emerge and I cannot upload the sketch to the Arduino. I am sure there are more errors but I cannot find them because of my stupidity. Would be greatefull if someone look through my sketch and correct it.  Thank you very much.


----------



## bluejets

For a start I have no idea why you include various items twice.
Could not see where you do a pinMode output for your buzzer either.


----------



## Angler

I also have no idea If I had I would have never asked for help.


----------



## kquiggle

Angler -

If you just want a working program with an option for beeps, you can find my sketch for this project at the link below. Looking at the sketch may also give you help with coding your own sketch.

Click on the link and scroll down to "Part 3: Coding"









						Academy of Lagado - Build - Electronic Indexing Head
					

[Feb. 3, 2017] - started placeholder page [Dec. 26, 2017] - added actual build notes [Jan. 7, 2019] - added notes on final version [Jan. 24, 2019] - final tests The drawing to the left is a temporary placeholder, pending completion of the project; it will be replaced by a photo of the completed




					sites.google.com


----------



## Angler

kquiggle said:


> Angler -
> 
> If you just want a working program with an option for beeps, you can find my sketch for this project at the link below. Looking at the sketch may also give you help with coding your own sketch.
> 
> Click on the link and scroll down to "Part 3: Coding"
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Academy of Lagado - Build - Electronic Indexing Head
> 
> 
> [Feb. 3, 2017] - started placeholder page [Dec. 26, 2017] - added actual build notes [Jan. 7, 2019] - added notes on final version [Jan. 24, 2019] - final tests The drawing to the left is a temporary placeholder, pending completion of the project; it will be replaced by a photo of the completed
> 
> 
> 
> 
> sites.google.com


Thanks. I'll try.


----------



## McRoth

Thanks everyone for this project!!!  It's almost exactly what I'm looking for.  I'm using it to build one out of a Brown & Sharpe #0, I think, dividing head.  It has a 40:1 ratio and I have a 3:1 pulley setup for a 120:1 ratio!  Anyhow, I wanted to see if there's a way to add an input so that I can program a relay in my mill to tell the control when to index using an M code instead of having to push a button each time?  

Also, I had to reverse the keypad pins to get it to work, just like someone else here.

Here's an Amazon link for that Aliexpress housing: BUD Industries PSP-11572-B Style G Plastic Box, 7-31/64" Length x 4-1/8" Width x 2-19/64" Height, Black .  I had ordered a plain box because I couldn't find this one and low and behold they suggested this one, lol!

Thanks!
Mike


----------



## xpylonracer

I have seen a mill setup using a fixed limit switch to index, when needed the table moved the tool away from the job to activate the limit switch to index and allow the part to rotate, then a delay before returning to the tool machining position.


----------



## McRoth

I'm a CNC engineer, so I'd like to automate this more than it seems I can right now.  I want to be able to enter an M code after each cut to trigger a relay/pulse telling the rotary table to index by whatever amount I had set in the indexer control.  This is probably a question for kquiggle, although he said he doesn't really want to add more functionality to his program.


----------



## xpylonracer

To do as I suggested earlier all you need is a couple of lines of G code in your program, the limit switch can be positioned on the column and operated from a fixed arm fitted on the table. Your sketch will need modding to provide the index when the switch is operated.


----------



## McRoth

That's what I have in mind, but without the switch. My problem is modding the code to accept an outside signal instead of a button push.  I've been wanting to learn more coding, so maybe this will be my chance, lol.


----------



## gjrepesh

McRoth said:


> Aliexpress housing: BUD Industries PSP-11572-B Style G Plastic Box, 7-31/64" Length x 4-1/8" Width x 2-19/64" Height, Black .


That looks like the same box I used for my rotary table. I found mine on eBay. This was my first project installing electronics into a box. I was surprised that I got all components to fit. Very pleased with the result. I'm thinking of doing a larger rotary table, thus a larger stepper, thus a larger stepper driver. This driver will not fit the box.


----------



## McRoth

gjrepesh said:


> That looks like the same box I used for my rotary table. I found mine on eBay. This was my first project installing electronics into a box. I was surprised that I got all components to fit. Very pleased with the result. I'm thinking of doing a larger rotary table, thus a larger stepper, thus a larger stepper driver. This driver will not fit the box.


Unfortunately that box was too small for my driver board and even the LCD I got was a bit too wide to fit it.  I ended up ordering this one: https://www.amazon.com/dp/B005T58ZTO?ref=ppx_yo2_dt_b_product_details&th=1 .  It should arrive today, hopefully it works well.  
I got the stepper mount done last night.  I think it'll work out well.  I'll post some pics when I get things farther along.
Thanks,
Mike


----------



## McRoth

Any idea why it would fry a power supply when plugging it into the arduino?  I set the output of the converter to 5.05VDC and as soon as you touch the plugs together they spark and fry both!  Should I have had a higher voltage, was it trying to pull too many watts at this voltage?  I have a 48VDC power supply going into my stepper controller & found a step down converter that would take 50VDC.  I have another uno and a 48VDC to usb output coming tomorrow that I'm just going to plug into the USB port on the uno instead of the barrel connector, hoping it works better.


----------



## ignator

McRoth said:


> Any idea why it would fry a power supply when plugging it into the arduino?  I set the output of the converter to 5.05VDC and as soon as you touch the plugs together they spark and fry both!  Should I have had a higher voltage, was it trying to pull too many watts at this voltage?  I have a 48VDC power supply going into my stepper controller & found a step down converter that would take 50VDC.  I have another uno and a 48VDC to usb output coming tomorrow that I'm just going to plug into the USB port on the uno instead of the barrel connector, hoping it works better.


These low cost 'Buck' converters (I suspect you're using a buck converter vs. a transformer stepdown converter), can fail with the output switch full on, and that puts the full input into the output, (minus maybe a diode drop). These are very cheap power supplies, and have no protection against overvoltage. Unless you can find an overvoltage protection circuit, you just live with random failures that can result in blowing up low voltage micro processors. I believe the Uno has a 5 volt input, with a 3.3volt power supply on board, that too is a buck converter.


----------



## densman

Hello
I have my components ordered to try and convert a 90-1 indexing head and a 72-1 rotary table I made based on the projects  _Philip Duclos_  published.
My electronics skills are weak but I am encouraged by this thread and Chuck Fellows thread.
My first question is what down load do I choose for the IDE installation.  Windows installer or windows zip file. If I understand this right if I use the more convenient installer I will always have to be connected to the computer to run programs? 
Dave


----------



## weir-smith

McRoth

The input voltage to all Arduinos can range from about 7 volts to 12 volts dc. For the internal 5 volt regulator to work, the input must be greater than 5 volts. The input is via the power connector not the five volt pins which are outputs from the regulator.

As for smoking your power supply  etc, the most likely reason is that you had the polarity reversed with your connections. They are polarity sensitive and no second chances. I am also supprised the current limit feature (of most switch mode power supplies) didn't save it.

The cheap converters often marketed as buck regulators are reasonably reliable. I have used well over twenty or so without any problems but you would have to expect a failure from time to time. You should also check the output voltage with a volt meter before connecting to your Arduino.

Bruce


----------



## Zeb

McRoth said:


> That's what I have in mind, but without the switch. My problem is modding the code to accept an outside signal instead of a button push.  I've been wanting to learn more coding, so maybe this will be my chance, lol.


Depending on how the code is set up, the same boolean (true/false) changed by a push button could also be flipped by any sensor writing to the same variable. The MAP function is handy, as you can map any voltage range (potentiometer, proximity sensor, hall effect, etc) and have the software switch trigger when in a desired analog range.
edit* Without the caffeinated nerd language. You can have a proximity sensor change a condition to true when distance is within a certain range.


----------



## McRoth

Thanks for the replies! I'm quite sure I had the polarity correct, I'm thinking it was pulling too much power at 5 volts, should've put it at 7 or 8 I'm thinking. They were cheap Amazon buck converters, so I'm not too worried about them. The step down to USB output is working good.
Zeb, thanks for the tip about the code. That does make sense to me.

Here are some progress pics. I have the stepper mounted and luckily I picked a powerful enough one, it turns great! I had the amps on the lowest setting at first and could hear it skipping steps accelerating and decelerating so I put it all the way up and it's good now.


----------



## McRoth

McRoth said:


> Thanks for the replies! I'm quite sure I had the polarity correct, I'm thinking it was pulling too much power at 5 volts, should've put it at 7 or 8 I'm thinking. They were cheap Amazon buck converters, so I'm not too worried about them. The step down to USB output is working good.
> Zeb, thanks for the tip about the code. That does make sense to me.
> 
> Here are some progress pics. I have the stepper mounted and luckily I picked a powerful enough one, it turns great! I had the amps on the lowest setting at first and could hear it skipping steps accelerating and decelerating so I put it all the way up and it's good now.


Here's the box I'm using.


----------



## firehousemerc

rodw said:


> The approach I took on this thread
> http://www.homemodelenginemachinist.com/showthread.php?t=25091&page=3
> was to accumulate the fractional error and add a step when it was > 1.0 add another step.
> 
> Chuck Fellowes followed another approach. For the start of each division, he tracked how far around the circle he was and calculated how far around the circle he would be after the division, take the difference and move that number of steps.
> 
> Ultimately the result is identical. The adjustment algorithm depends a bit on the complete methodology you use to do your divisions.
> 
> As far as the data structure goes, using int or long will make no difference unless the number of steps moved exceeds the resolution of the data type. When I did this, I wanted to avoid the use of floats and inevitable rounding errors so I measured angles in the number of seconds of a degree using an unsigned long as there are 1,296,000 seconds in a circle. I wrote routines to input and display this value for angles in degrees, minutes and seconds but internally worked with seconds. Then when actually moving the rotary axis, I  implemented a trapezoidal acceleration/deceleration algorithm to maximise torque on startup and overshoot at the end of the move. (You can't do instantaneous accelleration to maximum speed due to the laws of physics).
> 
> So what on the surface looks like a simple application becomes amazingly complex, particularly if you use interrupt driven step generation.


YOUR LINK IS NO LONGER PROPER AND GETS A "OPPS" ERROR


----------



## adzijderlaan

This is the unit I made.





reduction 1 : 4





inside




print




milling the PCB





Because I don't get a nice number for the original multiplier (35.555...)  I modified 3 lines:

line 32? -> const int Multiplier=(StepsPerRotation*TableRatio);  // I deleted division by 360
line 102? -> ToMove=map(Degrees,0,360,0,Multiplier);               // here is map used to get the amount of steps ToMove
line 109? ->ToMove=map(Degrees,0,360,0,Multiplier);

The degrees input is here limited to 360 degrees.
Steppermotor is set 1/16  so 3200 steps/rev  and the ratio is 4 --> Multiplier is 12800

I am happy that it works.


----------



## dazz

I am wondering if a n ESP32 would be a better choice than an Arduino.  It includes wifi which would enable wireless CNC control, or control from a mobile phone.


----------



## adzijderlaan

No need for speed. A wire is more secure than wireless, but maybe that is an old idea.


----------



## weir-smith

*adzijderlaan*

This project has been around for a long time and while the original contributor did (I think anyway) a reasonably good job of it. Yes there were a few issues but it was a good starting point for most. 

The main problem has been around the use of integers rather than reals so changing those is a good start. I have modified the sketch for many people for ratios from 4:1 to 120 :1 all of which have been successful.

As for exceeding 360 deg you need to use long integers otherwise it fails when you set a step deg of 280 deg or so. See the below section of code. When you are setting up a work piece in a four jaw chuck on the rotary table you need to be able to select 90 deg steps for the initial adjustment and finally say 1080 for the final check which gives you three continuous revs.

If you would like my sketch, send me an email.

Bruce Weir-Smith
Western Australia




void rotation(long tm, int d)
   { 
     for(long i = 0; i < tm; i++) // Problem Fix
       { 
       digitalWrite(stp, HIGH); 
       delay(stepdelay); 
       digitalWrite(stp, LOW); 
       delay(stepdelay); 
       }


----------



## adzijderlaan

@ Bruce
I will implement it.


----------



## Imre karoly

@ Bruce

I'd like to ask for a sketch.


----------



## weir-smith

Kim
Just send me an email along with the ratio of your rotary table and I will send you the sketch along with instructions to change the ratio if you ever need to.

Adzijderlaan

When you send me an email, could you also include the ratio you are using. I also have been to Amsterdam several times.

Bruce W-S


----------



## bluejets

bmac2 said:


> Libraries are simply programs someone smarter than me has written that our program can reference making everyone&#8217;s life a lot easier and you need the 2 attached below. Download the zip files and make sure you know where they are saved.
> To install the libraries open the Arduino IDE program and click on &#8220;Sketch&#8221;, &#8220;Include Library&#8221; and &#8220;Add .ZIP Library&#8221;. Navigate to where you saved LiquidCrystal_I2C-master.zip, select it and click &#8220;Open&#8221;. Do this again and select the Keypad.zip file. You need to close the Arduino IDE and open it again for the libraries to be recognised.



Just started to read through the project and came across this oddball reference (strange numbering)
Is it something to do with my browser not being set to a particular setting or what...?


----------



## jquevedo

Bruce, any chance we can get a copy of your code/sketch to upgrade my existing rotary table software..
I've been using an older version of the one previously published in this web site with very good results, other than some adjustments required between Arduino and motor drive ( I was having some backlash issues).
Seen your approach to handle the integers seems such a bright idea that I would love to upgrade my existing version.

Kind regards
Jaime


----------



## weir-smith

Jaime
Happy to send you the latest sketch. Just send me a personal email. I can't upload the sketch directly but email OK.
Just change the multiplier to suit the ratio of your rotary table. 

Bruce W-S


----------



## weir-smith

Rotary Table sketch.  For anyone who wants a copy, email me using the email :-   [email protected]  along with the ratio you are using.

Bruce W-S


----------



## Joseph Comunale

Imre karoly said:


> @ Bruce
> 
> I'd like to ask for a sketch.


I finally got mine to work with my equipment (LCD Screen, driver, etc.) --- but it was through the help of some talented individuals on the FaceBook Arduino forum.. Having the correct library for the hardware that you have is critical, and not trivial - as there are lots of different manufacturers of the electronic components.   Be prepared to go the full 15 rounds in getting this puppy to work.  It took me (with help from people that knew what they were doing)  a lot longer than I expected.    But it is a nice addition


----------



## wce4

weir-smith said:


> Rotary Table sketch.  For anyone who wants a copy, email me using the email :-   [email protected]  along with the ratio you are using.
> 
> Bruce W-S


Bruce I sent you a email, thank you for making your sketch available to everyone.


----------



## rsholl

Thanks for making your sketch available to everyone Bruce. I'm anxious to now to get going. I need to get back up to speed with the Arduino.
Your sketch will definitely make things go much faster.


----------



## payner

Yes Bruce thank you very much for the sketch, this will definitely speed things up when this hits the top of my " to do " list .
Bill


----------



## Cornnatron

Joseph Comunale said:


> I finally got mine to work with my equipment (LCD Screen, driver, etc.) --- but it was through the help of some talented individuals on the FaceBook Arduino forum.. Having the correct library for the hardware that you have is critical, and not trivial - as there are lots of different manufacturers of the electronic components.   Be prepared to go the full 15 rounds in getting this puppy to work.  It took me (with help from people that knew what they were doing)  a lot longer than I expected.    But it is a nice addition



What kind of lcd are u using ?
Cause im trying to get a fork of this to work with the 128x64 grapiclcd which is also hard.
Could i maybe get a copy of yours to see how they implemented it ?
My lcd uses the u8g2 or u8glib lib.
Then i just have to work on getting it compatable and work out the buttons.
Seeing i want a rotaryencoder switch to run it instead of the 4x4 buttons.


----------



## AndrewMcW

I have a silly question: do you really need a graphic LCD?  Or is it just for the challenge?
Aside from that: generally when I'm trying to get "new" (to me) hardware working on Arduino, I start with a demo program - either one that cam with the libraries or something  self-penned, but simple.  Once that's working you can get the settings from there. If you can't get "hello world" working, there's not much chance you'll get something more complicated working.
(Also: thank you Bruce for sharing the sketch!)
Cheers - Andrew


----------



## Cornnatron

Need is a big word its more cause thats what i got on the shelf left over from a 3d printer its a 128x64 grapiclcd with intergrated rotary encoder.
Got some 20x2 and 16x2 screens aswell but am lacking the 4x4 buttons .
And i got the screen working with the demo sketches but need to write it in to the sketch for the indexer


----------



## adzijderlaan

just for information.

the code I use. line 30: steps steppermotor / rotation     line 31: table ratio.


----------



## Qtron

SailplaneDriver said:


> As promised, here are pictures of the finished product after I got the electronics sorted. It now works well. All the electronics in the case with the keyboard and display.
> 
> View attachment 117693
> 
> View attachment 117694
> 
> View attachment 117695


hope all's ok! yeah a bit behind seeing this 2020 post, i couldnt see a desc of the big knurled disc thingo adjacent the split aluminium frame .. a harmonic drive? maybe i missed your desc.
Also is your f/w the same as B MAC or different/upgraded? Hard to know/choose the 'right' one!


----------



## kquiggle

Some time ago I posted to this site a link to indexer code I wrote which uses stepper motor acceleration and deceleration capabilities, and also includes additional functionality.Several people requested that I make some additional code modifications, and I am now making that update generally available.

While this latest release has 2019 in the file name (because it is based on code originally written in 2019), this is a new modification for 2022.  The following capabilities have been added (see notes in the code for additional details):

Ability to operate a relay
Ability to change the "clock-wise" designation to match the physical rotation of your indexer
When choosing "arc rotation" (indexer moves back and forth in a designated arc), the indexer does not move immediately after degree designation, but only when the "Go" key is pressed
The new code is available via the link below (as will be any future changes, if there are any) :

Academy of Lagado - Stepper Motor - AccelStepper.h


----------



## Qtron

kquiggle said:


> Some time ago I posted to this site a link to indexer code I wrote which uses stepper motor acceleration and deceleration capabilities, and also includes additional functionality.Several people requested that I make some additional code modifications, and I am now making that update generally available.
> 
> While this latest release has 2019 in the file name (because it is based on code originally written in 2019), this is a new modification for 2022.  The following capabilities have been added (see notes in the code for additional details):
> 
> Ability to operate a relay
> Ability to change the "clock-wise" designation to match the physical rotation of your indexer
> When choosing "arc rotation" (indexer moves back and forth in a designated arc), the indexer does not move immediately after degree designation, but only when the "Go" key is pressed
> The new code is available via the link below (as will be any future changes, if there are any) :
> 
> Academy of Lagado - Stepper Motor - AccelStepper.h


ah, thanks Kevin, yes its been quite a while, grateful for the improvements too, cheers


----------



## aarggh

Thanks for that, lot of good info there!


----------



## Fritz

Just built this, quite happy with it, and it works well.
I used the code from kquiggle linked in post #475  
If anybody wants to have a play with it, I put it in an Arduino simulator. (_I hope kquiggle is OK with me doing this._)
Rotary Table.ino - Wokwi Arduino and ESP32 Simulator
This is kquiggle's code. I'm not taking any credit for this. 


Couple of important things to note about the Simulation:
The Stepper driver and motor are powered by the Arduino. *Don't do that*. The simulation doesn't have an option to add an extra power supply.
For some reason the stepper motor starts at -2 steps instead of 0. I get this on most steppers on all of my simulations so your steps will be off by 2, but only in the simulation.
I had to comment out the getSettings() to get it to work on the simulation. Delete lines 1232 (/*) and 1246 (/) before you upload the code to the Arduino.
You can also delete lines 521 to 523.
Don't forget the AccelStepper library.
I used an Arduino Uno. this code almost maxes out the memory, so if you want to change any of it, you won't be adding much to it. (It's got room for maybe half a dozen new lines.)








I never thought I'd use the "Arc" option, but after taking out the bulk of the material, I set the dividing head up to the vertical position, set the arc to move from 0° to I think 292° and used it to finish off the outside arc of this piece. (Taking very light cuts, but it did it well)


----------



## kquiggle

Fritz - 

You are more than welcome to use my code.  I would also like to note that I recently made an update to the code to add some new options :

Ability to operate a relay
Ability to change the "clock-wise" designation to match the physical rotation of your indexer
When choosing "arc rotation" (indexer moves back and forth in a designated arc), the indexer does not move immediately after degree designation, but only when the "Go" key is pressed
You can find a link to the updated code here :

Academy of Lagado - Stepper Motor - AccelStepper.h

P.S.

There are no bug fixes in the new release, so if you are already using the previous version and it it working to your satisfaction, there is no need to update.


----------

