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. Aug 30, 2017 #261

    sns5400

    sns5400

    sns5400

    New Member

    Joined:
    Apr 12, 2013
    Messages:
    3
    Likes Received:
    1
    Hello,
    This look fine but, i try to compile this for the arduino uno, and get a error missing Boolfield.h can i find this somewhere ?
     
    weir-smith likes this.
  2. Aug 30, 2017 #262

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    That file is part of the LCD library. PLease start again on this thread.
    http://www.homemodelenginemachinist.com/showthread.php?t=25091
    Make sure you read it all and update the procedure as per my post near the end of the thread.
     
    xpylonracer likes this.
  3. Aug 31, 2017 #263

    sns5400

    sns5400

    sns5400

    New Member

    Joined:
    Apr 12, 2013
    Messages:
    3
    Likes Received:
    1
  4. Aug 31, 2017 #264

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    You have just learnt that nothing on the Arduino is plug and play :)

    I would say your LCD/keyboard shield is not compatible with the Freetronics hardware this was designed for. If you go to www.freetronics.com.au you should find the resistor values they use for the keyboard together with examples that show the cutoff values for each button. Then compare the values with your hardware. If you go through this thread, you will find an example how another member modified the library code for different hardware.

    Or you could take the easy way out and order a freetronics shield. :mad:
     
  5. Sep 1, 2017 #265

    sns5400

    sns5400

    sns5400

    New Member

    Joined:
    Apr 12, 2013
    Messages:
    3
    Likes Received:
    1
    Hello,
    i have the same problem, of my keys only right button work.
    Its a robot shield with 6 button.

    Is it possible to upload your LCD.cpp file

    Thank in advance

    Pieter
     
  6. Sep 1, 2017 #266

    Foozer

    Foozer

    Foozer

    Well-Known Member HMEM Lifetime Supporter

    Joined:
    Nov 26, 2008
    Messages:
    1,162
    Likes Received:
    69
    Gender:
    Male
    Occupation:
    Retired
    Location:
    Camano Island, WA
    DFRobot? Two versions different return values .
    From their info page . . .
    if (adc_key_in > 1000) return btnNONE; // For V1.1 us this threshold if (adc_key_in < 50) return btnRIGHT; if (adc_key_in < 250) return btnUP; if (adc_key_in < 450) return btnDOWN; if (adc_key_in < 650) return btnLEFT; if (adc_key_in < 850) return btnSELECT; // For V1.0 comment the other threshold and use the one below: /* if (adc_key_in < 50) return btnRIGHT; if (adc_key_in < 195) return btnUP; if (adc_key_in < 380) return btnDOWN; if (adc_key_in < 555) return btnLEFT; if (adc_key_in < 790) return btnSELECT; */
     
  7. Nov 23, 2017 #267

    fugalguido

    fugalguido

    fugalguido

    Member

    Joined:
    Aug 3, 2017
    Messages:
    9
    Likes Received:
    0
    Very frustrated, can someone please help me?.What is the proper operation of the buttons ( owners manual)? When it boots up it shows divide #... up/down starts. If I push select, it goes though various main menus. What button do I push to select ( lets say configure ). When I push the right button it seems to mimic the select button but in the opposite direction of the menus.
     
  8. Nov 23, 2017 #268

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    The reason why you are frustrated is that you are using different hardware to what was specified. Arduino is not a plug and play environment. Therefore, it is up to you to change the code to suit your hardware or if you can't do that, adopt the exact hardware that has been specified in terms of the Arduino itself and the LCD display shield.

    The reason why your buttons do not work as expected is that the random LCD shield you have used uses different resistor values for the buttons on the analog port to what the original Freetronics shield uses.

    Some people have modified the button handling code in the LCD library for different hardware and shared their results here. If you wish to persist with your current hardware then find that code, review the documentation for your LCD shield and that of the Freetronics shield, make your modifications and your buttons should work.

    This is not an entry level Arduino script or a tutorial on how to use the Arduino, nor is this a software forum. The LCD library, my extensions to it and my interrupt code push the poor little Arduino UNO to the limits and required terse and efficient code written for specific hardware. If you adopt different hardware, its up to you to take the time to READ the whole thread as chances are somebody has solved the problem before you.
     
  9. Nov 23, 2017 #269

    fugalguido

    fugalguido

    fugalguido

    Member

    Joined:
    Aug 3, 2017
    Messages:
    9
    Likes Received:
    0
    I don't know if the buttons are working correctly or not. I don't want a chase a problem that doesn't exist . I need a discussion on the operation of said buttons or a flow chart. I could find no dicussion on the operation of this software from a button operation viewpoint in the three plus threads on this board, if there is, could some please point where this is located. I know about the analog to read values in to the A0 pin between different boards.
     
  10. Nov 24, 2017 #270

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    You've told me you have a problem. I've told you what your problem is. Its up to you to either use the supported hardware or modify the code to suit your hardware. There is no need for discussion except to say:

    The original LCD library was written by a third party specifically for the Freetronics LCD display. His code is on github and I did link to it in these threads by way of acknowledgement. I originally had commenced writing my own number entry routines and menuing system but his were so good, I adopted his library and extended it as I was using Freetronics hardware. His library is high performance and uses a separate C program designed to run on a desktop pc to generate the keystroke handling routine based on the resistor values so his code is very cryptic in that area.

    Some people on this forum replaced his high performance generated code with their own and shared it on this thread. It is possible to modify his generator code to write to the Arduino Serial port so it can display the required code so you can cut and paste it.

    I extended some of his input routines to handle different number formats including entering degrees, minutes and seconds. But the fact remains it is written for specific Freetronics hardware......

    So finally to be 100% clear, to get your keyboard working it's not my code you need to modify but the third party LCD library I have used.
     
  11. Nov 24, 2017 #271

    fugalguido

    fugalguido

    fugalguido

    Member

    Joined:
    Aug 3, 2017
    Messages:
    9
    Likes Received:
    0
    Ok, got the buttons to work thanks to Torfilli's(sp) LCD.cpp code. But I need some operator directions as I mentioned previously on the use of the menu's. When I get to the setup menu and go to setup the step pin #, to say pin#2, I change it to from 1 to 2 the up down buttons, then rotate through to the Save and select yes, then hit select button. It doesn't save. It appears to reboot, when I go back to the setup menu Step pin is still at #1.



    Again to be 100% clear, I need a operators manual or instruction on the use of the menus, not a discussion on the hardware.


    Also another question where to you hook up the enable control from the drive. On my previously used programs a pin was defined for enable.
     
  12. Nov 25, 2017 #272

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    Well it seems to me that a discussion on the hardware resolved your buttons issue.

    I don't have a configured Arduino to guide you so am unable (and unwilling) to document a user manual.

    Hitting save in the setup menu will save the parameters to the UNO's EEPROM and it should be read from there on startup. And yes, it reboots at this point to force reload of the new config. Oh wait, you are not using a UNO are you? A 32 bit Arduino might be a bit different in the EEPROM department. As I said use different hardware, you are on your own.

    Configs are numbered sequentially from 0 and the current default config # is saved in eeprom and loaded on startup. Its possible your system is getting confused and not loading the config you changed. Load Config 0 and see if its correctly configured. Turn it on and off and see if the same config is loaded and check the parameters after startup. There is also a linear config type that might be used for drilling holes or as a milling machine table motor drive so make sure its a rotary config you are using.

    If you go through the various #defines at the start of the program, you should be able hardcode the default step and direction pins but that will probably break the multiple config functionality (which also depends on the EEPROM anyway).

    In my experience, the stepper enable signal is actually a disable signal so if it goes to +5v, it disables the stepper motors. Documentation for the stepper drivers I have does not recommend connecting it. If you wanted to add an estop button, you could steal 5 volts from the Arduino (unless its a 3.3 volt variety) and pass it through the estop button to the drive (dis)enable input. You'd just need to check which state (high or low) disables the drives.

    Many people are using this software without an ounce of trouble and you are the first to report issues loading configs. It will be related to your hardware.
    Let me know how you get on.
     
  13. Nov 25, 2017 #273

    fugalguido

    fugalguido

    fugalguido

    Member

    Joined:
    Aug 3, 2017
    Messages:
    9
    Likes Received:
    0
    Thanks for the reply. Yes, an UNO. Here what I did on your recommendation , Changed the DIR to 0, changed the STEP to 0, hit Save=yes. After rebooting up, the Dir did change to a 0, but STEP stays at 1. Went into the program IDE as per your advise, in the # define changed STEP_PIN to 0, uploaded, went into the setup on the UNO, STEP stayed at 1. The problem is with the STEP pin not changing states both thru the on board programing or the IDE (it is stuck on one) I also tried to change the STEP_PIN to a 4 in the #define , just see what would happen, no change stays at 1. Found another problem, can't change the #define DIR_PIN though the IDE, but can change it though the UNO and save it.

    So in summary;

    STEP pin can't be changed and saved at all from either the IDE or the UNO.

    DIR pin can't be changed and saved from the IDE, but can from the UNO.
     
  14. Nov 25, 2017 #274

    fugalguido

    fugalguido

    fugalguido

    Member

    Joined:
    Aug 3, 2017
    Messages:
    9
    Likes Received:
    0
    I just tried hooking up the Uno to the stepper driver using the pins the Uno is stuck on in RodW's program(Step pin 1 and dir pin 2), no movement in any function. I went back to Chuck's program and the Gary Liming program, everything works great using their programs. Did this to verify the drive, motor and wiring there ok. Have the config menu settings as follows DevTyp= Rotary /JgAn=30 seconds /DirP=2/StpP=1 /Stp/Rv=200 /M/step=1:1 /D/Rat=1:1 /MaxHz=10k /MinHz=5k, Also in the Contin menu (I am assuming this means continuous rotation) the only way to get out this menu is to reset the Uno, is this the way it is supposed to work?

    I did change the GoDivde portion(bug?) as you advised in the other thread after I got the keypad working. This Uno was just purchased in the last 6 months so it is up to date a far as the revisions. The keypad buttons seem to work properly now, so what could be the problem now.

    I could scope the two pins for switching signals, but like said they work on the other programs using those pins, so I don't think they're the problem. Whats next?
     
  15. Nov 25, 2017 #275

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    If you have to reset the UNO to escape out of Continuous Turn, I think there is still a button problem. The shields I used seemed to use very poor quality switches and I actually wore switches out when developing this sketch so I replaced the shield as I had similar problems to what you are experiencing. I would check the button function with a simple sketch (hopefully provided by your shield manufacturer) to confirm all buttons work as expected and do not stick. (or scope the A0 output).

    From your settings, I might know what your problem is. But first let me explain the config settings

    StepP = Step Pin
    DirP = Direction Pin
    JgAn = the amount the table jogs in jog mode
    Stp/Rv = 200 = standard 1.8 degree stepper eg steps per revolution)
    M/step = Microstepping (eg. Gecko stepper driver would need 10:1)
    D/Rat = 1:1 this is the gearing ratio. a standard Rotary Table might be 90:1 or 40:1
    MaxHz = 10k this is the fastest speed (steps/sec) that the stepper will operate at
    MinHz = 5k this is the slowest speed the stepper will operate at. (stepper starts at MinHz and ramps up to MaxHz)

    I believe that your frequency settings are far too high for a 1:1 stepper config with no microstepping. From my experience, the average stepper maxes out at about 450 rpm. (7.5 rev per second)
    So the maximum frequency your stepper can operate at is 7.5 * 200 = 1500 steps per second (1.5k) and you have 10k.
    With my 10:1 microstepping, the maximum frequency I could do was about 15,000 but I backed off to 10,000 Hz to be safe. You should do the same
    You will need to set MinHz and MaxHz to say 750 and 1000 for native resolution

    With hindsight, pins 1 & 2 are not an an ideal choice because they are used for USB communications. You get some buzzing from the stepper if connected when uploading a new script. Selecting say pins 3 & 4 might be a better option which avoids this.
     
  16. Nov 26, 2017 #276

    fugalguido

    fugalguido

    fugalguido

    Member

    Joined:
    Aug 3, 2017
    Messages:
    9
    Likes Received:
    0
    So, the JgAn if this is set to 1 degree, then each push of the right or left button the table moves 1 degree?

    If it was working right, to get out of the continuous turn hit the Select button?

    I think that I am going to build the button circuit on a separate board using industrial quality buttons and some 1% resistors to mimic the keypad. I did high end audio/analog design for 20+ years so I have the parts.

    I will change the freq. setting to what you recommend and see what happens. I will report back, thanks.
     
  17. Nov 26, 2017 #277

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    Sorry about the cryptic prompts but they kept getting shorter as the memory got tighter. If it is not a faulty button, it is possible for some reason that you have a memory overflow error. This could occur if the later versions of the compiler consume more static RAM than the earlier compiler versions.

    However, I've not had any other reports of this happening from recent users of the sketch.

    Yes, JogAn sets how far a rotary table moves on each press of the jog buttons
    Yes, Select should Exit and go back one level in all of the procedures.
    When Continuous turning, it will ramp down down to a stop on exit.

    The code is very readable. All procedures that actually do something (as opposed to getting user input) start with "go" as in
    goDivide() and goConTurn()
     
  18. Nov 26, 2017 #278

    fugalguido

    fugalguido

    fugalguido

    Member

    Joined:
    Aug 3, 2017
    Messages:
    9
    Likes Received:
    0
    Is there a way to see if memory overflow is the problem? I am using 1.8.1. I see that the newest is 1.8.5.

    Also, if I mimic the button circuit on the keypad that you used, I should go back to your original keypad/LCD program instead of Torfollis (sp) right, even though I am using the my LCD portion of the keypad?
     
  19. Nov 28, 2017 #279

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,125
    Likes Received:
    334
    There is no way of knowing except things stop working. Just shorten a few more menu prompts and see if things change. What the problem is that the Arduino stores text variable data in static RAM but on startup, it copies these over into limited dynamic global RAM, effectively creating 2 copies of each string. For unchanging menu text, this is very wasteful of resources. There is a way to use the static versions of strings using the PROGMEM definition but the text cannot be changed.

    The most useful extension anybody could make to this script would be to modify the LCD library so PROGMEM variables could be used for all of the menu prompts. This would free up an enormous amount of global memory.
     
  20. Jan 3, 2019 #280

    Harrih

    Harrih

    Harrih

    New Member

    Joined:
    Jan 3, 2019
    Messages:
    3
    Likes Received:
    0
    Location:
    Auckland NZ
    @rodw
    Hi there,
    I hope this thread is still being monitored.
    New to both this board and thread so hello to all.

    I am particularly intrigued by this thread as it solves many of the difficulties I have been facing attempting to implement more or less exactly what you have achieved here,
    so would like to try using your code and see how it goes.
    There are a couple of things i hope to slightly modify for my applications.
    First is to recompile it to run on a teensy3.2 micro so all the lcd stuff will have t change also pinouts etc.
    Other thing is to introduce backlash compensation, so that apart from incremental and continuous jog modes the motor always approaches the mark from the same direction
    (even if that means overshooting and then backing up).
    I understand this project is somewhat historical so probably well out of mind by now
    but if you had any suggestion re the best place to start inserting backlash compensation would be appreciated.
    There are 2 applications where I would find this very useful
    1 being a rotary table for a small machining centre
    the second as a downfeed for a surface grinder where measurements are in microns and the work must always be approached from one direction

    Hope to hear from you
    regards
    Harry
     

Share This Page