Arduino control for a 3” rotary table

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.
John, Rod, Ron Thanks guys.
John I think your right with swapping out the coupler for an Oldham I’ve used them before in model boats (didn’t know what they were called) but would have never thought of using one here.

Rod, I didn’t want to modify the rotary table so all I did was take off the crank handle. At first I thought the shaft was bent but I put a dial indicator on it today and it’s just not concentric. I suppose if it’s one of the corners that get cut in cheaper tools.

DJP
I haven’t torn down the control box yet, just enough to do a quick and dirty check of the MOSFETs. What it’s doing is current tripping on start-up unless the speed control is turned up very slowly. When it does start it just chugs along until the speed is high enough that it’s not noticeable. The boards in my mill look like something I would have worked on back in the mid 90’s. I think the problem is going to be in the current limit or the pulse width modulation circuit or both. :toilet: I have been toying with scrapping the controller boards all together and building my own.

[ame]https://www.youtube.com/watch?v=i9q5FsWUf7Q&feature=youtu.be[/ame]
 
John, Rod, Ron Thanks guys.


Rod, I didn’t want to modify the rotary table so all I did was take off the crank handle.

I have not modified the table either. Just took off the handle and utilised the mounting for the optional dividing plates. Consider shimming the stepper mounting bolts to adjust the alignment.
 
Your fingers are on the source of the problem. That pot with switch is very cheaply made and not robust at all. Like you I was considering ways to run the DC motor. I attached terminals directly to the motor so that I could at least finish a task if the controller failed completely. It limped along for a long time but in frustration I finally replaced it with a pot and separate switch.

The ON/OFF switch is now on the left panel and the pot only controls speed. In the zero speed position the motor will stop. The two DC connection points were installed in case I need to run the mill using a DC power supply.

Since changing the pot and soldering some 'iffy' connections it has bee solid.

IMG_3380.jpg
 
Yikes. :eek:
Sorry.
Just had it pointed out to me via YouTube that the sketch Does Not Compile! This was pure sloppiness on my part as all I did was bring it up in the Arduino IDE and copy / paste it into the post.

Did I check that it worked?

Did I check it was the right version?
Nope. :wall:

I just tried pasting it again into this post and I when looked at it in the Preview window some of the punctuation characters must have been picked up by the forum software and dropped out of the text.
This is the CORRECT sketch that does work. I’ll attach it as a zip.

View attachment Arduino_Rotary_Table_Control_2016.zip
 
Hi, Was wondering if someone could help...just spent 3 days and nights struggling with Arduino scripts to get my setup opperating and still isn't operating.
Stepper is fitted to rotary table and have a kit arduino Uno assembled....checks out with a blink script, got a 4x4 matrix keypad...blue numbers red letters off ebay and this LCD http://www.ebay.com.au/itm/131640986477?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT I have tried everything to get this working..swapped out Uno, Nano, Mega...tried all sorts of scripts anyway finally found a script that runs this LCD....seems I'm not the only one finding problems with this LCD.....here is the script View attachment LCD Script.pdf
My question is can this script I found be merged in with the script by Bmac2..... to get my table running...I am such a novice with Arduino and was about to call it quits from the frustration...any help is gratefully received.

Cheers Mike.
 
Hi Mike
First please use the sketch in the above zip file. Copy and paste from the first page won’t compile.
I’m at work so I can’t dig into this too far but I have a couple of things you can try just off the top of my head. One that bit me in the bum the first time I tried using an I2C display (got it super cheap from China but . . . . . no manual) is that I2C devices have and address. I see in the sketch you say works with your setup they set the address to 0x3F and in the sketch I used it is set to 0x27. So it might be just a simple edit.

Another simple one that got me is the jumper on the back of the display. It turns the display back light on and off so you can check that it’s there, mine was floating around in the antistatic bag.
All of a sudden I’m glad I didn’t clean all those pictures off my iPod.
Hope this helps . . Bob

0x3F address.jpg


0x27 address.jpg


IMG_1757.jpg
 
