Electronic Dividing Head using the Arduino

Discussion in 'Software and Programming' started by cfellows, May 21, 2012.

Help Support HMEM by donating:

  1. Nov 3, 2018 #281

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,292
    Likes Received:
    149
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    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...
     
  2. Nov 3, 2018 #282

    Foozer

    Foozer

    Foozer

    Well-Known Member HMEM Lifetime Supporter

    Joined:
    Nov 26, 2008
    Messages:
    1,163
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Retired
    Location:
    Camano Island, WA
    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: Nov 3, 2018
  3. Nov 3, 2018 #283

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    250
    Likes Received:
    76
    Location:
    Medina, Ohio USA
    FuBuddy
    If you are using the "Arduino" editor, just go to "File" Tab then "Preferences" and click " display line numbers "

    Scott
     
  4. Nov 4, 2018 #284

    skankky

    skankky

    skankky

    New Member

    Joined:
    Sep 18, 2016
    Messages:
    1
    Likes Received:
    0
    You should try a mega 2650 with a ramps board, the stepper drivers plug into the ramps and makes programing much easier
     
  5. Nov 4, 2018 #285

    Lindo

    Lindo

    Lindo

    Lindo

    Joined:
    Nov 17, 2013
    Messages:
    63
    Likes Received:
    10
     
  6. Nov 4, 2018 #286

    Lindo

    Lindo

    Lindo

    Lindo

    Joined:
    Nov 17, 2013
    Messages:
    63
    Likes Received:
    10
    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
     

    Attached Files:

  7. Nov 4, 2018 #287

    fubuddy

    fubuddy

    fubuddy

    Active Member

    Joined:
    Oct 18, 2018
    Messages:
    25
    Likes Received:
    2
    Gender:
    Male
    Location:
    orange
    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
     
  8. Nov 4, 2018 #288

    fubuddy

    fubuddy

    fubuddy

    Active Member

    Joined:
    Oct 18, 2018
    Messages:
    25
    Likes Received:
    2
    Gender:
    Male
    Location:
    orange
    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
     
    Scott_M likes this.
  9. Nov 4, 2018 #289

    Foozer

    Foozer

    Foozer

    Well-Known Member HMEM Lifetime Supporter

    Joined:
    Nov 26, 2008
    Messages:
    1,163
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Retired
    Location:
    Camano Island, WA
    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: Nov 4, 2018
  10. Nov 4, 2018 #290

    fubuddy

    fubuddy

    fubuddy

    Active Member

    Joined:
    Oct 18, 2018
    Messages:
    25
    Likes Received:
    2
    Gender:
    Male
    Location:
    orange
    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
     
  11. Nov 4, 2018 #291

    Foozer

    Foozer

    Foozer

    Well-Known Member HMEM Lifetime Supporter

    Joined:
    Nov 26, 2008
    Messages:
    1,163
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Retired
    Location:
    Camano Island, WA
    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 . .
     
    fubuddy likes this.
  12. Nov 4, 2018 #292

    fubuddy

    fubuddy

    fubuddy

    Active Member

    Joined:
    Oct 18, 2018
    Messages:
    25
    Likes Received:
    2
    Gender:
    Male
    Location:
    orange
    ohhh queso...tried that , high gives me a click, low rotates stepper.
    switched motors same result, so bad driver ?
     
  13. Nov 5, 2018 #293

    Foozer

    Foozer

    Foozer

    Well-Known Member HMEM Lifetime Supporter

    Joined:
    Nov 26, 2008
    Messages:
    1,163
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Retired
    Location:
    Camano Island, WA
    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 . .
     
  14. Nov 5, 2018 #294

    fubuddy

    fubuddy

    fubuddy

    Active Member

    Joined:
    Oct 18, 2018
    Messages:
    25
    Likes Received:
    2
    Gender:
    Male
    Location:
    orange
    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
     
  15. Nov 5, 2018 #295

    Foozer

    Foozer

    Foozer

    Well-Known Member HMEM Lifetime Supporter

    Joined:
    Nov 26, 2008
    Messages:
    1,163
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Retired
    Location:
    Camano Island, WA
    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 . .
     
  16. Nov 5, 2018 #296

    fubuddy

    fubuddy

    fubuddy

    Active Member

    Joined:
    Oct 18, 2018
    Messages:
    25
    Likes Received:
    2
    Gender:
    Male
    Location:
    orange
    yes sir, thanks for all the help, ill report back if the new driver fixes it or not.
     
  17. Nov 5, 2018 #297

    Foozer

    Foozer

    Foozer

    Well-Known Member HMEM Lifetime Supporter

    Joined:
    Nov 26, 2008
    Messages:
    1,163
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Retired
    Location:
    Camano Island, WA
    Yup - Tried to mimic the error but . . . So pulled the dir wire from arduino and tied it straight to gnd -> motor runs one direction, to +5 volts, motor runs the other way.

    Till your driver comes in - - Bob . . .
     
  18. Nov 5, 2018 #298

    Foozer

    Foozer

    Foozer

    Well-Known Member HMEM Lifetime Supporter

    Joined:
    Nov 26, 2008
    Messages:
    1,163
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Retired
    Location:
    Camano Island, WA
    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: Nov 5, 2018
  19. Nov 8, 2018 #299

    dwk

    dwk

    dwk

    Member

    Joined:
    Oct 20, 2018
    Messages:
    13
    Likes Received:
    2
    Gender:
    Male
    Location:
    united kingdom
    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.
     
  20. Nov 8, 2018 #300

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,292
    Likes Received:
    149
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    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: Nov 8, 2018

Share This Page