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

Question SMC3: Compatible with Encoder instead of Pot/Hall?

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by RMVS Team, Mar 12, 2017.

  1. RMVS Team

    RMVS Team New Member

    Joined:
    Dec 28, 2016
    Messages:
    6
    Location:
    San Jose
    Balance:
    136Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, SCN6, Arduino, 4DOF
    Hey XSim Community.

    I have been following this forum for awhile now and am going to start my DIY build with a table-top size simulator first to get familiarized with all the software and electronics before I invest into a large scale rig. I am going with a 3DOF seat mover design (two motors in the back for roll/pitch and one on the bottom for yaw or heave). Ultimately, I'd like to use linear actuators (like SCN5 or SCN6), but I plan on using 24V Hitachi DC motor with encoder (and possibly make them into linear actuators) for small scale.

    I am following the SMC3 guide written by RufusDufus.

    Although I have 10k ohm potentiometers, I am wondering how I can go about using the encoders on the motor. Would SMC3 be compatible with the encoders? I know for potentiometers/halls (3 pins), the feedback pins are A0, A1, and A2. However, the encoders have 4 pins, two of which are Output A and Output B (see images). This potentially means I need to use A0 and A1 for Motor 1, A2 and A3 for Motor 2, and A4 and A5 for Motor 3.

    This is my first time working with the encoder so I am not sure if I need both Output A and B. If it is possible to use the encoder, what code/components do I need to modify?

    Some specs you guys may be wondering about:
    - L298N H-Bridge x 2
    - 24V Hitachi DC Motor with Encoder x 3
    - 24V 5A Power Supply
    - Arduino Mega 2560

    Thanks. Your feedback is most welcome!

    Encoder4Pin.PNG Potentiometer3Pin.PNG
  2. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,650Coins
    Ratings:
    +1,009 / 9 / -1
    It's not impossible to use encoders but would be a reasonable change to the SMC3 code.

    Quadrature encoders send pulses on both the A and B signals which need to be monitored and depending on the current state and which one changes dictates which way the encoder/motor is turning. So the first thing you would need to do is write some functions (most likely ISR's) to do this - or find some prewritten libraries.

    Next this just gives a direction and step count, not an absolute position. So you need some way find a known position at power on and then keep track of all the steps from there. This is usually done by driving the motor one way until it hits a limit switch and then use that as reference zero.

    The next challenge is the ppr count on the encoder. The poor little arduino is working pretty hard on the PID calculations so if the ppr of the encoder is too high it might have trouble keeping track of all the pulse changes.

    I have seen somewhere that there was code for driving stepper motor... this might be a better place to start as I think they kept track of the steps of the stepper to track position - but I could be wrong.
  3. Bernd Manger

    Bernd Manger Active Member

    Joined:
    Oct 6, 2015
    Messages:
    156
    Occupation:
    Measurement and control mechanic
    Location:
    Germany
    Balance:
    1,050Coins
    Ratings:
    +263 / 12 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    That's right. But it's possible:

    https://www.xsimulator.net/community/threads/2dof-with-wheelchair-motors.7905/page-2#post-125188
    • Winner Winner x 1
  4. RMVS Team

    RMVS Team New Member

    Joined:
    Dec 28, 2016
    Messages:
    6
    Location:
    San Jose
    Balance:
    136Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, SCN6, Arduino, 4DOF
    Thank you both for responding. I believe I might have found the encoder library that I can use, and yes they are written with ISRs. @Bernd Manger, nice rig Bernd and I would love to see what you'll soon share about the related code for encoders.

    For now, I'll use pots to get familiar with interfacing the electronics with the software and see if I can write something for encoders. Thanks guys for your insights. Keep them coming.

    Attached Files:

    • Like Like x 1
  5. speedchase

    speedchase New Member

    Joined:
    Mar 10, 2017
    Messages:
    12
    Location:
    Plano, TX
    Balance:
    266Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    2DOF
    I would really like SMC3 to have a version for built-in encoders (which in most cases are optical) since it will save us all the hassle of dealing with Potentiometers (mechanical or hall). :!
    • Like Like x 1