Tips for Arduno software for Rotary Table Controllers

Discussion in 'Software and Programming' started by rodw, Feb 8, 2015.

Help Support HMEM by donating:

  1. Feb 18, 2015 #41

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    I downloaded your code, Rod, and it will not compile. Many errors. Are you using the libraries that came with the Arduino IDE, or new ones?.
    First error is " 'LCD' does not name a type."

    Chuck
     
  2. Feb 18, 2015 #42

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
  3. Feb 18, 2015 #43

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    It works on my arduino, but I dont have a stepper motor to try it with. I LOVE the menu, and the method of entering numbers, its just what I was planning. GREAT JOB

    A couple of issues I found...

    After program set and running, the display shuts off after 30 seconds. This would happen while cutting a gear tooth and appears to be power saving feature that may have been copied from another sketch?

    The user must hit a key to reactivate the display, then hit right button to advance the rotary table. I'd prefer to have the display remain active. I doubt anyone is using battery power so power conservation not an issue.

    Issue two, when setting degrees if you mistakenly enter a value in the 100's of degrees column (say 100 00' 00") there is no way to clear the 100's integer value back to zero, you are stuck with either 1, 2 or 3. The only option is to reset the arduino and start over. This could be fixed to allow zero as a valid input

    Question, would it be easy to change the ratio and math to make this work to control a non rotary table indexing head with 5 to 1 ratio with the obvious limitation on step resolution to 0.36 deg per step?

    photo.jpg
     
    Scott_M likes this.
  4. Feb 18, 2015 #44

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
    Hi Rod

    Very nice work !
    I had a few minutes at lunch time to try it, Everything works great. I also agree with TB about the screensaver. But I just increased the wait time to 3 minutes, which I think will be fine for now. A lot will depend on what has to be done when you get to the indexed position.

    Thank you so much for all of your hard work, it is appreciated very much !

    Scott
     
    TorontoBuilder likes this.
  5. Feb 18, 2015 #45

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    I thought I'd try to make a quick change to see how easy this sketch would be to adapt to a more basic indexing head.

    I changed the step resolution to 1000 to reflect 200 full steps per motor x 5 for the 5 to 1 gear ratio. Then I programmed in 6 deg per step... but the math converted to 62 steps when the result should have been 60 teeth...

    see image 1

    I then tried 1200 steps per revolution and got a good result for that one gear setting at least...

    see image 2

    anyway I'll have to play with this more to understand the math and rounding the sketch is doing.

    photo (1).jpg

    photo (2).jpg
     
  6. Feb 18, 2015 #46

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    The timer library link shows 2 libraries. Which one do I need?
    I have the Sainsmart LCD. I will try it with that.

    Chuck
     
  7. Feb 18, 2015 #47

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
  8. Feb 18, 2015 #48

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    The newest one... check the dates. I had no trouble with my sainsmart lcd display and keypad.
     
  9. Feb 18, 2015 #49

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    Thanks to these threads on the arduino and rotary tables I have finally gotten the motivation to dig out my hemingway rotary table kit.

    Sadly I'm still not up and running on my lathe thanks to the utter incompetence of the busybee tools recommended delivery stooge.
     
  10. Feb 18, 2015 #50

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    I can't get Rod's sketch to work. It loads, I can set divisions, but the stepper doesn't move, and successive steps give a garbled display.
    I'm back to using Chuck F's sketch, and will give my poor brain a rest.

    Chuck
     
  11. Feb 18, 2015 #51

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
    Hi Chuck

    Did you switch the step and direction pins ?
    Chucks used 2 & 3
    Rods uses 1 & 2

    I am pretty sure I just had to move the wire from 3 to 1 , 2 stayed where it was.


    Scott
     
    darkoford likes this.
  12. Feb 18, 2015 #52

    darkoford

    darkoford

    darkoford

    Member

    Joined:
    Dec 9, 2014
    Messages:
    11
    Likes Received:
    3
    Try :

    #define stepPin 1
    #define dirPin 2

    replace:

    #define stepPin 2
    #define DirPin 1


    Or if you are using some other pins.
     
  13. Feb 18, 2015 #53

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Wow guys, 2 pages of comments while I was sleeping!

    I have edited post #1 to point to the posts with the latest code and will maintain that over time As I add new versions.

    A couple of things:

    All parameters you need # steps, stepper pins etc are all configurable in the #defines and global variables at the top of the sketch. I had to change the pins because of a conflict with the freetronics board.

    To change a value from say 100 degrees to 90 degrees, position the cursor in the tens column, not the hundreds, and the down button will let you change the hundreds. This code is in the degreefield files that are part of the LCD library. I wrote this new class based on tbe existing time field datdata type. I did not want the cursor to be left hanging. Maybe I can change how this works.

    The maths looks convoluted. It got confusing. Initially, I was simply calculating the number of stepper steps per division. Then when we wanted to enter an arbitrary angle, I changed it so that the stepper steps is calculated from the angle. The angle is maintained internally in seconds so it does not need to muck about with odd data types. Eg 1 degree is internally stored as 3600 seconds. The number of seconds in a circle is WAY more than any conceiveable number of stepper steps in a circle so the conversion maths seems to still be accurate so I settled on this for all divisions. The code that uses float data type basically simply calculates the ratio for the entered angle vs 360*60*60 seconds in a circle then multiplies that by the number of steps in a circle. If I did not use a float, we got rounding errors.

    If the Screen saver triggers, the stepper dividing functions won't be affected as the interrupt routine still runs in the background. The keystroke that enables the display and it gets eaten so it does not affect anything. Eg. does not trigger another division! You can comment out the call in the setup () function.

    So a question. Should the number of divisions be entered as an arbitrary number like the angles are entered? Currently it starts at 1 and goes up or down 1 step at a time.
     
    Scott_M and darkoford like this.
  14. Feb 18, 2015 #54

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    Chuck just modify these two entries:
    #define stepPin 1
    #define dirPin 2

    changing to this:

    #define stepPin 3 //Digital Pin 3 outputs Step Execution
    #define dirPin 2 //Digital Pin 2 outputs Step Direction

    assuming your system kept Chuck Fellow's program unmodified.

    Always try to change software before hardware...
     
  15. Feb 18, 2015 #55

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    divisions shud be entered as arbitrary number like angles are entered if possible... entering 60 sucks at present.

    Not sure I followed how to comment out the screen saver...

    Do I change this code:
    lcd.enableScreenSaver(30);

    to this:
    lcd.enableScreenSaver();
     
  16. Feb 18, 2015 #56

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    I changed the step and direction parameters to match my physical setup. I used 4 and 3.

    Chuck
     
    TorontoBuilder likes this.
  17. Feb 18, 2015 #57

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    When stepping by degrees, the number of steps (62) is meaningless as it is the number of steps per stepper movement that counts. You'd need to check that the stepper is actually moving 6 degrees. I am pretty sure it will be. I reused the same procedure to save code space, maybe the "of 62" should not be displayed in this case. If you think about it, if you set a movement of 300 degrees, it is not an equal division of a circle.

    Hopefully the error you observed has on affect on the code.
     
    TorontoBuilder likes this.
  18. Feb 18, 2015 #58

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    I think the "of 62 error" error is here
    on line 214 in enterDegrees()
    Code:
    divisions = STEPS_PER_REV /  stepsPerDiv;  
    this should be linked to degrees for greater acuracy

    I have not tried it, but I think it should be like
    Code:
    divisions = (long)((float) MINUTES_IN_CIRCLE / (float) angleField.value());
    
     
    TorontoBuilder likes this.
  19. Feb 18, 2015 #59

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    I am sure that it doesnt help that 6 degrees isnt equally divisible by the 0.36 deg /step if I change div /rotation to 1000
     
  20. Feb 18, 2015 #60

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Change it to
    Code:
      //lcd.enableScreenSaver(30);
    to ignore this line of code (turn into a comment).

    To change the input so it does not suck, try changing Line 57 to
    Code:
    GetIntField divfField(divideForm, "Divisions", 1, 1000, 1, 3, " ");
    Working hours now so not playing with the script. if you get syntax errors, check the form example script for how to use it. I don't think there will be any flow on changes required.
    NOte this code sets the maxiimum divisions to 1000.
     
    TorontoBuilder likes this.

Share This Page