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 14, 2015 #21

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

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

    Thanks Rod !

    I have the SainSmart LCD. I will see if it is adaptable, if not I will get the FreeTronics, I like those buttons better anyway.

    Many Thanks

    Scott
     
    rodw likes this.
  2. Feb 15, 2015 #22

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Good luck with it Scott. I connected a NEMA 23 stepper up to my 90:1 Vertex 6" rotary table today and with a few tweaks, it works!

    Initially, I was missing a few steps so I experimented with changing the Timer delay and slowed it down to get more torque. I also swapped the values around for the Direction.

    Code:
    #define CLOCKWISE     LOW
    #define ANTICLOCKWISE HIGH
    #define TIMER_DELAY 80
    
    I took a few photos of how I attached the stepper to the table so will post them up later this evening. First time I broached a keyway and it worked nicely.

    I just held the Stepper in my hands at this stage. The next "step" is to make the mount to attach it permanently. I was never sure if the stepper I had was strong enough to drive the table.
     
  3. Feb 15, 2015 #23

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Photo time.

    First all of the hardware
    [​IMG]

    The Arduino and Freetronics Terminal Shield with the LCD display on top. The Gecko GX251 Micro drive stepper driver. It is being powered by a 19 volt laptop power supply. You can see I have used a flexible coupler for the stepper motor.

    [​IMG]

    In business mode!

    THis is the Gecko controller

    [​IMG]

    Here is the 6" Rotary table with the handle removed
    [​IMG]

    The shaft is 12mm and the keyway is 4mm. The diameter of the backplate is 56mm. I have some 55mm round stock here that will be perfect to make the mount from. You can see the plate at the back has some M5 threaded holes in it. I made these on a PCD of 32mm.

    So I decided if I made a 20mm long collar with a 12mm bore, I could broach a keyway in it.

    Then all I'd need to do would be to make a 20mm long adapter shaft that was M12 at one end (with a keyway milled in it) and 8mm to match the stepper shaft at the other.

    Sorry, but when I checked my stock of keys, I did not have a 4mm one so I had to file one down and I ended up pressing it in (it's tight!) so no photo of the adapter shaft but you'll get the idea.

    [​IMG]

    I did not bother to add a set screw here as once its assembled, it can't fall apart. I have to get M3 set screw though!

    And here's the other end that will mate up with the rotary table shaft.

    [​IMG]

    So here is it all in place!

    [​IMG]

    Initially, I made the collar out of 19mm dia aluminium and thought there might not be enough meat for the keyway so I remade it out of 25mm. I should have used the original one! I've since turned the collar down to 20mm to make it easier to gain clearance for the adapter.

    I've measured up the adapter and will draw it up properly, but it looks pretty straightforward. It will need a slot in it to reach the various set screws.
     
    Scott_M and darkoford like this.
  4. Feb 15, 2015 #24

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
    Success !!

    It works with the SainSmart LCD shield. I had to change my step and direction wires to 1&2 from 2&3. I also had to change the timer delay, 50 worked but I changed it to 60 for a little more margin of safety. I also added more delay to the screensaver(30) 10 sec was too short, the screen would blank before it finished making some moves requiring 2 button presses to go to the next position. I set div to 1 and timed it, with this power supply 21 sec. for 90 turns of the motor.

    You mentioned something about moving the cursor and entering values, was that something that will be implemented or should work now?
    If it should work now, either it does not or I can't figure it out.
    All the buttons seem to do what they are supposed to , up , down , left , right and select.

    This is more than sufficient for my needs , just curious about the cursor.

    Very well done sir !! Many thanks !

    Scott

    EDIT

    I just played with the Form sketch, The cursor moves there and I can change values. ???
     
  5. Feb 15, 2015 #25

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
  6. Feb 15, 2015 #26

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    is the complete working code posted somewhere?
     
  7. Feb 15, 2015 #27

    darkoford

    darkoford

    darkoford

    Member

    Joined:
    Dec 9, 2014
    Messages:
    11
    Likes Received:
    3
    Great Rod! Thm:

    I have a problem with the keys, how and where to make it right?

    Thank you!
     
  8. Feb 15, 2015 #28

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
    Yes, Post #20
     
  9. Feb 15, 2015 #29

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Ron, sorry, I missed this. I'd tried writing my own and then found a couple of promising libraries but they refused to play together. I dropped one and bave posted all of the required resources on post #20
    http://www.homemodelenginemachinist.com/showpost.php?p=261783&postcount=20

    So read on from there.
     
  10. Feb 15, 2015 #30

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Scott, awesome that you have got this up and running with so few changes. I was kinda hoping the keyboards were compatible with each other.

    I had thought of disabling the screen saver on entry to the godivide () function and reenabling on exit but your solution is probably better. It did not annoy me until i got out in the shed.

    Glad you sorted out the cursor as I didn't have a clue what I had said.
     
  11. Feb 15, 2015 #31

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
    Hi Rod
    The cursor works in the form sketch
    But not in your sketch, on my setup. Again, I am not really sure I need it, just giving feedback.

    Again, many thanks

    Scott
     
  12. Feb 15, 2015 #32

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    The Freetronics and SainsSmart are an analog keyboard so they use a single analog port with a series of resistors that alter the voltage to a known value when a key is pressed. Freetronics has a good description of how this works and the wiring diagram for them.

    If your keys are not analog keys then it won't work. If they are analog keys, search in the LCD library code for call to an analog read and review the code there. Change it to values that suit you. Or make your own keyboard and use the resistor values Freetronics uses. You can change the analog port when you create the LCD variable.
     
  13. Feb 16, 2015 #33

    darkoford

    darkoford

    darkoford

    Member

    Joined:
    Dec 9, 2014
    Messages:
    11
    Likes Received:
    3
    This is what I use.
    [​IMG]

    At Chuck first version worked like this:

    if (adc_key_in < 60) return btnRIGHT;
    if (adc_key_in < 200) return btnUP;
    if (adc_key_in < 400) return btnDOWN;
    if (adc_key_in < 880) return btnLEFT;
    if (adc_key_in < 950) return btnSELECT;

    My C ++ is bad so now I do not know where I change the value in your program.

    Thanks for your help!
     
  14. Feb 16, 2015 #34

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Assuming you have made your own keyblard as per the circuit shown, and are not using a pre made shield, you could replace your resistors with the values shown here
    http://www.freetronics.com.au/pages/16x2-lcd-shield-quickstart-guide#.VOFbeZt47MI

    That would provide compatability with the Sainsmart and Freetronics boards which might be a good thing.
     
    darkoford likes this.
  15. Feb 16, 2015 #35

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Ok, modifying the code to use different resistor values is not simple.

    In LCD.cpp, this code needs to be modified
    It is generated by a separate program (genlookup.c) designed to run on a desktop PC. The program is here and is part of the LCD library I linked to in post #20.
    https://github.com/rweather/arduinolibs/blob/master/gen/genlookup.c

    So what you have to do is to establish the values returned by each button by an analog read, Then modify genlookupc.c

    and change these values

    Code:
    #define LCD_BUTTON_VALUE_GAP    10
    #define LCD_BUTTON_RIGHT_VALUE  0
    #define LCD_BUTTON_UP_VALUE     145
    #define LCD_BUTTON_DOWN_VALUE   329
    #define LCD_BUTTON_LEFT_VALUE   505
    #define LCD_BUTTON_SELECT_VALUE 741
    Then compile and run the program and insert the output into LCD.cpp

    You could run this generator on an Arduino if you modify genlookup.c to use serial.print to print it to the serial port.
     
  16. Feb 16, 2015 #36

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Just added a new feature for jogging.

    Left and right button turn the table either direction while the button is held down.
    Up and down button moves left or right 1 single step.

    Initially I though this code was not working with my microstep drive but if you hold you hand on the stepper, you could just feel the slightest bump (angle is 0.8 seconds) so I changed it to 10 steps. eventually, I will make this user configurable.

    Give me a few more days to add a bit more to it before I post up the code.

    Speed control, home position memory, and enter a dividing angle in DMS still to come.
     
    Scott_M likes this.
  17. Feb 16, 2015 #37

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
    Very Cool !!

    Scott ( your faithful beta tester )
     
    rodw likes this.
  18. Feb 16, 2015 #38

    darkoford

    darkoford

    darkoford

    Member

    Joined:
    Dec 9, 2014
    Messages:
    11
    Likes Received:
    3
    Resistance values are the same on my schedule as well as on http://www.freetronics.com.au/pages/16x2-lcd-shield-quickstart-guide#.VOFbeZt47MI

    I think the problem was the length of the wires that were not coax so that the issue is resolved one capacitor.

    It would be good to add in parallel to each key by a capacitor cca.100nF.

    [​IMG]

    Thanks for your help!

    Btw. It would be good to do (do not know his name) and this possibility

    [​IMG]
     
    rodw likes this.
  19. Feb 18, 2015 #39

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,132
    Likes Received:
    334
    Hi guys, I've attached an update for my faithful beta testers. The code has been changed quite a lot so beware any bugs!

    We now have the following features:
    1. Menu has changed to make it flatter. To open a menu procedure, press the up or down arrows
    2. Pressing Select exits a procedure.
    3. Divide feature entering # of divisions
    4. Divide feature by entering Degrees, Minutes, Seconds. Cursor left and right along the field and change digits with the up and down buttons. Press Select to move to operation
    5. Jog function. Rotary Table operates continuously while the left or right button is held down. Up and down button moves stepper NUMBER_JOG_STEPS each button press. This should let you get a perfect setup if say you wanted to drill holes in the side of a hex bar.

    The other feature I want to add is the ability to remember a home position and be able to return to that position by simply pressing a button. That needs a bit of thought as the distance from home needs to be maintained within the ISR procedure.

    View attachment RotaryTableChuck2.zip
     
    Scott_M, darkoford and TorontoBuilder like this.
  20. Feb 18, 2015 #40

    Scott_M

    Scott_M

    Scott_M

    Well-Known Member

    Joined:
    Apr 13, 2013
    Messages:
    251
    Likes Received:
    76
    Location:
    Medina, Ohio USA
    Hi Rod
    I may have time later today to give this a try. Sounds like a bunch of new features. I hope the cursor works for me now.
    I will report back.

    Thanks again

    Scott
     
    rodw likes this.

Share This Page