Electronic Dividing Head using the Arduino

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.
yes, thats how i have it and what it says, line 276, im assuming you meant 27.... my editor does not have lines labeled... is there a better arduino code program ? im used to using context, where i can search words, and scroll straight to numbered lines, and this has none of the good stuff.

what currently happens, is when i hit A it moves forward, when i hit B it makes a clicking sound, when i hit A again it sometimes advances, and sometimes makes the clicking sound, if i hit A again after the clicking sound it advances forward again.
yellow is on pin 3 and goes to Dir + , green is on pin 2 and goes to Pulse + , orange is connects to a ground, and goes to all 3 negatives.
enable is wired but not used in the code.

View attachment 105051

fubuddy, if you want a code editor that displays line #'s, check out Notepad++. Lots of features. Check that your stepper is wired properly, that may be why you're getting the clicking...
 

Ok - Plugged in my data 400 steps per rev, table ratio 36 multiplier (400*36)/360 Works as written -
DSCF0307.JPG

So having it operate will plug in your stepper numbers - After the honey do list - She Found Me . .
Back Later - - -

Back - OK just to check - your stepper is 0.3 degree -> 1200 steps per rotation -> 6:1 table ratio -> 7200 steps per 360 degree table rotation? Correct . .
So switches on 6600 1-off 2-on 3-on [Half Step]
StepsPerRotation 2400
TableRatio 6
Multiplier (StepsPerRotation*TableRatio)/360