Have found that what the supplier shows as the i2c address isn't always so.
My own 20x4 came out to be
LiquidCrystal_I2C lcd(0x3B, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

Can run the brute force scanner to verify what arduino sees . . .

copy, compile, run

  1. // i2c_scanner
  2. // Version 1
  3. // This program (or code that looks like it)
  4. // can be found in many places.
  5. // For example on the Arduino.cc forum.
  6. // The original author is not know.
  7. // Version 2, Juni 2012, Using Arduino 1.0.1
  8. // Adapted to be as simple as possible by Arduino.cc user Krodal
  9. // Version 3, Feb 26 2013
  10. // V3 by louarnold
  11. // Version 4, March 3, 2013, Using Arduino 1.0.3
  12. // by Arduino.cc user Krodal.
  13. // Changes by louarnold removed.
  14. // Scanning addresses changed from 0...127 to 1...119,
  15. // according to the i2c scanner by Nick Gammon
  16. // http://www.gammon.com.au/forum/?id=10896
  17. // Version 5, March 28, 2013
  18. // As version 4, but address scans now to 127.
  19. // A sensor seems to use address 120.
  20. // Version 6, November 27, 2015.
  21. // Added waiting for the Leonardo serial communication.
  22. //
  23. //
  24. // This sketch tests the standard 7-bit addresses
  25. // Devices with higher bit address might not be seen properly.
  26. //
  27. #include <Wire.h>
  28. void setup()
  29. {
  30. Wire.begin();
  31. Serial.begin(9600);
  32. while (!Serial); // Leonardo: wait for serial monitor
  33. Serial.println("\nI2C Scanner");
  34. }
  35. void loop()
  36. {
  37. byte error, address;
  38. int nDevices;
  39. Serial.println("Scanning...");
  40. nDevices = 0;
  41. for(address = 1; address < 127; address++ )
  42. {
  43. // The i2c_scanner uses the return value of
  44. // the Write.endTransmisstion to see if
  45. // a device did acknowledge to the address.
  46. Wire.beginTransmission(address);
  47. error = Wire.endTransmission();
  48. if (error == 0)
  49. {
  50. Serial.print("I2C device found at address 0x");
  51. if (address<16)
  52. Serial.print("0");
  53. Serial.print(address,HEX);
  54. Serial.println(" !");
  55. nDevices++;
  56. }
  57. else if (error==4)
  58. {
  59. Serial.print("Unknow error at address 0x");
  60. if (address<16)
  61. Serial.print("0");
  62. Serial.println(address,HEX);
  63. }
  64. }
  65. if (nDevices == 0)
  66. Serial.println("No I2C devices found\n");
  67. else
  68. Serial.println("done\n");
  69. delay(5000); // wait 5 seconds for next scan
  70. }
Suppliers link shows

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

as the parameters for the display mentioned
 
Last edited:
Hi Bob,
Spent another day trying to figure it out then found out about i2c scanner...which I ran only to find out that no I2c was detected...I had switched from Uno to Mega cos Ftdi broke it's pins into the Uno...anyway then realised that SDA and SDL weren't A4 and A5...about this time I had checked out your post and scanned the I2c again with SDA and SDL in there right place and got an address of 0x3....now I have a screen with two O's and nothing else...keyboard not working...stepper not stepping....but definitely moving forward with all your help and advise...so your help is very much appreciated, as I say trying to get my head around this is difficult for me...but learnt heaps in the last 4 days.
I have to download scripts from another area where the pc is as the RT is in the Shed so plugging in and out all day for 4 days isn't ideal.
Here is a snap of what I have changed so far...
#include <LiquidCrystal.h>

/*
4x4 matrix keypad amd a 20 x 4 LCD.
Edit StepsPerRotation & TableRatio(# of turns for 360 degrees)in line 29
A4988 Stepstick/M542driver
5/2/2015
*/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

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

byte rowPINS[ROWS] = {11,10,9,8};
byte colPINS[COLS] = {7,6,5,4};

Keypad kpd = Keypad(makeKeymap(keys),rowPINS,colPINS, ROWS, COLS);
LiquidCrystal_I2C lcd(0x3f,20,21); // set the LCD address to 0x3 for a 16 chars and 4 line display
// SCL - 20, SDA - 21, VCC - +5, Gnd - Gnd
//setup vars
const int stp = 2; // connect pin 2 to step
const int dir = 3; // connect pin 3 to dir
const int StepsPerRotation = 400; // Set Steps per rotation of stepper NOTE the driver is set to Half step
const int TableRatio = 90; // ratio of rotary table
const int Multiplier = (StepsPerRotation * TableRatio)/360; // 200*90=18000/360 = 50
const int stepdelay = 1;
float Degrees = 0; // Degrees from Serial input
float ToMove = 0; // Steps to move
float bob = 0;
int cho = 0;

I'm getting an Invalid library found in home/mike/Arduino/wires . /home/mike/Arduino/wires.
Sketch still compiles and error is white lettering...is this a problem ?...or just ignore ?.
I will try out Foozer's I2c brute force a little later...so thanks Foozer....much appreciated.
 
Ok. Mike on a guess it sounds like it library problem. Works nuts right now but give me a day or so and I’ll get together something with the libraries I’m using.
 
Thanks Bob....Appreciated....another day with no luck...just walked in from the shed...8pm.....think I have tried everything...unless the LCD is faulty....I have altered the sketch to the best of my limited ability and sketch compiles and uploads without errors now but just doesn't do anything....anyway...happy friday.

Cheers.
 
I think you are trying to do too much at once. You said you had the screen working with one script. Fantastic! study the script until you understand it.

Then find the shortest, most basic introductory stepper motor driver script. Disconnect your stepper from the rotary table and get the stepper to move.

Then, merge the 2 introductory scripts together so you are printing stepper related stuff on the screen.

If you are going to use a matrix keyboard, get it working with a demo script.

So now with all that done, you should know a lot more about the Arduino and your hardware then you do now so you should be in a position to get the rotary table controller going.

Remember, this is not a plug and play environment. Its all dependent on the hardware. If you are still stuck then might I suggest you scrap your hardware and buy exactly what has been used in the past.

You could consider my controller as you can configure it in a setup menu so it will work with your hardware
http://www.homemodelenginemachinist.com/showthread.php?t=25091
but deviate from the hardware I list at your peril. (Although several have used Sainsmart hardware)
 
In Arduino - Examples - The LCD library should have an example script with it e.g. 'Hello World'
Load it to focus just on the LCD operation. The generic script command
LiquidCrystal_I2C lcd(0x3F); // Set the LCD I2C address
doesn't work for the 20x4 with backpacks I use regardless of vendor . . . whereas
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
does [provided I2C address is 0x3F]

Had one lcd that wouldn't work, screen lit up but no adj of the backlight screw would alter the brightness . So the Mega is SDA @ 20 and SCL @ 21. Get it to work with the library example and you're half way there.
 
Thanks Foozer....followed your advice and spent many hours at it again....Freetronics have a lcd sketch, the seller of the LCD have a simple sketch along with many others I tried and many other I changed trying to get a result....here is a sample of the simple sketch.



#include <Wire.h>
#include <LiquidCrystal.h>


LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );

