1. 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 Download Package Now!
  2. 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
  3. 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 here. Do not following these rules will lead to permanent exclusion from this website: Read the forum rules.

Simtools with raspberry, need more basics understanding

Discussion in 'SimTools compatible interfaces' started by Michael Hensen, Dec 15, 2017.

  1. Michael Hensen

    Michael Hensen Active Member

    Joined:
    Mar 25, 2014
    Messages:
    166
    Occupation:
    C# Software Engineer
    Location:
    Almere, Netherlands
    Balance:
    576Coins
    Ratings:
    +150 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    Hi All,

    I want to do a raspberry implementation for controlling Servo motor drivers..
    I intend to build a D-box style sim with Nema34 closed loop steppers. Now I need to drive these drivers through pulses generated by, in this case, a raspberry.

    But to do the C# coding I need to have a bit more understanding on how Simtools works..
    This is my assumption now..

    A game outputs telemetry ->
    a games plugin captures and translates this in values of 0-255 according to the level ->
    Simtools than translates all these values to the required axis and outputs per axis a value of 0-255

    in the case of the raspberry captures the UDP package and translates the values of 0-255 to the required amount of steps. Splitting between -127 - 0 - 127 will give the direction of movement where -127 is the minus and 127 is the max..


    Am I correct in these assumptions or is this way off, or is there any docs on what simtools outputs?
    I am a C# developer so codewise it shouldn't be a problem.. it is just to understand how I need to interpret the output of Simtools..

    Thanks in advance and yes as soon as I have something I will share it back to the community..
    But that will be a while as I am just in the planning and intention phase.. Will be ordering a motor and driver in January and start playing with driver and raspberry after arrival..

    With kind regards,

    Michael
  2. Zed

    Zed VR Simming w/Vive

    Joined:
    Apr 4, 2017
    Messages:
    688
    Location:
    USA
    Balance:
    3,799Coins
    Ratings:
    +709 / 3 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Raspberry Pi's run a full-up OS that isn’t a "real time" style of OS. With all the tasks, there can be delays before it gets back to your C# routine. They also don’t have a super-fast CPU which compounds the problem.

    For the actual motion control you need more deterministic controllers that don’t get interrupted by display and network stacks and such. It sounds like you are possibly thinking of using the Pi as the main controller and having it talk to an array of Servo controllers? But if so, SimTools already does all that. It uses the plugins to gather telemetry and outputs commands to the motion control bits.

    Maybe I’m not understanding. Most use Arduino-style/class micros for actual motion control. You could certainly experiment with the Pi for that kind of duty but at least when I was using them, they ran Linux and an RTOS wasn’t available though you can really trim Linux to bare bones. And maybe an RTOS is available now. I just mention since you didn’t.

    Not sure if that helps at all, but not sure I understand what you are trying to do?
    • Agree Agree x 1
    • Informative Informative x 1
  3. Michael Hensen

    Michael Hensen Active Member

    Joined:
    Mar 25, 2014
    Messages:
    166
    Occupation:
    C# Software Engineer
    Location:
    Almere, Netherlands
    Balance:
    576Coins
    Ratings:
    +150 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    I indeed was looking for connecting the raspberry to 4 servo drivers as the motioncontroller that listens to Simtools.. there where normally the Arduino would be..

    Edit: But you made me look at Arduino vs Raspberry.. and I must admit you are right. Better to use an Arduino for controlling then a raspberry..

    Too bad.. no fancy C# program :)
    • Agree Agree x 1
    Last edited: Dec 15, 2017
  4. Zed

    Zed VR Simming w/Vive

    Joined:
    Apr 4, 2017
    Messages:
    688
    Location:
    USA
    Balance:
    3,799Coins
    Ratings:
    +709 / 3 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    You may still be able to do C#. There is code already developed for using Arduinos if you just want something canned and ready to go. Links and code listings can be found here but I don’t have a link handy. But you don’t have to use the Arduino environment. I’m pretty sure you can use whatever compiler you want and shoot the code down using their boot loader. There are a lot of other pure Atmel (the microcontrollers used in Arduinos) boards out there as well. Good luck!
    • Like Like x 1
    • Agree Agree x 1
  5. Zed

    Zed VR Simming w/Vive

    Joined:
    Apr 4, 2017
    Messages:
    688
    Location:
    USA
    Balance:
    3,799Coins
    Ratings:
    +709 / 3 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    Hey Michael - check Thanos' Kickstarter announcement in the Interfaces topic area. He uses an Arduino with custom firmware to interface with the host computer running SimTools as a front end to his motion interface circuits and setup and display interface. That sounds something like what you might be looking to do?
  6. Michael Hensen

    Michael Hensen Active Member

    Joined:
    Mar 25, 2014
    Messages:
    166
    Occupation:
    C# Software Engineer
    Location:
    Almere, Netherlands
    Balance:
    576Coins
    Ratings:
    +150 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    Yep.. it's just that the kickstarter has finished and now is full price.. Now it is getting a bit to pricey if I can do it with an Arduino and some code.. the kickstarterprice was OK for me..
    And in the spirit of DIY, the coding part would be the most challenging part.. So I will have a shot at that first..

    Like make a stepper motor follow the movements in simtools.. I will search the forums for clues and have a look at scm3.. perhaps I will get a clue from there.. although I think that it is more PWM output and not pulse output.. But I'll get the code and the utils .. and trace what simtools is sending and hopefully I can make something out of it :)
  7. Leo Salo

    Leo Salo New Member

    Joined:
    May 30, 2017
    Messages:
    11
    Occupation:
    Electronics Engineering
    Location:
    Melbourne, Australia
    Balance:
    177Coins
    Ratings:
    +19 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor
    Hi @Michael Hensen. I'm not sure if you've seen my thread (https://www.xsimulator.net/community/threads/3dof-concept-model-using-raspberrypi.10570/). This project uses a RaspberryPi to control three RC servos, and communicates via the LAN connection. Everything is there in the thread to help you get set up and duplicate this if you want, and it should really help you understand the communication between the game engine and your controller a bit better. If you wanted to use stepper motors instead of servos then it would need an overhaul, and some different hardware - but I'm sure the RPi could do it. I was actually really surprised at how responsive it was running just a Python script - I was expecting lag, but there was nothing noticeable.
  8. Michael Hensen

    Michael Hensen Active Member

    Joined:
    Mar 25, 2014
    Messages:
    166
    Occupation:
    C# Software Engineer
    Location:
    Almere, Netherlands
    Balance:
    576Coins
    Ratings:
    +150 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    Thanks for your comments.. To get a feel of what simtools does I, for now, have a Arduino setup made with 2 nema17 motors.. But now you make me want to write the software again for the Raspberry.. I have one more laying around.
    Perhaps I will do something different.. Perhaps I will have the raspberry control an Arduino whereas the raspberry will do all the calculations and has all the settings.. herby having the raspberry spitting out the motor positions and have Arduino run the motor to the position.
    All not written in concrete as I have my stuff for a single actuator in the shipping state. But hopefully I will have an idea by the end of the month.. But it gives me at least confidence that I should be able to pull it off..

    Would like the graphical power of the raspberry to show what it going on .. Touchscreen for the settings.. and Arduino for the pulse generation.. :)
  9. Leo Salo

    Leo Salo New Member

    Joined:
    May 30, 2017
    Messages:
    11
    Occupation:
    Electronics Engineering
    Location:
    Melbourne, Australia
    Balance:
    177Coins
    Ratings:
    +19 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor
    I think you're on the right track. The main problem with the RaspberryPi is that there is no hardware PWM outputs, which makes controlling a H-bridge or stepper motor difficult - ie. you need to add some other hardware to generate the PWM signals. I used a ready made 10-channel LED controller board, but you could equally use an Arduino to serve the same function. You just need to work out the communication between the two - and the LED controller board already had a Python library available to handle all this, so that made it super easy to get going.
    • Informative Informative x 1
  10. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimTools Developer SimAxe Beta Tester Gold Contributor SimTools 2.0 Beta Tester

    Joined:
    Feb 9, 2007
    Messages:
    2,816
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    30,409Coins
    Ratings:
    +2,970 / 9 / -0
    The Pi will probably work great as in interface controller.
    But keep in mind, that adding the screen will make it a bit slower.
    So you may want an option to turn it off once all setup.
    Excited to see where this goes thou. :thumbs
    Take care,
    yobuddy
    • Like Like x 1
  11. Michael Hensen

    Michael Hensen Active Member

    Joined:
    Mar 25, 2014
    Messages:
    166
    Occupation:
    C# Software Engineer
    Location:
    Almere, Netherlands
    Balance:
    576Coins
    Ratings:
    +150 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    Thanks!! Did what you suggested.. the Screen updates can be turned off..
    If it is needed is something I only can see in the final testing..