farther down for(int i=0; i < tm;

degrees = StepsPerRotation/num

and slowed down the motor
StepDelay = 2

LCD reads right and this motor (1.8 degree) spins as it should - 6 revolutions for 2400 steps which should be 1 revolution for yours.
Bride found me again - Will check back . .
 
Last edited:
FuBuddy
If you are using the "Arduino" editor, just go to "File" Tab then "Preferences" and click " display line numbers "

Scott
 
You should try a mega 2650 with a ramps board, the stepper drivers plug into the ramps and makes programing much easier
 
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.

db5e6546.jpg


Available online for under $30, has 32K memory, numerous analog and digital inputs and outputs, including serial and PWM.

Next, the Sainsmart LCD display and keyboard shield

b829d9dc.jpg


This board is called a shield because it is pin compatible with and piggybacks right on top of the Arduino board. It has a 2 line x 16 character display and 5 input keys plus a reset. The keys are configured like the cursor keys on a PC having a left, right, up, and down as well as a select. So, with this shield in place, the microcontroller can be used with only a power supply and doesn't have to be tethered to a computer. The keys provide input and the LCD provides the display.

Here is the Sainsmart shield mounted on the Arduino...

f89430c6.jpg


The Sainsmart gets its power from the Arduino.

Another picture

93e96bf4.jpg


The Arduino is programmed by hooking it up to your PC through a USB cable. This also provides power to the Arduino board. A free programming environment is available for the PC and allows you to develop programs in a language that looks almost exactly like C. There are a host of standard libraries for interfacing to LCD's, keyboards, wireless, serial devices, and others. You write the programs and compile them on the PC. The compiler then automatically downloads the program to your Arduino. Once the program is loaded on the Arduino, you can decouple it from the computer and run it off a separate power supply from 9 - 12 volts. The program will stay in the Arduino memory even when the power is switched off.

423c8d56.jpg


So this is the basis for controlling my electronic dividing head. The up and down arrow keys will be used to set the number of divisions I want, then the left and right arrow keys will be used to step forward or backward one division at a time. The program I have written will calculate the number of stepper steps need for each division and keep track of the position I'm on. The display shows the number of divisions and the current dividing head position.

I have purchased a stepper driver board that is about the size of a postage stamp and will power a stepper of up to 2 amps, 35 volts. I still have to select the stepper motor I want to use and build the mechanical part of the dividing head. Still have a few challenges ahead of me.

Chuck
 
Thanks Chuck
Reference your Indexer.
I built one similar, it includes Angular, Divisions, continual run , jog, and I can change the ratio either driving the indexing head or my different circular tables.
All Arduino based electronics.
I currently have a 12T/72T a 6:1 ratio to the indexer, a 90: 1 and 72:1 ratios for my circular tables, the Arduino sketch can be altered to suit any integer ratio numbers as required.
The Indexing head I built from steel box section. originally as a horizontal head for my vertical mill, using
the bevel and pinion gears out of an angle grinder. The pinion was brazed to a stub arbor for the mill quill, the
bevel gear machined to fit the indexer spindle.
The indexer spindle is a converted lathe tailstock quill with a#2 Morse taper. this runs in the indexing head steel box with tapered roller bearings and oil seal at the front.
I machine a lot of T5 timing belt pulleys in my hobby, and fly cut the teeth using the indexer.Works out well.
Certainly cuts down on the cost of purchasing pulleys.
Hope photos will be of interest, worth a thousand words.
John
Spain
 

Attachments

  • 10T pulley and belt.JPG
    10T pulley and belt.JPG
    85.2 KB · Views: 493
  • 72 T pulley with belt flange.JPG
    72 T pulley with belt flange.JPG
    47.6 KB · Views: 502
  • Complete indexer parts.JPG
    Complete indexer parts.JPG
    93.9 KB · Views: 577
  • Complete set up.JPG
    Complete set up.JPG
    100.8 KB · Views: 547
  • Control box.JPG
    Control box.JPG
    70.8 KB · Views: 527
  • Cutting 30T pulley.JPG
    Cutting 30T pulley.JPG
    78.2 KB · Views: 501
  • DSC00597.JPG
    DSC00597.JPG
    82.9 KB · Views: 491
  • DSC00668.JPG
    DSC00668.JPG
    46.4 KB · Views: 495
  • DSC00669.JPG
    DSC00669.JPG
    41.2 KB · Views: 493
  • Mill sett up.JPG
    Mill sett up.JPG
    90.9 KB · Views: 458
OK just to check - your stepper is 0.3 degree -> 1200 steps per rotation -> 6:1 table ratio -> 7200 steps per 360 degree table rotation? Correct . .
So switches on 6600 1-off 2-on 3-on [Half Step]
.

nope, its 200 steps per rev, 1/6 raito, = 1200 steps per rev total, i did not see the need for the code to do that math, so i just enter 1200 for steps and 1 for raito, ive tried the math for all my driver settings, and always get a 1/3 or 2/3 decimal.

the code works for you and goes in reverse ?
thats the only thing i actually want at this point, i got it installed on the mill and cut a 5 and 6 sided reamer's

using my f'd code with 1200 as degrees , i just do a lil quick head math, divisions of 1 2 3 4 5 6 8 and 16 by 1200 are all real easy
20181018_151229 (1).jpg
20181101_185956.jpg
 
FuBuddy
If you are using the "Arduino" editor, just go to "File" Tab then "Preferences" and click " display line numbers "

Scott

thanks Scott, that will definitely help a lotabit, i wont have to count arrows down to 276 again :p but i still want those good old compare script and search features :p
 
nope, its 200 steps per rev, 1/6 raito, = 1200 steps per rev total, i did not see the need for the code to do that math, so i just enter 1200 for steps and 1 for raito, ive tried the math for all my driver settings, and always get a 1/3 or 2/3 decimal.

the code works for you and goes in reverse ?
thats the only thing i actually want at this point, i got it installed on the mill and cut a 5 and 6 sided reamer's

Works fine FWD and REV . . . [Note - 276 referred to your post number not script line number] You should be able to change the numbers if your full stepping 200 for StepsPerRotation, 400 for half stepping [runs smoother on half stepping


Ok after the Bride lets me free I'll do a quick and dirty test script for FWD and REV - I'll Be Back . .
Back - Should run motor fwd and rev -

#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_I2C.h>
int stp = 2;
int dir = 3;
int stepdelay = 2000; // Reduce number to speed up motor
int revolution = 400; // Half Stepping - Set TB6600 switches accordinly ie: 1 OFF, 2,3 ON
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
void setup() {
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
lcd.begin(20,4);
}
void loop() {
delay(500);
digitalWrite(dir,HIGH);
lcd.setCursor(6,2);
lcd.print("Forward");
for (int x = 0; x < revolution; x++)
{
digitalWrite(stp, HIGH);
delayMicroseconds(stepdelay);
digitalWrite(stp, LOW);
delayMicroseconds(stepdelay);
}
delay(500);
digitalWrite(dir,LOW);
lcd.setCursor(6,2);
lcd.print("Reverse");
for (int x = 0; x < revolution; x++)
{
digitalWrite(stp, HIGH);
delayMicroseconds(stepdelay);
digitalWrite(stp, LOW);
delayMicroseconds(stepdelay);
}
}
int stp = 2;
int dir = 3;
int stepdelay = 2000; // Reduce number to speed up motor
int revolution = 400; // Half Stepping - Set TB6600 switches accordinly ie: 1 OFF, 2,3 ON
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
void setup() {
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
lcd.begin(20,4);
}
void loop() {
delay(500);
digitalWrite(dir,HIGH);
lcd.setCursor(6,2);
lcd.print("Forward");
for (int x = 0; x < revolution; x++)
{
digitalWrite(stp, HIGH);
delayMicroseconds(stepdelay);
digitalWrite(stp, LOW);
delayMicroseconds(stepdelay);
}
delay(500);
digitalWrite(dir,LOW);
lcd.setCursor(6,2);
lcd.print("Reverse");
for (int x = 0; x < revolution; x++)
{
digitalWrite(stp, HIGH);
delayMicroseconds(stepdelay);
digitalWrite(stp, LOW);
delayMicroseconds(stepdelay);
}
}
 
Last edited:
hmmm smoother but just as fast ? or does it also slow it down, i was under the impression that more micro steps = slower rotation
and i rather have it fast than smooth.
ive checked the wiring labeling to make sure i had it right and i do, according to china, but ive had stuff come with + and - mixed up before...
ill physically confirm that it is correct
if the code i posted with my bad working for me code, makes yours go forward and back i would assume something is wrong in my wiring, or one of the lines i changed that you changed back only applies to forward.
still need to find a box for it...

20181104_113719.jpg
 
ill physically confirm that it is correct


View attachment 105085
Smoother and slower . .

Thinking first to see if your motor will rotate both directions - Real simple one. . .

// Begin
int stp = 2;
int dir = 3;
int stepdelay = 2000; // Reduce number to speed up motor Too low and the motor will just buzz not turn.
int revolution = 400; // Half Stepping - Set TB6600 switches accordinly ie: 1 OFF, 2,3 ON
void setup() {
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
}
void loop() {
digitalWrite(dir, HIGH); // Switch to LOW for opposite direction ie: digitalWrite(dir, LOW);
{
digitalWrite(stp, HIGH);
delayMicroseconds(stepdelay);
digitalWrite(stp, LOW);
delayMicroseconds(stepdelay);
}
}
// End

Cut and paste into arduino, load, TB6600 set to half step motor should turn . Change the dir,HIGH to dir,LOW reload and motor should turn in opposite direction.

Makes no difference to this if the TB6600 is set to full step [200] If you get it to forward reverse the rest is easy . .
 
ohhh queso...tried that , high gives me a click, low rotates stepper.
switched motors same result, so bad driver ?
 
ohhh queso...tried that , high gives me a click, low rotates stepper.
switched motors same result, so bad driver ?

Low rotates stepper - take it rotates it a bit slower than the original script did [was the intent] The 6600 is grounded to the arduino ? all things share a common ground? Lacking a good kick may be that the 6600 is a tad flakey . .
 
correct, a lil slower but not much.
yes all negative on driver are wired to a single negative terminal on arduino
is there another driver you might recommend, ordered another 6600
3.0 amp nema 23
 
correct, a lil slower but not much.
yes all negative on driver are wired to a single negative terminal on arduino
is there another driver you might recommend, ordered another 6600
3.0 amp nema 23

I have three of those 6600, all work fine on nema 23's 3.5 amp. Only time won't turn is if I try to run them too fast, [won't start is the pluses are too fast] and it's more of a buzz than a click. You can set the stepdelay down to 4000, 6000 - should run slower.
Other that having in hard am at a lose right now as to your click noise . . .
Guess till your new 6600 comes in - shall wait . .
 
yes sir, thanks for all the help, ill report back if the new driver fixes it or not.
 
I really must thank Chuck and others for their valuable information. Having no experience of coding the info here has been most useful.
My only problem with Chucks code (from post #50) or my setup is the lack of reverse direction. Can anyone tell me where I may be going wrong?

I'll give it a try but Chucks stuff is so far above my skill level, but what the heck . . .
Ok dug out the sainsmart - - First hookup - No reverse - Looked up the shield pin callout
Hooked to the wrong pins - Again.

Left to Right D13 - D12 - D11 - D3 - D2 - D1 - D0 - GND - 5V
Had driver hooked to D2-D1 - [Looks on the shield they should be D2-D3 Right?] Moved over one spot to match the actual pin callout and all is good . . .
 
Last edited:
ok, everything seems to be working fine except the reverse! So this is my setup:-
Arduino uno
Sainsmart lcd display shield
TB 6560 stepper motor controller.
Anyone with same setup show me how they have it connected or have any ideas.
 
TB6560.JPG
I just finished 're-building' my controller. I had built it using a non I2c 2004' but, several months ago I tore it apart to use the mega in another project. About a month ago I decided to re-build it, designing a new case as I went. I decided to order a I2c 2004 lcd, and though shipped from California, it took 4 weeks to get here... I had previously added a 9 pin sub D connector and longer leads to the stepper,. This time I took the time to set up modular wiring as much as possible. I still need to draw up a schematic diagram. Short version, I also used a TB6560 driver board. My connections were as in the attached picture. My setup is again torn apart until I finish printing the new case, but if needed, I can re-assemble and take pictures.
Hope this helps
 
Last edited:

Latest posts

Back
Top