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. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,643Coins
    Ratings:
    +1,009 / 8 / -1
    @Petar2, Ok it looks like it is just the PWM1 and PWM2 that are swapped...

    just search the .ino file for the following two lines (about line 140 in code):
    Code:
    const int PWMpin1 =9;          // PWM output pin for Motor 1  
    const int PWMpin2 =10;         // PWM output pin for Motor 2    
    and replace with:
    Code:
    const int PWMpin1 =10;          // PWM pin Motor 1 - special mod for Petar2  
    const int PWMpin2 =9;         // PWM pin Motor 2 - special mod for Petar2   
    Note:
    1. Any comments in the code referring to the pin numbers will be incorrect
    2. Any updates to the SMC3.ino posted (that you choose to use), will need to have the same change
    • Agree Agree x 1
  2. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,643Coins
    Ratings:
    +1,009 / 8 / -1
    @Petar2, note with this modification and wiring you want to use the default MODE 1.

    Edit: Also be careful the first time you use it... if the other code you use drives the motors in opposite directions to my code (ie EN pins swapped) then it will race off to the limits and shutdown the power. In this case you will also need to reverse the EN pins for the problem motor(s) - same place in the code
    Last edited: Jan 23, 2015
  3. Petar2

    Petar2 Member

    Joined:
    May 23, 2014
    Messages:
    59
    Location:
    Valencia
    Balance:
    715Coins
    Ratings:
    +41 / 0 / -0
    My Motion Simulator:
    2DOF, Arduino
    thank you very much RufusDufus
    I have already tested and has just miss need to change these two lines of code.
    EN pin has no lack modify miss .
    Now I can use both software without rewiring , much more comfortable and efficient.
    again many thanks .
    a greeting
    • Agree Agree x 1
  4. tombo

    tombo Active Member

    Joined:
    Oct 5, 2013
    Messages:
    269
    Location:
    Germany
    Balance:
    2,436Coins
    Ratings:
    +246 / 2 / -0
    My Motion Simulator:
    DC motor, Arduino
    Hello,
    all my parts for electronics are arrived, and i put it all together today.
    I use an Arduino Nano with smc § Firmware to controll two Motormonsters like descriped by Pit.

    I used this for my wireing
    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)

    Also 5V and Gnd from Arduino are connected.Connection between Smc utilities and Arduino is fine. Also pot connetion is fine.

    I don't have connected my motors yet. Only 12v power supply and tried these steps
    1. Set the Kp, Ki, Kd, PWMmin, PWMmax, PWMrev to 0 for ALL motors (This will make sure the motors don’t move)
    2. Set Clip to 255 (you need to do this first) and Limit to 255 (This will give you plenty of margin if something goes wrong while setting up)
    3. Turn on the power to your motors – nothing should move at this stage!
    4. Set Kp to about 400
    5. Now slowly, increase PWMmax… at some point the motor should start to move. When it does check the “Green” feedback line is moving toward the “Blue” target position.
    as descriped on the first post. If i turn my powersupply on the red led for input lights up at the MM. But there is no led for direction lighting up. I checked EnA and B with voltmeter and meassured nothing when turning the pot. Also MM output is dead.
    5v to MM is ok, it reads about 4,47 on my cheap Multimeter.

    Did i miss something? In code i selected Mode 1. I read somewhere on this thread that a nano works, but did i have to change anything for Nano to work? It's th exact same on both MM and measurements are the same on both.

    Thanks for all your work on Hard and Software, and hopefully i can fix this.
    • Winner Winner x 1
  5. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    Please post high resolution pictures to be sure all wiring is done correctly.
    As designed. No issue here.
    To be sure: A1 and B1 have the same polarity, A2 and B2 have the same polarity.
    That is OK.
    Correct.
    The Arduino Nano is a board based on the ATmega328 (Arduino Nano 3.x) and has more or less the same functionality of the Arduino Duemilanove. As far I have read in comparison with an Uno R3 (from a programming point of view) there is no real difference between the Duemilanove and the Uno 3.

    Perhaps you should try out as a very first strep one h-bridge in "normal" parallel mode to be sure that all works fine.
  6. ericRacer

    ericRacer You get old because you stop playing ! Gold Contributor

    Joined:
    Jun 11, 2009
    Messages:
    251
    Occupation:
    Pilot
    Location:
    Canada, Quebec
    Balance:
    989Coins
    Ratings:
    +147 / 2 / -0
    My Motion Simulator:
    3DOF, Arduino, Motion platform
    Hi,
    I use both (duemilanove and Nano) and they works well, nothing to change.
  7. tombo

    tombo Active Member

    Joined:
    Oct 5, 2013
    Messages:
    269
    Location:
    Germany
    Balance:
    2,436Coins
    Ratings:
    +246 / 2 / -0
    My Motion Simulator:
    DC motor, Arduino
    Thanks for the fast answeres and confirming that it's not the nano.

    Maybe a little error in understanding. I mean the direction Pins from Arduino to MM.
    The outputs A1+A2 and B1+B2 didn't meassure any voltage at all.

    I tired to make as good pictures as possible, because everything is conneted.

    IMG_3523.jpg IMG_3524.jpg

    I've testet all connections again with multimeter and they are on the corret pins.
  8. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    ooops, I did not read your phrase correctly - sorry. ->
    Impossible to confirm if all is correct, IMO you should never use same colors.
    Are you sure? On the MM photo is it hard to determine if 4 and 9 (INA2 and INB2) are both connected, it seems that 9 and 8 are wired together? And why you use silicone? If somethings goes wrong how you want to clear of that stuff?
  9. tombo

    tombo Active Member

    Joined:
    Oct 5, 2013
    Messages:
    269
    Location:
    Germany
    Balance:
    2,436Coins
    Ratings:
    +246 / 2 / -0
    My Motion Simulator:
    DC motor, Arduino
    I only used the same colors for Direction lines. I'm 100% shure wires are correct.
    It is no silicone. It is hotglue to prevent cables from bending at the connection. I heat this up 2-3 seconds with hotairgun and can remove it. I removed a little bit to show better the wireing.

    When i turn the power supply off the led for powerinput is light up very dimm. Maybe there is the error?

    IMG_3529.jpg
    Last edited: Feb 14, 2015
  10. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    ok, please do the following: open SMC3

    Connect the pot (if not done already), set the pot to "zero" (exact in the middle position, controlled by SMC3). Measure Motor 1 PWM and GND, must be nearly zero V. If you raise "Manual" motion, Motor 1 PWM must raise the Voltage. INA2 and INB2 show always ~(-) 4.66 V (voltmeter + on INA2, voltmeter - on INB2), the switching polarity depends the position of the SMC3 motion slider.
    • Like Like x 1
    Last edited: Feb 14, 2015
  11. tombo

    tombo Active Member

    Joined:
    Oct 5, 2013
    Messages:
    269
    Location:
    Germany
    Balance:
    2,436Coins
    Ratings:
    +246 / 2 / -0
    My Motion Simulator:
    DC motor, Arduino
    Everything seems to be right. Getting the 4,.. V alt the Ina1 and 2 lines depending on direction. Pwm channel measueres something about 1V
  12. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    PS: do not connect the MM yet, try the Ard first.
  13. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    ok, so far your Ard works fine. Please try the MM first in parallel mode. Due to the fact that you have already all wired and welded, not the best solution so far, but if you want to know if your MM works or not you have to go back (IMO) to avoid any issues. I always check the MM first in parallel mode and than if all seems to be fine I go forward to the half bridge mode.
  14. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    one more thing - you did not upload a SMC3 screenshot, sometimes it is better to upload any screenshots than write down all the stuff.
    • Agree Agree x 2
  15. tombo

    tombo Active Member

    Joined:
    Oct 5, 2013
    Messages:
    269
    Location:
    Germany
    Balance:
    2,436Coins
    Ratings:
    +246 / 2 / -0
    My Motion Simulator:
    DC motor, Arduino
    Hi,
    Thanks for your help.
    I found the problem. After removing all the wires testing the parralel mode soldering new wires and still no success. I found out it was a simple error in Smc3 Utilities. It was the first time i use it so i didn't see that th motor shuts of itself since the pot goes over limits. So since its off i can't meassure anything :roll:)

    No i got it all connectet and reading the correct voltages.
  16. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    @tombo it is not an error it is a feature. Your example of running into issues confirms me again, in future no further support until the member has posted all screenshots or pictures...anyway glad you solved the issue.
  17. Outatime

    Outatime New Member

    Joined:
    Apr 21, 2014
    Messages:
    29
    Balance:
    215Coins
    Ratings:
    +6 / 1 / -0
    Hello RufusDufus,

    thank you for your great software, motion sim code and wiring diagrams.
    That was very helpful.
    I can build things along a given "path" but I am not good at problem diagnostic and Arduino code.

    I have read all 26 pages of this thread to find a solution for my problem but I didn't find any.

    My setup, some pictures attached:

    ATX powersupply 13A (only for testing, will be changed to a higher AMPs later)
    2x China IBT-2 H-bridges
    2x pots 10k
    2x 12v car winch motors
    Arduino Uno clone running SMC3 firmware
    SimTools v1.3 runs on 1 PC (Windows 7)

    All connections made like in this picture from page 1
    http://www.xsimulator.net/community/attachments/wiring-2-motors-jpg.10925/

    I have been able to make the attached DC motor move with the SMC3 software.
    But both motors only move in one direction and the lines in SMC3 do not follow the feedback line.
    See both screenshots Motor 1 and 2.

    I have tried two days testing all kinds of settings and your code 0.63 and 0.7 in MODE2 and MODE1 but the same results.

    Can you give me a hint please ?
    Thank you very much.
    Jens

    Attached Files:

  18. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    I am on holidays so only a short suggestion before an other would probably help you : Some winches turn only in one direction.
    Last edited: Feb 19, 2015
  19. Outatime

    Outatime New Member

    Joined:
    Apr 21, 2014
    Messages:
    29
    Balance:
    215Coins
    Ratings:
    +6 / 1 / -0
    I had tried the winches with a car battery and they turn both ways.
    They are normal DC motors with two wires.

    But maybe my 13A power supply is to weak. It can't start a single winch motor connected directly (Power supply shuts down).
    Only the PWM with SMC3 makes it possible to drive them.
  20. Pit

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

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,415Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    My winches don't start using a standard PC 1000W PSU (30A). So in this case your PSU is too weak