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

Simtools output and Arduino speed calculation

Discussion in 'Miscellaneous' started by RacingMat, Sep 17, 2013.

  1. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Hello ! :hi:

    I'd like to determine if it's feasible to refine and streamline the performance of the couple : Simtools + Arduino. ;D

    I'm not talking about just Arduino calculation speed :
    ok, I can count the time elapsed for 1.000.000 loops in the Arduino and compare to Teensy or other controllers for example.

    Yes, but I would like to find a way to measure actual speed of arduino's program loop vs actual serial reading from Simtools.
    I wish to see intimatly how many orders sent by Simtools are read and computed by Arduino :

    Maybe if a number (looping from say : 0 to 1000) could be temporarily added to the interface output : like <Axis1><Chrono>
    I could store in a array the substractions of each successive chrono numbers.
    It would tell me if the Ard miss 1 or more orders !

    @aarondc : could I retrieve the results with your snooping tool ?
    Or I can read the value in memory after the 1000 cycles.

    With the results, I could fine tunes on the one hand, the Simtools refresh rate
    and on the other hand, the arduino/teensy.


    Thanks for your reading !
    Mat

  2. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,643Coins
    Ratings:
    +1,009 / 8 / -1
    From RufusDufus :
    Hi Matt, there are a number of ways of doing this depending on how complex you want to go. I did the the same but probably went over the top. I have written my own arduino controller specific for my sim and added a second com port using the software serial library and then have a complete separate interface that I plug a laptop into with another tool I developed to monitor the axis and tune the PID loop and display a chart of the motion targets vs the motor position. Happy to make available if anyone interested but it is pretty customised to my specific needs.

    Other ideas would be to modify the arduino code to check for overruns in the serial buffer and count them. You could store the result in the EEPROM with a command to read it back at a later time using some terminal software.

    If you have access to electronic test gear you could toggle a pin every time round the loop and then use a pulse counter to display or use an oscilloscope to monitor.

    If you have a display you could display the error count or loop count on that.

    From my tests if you are using an arduino uno with basic PID algorithm with 3 motor calculations you would probably get about 1000 to 2000 loops per second without too much code optimisation.

    If you want to know how many serial commands you can send then it is(approx):

    Time to send command = 1/baud * 10 * number of axis * number of bytes in command

    Note sim tools also adds a delay between packets (1ms min) user selectable

    Therefore freq of command packets = 1 / (Time to send command + simtools packet delay)

    Not sure if this is the level of detail you are after but hopefully it is useful either way.
    • Informative Informative x 1
  3. value1

    value1 Nerd SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Jan 9, 2011
    Messages:
    2,184
    Location:
    Zug, Switzerland
    Balance:
    14,495Coins
    Ratings:
    +3,319 / 11 / -1
    My Motion Simulator:
    2DOF, DC motor, JRK, Joyrider
    From Value1 :
    Hi Mat
    I can temporarily add the Windows time in [ms] to a plugin as Extra1 if this helps. As I dont want to change all the plugins, you would have to specify for which plugin.
  4. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Thanks guys !

    Sorry for the delay for replying to you: the post hasn't been converted into the new site...

    You have very good ideas :cool: Thanks !

    @RufusDufus : counting overruns is smart and short ! I like it !
    Implementing another serial link or LCD lib, would make me fear that it impacts significatively the whole performance and false the measure...

    @value1 : You're really nice ! I'll try first the above approach as I can be autonomous.

    Thanks
    Mat
  5. aarondc

    aarondc Member

    Joined:
    Jun 12, 2013
    Messages:
    133
    Location:
    Melbourne, Australia
    Balance:
    187Coins
    Ratings:
    +7 / 0 / -0
    My snooping tool is nothing more than a serial monitor, so you'd need a spare USB / serial port to use it.