void setup()
{
lcd.begin(16, 2);
lcd.print("hello, world!");
}

void loop()
{
// your main loop code here...
}


I got a few to compile and upload but best I got was 2...zero's on the LCD, I have a clone sainsmart lcd and a replacement for this lcd coming through the week....but at this stage I would say I should have stumbled across something that I have tried and would have worked...but not so...anyway I do appreciate every ones help...very frustrating not to get a good result....when things like this are difficult and the longer and harder you try the more your likely to confuse yourself....cheers
 
Did you actually try the code on the ebay listing? IT will need to be changed for the 20x4 line display.

I think you have been trying to use the wrong libraries from day dot.

Read this http://wentztech.com/radio/arduino/files/LCDI2C.html and connect the pins as they say.

Code:
1	+5 Volts
2	Ground
3	Pin 4(SDA)
4	Pin 5(SDA)

Download the library and install it.

Then try this code from your ebay listing set for 20 x 4 lines.

Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4); //set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("b2cqshop");
lcd.setCursor(0, 1);
lcd.print("Voltage: ");
lcd.setCursor(13, 1);
lcd.print("V");
}
void loop()
{
int val;
float temp;
val=analogRead(0);
temp=val/4.092;
val=(int)temp;//
lcd.setCursor(9, 1);
lcd.print(0x30+val/100,BYTE);
lcd.print(0x30+(val%100)/10,BYTE);
lcd.print('.');
lcd.print(0x30+val%10,BYTE);
delay(100);
}
 
Pulled the covers from the two units that have a 20x4 LCD display. Each is a different type of backpack [gives different address], hooked each in turn to a mega. Loaded short code


