Arduino Rotary Table for Dummies

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

bmac2

Well-Known Member
Project of the Month Winner
Joined
Aug 16, 2013
Messages
1,033
Reaction score
764
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. . . .

Arduino Rotary Table for Dummies.jpg
 
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
 
[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]

Arduino Uno.jpg
 
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.

I2C Display.jpg
 
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.

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

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

XL6009 DC-DC Buck.jpg


LM2596 Buck Converter.jpg
 
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
 
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.

Board Select.jpg


COM Port.jpg
 
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!

Sketch Upload.jpg


Blink Edit.jpg
 
Libraries are simply programs someone smarter than me has written that our program can reference making everyone’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 “Sketch”, “Include Library” and “Add .ZIP Library”. Navigate to where you saved LiquidCrystal_I2C-master.zip, select it and click “Open”. 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

Zip Library.jpg


View attachment LiquidCrystal_I2C-master.zip
 
Last edited:
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]

IMG_1900.jpg


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

I2C address.jpg


View attachment I2C_Scanner.zip
 
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.

Hello World.jpg


I2C address 2.jpg


IMG_1902.jpg


Jumper.jpg
 
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]

IMG_1912.jpg


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

Address Check 2.jpg


View attachment Arduino_Rotary_Table_Control_2016.zip
 
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.

IMG_1916.jpg


IMG_1918.jpg
 
Almost done. On the TB6560 we have 3 connections to the Arduino. Step, Gnd, Direction, and a short jumper between “CLK -“ and “CW -“. 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.

IMG_1905.jpg


IMG_1919[1].jpg


Scope.jpg
 
Hooking up the stepper motor to the controller is straight forward. Connect the power supply positive (+) to the “+24” terminal on the controller. It’s labeled +24 but I’ve found that it works fine as low as 9 volts. Connect the power supply negative (–) to the “GND” 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 “StepsPerRotation” 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 “A” for forward just reverse the stepper connections at the controller.

IMG_1920.jpg


TB6560 At 0.3 amp.jpg


TB6560 Stepping Mode.jpg
 

Latest posts

Back
Top