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,603Coins
    Ratings:
    +1,008 / 8 / -1
    For those interested in another Arduino controller...

    SMC3

    The SMC3 is a "Simulator Motor Controller for 3 Motors" written for the Arduino UNO R3. At the time of writing this it has not been tested on any other Arduino model. The SMC3 uses a PID motor control loop. The PID algorithm has been optimised for this application and achieves 4096 PID updates per second for all three motors giving smooth precise motor control with well tuned parameters. Some characteristics of the controller:

    • Designed specifically for use with Simtools motion control software
    • Controls the position of upto three motors using analogue feedback
    • Hard (reverse) braking if motors move beyond defined limits
    • 10bit accuracy (1024 steps) for both "target" position commands and position "feedback"
    • Extensive command set to setup and monitor the parameters for each motor
    • A second serial port for (optional) real time "live" monitoring/configuration
    • 4096 PID calculation updates per second for each motor
    • Companion windows software to configure and monitor the SMC3
    There are currently two MODES of operation that are configured by a single line of code at compile time before uploading to the Arduino.

    MODE1: Supports the more common H-Bridges used in the forums. This mode has a PWM output pin plus two Motor Direction output pins. Examples include the MonsterMoto shield.

    MotoMonster.jpg

    REFER TO POST #3 BELOW IF YOU NEED MORE POWER

    MODE2: Designed for H-Bridges that require direct drive of Highside and Lowside switch inputs. In this mode one switch is driven as a direction pin and the other with the PWM output however the PWM duty needs to be inverted whenever the motor changes direction with the direction pin. (An alternate approach would be to switch the PWM between inputs as direction changes) An example H-Bridge that uses this mode is the cheap 43A IBT-2 found on ebay.

    IBT-2.JPG

    Software Setup

    As the SMC3 is an Arduino motor controller the first thing you need to do is get the software onto your "Arduino UNO R3".

    1. Download the SMC3 software attached to this post (SMC3.ino)
    2. Get the Arduino IDE tools installed on your computer if you don't already have them. Follow the Arduino Getting Started guide found here: http://arduino.cc/en/Guide/Windows (Note the step for installing the drivers!)
    3. Open the SMC3.ino with the Arduino IDE
    4. Edit the code at the top if the file to select the MODE you will be using
    5. Compile and Download the SMC3.ino program to your Arduino UNO R3

    If you want, you could now jump to the Windows SMC3 Configuration software and check communications before proceeding further. (Refer next post)

    Wiring Details

    Code:
    //                    +----+              +------+
    //                  +-|PWR |--------------| USB  |-----+
    //                  | |    |              |      |     |
    //                  | +----+              +------+    o|
    //                  |                                 o|
    //                  |                                 o|AREF
    //                  |                                 o|GND
    //                NC|o                                o|13    TTL (software) Serial
    //             IOREF|o  +----+                        o|12    TTL (software) Serial
    //             RESET|o  |    |                        o|11~  PWM Motor 3
    //              3.3V|o  |    |                        o|10~  PWM Motor 2
    //                5V|o  |    |    Arduino             o|9~    PWM Motor 1
    //               GND|o  |    |      UNO               o|8
    //               GND|o  |    |                         |
    //               VIN|o  |    |                        o|7      Motor 3 ENB
    //                  |   |    |                        o|6~    Motor 3 ENA
    //   Motor 1 Pot  A0|o  |    |                        o|5~    Motor 2 ENB
    //   Motor 2 Pot  A1|o  |    |                        o|4      Motor 2 ENA
    //   Motor 3 Pot  A2|o  |    |                        o|3~    Motor 1 ENB
    //                A3|o  |    |                        o|2      Motor 1 ENA
    //                A4|o  |    |                        o|1
    //                A5|o  +-/\-+                        o|0
    //                  +-\                      /---------+
    //                     \--------------------/
    
    SMC3Pinout.JPG

    MODE1:

    Example wiring details for Monster Motor Board (again thanks to @eaorobbie for drawing)
    MotoMonsterSetup.jpg

    MODE2:

    Edit the SMC3 code for Mode 2 like this.

    Arduino to H-Bridge (Chinese 43A)

    ENA ----> IN1/RPWM
    ENB --+-> EN1/R_EN
    +-> EN2/L_EN (ie connect ENB to both R_EN and L_EN)
    PWM ----> IN2/L_PWM
    n.c. ----> IS1/R_IS
    n.c. ----> IS2/L_IS
    +5V ----> VCC
    GND ----> GND


    The image below shows wiring for two motors... Thanks to @eaorobbie for getting me started with the image :thumbs
    Wiring-2-Motors.jpg

    *** to come ***

    Initial Setup

    I strongly recommend you follow the steps below if this is the first time you are using SMC3 with your simulator to reduce the risk of damaging anything.

    1. Disconnect the motor power supply
    2. Make sure Simtools is not running – we’re not ready for that yet!
    3. Wire up the Arduino (with SMC3 installed) to your H-Bridges and connect to your computer via USB
    4. Run the Windows SMC3 Utility software and make sure it communicates with the Arduino (There is no need to set baud rates, they are not configurable)
    5. Set the Kp, Ki, Kd, PWMmin, PWMmax, PWMrev to 0 for ALL motors (This will make sure the motors don’t move)
    6. 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)
    7. Turn on the power to your motors – nothing should move at this stage!
    8. Set Kp to about 400
    9. 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.
      • If it is then that motor and feedback is wired correctly - proceed to test other motors.
      • If it is moving away turn off motor power immediately (or quickly reduce PWMmax again). In this case you need to either reverse the wires to the motor being tested –OR– reverse the +5V and GND wires to your feedback pot for the motor being tested (do not do both). Restart the test from the beginning.
    10. Do the above for each motor

    The Second Serial Port

    Temporarily disabled as of v0.63 - Use UDP Mode with SMC3Utils instead.

    The SMC3 has a second (software driven) serial port that can also be used to setup and monitor the controller. The main use for this port is to provide “live” setup and monitoring while the controller is actually running and connected to simtools via the main USB serial port. All of the SMC3 commands are available through the second serial port however you need to be aware that only one port should be used to send position commands. You would normally connect to this second serial port using a second computer such as a laptop or an old desktop. I would not recommend using the Game machine or the computer running Simtools (especially if you are just starting out with Sim software) to also monitor the SMC3 second serial port.

    To use the second serial port you will typically require a TTL serial to USB interface board (commonly found on ebay for a couple of $). Once you have the second serial port connected to a computer you can run the Windows SMC3 Utility software to setup and monitor the controller in the same way as the main serial port, but as mentioned above generally it would be left in the monitor mode so that Simtools is the only program sending position commands to the SMC3.

    Why is a second serial port necessary you may ask… well it isn’t necessary however it allows you to see how well the SMC3 Motor Feedback loop actually tracks the motion data being sent by Simtools allowing fine tuning of the parameters while working with real motion data rather than just a square or triangle wave etc.

    As with the main USB serial port, the second serial port is hard coded to operate at 115200 baud, No Parity, 8 data bits, 1 stop bit.



    Simtools Setup

    Setup for Simtools 2 is very straight forward:

    Interface Type - Serial

    ComPort = the Arduino ComPort, you can find it in Windows Device Manager.

    BitsPerSec - 500000

    Data Bits - 8

    Parity - None

    Stop Bit -1

    Output Bit Range - 10

    Output Type - Binary

    Interface Output - [A<Axis1a>][B<Axis2a>][C<Axis3a>]
    [​IMG]

    *** NEW VERSION SMC v1.0.zip AVAILABLE 21/05/17 ***
    Updates Version 1.0

    • Fixed bug where Fpwm was loaded after the timers were initialised hence user set values were not used
    • Fixed bug where minimum cutoff limits for motors 2 and 3 where incorrectly using the motor 1 limit.
    Updates Version 0.7

    • Added a POT scaling input that can be used to scale the motion output based on the POT position
    • POT scaling can be setup as one of two modes - Linear or non-linear
    • DO NOT ENABLE POT SCALING UNLESS POT ATTACHED TO ARDUINO
    • AN5 used for POT scaling input
    • The non linear scaling is designed to try and reduce the overall motion but maintain the "smaller" movements as best possible - ie road noise and stuff, but scale back on the huge side to side motion you get in higher power cars.
    scaling.jpg

    Updates Version 0.63

    • Fixed a timer rollover bug
    • Removed second software serial as conflicts with PWM freq change (UDP is much more convenient anyway)

    Updates Version 0.6
    • Added ability to change PWM freq (5,10,15,20,25,30,35 kHz for motors 1 and 2) (4 and 31 kHz for Motor 3 - Arduino limitations)
    • Added I term reset when the error is zero
    • Added the ability to change the PID calculation rate (Fpid divider)
    • Added a smoothing function to the D term calculations (Ks)
    • Updated interface commands to support latest Windows SMC3Utils program

    Attached Files:

    • Like x 52
    • Winner x 11
    • Informative x 11
    • Useful x 4
    • Agree x 3
    • Friendly x 2
    Last edited by a moderator: Aug 16, 2023
  2. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,603Coins
    Ratings:
    +1,008 / 8 / -1
    SMC3 Windows Utilities

    *** NEW VERSION SMCUtils v1.01.zip AVAILABLE 29 Sep 15 ***
    SMC3Utils Explained.JPG

    Installation

    Simply unzip the SMC3Utils (attached) into a directory of your choice and run from there.

    Edit the SMCUtils.ini file with notepad or a text editor to setup your serial comm port used to connect to Arduino.

    Tuning Parameters

    OK, now that you know your motors aren’t going to race off in the wrong direction you can start tuning the parameters. Again this is done with the Windows SMC3 Utility software – so far we haven’t gone near any sim software! If you have experience tuning PID control loops then you can probably jump in and setup to your liking, however it would be worth scanning the following steps to get familiar with the clipping, limiting, and braking parameters

    Clip Input Used to create a band at either limit of the target range beyond which any values sent to the SMC3 are clipped. In addition to this clipping, if the motor feedback does move beyond this range (typically through inertia), the SMC3 will attempt to brake the motors hard by driving them in reverse until they are back out of this limit zone. The value can be anything from 0-255 (however can’t be less than the current limit setting). Reverse braking is applied in the band between the Clip Input and the Max Limit settings. Reverse braking can be disabled - refer to PWMrev.

    Max Limits Used to create a band at either limit of the feedback range beyond which if the motors move (typically through inertia) the SMC3 will automatically shutdown the drivers and keep them disabled until reset. This is essentially a safety mechanism if something goes wrong. The value can be between 0-255 (however can’t be greater than the current clip setting).

    Limits.JPG

    Deadzone This creates a hysteresis zone for the motor feedback If you need values greater than 1, you probably have too much “slack” in your mechanical setup.

    Fpid / By default the PID loop performs 4000 calculation updates per second. This divider enables you to reduce the number of PID calculations per second by the divided amount. Sometimes this can help if the motor windings are producing audible noise. The approx number of calcs per second is displayed in the center bottom of the SMC3 Utils window. (This may jump around a bit as it is just an indicator)

    Kp The proportional term of the PID loop. Essentially the larger the value here the “harder” the SMC3 controller will try to drive the motor to bring it to its target position. It is scaled by the distance away the motor is from its current target position, again the further away the harder it is driven (within the constraints set by other parameters) This is typically the main tuning parameter and the greatest effect – this can even be used alone with Ki and Kd set to 0. The setting will be very dependent on the motors, H-bridges, and mechanical loads however values in the range 300 to 500 would not be uncommon with the SMC3. Allowed values range from 0-1000.

    Ki The integral term is useful to help get the steady state error closer to zero. Generally speaking for sim designs I have found that if you have large enough PWMmin and Kp values the need for Ki is reduced and it can often be set to 0. Too large a Ki can cause the position to overshoot and oscillate.

    Kd The derivative term is great for reducing overshoot on fast step changes in position... The negative effect is that it can slow down the movement particularly when the target undergoes a step change.

    Ks This is a "smoothing" parameter for the Kd term. Essentially the Kd parameter is only computed when the loop counter matches this value. So a Ks of 5 means the Kd term will only be updated once every 5 times the other parameters are calculated.

    Fpwm The frequency of the selected Motor PWM. Note Motors 1 and 2 are tied together and will always have the same PWM frequency and have more selection options than Motor 3. This is a limitation of the microprocessor used on the Arduino Uno.

    PWMmin This is the minimum duty cycle that is used to drive the motors to their target position. For example if the motors are already close to target they will not need to be driven as hard as if they are a long way from target (or they may overshoot and oscillate). The reason we don’t just use 0 is that due to friction, loads, and other factors, the motors will need a certain minimum current just to get them moving. This helps us set that minimum. Settings are in the range 0-255 (which are mapped to the range of 0-100% duty cycle) however cannot be greater than PWMmax setting.

    PWMmax This is the maximum duty cycle that is used to drive the motors to their target position. As the target position gets further away from the actual position the control loop attempts to increase the motor drive (PWM) to get it to the target position. It will increase the PWM until it reaches PWMmax.

    PWMrev This is the PWM duty cycle that is used to drive the motors in reverse (hard brake) if they enter the limit zone. Higher values here will brake the motor harder but will draw more current and heat the H-Bridge more. It may also cause an abrupt jolt in your sim as it tries to change direction. Setting this to a similar value as PWMmax would make sense. If you want to disable the revers braking then simply set this value to 0 and the position will be driven by the normal PID algorithm. Settings are in the range 0-255 which are mapped to the range of 0-100% duty cycle.



    Other Settings



    Connecting to Simtools via UDP

    Simtools has the great ability to output the motion data over your network via UDP instead of (or as well as) sending data via a serial port. The Windows SMC3 Utility software now has the ability to receive this network UDP motion data from Simtools and pass it onto the Arduino SMC3. So why setup such a complicated arrangement? Well it’s not actually that complicated and it allows you to perform real time monitoring and setup of the controller while Simtools is running without the need for the second serial port hardware mentioned above. If this approach is used it is still recommended that a second computer be used to run the Windows SMC3 Utility software (especially if you are just starting out with Sim software).

    udp.jpg

    *** NEW VERSION SMCUtils v1.01.zip AVAILABLE 29 Sep 15 ***

    Updates Version 1.01

    • Same as v1.00 but with cmd debug window removed
    • v1.00 Added buttons to center motors in manual mode - buttons next to slider on right

    Updates Version 0.63

    • Fixed variable locking between UDP and Main threads
    • Optimised charting

    Updates Version 0.6
    • COMM Port# Now setup in SMCUtils.ini file - edit with notepad or text editor
    • Added UDP Simtools monitoring and pass through
    • Provided a "step by" value to assist in changing parameters faster
    • Added a save chart snapshot button
    • Added save/load parameters to/from file
    • Improved the charting
    • Increased Arduino comms speed to 500 Kbaud
    • Added manual mode control and adjustment slider

    Attached Files:

    • Like x 43
    • Winner x 7
    • Useful x 2
    • Agree x 1
    • Optimistic x 1
    Last edited: Sep 29, 2015
  3. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,603Coins
    Ratings:
    +1,008 / 8 / -1
    WANT MORE POWER??

    Thanks to @Pit's experiments he has worked out how two connect two Monster Moto output drivers together to drive a single motor using SMC3, thus increasing the available power available to drive the motor.

    His full thread and discussion can be found here: http://www.xsimulator.net/community...cts-as-a-single-motor-driver-more-power.5482/
    And the main post has been included below for convenience to get you started.

    --------------------------------------------------------------

    The Monster Moto (MM) from Sparkfun or dx.com (Hummer Driver) uses the VNH2SP30-E motor driver, these bridges will be used as a high power full (double) bridge driver normally. If someone is using strong motors like winches (as the mines) you need more powerful h-bridges: The VNH2SP30 can be used as a half-bridge. The famous jrks12v12s works great but are expensive (~100$ one sample). The Monster Motos are cheap (one bridge about 17$ at Aliexpress.com) and easy to use with an Arduino as a controller (17$).

    [​IMG]

    The VNH2SP30 has a maximum current rating of 30 A and a continuous current of 14 A. As a half bridge (using two VNH2SP30 for one motor) you "double" the power of your h-bridge. That means, if more "Ampere" is needed, the MM can handle it. "Volt" is being left unchanged.

    This tutorial is an addition to the SMC3 Arduino 3DOF Motor Driver and Windows Utilities code. Not tested but probably working the Arduino UNO/Duemilanove 2dof firmware (caution notice: different wirings to the Arduino needed!!).

    To get one Monster Moto working you have to wire the two boards described as follows:

    [​IMG]
    Remark: The wiring meets the specifications of the MM. This is important to prevent any short circuit.

    SMC3 code can access up to 3 motors using one Arduino. If you want to connect 3 MM please wire described as follows:

    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)

    The outputs:
    A1 and B1 will have the SAME polarity
    A2 and B2 will have the SAME polarity, too.

    FAQ - PLEASE READ

    - To be sure before connecting a motor to the h-bridge use a power meter to check the polarity of A1/B1 and A2/B2 separately if all is wired correctly!
    - Use any coolers. You could (and will) damage the bridge in despite of the thermal shutdown.
    - The settings and values of the two motors (or VNH2SP30 chips) of SMC3 MUST be identical.
    - All other postings with different wirings in this thread are obsolete.


    All on your own responsibility!

    All Credit belongs to @@RufusDufus :) He helped a lot and without him I would be helpless and nowhere.



    Update 6/11/2014

    ----------------------------------------------------------------------------------

    SMC3 Command Set

    All commands to/from the SMC3 are sent as data packets each 5bytes long. They start with a left square bracket '[' and end with a right square bracket ']'. Typically the second byte is the command and the third and forth bytes are the parameters.

    Code:
    Packet Sent            Description                                                                                              Response Packet
    -------------------------------------------------------------------------------------------------------------------------------------------
    [Axx],[Bxx],[Cxx]  Send position updates for Motor 1,2,3 where xx is the binary position limitted to range 0-1024            None
    [Dxx],[Exx],[Fxx]  Send the Kp parameter for motor 1,2,3 where xx is the Kp binary value (restrict to 0 - 1000)              None
    [Gxx],[Hxx],[Ixx]  Send the Ki parameter for motor 1,2,3 where xx is the Ki binary value (restrict to 0 - 1000)              None
    [Jxx],[Kxx],[Lxx]  Send the Kd parameter for motor 1,2,3 where xx is the Kd binary value (restrict to 0 - 1000)              None
    [Mxx],[Nxx],[Oxx]  Send the Ks parameter for motor 1,2,3 where xx is the Ks (d term smoothing parameter between 1 and 20)    None
    [Pxy],[Qxy],[Rxy]  Send the PWMmin and PWMmax values x is the PWMmin and y is PWMmax each being in range 0-255              None
                        PWMmax should always be greater than or equal to PWMmin
    [Sxy],[Txy],[Uxy]  Send the Motor Min/Max Limits (x) and Input Min/Max Limits (y) (Note same value used for Min and Max)    None
    [Vxy],[Wxy],[Xxy]  Send the Feedback dead zone (x) and the PWM reverse duty (y) for each motor                              None
    [mo1],[mo2],[mo3]  Request continous motor position, feedback, pwm and status data (all packets sent every 15ms)            [Axy][Bxy][Cxy][axy][bxy][cxy]
    [mo0]              Disable continuous feedback from previous [mo1],[mo2], or [mo3] command                                  None
    [ena]              Enable all motors                                                                                        None
    [sav]              Save parameters to non-volatile memory                                                                    None
    [ver]              Request the SMC3 software version, returned value is mult by 100.  (ie: 101 is ver 1.01)                  [vyy]
    [rdA],[rdB],[rdC]  Request motor target and feedback for Motor 1,2, or 3 parameters scaled 0-255.                            [Axy][Bxy][Cxy]
    [rda],[rdb],[rdc]  Request motor pwm and status data for Motor 1,2, or 3 parameters scaled 0-255.                            [Axy][Bxy][Cxy]
    [rdD],[rdE],[rdF]  Request the Kp parameter for motor 1,2,3 where xx is the Kp value multiplied by 100                      [Dxx][Exx][Fxx]
    [rdG],[rdH],[rdI]  Request the Ki parameter for motor 1,2,3 where xx is the Ki value multiplied by 100                      [Gxx][Hxx][Ixx]
    [rdJ],[rdK],[rdL]  Request the Kd parameter for motor 1,2,3 where xx is the Kd value multiplied by 100                      [Jxx][Kxx][Lxx]
    
    
    Note the Arduino SMC3 code does not check values sent are within valid ranges.  It is the job of the host application to keep values within
    sensible limits as recommended above.


    **** Documentation in progress ***
    • Like Like x 28
    • Useful Useful x 4
    • Informative Informative x 3
    • Friendly Friendly x 3
    Last edited: Nov 22, 2014
  4. Historiker

    Historiker Dramamine Adict Gold Contributor

    Joined:
    Dec 16, 2010
    Messages:
    2,158
    Occupation:
    Retired
    Location:
    Michigan USA
    Balance:
    9,176Coins
    Ratings:
    +2,156 / 19 / -1
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    This is Awesome! Thanks Rufus! :thumbs
    • Like Like x 2
  5. davepeebs

    davepeebs New Member

    Joined:
    Nov 11, 2013
    Messages:
    24
    Occupation:
    G.M
    Location:
    Sydney Australia
    Balance:
    619Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Great work! Thank you for all your efforts.
    • Like Like x 2
    • Creative Creative x 1
  6. RaceRay

    RaceRay Administrator Staff Member SimAxe Beta Tester

    Joined:
    Nov 8, 2006
    Messages:
    4,656
    Occupation:
    Self-employed | Web and application development
    Location:
    Hamburg, Germany
    Balance:
    23,837Coins
    Ratings:
    +1,958 / 13 / -0
    My Motion Simulator:
    2DOF, DC motor, SimAxe, SimforceGT
    • Like Like x 2
  7. doctorxeno

    doctorxeno Member

    Joined:
    Nov 10, 2013
    Messages:
    33
    Balance:
    607Coins
    Ratings:
    +19 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    • Like Like x 1
    • Agree Agree x 1
    • Useful Useful x 1
  8. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,133
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    47,907Coins
    Ratings:
    +5,027 / 16 / -0
    I would use a cross-over cable rather than a network switch.
    you can put a second network card in the SimTools PC (if you still want internet from the first nic), and then use a cross-over cable between the SimTools and the SMC3 PC.
    (static network settings needed)

    This would give that fastest possible connection and may improve the output speed a bit.
    yobuddy
    • Like Like x 3
    • Winner Winner x 2
    • Agree Agree x 1
    Last edited: Dec 13, 2018
  9. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,603Coins
    Ratings:
    +1,008 / 8 / -1
    Good point... it is always worth highlighting the various options, different approaches may work better for various individuals. (I already have a 1Gbit network switch between computers so didn't even occur to me there maybe other possibilities).

    Note wireless could also be used. Probably the slowest overall but if that is all you have it would be worth doing some tests before committing loads on extra hardware.

    As the final link in the communications chain is serial running at 115200baud it will take 1.3ms to transfer 3 packets of data for all three motors and Simtools has a 1ms delay minimum between position commands. From experience the speed if this connection is not super critical. Trying to send data packets at a rate faster than this is unnecessary as the PID loop won't be getting any benefit from the extra data. What is more critical is the lag that is created from the game motion output to the sim movement. Of course minimising unnecessary delays in comms setups is always good practice though.
    • Like Like x 2
  10. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,603Coins
    Ratings:
    +1,008 / 8 / -1
    pololu-20a-single-motor-controller.jpg
    I would use SMC3 in MODE1 which can drive the Pololu board in its "Sign-magnitude (drive-brake)" mode

    Connections would be:

    SMC3 <----> Pololu Board
    GND <----> GND
    PWM ----> PWM_H
    ENA ----> DIR
    ENB ----> not connected
    not connected ----> PWM_L

    It is always a good idea to first test using a cheap toy motor and a 1.5V battery (may need 6v lantern or 9v battery for this board to power the logic!) if you have them handy. (manually turn the feedback pot and the motor should speed up, slow down, and change direction as you adjust the pot around the target position.

    I note the board in question has no over temp or over current protection so be careful, and keep them cool. Start out using a PWMmax setting below 200 until you get things working well and see how hot everything gets.
    • Like Like x 3
    Last edited: Dec 12, 2013
  11. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,568Coins
    Ratings:
    +1,831 / 32 / -1
    Nice piece of work @RufusDufus :cool:. I would like to ask you what language was used to create the SMC3 Windows Utilities? And are you able to give any insight as to how the oscilloscope is implemented in the code? I was wondering if it uses an independent control or if you hard coded its workings. I program in vb6 and I can’t seem to find a oscilloscope control for it anywhere. At least not now. Thanks.
    • Like Like x 2
  12. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,603Coins
    Ratings:
    +1,008 / 8 / -1
    It is written if Freebasic mand just draws lines straight to the graphics region - quite low level (and quite messy code). I generally write code to get the results I want in the quickest way possible rather than for neatness, code readibility, sharing, and all that other good stuff! ;)
    • Like Like x 2
  13. 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
    This is Awesome! Great work! :thumbs This is our holiday gift :thumbs

    I am very excited to try it with my new project. I think using your software with this motor driver :
    http://www.robotshop.com/ca/en/pololu-dual-motor-driver-14a.html
    i think it is a good choice ? :thinkbut.....I hesitate a bit

    Because there is another interesting solution .... Polulu with feedback, but much more expensive

    http://www.robotshop.com/ca/en/pololu-jrk-12a-6-16v-usb-motor-controller-with-feedback.html
    $ 420 (4x105.00(single)) for 4 engines

    versus

    http://www.robotshop.com/ca/en/pololu-dual-motor-driver-14a.html
    $ 126 (2x63.11(dual)) for 4 engines (with arduino)


    So, before buying my pieces, I wonder which is the best solution or are they equivalent?

    Eric :cheers
    • Like Like x 2
  14. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,603Coins
    Ratings:
    +1,008 / 8 / -1
    The Pololu products definately seem to have a good reputation in the sim community. @bsft and @eaorobbie have plenty of experience and good things to say.

    And yes difficult choices to make... going the off the shelf route often seems more expensive but if you are a bit unsure about setting up the DIY approach you can often burn lots of money having to replace parts if they get damaged.

    I think all the models you have linked to are good products - it really just comes down to the DIY vs Risk trade offs and which one makes you more comfortable. I have an electronics background and like "playing" so that was half the decision for me and if I destroy something... well its my fault because I should know better. :think
    • Like Like x 4
    • Agree Agree x 1
  15. bsft

    bsft

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
    I only have experience in the Pololu JRK, but apart from user stupidity (points to himself), it has been almost bulletproof for 12v simplicity in set up.
    • Like Like x 3
  16. value1

    value1 Nerd SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Jan 9, 2011
    Messages:
    2,184
    Location:
    Zug, Switzerland
    Balance:
    14,462Coins
    Ratings:
    +3,318 / 11 / -1
    My Motion Simulator:
    2DOF, DC motor, JRK, Joyrider
    LOL me too. My learnings: Don't short when voltage applied and don't let an electrostatic spark destroy your JRK :D
    • Like Like x 1
  17. 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
    Thanks for your answer ! :)

    @RufusDufus :
    I know Polulu JRK are highly appreciated by the community, :rolleyes: but I am more familiar with Arduino :think

    I also have a background in electronics (a very long time ago) and I'm somewhat familiar with Arduino.

    The reason I find it difficult to decide between the two solutions is (perhaps) the benefit of Polulu JRK that integrates PID function with Drivers on the same Board while with Arduino, there communication between drivers and Arduino.

    So if you think this difference is negligible, I will continue with Arduino :nerd

    Thanks for your work and fast reply :cheers
    Eric
    • Agree Agree x 1
    Last edited: Dec 12, 2013
  18. eaorobbie

    eaorobbie Well-Known Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,574
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    20,390Coins
    Ratings:
    +1,683 / 23 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    I would have to disagree the Jrk is much faster at what it does I have had both systems, motion once refined in the Jrk settings can be quite amazing with precise control, you get what you pay for , plus easy of hook up and setup.
    The Ard stuff has come along way and to me if you are more familiar and as stated have some electronic knowledge then the Ard is the pick for you and you
    • Like Like x 1
    • Agree Agree x 1
    • Old Old x 1
  19. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,568Coins
    Ratings:
    +1,831 / 32 / -1
    Thanks for the information @RufusDufus . I see that freebasic has an easy way to move a chunk of graphics around. However, if I understand enough, it lacks any controls unless they’re in libraries somewhere I don’t know about. That takes me back to ’80 style programming and after using vb6 with a massive amount of controls I wouldn’t want to go back. It just saves so much time its unreal.

    As far as coding goes, if you are coding alone and don’t plan on anyone else seeing it, then sloppy is fine by me. That is, as long as your code stays fairly optimized. It’s like when I would rather spend time on my rig and writing code instead of cleaning my house. I don’t mind it a little sloppy but it’s a little embarrassing when others see it that way! :blush

    Thanks for sharing! Again, terrific job.

    PS You must be a perfectionist because your arduino code is very well commented. I hate taking the time to do that myself so I appreciate it.
    • Like Like x 2
    • Agree Agree x 1
  20. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,603Coins
    Ratings:
    +1,008 / 8 / -1
    Correct it doesn't have inbuilt windows control libraries. There is a library called gui_chung (easy to find with google) that I use that makes things alot easier but it's still no where near VB.
    • Like Like x 2
    • Agree Agree x 1