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 Now a Download Plan!
  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. 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

Help with model code

Discussion in 'New users start here - FAQ' started by Abram Manoge, Apr 6, 2021 at 20:57.

  1. Abram Manoge

    Abram Manoge Member

    Joined:
    Tuesday
    Messages:
    33
    Occupation:
    Web developer
    Location:
    South Africa
    Balance:
    242Coins
    Ratings:
    +4 / 0 / -0
    Hi i need your assistance. im using this code. the servo moves when i send commands in serial monitor (ex L90) but i cant seem to get it to move in sim tools . What do i put in "Axis assignments" . I entered the information in interface settings the same as the picture you have attached and i have game manager running and set to live for speed
  2. Ads Master

    Ads Master

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
  3. Abram Manoge

    Abram Manoge Member

    Joined:
    Tuesday
    Messages:
    33
    Occupation:
    Web developer
    Location:
    South Africa
    Balance:
    242Coins
    Ratings:
    +4 / 0 / -0
    Im currently waiting for wiper motors and motor drivers to start building my sim. Can you please assist in turning your code to a small scale model one . im gonna use the following

    Arduino uno r3
    2x SG90 servos (2dof setup)

    im currently using the following code but i cant seem to get it to communicate with sim tools although in ardunio ide i can get the servos to move by sending serial commands(ex L120 or R90). here is the code

    "
    //********************************************************************************************
    // RC Model Servo
    // Written By EAOROBBIE (Robert Lindsay)
    // For free use for Sim Tool Motion Software
    //********************************************************************************************

    #include <Servo.h>

    Servo myservo1; // create servo object to control a servo
    Servo myservo2; // create servo object to control a servo
    char kind_of_data; // to capture which servo needs to be move
    int valLSP = 90; // set the intial Left Servo Position to centre
    int valRSP = 90; // set the intial Right Servo Position to centre

    void setup()
    {
    myservo1.attach(4); // attaches the servo on pin 5 to the servo object
    myservo2.attach(5); // attaches the servo on pin 4 to the servo object
    myservo1.write(valLSP); // sets the servo position according to the scaled value
    myservo2.write(valRSP); // set the servo position according to the scaled value

    Serial.begin(9600); // opens serial port at a baud rate of 9600
    }

    void loop()
    {

    //****************************** READ DATA FROM SERIAL ******************************
    while (Serial.available() > 0)
    {

    kind_of_data = Serial.read();
    if (kind_of_data == 'R' ) Read_RightServo();
    if (kind_of_data == 'L' ) Read_LeftServo();



    myservo1.write(valRSP); // sets the servo position according to the scaled value
    myservo2.write(valLSP); // sets the servo position according to the scaled value
    }
    }

    void Read_RightServo(){

    int RightServoPos = 0;
    delay(2);
    int RSP100 = Serial.read();
    delay(2);
    int RSP10 = Serial.read();
    delay(2);
    int RSP1= Serial.read();

    RSP100 = ((RSP100)-48)*100;
    RSP10 = ((RSP10)-48)*10;
    RSP1 = ((RSP1)-48)*1;
    if (RSP10 < 0 && RSP1 < 0){RSP100 = RSP100/100;RSP10 = 0;RSP1 = 0;}
    if (RSP1 < 0){RSP100 = RSP100/10;RSP10 = RSP10/10;RSP1 = 0;}
    //Serial.println(RSP100); // these are here for debugging purposes
    //Serial.println(RSP10); // these are here for debugging purposes
    //Serial.println(RSP1); // these are here for debugging purposes
    RightServoPos = RSP100+RSP10+RSP1;
    valRSP = map(RightServoPos, 0, 255, 0, 179); // scale it to use it with the servo (value between 0 and 180)
    //Serial.println(RightServoPos); // these are here for debugging purposes
    //Serial.println(valRSP); // these are here for debugging purposes

    }

    void Read_LeftServo(){

    int LeftServoPos = 0;
    delay(2);
    int LSP100 = Serial.read();
    delay(2);
    int LSP10 = Serial.read();
    delay(2);
    int LSP1= Serial.read();

    LSP100 = ((LSP100)-48)*100;
    LSP10 = ((LSP10)-48)*10;
    LSP1 = ((LSP1)-48)*1;
    if (LSP10 < 0 && LSP1 < 0){LSP100 = LSP100/100;LSP10 = 0;LSP1 = 0;}
    if (LSP1 < 0){LSP100 = LSP100/10;LSP10 = LSP10/10;LSP1 = 0;}
    //Serial.println(LSP100); // these are here for debugging purposes
    //Serial.println(LSP10); // these are here for debugging purposes
    //Serial.println(LSP1); // these are here for debugging purposes
    LeftServoPos = LSP100+LSP10+LSP1;
    valLSP = map(LeftServoPos, 0, 255, 179, 0); // scale it to use it with the servo (value between 0 and 180)
    //Serial.println(LeftServoPos); // these are here for debugging purposes
    //Serial.println(valLSP); // these are here for debugging purposes
    }
    "
  4. Abram Manoge

    Abram Manoge Member

    Joined:
    Tuesday
    Messages:
    33
    Occupation:
    Web developer
    Location:
    South Africa
    Balance:
    242Coins
    Ratings:
    +4 / 0 / -0
    Here are screenshots of my simtools settings. i also have game manager open running live for speed please assist sim settings.png
  5. Halloween2go

    Halloween2go Member Gold Contributor

    Joined:
    Dec 12, 2019
    Messages:
    96
    Balance:
    755Coins
    Ratings:
    +64 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform
    Abram, it's not my code for sure.. AEROBBIE code. Take a look at this link if you have time. I used it to initially set up my simtools. I cant tell what the characters are in the interface output section you show but they should be like this:
    [A<Axis1a>][B<Axis2a>]
    also Output Type - Binary
    and BitsPerSec - 500000
    Read through this link. Set it up the same I would think.
    https://www.xsimulator.net/communit...3dof-motor-driver-and-windows-utilities.4957/
  6. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    16,460
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    119,803Coins
    Ratings:
    +9,531 / 47 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Check your Interface Output, as you seem to have an extra character * at the end: R<Axis1a>~L<Axis2a>~

    Like this:

    [​IMG]
  7. Abram Manoge

    Abram Manoge Member

    Joined:
    Tuesday
    Messages:
    33
    Occupation:
    Web developer
    Location:
    South Africa
    Balance:
    242Coins
    Ratings:
    +4 / 0 / -0
    I'll go ahead and check the link. Thank you
  8. Abram Manoge

    Abram Manoge Member

    Joined:
    Tuesday
    Messages:
    33
    Occupation:
    Web developer
    Location:
    South Africa
    Balance:
    242Coins
    Ratings:
    +4 / 0 / -0
    It doesnt seem to work with and without the star. The setup is decimal on the thread I was following .
  9. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    16,460
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    119,803Coins
    Ratings:
    +9,531 / 47 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  10. Abram Manoge

    Abram Manoge Member

    Joined:
    Tuesday
    Messages:
    33
    Occupation:
    Web developer
    Location:
    South Africa
    Balance:
    242Coins
    Ratings:
    +4 / 0 / -0
  11. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    16,460
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    119,803Coins
    Ratings:
    +9,531 / 47 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  12. Abram Manoge

    Abram Manoge Member

    Joined:
    Tuesday
    Messages:
    33
    Occupation:
    Web developer
    Location:
    South Africa
    Balance:
    242Coins
    Ratings:
    +4 / 0 / -0
    Yes it's for a 2DOF . The part I'm having an issue with is doing the axis assignments section or can I leave that part blank, I cant seem to understand how I'm supposed to set that part?
    Sorry for the many questions
  13. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    16,460
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    119,803Coins
    Ratings:
    +9,531 / 47 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Grab a copy of the SimTools manual and keep it handy for reference: https://www.xsimulator.net/community/faq/rtfm-start-with-the-official-simtools-documentation.117/

    Axis Assignment % totals should be around 100% total: https://www.xsimulator.net/community/faq/axis-assignment-percentage-totals.120/

    Generally you start with something like 20% per axis and configure which way each axis should move: https://www.xsimulator.net/community/faq/which-way-to-set-simtool-axis-movements.230/

    Once that is sorted and everything is working as expected in Output Testing then a motion profile can be configured for a game, see the tips here: https://www.xsimulator.net/community/faq/steps-to-create-a-motion-profile.228/
  14. Abram Manoge

    Abram Manoge Member

    Joined:
    Tuesday
    Messages:
    33
    Occupation:
    Web developer
    Location:
    South Africa
    Balance:
    242Coins
    Ratings:
    +4 / 0 / -0
    I've tried everything suggested. I ended up giving up after a whole day of trying
  15. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,184
    Location:
    Oklahoma City, USA
    Balance:
    16,244Coins
    Ratings:
    +1,835 / 32 / -1
    From reading the sketch in post 2 it looks like your simtools settings in post 3 should work. I suggest you try using axis setting for output testing from Simtools instead of dof.
  16. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,184
    Location:
    Oklahoma City, USA
    Balance:
    16,244Coins
    Ratings:
    +1,835 / 32 / -1
    If it still doesn't work try using only R<Axis1a>L<Axis2a>. However it looks like anything else in there is just ignored anyway.
  17. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,184
    Location:
    Oklahoma City, USA
    Balance:
    16,244Coins
    Ratings:
    +1,835 / 32 / -1
    Help.jpg
    I got this from my inbox. You must have deleted it though? Are you a quitter?
  18. Abram Manoge

    Abram Manoge Member

    Joined:
    Tuesday
    Messages:
    33
    Occupation:
    Web developer
    Location:
    South Africa
    Balance:
    242Coins
    Ratings:
    +4 / 0 / -0
    No i didn't lol. a moderator deleted is as spam i think. I'm still gonna continue looking for solutions