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

Arduino code to drive 4 motors

Discussion in 'SimTools compatible interfaces' started by Nicko355, May 2, 2015.

  1. Nicko355

    Nicko355 New Member

    Joined:
    Oct 17, 2009
    Messages:
    27
    Occupation:
    Automotive Tech
    Location:
    Sydney , Australia
    Balance:
    483Coins
    Ratings:
    +15 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Hi, ok so I have learned more from experimenting with Racingmats build instructions, so far i am beginning to understand the relationship between AXIS and DOF , i am using racingmats 2Dof arduino code , my question is can i run 4 motors with this code? Or does it need to be modified?
  2. speedy

    speedy Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,193
    Location:
    Alexandria , Egypt
    Balance:
    7,918Coins
    Ratings:
    +1,285 / 10 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    Although I don't know that much about coding ... But obviously what is written for a 2DOF can't be used for 4motors without modifications ... [ Motor Drivers ] need specific signal requirements to operate properly ... some of them operate with two direction signals and the others just operate on one direction signal for forward and reverse operation .
    Last edited: May 2, 2015
  3. Pit

    Pit - - - - - - - - - - - - - - - - Gold Contributor

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,416Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    As far as I know Ard supports up to 3 motors - depending on the code.
  4. speedy

    speedy Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,193
    Location:
    Alexandria , Egypt
    Balance:
    7,918Coins
    Ratings:
    +1,285 / 10 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    Yes @Pit ... and I guess @prilad and his colleagues did it for 6 motors on the mal4x.ru forum ... but I don't know why ? I still can't read it under Google translation .
  5. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,895Coins
    Ratings:
    +2,084 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    • Informative Informative x 1
  6. Nicko355

    Nicko355 New Member

    Joined:
    Oct 17, 2009
    Messages:
    27
    Occupation:
    Automotive Tech
    Location:
    Sydney , Australia
    Balance:
    483Coins
    Ratings:
    +15 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Ok yes Racingmat, I just re read your code and I understand it better , so i will connect another motor monster and 2 more motors and continue experimenting, THANKS ALL once again CHEERS Nick
  7. gorzasty

    gorzasty Active Member

    Joined:
    Apr 2, 2012
    Messages:
    151
    Occupation:
    photographer, IT specialist
    Location:
    Poland, Wrocław
    Balance:
    1,060Coins
    Ratings:
    +41 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    And what if we want to use four bigger motors (250w) and we have to use two MM for each?
  8. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,895Coins
    Ratings:
    +2,084 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    @gorzasty
    4 motors driven by 8 motomonster only require 1 arduino and same code :)

    because 2 motomonsters wired together is seen like a single motomonster : 1 PWM pin and 2 Direction pins
  9. gorzasty

    gorzasty Active Member

    Joined:
    Apr 2, 2012
    Messages:
    151
    Occupation:
    photographer, IT specialist
    Location:
    Poland, Wrocław
    Balance:
    1,060Coins
    Ratings:
    +41 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Sorry my mistake @RacingMat, I was thinking about the 4 mototrs driven by the 4 MM. Thx to @Pit thread I know that we can use wireings like this:

    Arduino -------- Monster Moto
    2 (Motor 1 H-Bridge ENA) ---------------7 and 8 (INA1 and INB1)
    3 (Motor 1 H-Bridge ENB)----------------4 and 9 (INA2 and INB2)
    9 (Motor 1 PWM) --------------------------5 and 6 (PWM1 and PWM2)

    Arduino -------- Monster Moto 2
    4 (Motor 2 H-Bridge ENA) ---------------7 and 8 (INA1 and INB1)
    5 (Motor 2 H-Bridge ENB)----------------4 and 9 (INA2 and INB2)
    10 (Motor 2 PWM) --------------------------5 and 6 (PWM1 and PWM2)

    Arduino -------- Monster Moto 3
    6 (Motor 1 H-Bridge ENA) ---------------7 and 8 (INA1 and INB1)
    7 (Motor 1 H-Bridge ENB)----------------4 and 9 (INA2 and INB2)
    11 (Motor 1 PWM) --------------------------5 and 6 (PWM1 and PWM2)


    but no word about 4'th motor. I think there is no place for it in the Arduino, but I'm a newbe...
  10. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,895Coins
    Ratings:
    +2,084 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    • Informative Informative x 1
  11. gorzasty

    gorzasty Active Member

    Joined:
    Apr 2, 2012
    Messages:
    151
    Occupation:
    photographer, IT specialist
    Location:
    Poland, Wrocław
    Balance:
    1,060Coins
    Ratings:
    +41 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
  12. kingh3

    kingh3 Member

    Joined:
    Sep 26, 2013
    Messages:
    42
    Balance:
    256Coins
    Ratings:
    +10 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SimAxe, Arduino, JRK, Motion platform
    Excuse me! could you tell me about the data from simtool sent to arduino? A packet of data include 8 bit or 3 bit? And I don't understand how it calculate in this episode:
    byte Data[3]={'0','0','0'};
    // keep this function short, because the loop has to be short to keep the control over the motors

    if (Serial.available()>2)
    {
    //parse the buffer : test if the byte is the first of the order "R"
    Data[0]=Serial.read();
    if (Data[0]=='L')
    {
    Data[1]=Serial.read();
    Data[2]=Serial.read();
    // call the function that converts the hexa in decimal and that maps the range
    DataValueR=NormalizeData(Data);
    }
    Could you explain to me? Thank you so much. @RacingMat
  13. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,895Coins
    Ratings:
    +2,084 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    why do you want to change anything?
  14. kingh3

    kingh3 Member

    Joined:
    Sep 26, 2013
    Messages:
    42
    Balance:
    256Coins
    Ratings:
    +10 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SimAxe, Arduino, JRK, Motion platform
    No, I don't want to change. I just don't understand about it.
  15. fafay

    fafay New Member

    Joined:
    Dec 19, 2016
    Messages:
    16
    Occupation:
    boulanger patissier
    Location:
    france albi
    Balance:
    341Coins
    Ratings:
    +4 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    It's not all bad
    I will try when I receive my two card monster motorcycle