Project of the Month built by gbritnell

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

Reply
 
Thread Tools
Old 04-24-2017, 01:10 AM   #11
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

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!


Attached Thumbnails
Sketch Upload.jpg   Blink Edit.jpg  
__________________
Bob
Alberta, Canada
bmac2 is offline  
2
People Like This 
Reply With Quote
Old 04-24-2017, 01:13 AM   #12
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

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.


Attached Thumbnails
Zip Library.jpg  
Attached Files
File Type: zip keypad.zip (18.5 KB, 142 views)
File Type: zip LiquidCrystal_I2C-master.zip (20.2 KB, 109 views)
__________________
Bob
Alberta, Canada

Last edited by bmac2; 05-17-2017 at 01:51 AM. Reason: Uploaded the correct I2C library
bmac2 is offline  
Maxmekker50 Likes This 
Reply With Quote
Old 04-24-2017, 01:17 AM   #13
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

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

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.
Attached Thumbnails
IMG_1900.jpg   IMG_1901.jpg  
__________________
Bob
Alberta, Canada
bmac2 is offline  
Maxmekker50 Likes This 
Reply With Quote
Old 04-24-2017, 01:19 AM   #14
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

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.
Attached Thumbnails
I2C address.jpg  
Attached Files
File Type: zip I2C_Scanner.zip (763 Bytes, 125 views)
__________________
Bob
Alberta, Canada
bmac2 is offline  
Maxmekker50 Likes This 
Reply With Quote
Old 04-24-2017, 01:22 AM   #15
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

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.
Attached Thumbnails
Hello World.jpg   I2C address 2.jpg   IMG_1902.jpg   Jumper.jpg  
__________________
Bob
Alberta, Canada
bmac2 is offline  
Maxmekker50 Likes This 
Reply With Quote
Old 04-24-2017, 01:25 AM   #16
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

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

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.
Attached Thumbnails
IMG_1912.jpg   IMG_1828.jpg  
__________________
Bob
Alberta, Canada
bmac2 is offline  
Maxmekker50 Likes This 
Reply With Quote
Old 04-24-2017, 01:26 AM   #17
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

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_T able_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.
Attached Thumbnails
Address Check 2.jpg  
Attached Files
File Type: zip Arduino_Rotary_Table_Control_2016.zip (2.2 KB, 150 views)
__________________
Bob
Alberta, Canada
bmac2 is offline  
 
Reply With Quote
Old 04-24-2017, 01:28 AM   #18
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

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.
Attached Thumbnails
IMG_1916.jpg   IMG_1918.jpg  
__________________
Bob
Alberta, Canada
bmac2 is offline  
Maxmekker50 Likes This 
Reply With Quote
Old 04-24-2017, 01:33 AM   #19
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

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.
Attached Thumbnails
IMG_1905.jpg   IMG_1919[1].jpg   Scope.jpg  
__________________
Bob
Alberta, Canada
bmac2 is offline  
Maxmekker50 Likes This 
Reply With Quote
Old 04-24-2017, 01:40 AM   #20
bmac2
 
bmac2's Avatar
 
Join Date: Aug 2013
Posts: 854
Liked 510 Times on 390 Posts
Likes Given: 217

Default

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, counter clockwise when you press “A” for forward just reverse the stepper connections at the controller.


Attached Thumbnails
IMG_1920.jpg   TB6560 At 0.3 amp.jpg   TB6560 Stepping Mode.jpg  
__________________
Bob
Alberta, Canada
bmac2 is offline  
2
People Like This 
Reply With Quote
Reply


Thread Tools

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

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

Forum Jump

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



Newest Threads






- Top - Member List