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

Tutorial SMC3 Arduino 3DOF Motor Driver and Windows Utilities

Discussion in 'SimTools compatible interfaces' started by RufusDufus, Dec 1, 2013.

  1. Enrique.Rolon

    Enrique.Rolon New Member

    Joined:
    Aug 5, 2016
    Messages:
    18
    Location:
    Argentina
    Balance:
    73Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    Arduino
    Just to be sure, i need to see the motor rotating with the SCM Utility? or is the SimTools who do that?
  2. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,451Coins
    Ratings:
    +3,091 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    Driver failure....
    If the motor does not spin using SMC3 you wont be able to run SimTools
  3. Enrique.Rolon

    Enrique.Rolon New Member

    Joined:
    Aug 5, 2016
    Messages:
    18
    Location:
    Argentina
    Balance:
    73Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    Arduino
    I tried the first attached code (name 6), just for testing, and the motor starts running with the same circuit as the first page tutorial says.
    Now, analyzing the SMC3 code, i tried the second attached code (name 7) but it does not work. The "portstatus &= ~(1 << PIN_NB);" and "PORTD = portstatus" will disable the specified pin, and also there is a sentence that enable the pin, as if u write the sentence "writeDigital(PIN_NB, LOW)" and viceversa. Any idea why this sentences are not working? kinda lost

    Attached Files:

    • 6.jpg
      6.jpg
      File size:
      70.2 KB
      Views:
      709
    • 7.jpg
      7.jpg
      File size:
      104.5 KB
      Views:
      699
  4. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,451Coins
    Ratings:
    +3,091 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    Sorry I cannot follow your progress, which code (sketch) did you use?
  5. Enrique.Rolon

    Enrique.Rolon New Member

    Joined:
    Aug 5, 2016
    Messages:
    18
    Location:
    Argentina
    Balance:
    73Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    Arduino
    First, the attached file (first sketch) attached above (file name: 6.jpg). The motor runs, meaning the circuit is fine (i think). The circuit is the same as the first page of this thread says.

    The second attached file above (file name: 7.jpg, re-upload in this answer). The motor dont run, and the code i wrote there is based on the SMC3.ino code, following the lines that activates the motor.

    Conclusion: I believe the sentences "portstatus &= ~(1 << EN_PIN_NB);" and "PORTD = portstatus" dont work as they should in my Arduino Mega 2650. (EN_PIN_NB is the pin ENAPin1 or ENAPin2 in the SMC3 code).

    The documentation (https://www.arduino.cc/en/Reference/PortManipulation) says that the PORTD can be used exactly like the sentence "digitalWrite(EN_PIN_nb, LOW or HIGH)" with less clocks cycles (i.e time)

    Im getting crazy

    Attached Files:

    • 7.jpg
      7.jpg
      File size:
      103.3 KB
      Views:
      658
  6. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,012
    Location:
    Switzerland
    Balance:
    30,451Coins
    Ratings:
    +3,091 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    sorry no support from my side of any modified code.
  7. Enrique.Rolon

    Enrique.Rolon New Member

    Joined:
    Aug 5, 2016
    Messages:
    18
    Location:
    Argentina
    Balance:
    73Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    Arduino
  8. Grigory

    Grigory Active Member Gold Contributor

    Joined:
    Jul 6, 2016
    Messages:
    202
    Location:
    Moscow
    Balance:
    217Coins
    Ratings:
    +304 / 1 / -0
    My Motion Simulator:
    3DOF, 6DOF

    Did the test:

    With Kp=100 and PWMmax=70 motor runs fine. If I set PWMmax to 80 motor halts after a couple of seconds.

    Strangely, the radiator on IBT-2 gets very hot (I can barely touch it) even in this mode without any load and with PWM limited to 70. Current meter shows no more than 2.5 amps.

    If the motor halts I can reset things by restarting Windows application, cycling power to the driver does nothing.

    Does all this look like the problem is with the driver?
  9. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    H-Bridges are known to get hot with many recommendations to add extra heatsinks and cooling. With the Chinese IBT-2 I suggest removing the heatsink and adding some thermal paste and refitting, also add heatsink to chip case as well.

    It is unusual they get hot without load but will depend on motors etc - try another one and see if it is the same.

    Recheck your wiring between H-Bridge and Arduino. Post photos and videos.
  10. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,621Coins
    Ratings:
    +1,835 / 32 / -1
    There may be an error in the arduino programmer because it should not compile for a Mega if it includes incompatible commands. The information I located does not mention the ATmega2060 chip though. https://www.arduino.cc/en/Reference/PortManipulation
    I must change my statement to say that I can verify that the Mega works with SMC3 in mode 3.
  11. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    I guess you could search the code and everywhere there is a:

    PORTD=portstatus;

    replace it with:

    digitalWrite(PD0, portstatus & 0x01);
    digitalWrite(PD1, portstatus>>1 & 0x01);
    digitalWrite(PD1, portstatus>>2 & 0x01);
    digitalWrite(PD1, portstatus>>3 & 0x01);
    digitalWrite(PD1, portstatus>>4 & 0x01);
    digitalWrite(PD1, portstatus>>5 & 0x01);
    digitalWrite(PD1, portstatus>>6 & 0x01);
    digitalWrite(PD1, portstatus>>7 & 0x01);
  12. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    EDIT: IGNORE THIS POST - I see you have two versions of 7.jpg

    You haven't defined or initialised pwmdirection1l and pwmdirection1r in the 7.jpg.
    You should also be initialising portstatus by reading the register first at startup.
    As you have your test code in loop the pwmdirection1l should be toggling very fast and you may have trouble seeing changes without a CRO?
    Last edited: Aug 12, 2016
  13. Enrique.Rolon

    Enrique.Rolon New Member

    Joined:
    Aug 5, 2016
    Messages:
    18
    Location:
    Argentina
    Balance:
    73Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    Arduino
    YEah y correct the first one, the second one was the one i runned.
    BTW: i got it working. "PORTD=portstatus;" does not work in mega 2560, replace it with digitalWrite(PIN_NB, LOW/HIGH); (aint tested "digitalWrite(PD1, portstatus>>7 & 0x01);" but the issue of PORTD is the new mega mapping for sure and not update of the PORTD return values).
    AND i found some discrepancy between the Pin distribution in the code SMC3 and the circuit image for ITB_2 in the first page of this thread. In this technical post: http://www.hessmer.org/blog/2013/12/28/ibt-2-h-bridge-with-arduino/ there is two ways of usage in the IBT-2 with arduino, and the circuit image + SMC3 code are mixing both and that is why it not work for me (not sure for all)
    Maybe later i will post some images and code with specifications about i said but, now i am delay about 1-2 days for this issue. Thanks u all
  14. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    Thanks, I'll make necessary corrections if you provide details.

    HaHa, just because somewhere on the web it says there are only two ways doesn't mean there are only two ways. It's been a long time since I looked at this code - I was doing something I specifically needed. If you read the datasheets for the BTS7960, compare to the circuit and it should make sense. It's all to do with whether you want the highside or lowside or both switches to do the work and whether you want drive/coast or drive/brake mode.

    I use these drivers in my sim so it definately works.

    Glad you could get things working.
  15. Gean Cesar Silva

    Gean Cesar Silva New Member

    Joined:
    Aug 14, 2016
    Messages:
    1
    Location:
    Brazil
    Balance:
    155Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    SCN6, Arduino
    Hi Guys!
    I wanna know how could I control a linear actuator made with a stepper motor using the smc3 code?
    Is there any device that can convert pwm rate to step pulses?
  16. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    It can be done although I can't think of any quick ways at the momemt. SMC3 is a closed loop control algorithm so requires position feedback from a POT or other mechanism.

    What sort of controller are you using, a typical step/dir pulse input? I guess you could modify the code so that it changes the PWM frequency instead of the PWM duty cycle and leave it as 50%.
  17. LuisBranco

    LuisBranco New Member

    Joined:
    Aug 14, 2016
    Messages:
    6
    Location:
    Rio de Janeiro
    Balance:
    188Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF
    Hey guys!

    I have a doubt, and I didn't find the answer anywhere here!

    I'm using the SMC3 with SimTools to move my 2DOF simulator (Roll and Pitch).

    I was testing the Roll and Pitch movements separately, so I put only Roll, using 50% on axis 1 and 50% on axis 2 like in the image (is this correct?)

    To test I used "Axis Testing". When I choose 100% on axis 1 and 100% on axis 2, it tilts all the way left, when I choose -100% on axis 1 and -100% on axis 2, it tilts all the way right (as expected).

    But when I test the Pitch movement (the same way), it moves just like the Roll instead of going forward and backward. I tried checking the red box (Dir) but it still moves the same way as before.

    Is there something wrong with my configuration?

    My simulator looks like this one in the picture

    And these are my Axis Assignments (one for Roll, and both I tried to use for pitch).

    Thank you for your attention guys!

    Attached Files:

  18. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,952Coins
    Ratings:
    +1,016 / 10 / -1
    @LuisBranco - output testing uses the "Default" setup I think (or check there may even be an output testing setup? (been a while since I've done that). Ie I'm talking about the dropdown box that has "No Limits Simulator" in your screenshots.
    • Like Like x 1
  19. LuisBranco

    LuisBranco New Member

    Joined:
    Aug 14, 2016
    Messages:
    6
    Location:
    Rio de Janeiro
    Balance:
    188Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF
    Thank you for your fast answer!

    I don't think it's the case. I'll only be able to test that on the simulator tomorrow, but I tested the Default following the graphics in SMC and in both situations the blue line goes the same way (even selecting "Dir" to pitch)

    About the Output test setup, if that exists, I haven't found.
  20. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,142
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    148,547Coins
    Ratings:
    +10,902 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    @RufusDufus is correct, you use the Default profile for Output Testing. The Output Testing button is second from the bottom on the left side of the SimTools Game Engine window.

    It is helpful to fully explain the hardware you are using, how it is configured, and post a picture of your SimTools Interface settings.

    Do make yourself familiar with the SimTools documentation: https://www.xsimulator.net/simtools-complete-documentation/

    The Dir box controls direction, so roll will have one checked and the other not, pitch will have none or both checked.

    This is how your simulator should be configured to move in Output Testing: https://www.xsimulator.net/community/faq/which-way-to-set-simtool-axis-movements.230/

    Here are the steps to creating a motion profile once you have the simulator moving correctly in Output Testing: https://www.xsimulator.net/community/faq/steps-to-create-a-motion-profile.228/
    • Like Like x 1
    Last edited: Aug 19, 2016