1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

New XPID software for Arduino UNO/Mega and Sabertooth (with LCD !!)

Discussion in 'SimTools compatible interfaces' started by vthinsel, Apr 1, 2015.

  1. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    Hello,

    Sabertooth 2x60 doesnt look to have a usb connector. There should be a way to configure it using a serial connection instead. check the sabertooth documentation
    For the code, I have stopped using uno/LCD and moved to mega/TFT. The first goal would be to be able to compile the sketch. I tried to compile it, and it failed but with a different issue than yours: you do not have the menubackend properly installed in the Arduino/libraries folder.

    Attached Files:

  2. Pierre Lalancette

    Pierre Lalancette Sir Lalancelot Gold Contributor

    Joined:
    Dec 11, 2016
    Messages:
    949
    Occupation:
    Tech Artist
    Location:
    Quebec, Canada
    Balance:
    7,719Coins
    Ratings:
    +892 / 6 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, 6DOF
    I have updated my arduino and I added the backend library that I could not find yesterday. Yesterday, nothing worked for me. I guess it was the forthcoming of a 50cm of snow that made me not patient and so grumpy. So, now that I am stuck at home, I tried to download everything again and add the library. This is now what I get.
    Arduino: 1.6.14 Hourly Build 2016/12/19 06:33 (Windows 10), Board: "Arduino/Genuino Uno"
    Build options changed, rebuilding all
    XPID_SimTools_3.13:134: error: 'menuUseEvent' was not declared in this scope
    MenuBackend menu = MenuBackend(menuUseEvent, menuChangeEvent);
    ^
    XPID_SimTools_3.13:134: error: 'menuChangeEvent' was not declared in this scope
    MenuBackend menu = MenuBackend(menuUseEvent, menuChangeEvent);
    ^
    exit status 1
    'menuUseEvent' was not declared in this scope

    I also done research on SilentChill build that used Arduino and Sabertooth 2x60. So I may end up using the SMC3 code he is using to finish my testing. To use your code, I may update to a Arduino Mega with a touch screen later. But, if you want to keep on debuging your code, I am willing to help you as much as I can and I will look into the sabertooth doc.

    Merci.
  3. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    This is the error I also get. I suspect the arduino framework is the culprit. I'll try to find out which version worked with it, but the mega + tft rocks :)
  4. Wanegain

    Wanegain Active Member

    Joined:
    Nov 6, 2013
    Messages:
    564
    Location:
    Bruxelles
    Balance:
    1,971Coins
    Ratings:
    +298 / 2 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 4DOF
    • Useful Useful x 1
  5. Pierre Lalancette

    Pierre Lalancette Sir Lalancelot Gold Contributor

    Joined:
    Dec 11, 2016
    Messages:
    949
    Occupation:
    Tech Artist
    Location:
    Quebec, Canada
    Balance:
    7,719Coins
    Ratings:
    +892 / 6 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, 6DOF
    Yes, it compile and transfert now. But that`s about it.
    I set the switch on the sabertooth, connected arduino 3 to S1, 2 to the ground (no screen), the pot to A1, ground, 5v, and then I started simtool to provoc some movements.
    Nothing of course, as I have no Idea how to use all this. No lights blinking on the arduino during simtool manipulation. It does look like it is communicating at all.
  6. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    Well well weel.... You need to configure some values using the LCD, configure Simtools properly (axes, interfaces,...) and test,test,test. Before using XSim, you can send positions to the arduino using a serial console (I use https://sites.google.com/site/terminalbpp/ )
    The learning curve is a tough journey, but it is worth the investment.

    In the code, uncomment the #define DEBUG on line 49 so you get some output on the arduino console and upload the sketch again. This is to help you to troubelshoot, then remove it for "production" usage when everything is OK.

    Bon courage !
  7. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    I did a quick test using a standalone arduino nano, checking the console (at 19200 bps, which should math the sabertooth speed by the way). Here is the output I got:

    --------------
    EEPROM Content
    --------------
    Var Address size val
    EEInit 52 2 313
    M1.getMax() 2 2 65535
    M1.getMin() 4 2 1
    M2.getMax() 6 2 1021
    M2.getMin() 8 2 1
    FeedbackPotDeadZone1 10 2 0
    FeedbackPotDeadZone2 12 2 4
    M1.getK() 14 4 1.00
    proportional1 18 4 nan
    integral1 22 4 nan
    derivative1 26 4 nan
    M1 Stdby 54 2 512
    M2.getK() 30 4 1.00
    proportional2 34 4 nan
    integral2 38 4 nan
    derivative2 42 4 nan
    M2 Stdby 56 2 512
    DeadZone 46 2 4
    ReadAnalog 48 2 8
    SabertoothType 50 2 65535
    ------------
    Current Vars
    ------------
    Var val
    EEInit 313
    M1.getMax() -1
    M1.getMin() 1
    M2.getMax() 1021
    M2.getMin() 1
    FeedbackPotDeadZone1 0
    FeedbackPotDeadZone2 4
    M1.getK() 1.00
    proportional1 nan
    integral1 nan
    derivative1 nan
    M2.getK() nan
    proportional2 nan
    integral2 nan
    derivative2 nan
    DeadZone 4
    ReadAnalog 8
    SabertoothType -1
    EEPROM XPIDVERSION:313
    XPIDVERSION:313
    EEPROM OK.
    Starting navigation:
    Up: u Down: d Left: l Right: r Use: e
    Menu change "MenuRoot" TO "Showtime !"
    Menu change "Showtime !" TO "Motor 1"
    Menu change "Motor 1" TO "Showtime !"
    Menu change "Showtime !" TO "Reset"
    Menu change "Reset" TO "Global Settings"
    Menu change "Global Settings" TO "Dead Zone"
    Menu change "Dead Zone" TO "Read Analog"
    Menu change "Read Analog" TO "FeedbackMax1"
    Menu change "FeedbackMax1" TO "FeedbackMin1"
    Menu change "FeedbackMin1" TO "FeedbackMax2"
    Menu change "FeedbackMax2" TO "FeedbackMin2"
    Menu change "FeedbackMin2" TO "ST 1=2.25 2=2.32"
    Menu change "ST 1=2.25 2=2.32" TO "Global Settings"
    Menu change "Global Settings" TO "Dead Zone"
    Menu change "Dead Zone" TO "Read Analog"


    It has the same issue as the TFT version, which I corrected recently. In the menu, goto "reset EEPROM" to get rid of the nan value.
    What we can see is that if the LCD shield is not mounted, the floating pins create noise that the menu interprets wrongly.... is not using the shield, wire some resitors to represent the voltage splitter (diviseur de tension).

    Once you fix this, it should run smoothly.

    Note that you should check if your sabertooth is more like a 2*25 or 2*32 and change the setting accordingly in the menu

    Bonne chance !
    • Informative Informative x 1
  8. Wanegain

    Wanegain Active Member

    Joined:
    Nov 6, 2013
    Messages:
    564
    Location:
    Bruxelles
    Balance:
    1,971Coins
    Ratings:
    +298 / 2 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 4DOF
    It's exactly what I was thinking he needed to do first.
  9. Pierre Lalancette

    Pierre Lalancette Sir Lalancelot Gold Contributor

    Joined:
    Dec 11, 2016
    Messages:
    949
    Occupation:
    Tech Artist
    Location:
    Quebec, Canada
    Balance:
    7,719Coins
    Ratings:
    +892 / 6 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, 6DOF
    Thanks, I'll try to find the time to try this weekend. Like you said, a tough learning curve.
    19200 bps, noted. Don't know if it is more like a 2*25 or 2*32.
  10. Pierre Lalancette

    Pierre Lalancette Sir Lalancelot Gold Contributor

    Joined:
    Dec 11, 2016
    Messages:
    949
    Occupation:
    Tech Artist
    Location:
    Quebec, Canada
    Balance:
    7,719Coins
    Ratings:
    +892 / 6 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, 6DOF
    I got it working with my Arduino uno using smc3 code.
    6 DOF from scratch
    Still, I ordered your touch screen and funduino compatible mega clone. To do some test, they were not to expensive. Will post again when I'll receive them.
  11. mirkobastianini

    mirkobastianini Active Member

    Joined:
    Jan 23, 2017
    Messages:
    193
    Occupation:
    informatic
    Location:
    italy
    Balance:
    1,300Coins
    Ratings:
    +77 / 2 / -0
    My Motion Simulator:
    2DOF
    Hi,

    i've read this thread and I'm try to understand... I' building my sim, and in my original plans I've thinked to use JRK. Now I'm thinking to buy one 2x32 Saber (i'm building 2DOF, 12A motor)...I already have Arduino Mega.

    This is the best choice for software with Arduino Mega? With this I can easy control parameter without using SMC3?

    thanks
  12. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    Hello,

    It is a choice, maybe not the best. It is up to you to try several ones and pick the one that suits you. Indeed, this one doesnt rely one SMC3. All parameters are done through the touchscreen (dead zones, reactivity, ....)

    Edit: I just realized I didn't release the latest version.... will be online in a couple of hours. Sorry for that.
  13. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    I updated the first post with the latest version. It is also available on github here : https://github.com/vthinsel/XPID
    I'll post a video one of these days....
    • Like Like x 4
  14. Meawto

    Meawto Sorry for bad English ;'(

    Joined:
    Aug 10, 2015
    Messages:
    96
    Location:
    Thailand
    Balance:
    - 336Coins
    Ratings:
    +43 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    hi i have problem with my touch screen. the touch is not working with your libraries. I have test with tftpaint.ino "https://github.com/adafruit/TFTLCD-Library" and the touch screen are fine(but it write in the reverse picture)
    what wrong is its ? can you help me ?

    ps.i think i use ILI9325 driver 2.8" Touch Screen

    Last edited: Jul 24, 2017
  15. graz

    graz New Member Gold Contributor

    Joined:
    Aug 19, 2014
    Messages:
    25
    Occupation:
    mechanic
    Location:
    melbourne australia
    Balance:
    - 28Coins
    Ratings:
    +21 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    just wanted to say a big thanks to @vthinsel for the code with tft, makes changing pid settings on the fly very easy and together with @RufusDufus simple scope made setting the whole rig up fairly simple. Here are my final pid settings, some shots of the scope and a test video, I think it is all working very nicely.
    If I should be posting some of this somewhere else or you want me to start a new thread with my build let me know.
    P.S. the bad driving in the video cos I was using the laptop and keyboard to drive.

    Attached Files:

    • Like Like x 3
    • Friendly Friendly x 1
    Last edited: Oct 22, 2017
  16. CPSNine

    CPSNine New Member

    Joined:
    Apr 9, 2017
    Messages:
    6
    Location:
    Canada
    Balance:
    277Coins
    Ratings:
    +2 / 0 / -0
    Hello @vthinsel (and others).
    I am just starting with Motion sim. and the motor control part is by far the thing I struggle most with.

    By reading the forum I decided to go with a Sabertooth 2x32 for the 2DOF seat mover I am planing to build (and two motors 1:25 from pgsaw).
    I also decided to go with an Arduino mega as you seemed to say clones are not a problem, they are not that much expensive than Uno.
    However I am not sure if I should or not go the TFT display route with your code or not.
    It seems to be described for advanced users and I have absolutely no knowledge of Arduino coding or motor control.
    Also I don't totally understand what the displays really add to the simulator itself (my understanding is it regards settings but that is pretty much it).

    I guess my question is, as a novice, should I stick with the @BlazinH version for simplicity.
    Also, aside from the TFT functionality, is there any other major differences between the two codes.
    Is there any limitations, with one or the other, if you want to add a 3rd motor for an extra DOF later.

    Thanks.
  17. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    439
    Location:
    FRANCE
    Balance:
    6,010Coins
    Ratings:
    +564 / 2 / -0
    My Motion Simulator:
    Arduino, 4DOF
    Hello,

    TFT allows quick and efficient tuning as it displays graphically the behavior of the PID algorithm so you can check latency of the system.
    The LCD allows tuning but no visualization (which you can have in // using an oscilloscope). I stopped updating the dev of the LCD, so the TFT is more robust and behaves better.
    Both LCD and TFT are for 2 DOF. Adding a DOF is feasible, but not in my plan yet.
    • Like Like x 1
    • Informative Informative x 1
  18. miaziol

    miaziol New Member

    Joined:
    Dec 20, 2020
    Messages:
    29
    Location:
    Poland
    Balance:
    - 77Coins
    Ratings:
    +13 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Hello I try to make it but I have problem with calibration. I try change pins but it nothing change
  19. miaziol

    miaziol New Member

    Joined:
    Dec 20, 2020
    Messages:
    29
    Location:
    Poland
    Balance:
    - 77Coins
    Ratings:
    +13 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Ok i find answer, install new Touchscreen library, and everything works fine. Now time to test rest :D
    • Like Like x 1