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

MM can drive motor and change speed of motor, but direction will not change.

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by Zeraxx, Jul 6, 2018.

  1. Zeraxx

    Zeraxx Member

    Joined:
    Jun 28, 2018
    Messages:
    38
    Balance:
    188Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    2DOF
    Hey guys I'm using two sparkfun MM's to power 2 50:1 Motors. I just finished connected my motor monsters, and they exhibit the exact same behavior. I'm using the following wiring.

    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)

    1) Whenever the Arudino starts the SCM3 execution. The motor starts to rotate CCW.
    2) I can adjust the speed using SCM3 Utilities by increasing the PWM Max.

    However if I take manual control the motors will not stop or rotate CW.

    I have taken the motors out of the equations and just hook up a multimeter, and i'm reading a constant 12V.

    I thought it was an issue with my board. so I tried it on the other board, and the exact same behavior is observed, which makes me believe its either a wiring issue or something else.

    As a note, I don't have any pots hook up I'm just shooting the A0 the 5V. Not sure if thats causing any issues with the SCM3 code. As I was just trying to manual drive the motors to check out the MM.

    Any help or suggestions would greatly be appreciated.
  2. Zeraxx

    Zeraxx Member

    Joined:
    Jun 28, 2018
    Messages:
    38
    Balance:
    188Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    2DOF
    Just wanted to post an update I used some code to test out the motor motors and edited it to turn the motors CCW for 5 seconds and then CW for 5 seconds, and the code works just fine, so it makes me think its something with SCM3 that I might be doing wrong?

    Here is example of code.
    Code:
     
    /*  MonsterMoto Shield Example Sketch
      date: 5/24/11
      code by: Jim Lindblom
      hardware by: Nate Bernstein
      SparkFun Electronics
    
     License: CC-SA 3.0, feel free to use this code however you'd like.
     Please improve upon it! Let me know how you've made it better.
    
     This is really simple example code to get you some basic
     functionality with the MonsterMoto Shield. The MonsterMote uses
     two VNH2SP30 high-current full-bridge motor drivers.
    
     Use the motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
     function to get motors going in either CW, CCW, BRAKEVCC, or
     BRAKEGND. Use motorOff(int motor) to turn a specific motor off.
    
     The motor variable in each function should be either a 0 or a 1.
     pwm in the motorGo function should be a value between 0 and 255.
     */
    #define BRAKEVCC 0
    #define CW   1
    #define CCW  2
    #define BRAKEGND 3
    #define CS_THRESHOLD 100
    
    /*  VNH2SP30 pin definitions
     xxx[0] controls '1' outputs
     xxx[1] controls '2' outputs */
    int inApin[1] = {2};  // INA: Clockwise input
    int inBpin[1] = {3}; // INB: Counter-clockwise input
    int pwmpin[1] = {9}; // PWM input
    int cspin[1] = {A0}; // CS: Current sense ANALOG input
    unsigned long pwnSize = 1023;
    int statpin = 13;
    
    void setup()
    {
      Serial.begin(9600);
     
      pinMode(statpin, OUTPUT);
    
      // Initialize digital pins as outputs
      for (int i=0; i<1; i++)
      {
        pinMode(inApin, OUTPUT);
        pinMode(inBpin, OUTPUT);
        pinMode(pwmpin, OUTPUT);
      }
      // Initialize braked
      for (int i=0; i<1; i++)
      {
        digitalWrite(inApin, LOW);
        digitalWrite(inBpin, LOW);
      }
      // motorGo(0, CW, 1023);
      // motorGo(1, CCW, 1023);
    }
    
    void loop()
    {
      motorGo(0, CW, pwnSize);
      delay(5000);
    
      motorGo(0, CCW, pwnSize);
      delay(5000);
     
      if ((analogRead(cspin[0]) < CS_THRESHOLD) && (analogRead(cspin[1]) < CS_THRESHOLD))
        digitalWrite(statpin, HIGH);
    }
    
    void motorOff(int motor)
    {
      // Initialize braked
      for (int i=0; i<1; i++)
      {
        digitalWrite(inApin, LOW);
        digitalWrite(inBpin, LOW);
      }
      analogWrite(pwmpin[motor], 0);
    }
    
    /* motorGo() will set a motor going in a specific direction
     the motor will continue going in that direction, at that speed
     until told to do otherwise.
    
     motor: this should be either 0 or 1, will selet which of the two
     motors to be controlled
    
     direct: Should be between 0 and 3, with the following result
     0: Brake to VCC
     1: Clockwise
     2: CounterClockwise
     3: Brake to GND
    
     pwm: should be a value between ? and 1023, higher the number, the faster
     it'll go
     */
    void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
    {
      if (motor <= 1)
      {
        if (direct <=4)
        {
          // Set inA[motor]
          if (direct <=1)
            digitalWrite(inApin[motor], HIGH);
          else
            digitalWrite(inApin[motor], LOW);
    
          // Set inB[motor]
          if ((direct==0)||(direct==2))
            digitalWrite(inBpin[motor], HIGH);
          else
            digitalWrite(inBpin[motor], LOW);
    
          analogWrite(pwmpin[motor], pwm);
        }
      }
    }
  3. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,533
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    145,022Coins
    Ratings:
    +10,776 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  4. Zeraxx

    Zeraxx Member

    Joined:
    Jun 28, 2018
    Messages:
    38
    Balance:
    188Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    2DOF
    Yeah I know it's documented, but the documentation doesn't mention if potentiometers are required. However i now know they are, it was probally throwing odd the PID since the pots weren't hooked up, I mounted all the pots to their motors and everything is working like a dream.
  5. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,533
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    145,022Coins
    Ratings:
    +10,776 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Indeed pots are requires and are shown in the wiring diagram of the instruction, as they provide the positional feedback.