#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address //sainsmart lcd2004
LiquidCrystal_I2C lcd(0x3b, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address to units address e.g. 0x27, 0x3f etc
// other backpack changeable i2c address
void setup()
{
lcd.begin(20,4); // initialize the lcd
lcd.home (); // go home
lcd.print("Hello World ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print (" Line Two");
lcd.setCursor ( 0, 2 ); // go to the next line
lcd.print (" Line Three");
lcd.setCursor ( 0, 3 ); // go to the next line
lcd.print (" Line Four");
}
void loop(){}
First photo backpack looks like yours I2c scanner reports address as 0x27 - Loaded script and POOF! Prints out
Second photo is the other same script just different address same POOF! as shown in third photo [bad photo] but can keep that a secret]

Using 'LiquidCrystal_I2C lcd(0x27,20,4)' in script and I get black screen on both LCD units

DSCF0144_zpskaszxpke.jpg



DSCF0145_zpsgbn6i9jz.jpg



DSCF0147_zpsblytwsye.jpg
 
Hi Mike
Trying to post some help here but can't get the attachments to upload. I've tried on 3 different computers and no luck.
I'll try again later tonight.
 
Ok I can upload attachments
I don’t think it’s a hardware dependency. I’ve ran the sketch on an Arduino Mini, Nanos (3v and 5v), Uno (original and clone) and a Mega so 7 different platforms. The only problem I had was with the vision of the libraries I had loaded on my laptop.
The stock sketch should work without any need to edit aside from the address for the I2C display just be sure you are using the one from the zip file attached in post #24.
First you’ll want to get the controller into the same room as the computer. We’re going to be doing a fair bit of downloading and testing.
Checking the Libraries.
I don’t know if you’ve installed libraries so we’ll go the “Arduino for Dummies” route. Download the 2 zip files and make note of where they have been saved.
Open the Arduino IDE and click on “Sketch”, “Include Library”, “Add Zip Library”
Navigate to the directory you saved the Zip files (I sound all Microsoft there) and select “Keypad.zip” and then click “Open”. Then do the same thing selecting “LiquidCrystal_I2C” and were done. You have to close the Arduino IDE and open it again for the changes to take effect.

View attachment Keypad.zip

View attachment LiquidCrystal_I2C.zip

Library 01.jpg


Library 02.jpg
 
My entire Arduino graveyard is from when I had things hooked up to an unregulated power supply. Most of which are from me working on a PWM speed control for my Mini Mill. So first let’s disconnect the stepper motor. I have never blown up anything with an Arduino connected to a USB port. All we have here are logic levels, if you accidently connect an input to an output it just won’t work. Connect it to 90vdc and you get a collection like mine.

IMG_1858.jpg
 
Thanks Rodw, downloaded and installed all library files and swapped scl and sca pins to A4 and A5 ran sketch...;error was 'BYTE keyword no longer supported.'
changed scl and sca to pins 21 and 20 cos its a Mega and got same error.

Thanks Foozer...tried your sketch but changed address to 0x3F as per address scan....error was 'Positive not declared in this scope'...

Thanks Bmac....

Cheers Mike.
 
This is a quick test for the key pad. Its setup to work with the same wiring used in the rotary table sketch so you don’t have to make any changes. Download “4x4_Keypad_Test.zip”and unzip it into your Arduino folder usually “C:\Users\User\Documents\Arduino”. Open the sketch “_4x4_Keypad” and upload it onto your Arduino. Open the serial monitor and you can test that the keys are working. If not, the only thing that can be wrong is the wiring, or the keypad is bad. I only have a 4x3 pad on hand so I had to fake the forth row but it works.

The connections should be –
Arduino D4 to Keypad pin 1
Arduino D5 to Keypad pin 2
Arduino D6 to Keypad pin 3
Arduino D7 to Keypad pin 4
Arduino D8 to Keypad pin 5
Arduino D9 to Keypad pin 6
Arduino D10 to Keypad pin 7
Arduino D11 to Keypad pin 8

You can test the keypad with a multimeter. Pins 1-4 are the columns and 5-8 are the rows. Set the meter to ohms put 1 probe on pin 1 and the other on pin 5 you should get continuity when you press the “D” button. Pins 1 and 6 will be “C” etc.

View attachment 4x4_Keypad_Test.zip

IMG_1860.jpg


Keypad Test.jpg
 
Back
Top