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

Resolved SMC3 Arduino and changing hall sensor direction?

Discussion in 'New users start here - FAQ' started by xytras, Mar 9, 2017.

  1. xytras

    xytras Member Gold Contributor

    Joined:
    May 28, 2015
    Messages:
    92
    Location:
    germany
    Balance:
    587Coins
    Ratings:
    +23 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Currently I am switching to bigger motors for my 2DOF and while doing so I noticed that one POT delivers quite noisy results so I want to switch to hall sensors and got two of these 6127V1A180L.5 from Farnell.
    Ordered yesterday, got them today :)

    Anyway, I just tried one and connected it to the Arduino. Works almost perfect with very exact output and it can turn 360° and doesn´t get killed. However how do I place it on the opposite side?

    I have two ideas in mind and I don´t like one of them but since many of you already use hall sensors maybe I think too complicated.

    My pots/now sensors are directly mounted to the motor shaft so I could either disassemble one of the sensors and turn the sensor in it around or change the code of SMC3 to recalc the values for the second sensor.

    A different approach would be to directly put a
    SS495A
    on the motor mount and a magnet on the lever. That way is nice since there wouldn´t be any mechanical connection between shaft and sensor and the motor could turn 360° but it also means more work and alignment and I already got the rotary sensors ;-)
  2. xytras

    xytras Member Gold Contributor

    Joined:
    May 28, 2015
    Messages:
    92
    Location:
    germany
    Balance:
    587Coins
    Ratings:
    +23 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    I guess I just found out myself...
    //#define REVERSE_MOTOR1

    :D
    • Winner Winner x 1
  3. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,643Coins
    Ratings:
    +1,009 / 8 / -1
    Yes that will work but only for one Motor - you will need to update code to do the other. This was really only testing code and isn't necessary.

    If the POT is turning in the opposite direction to the Motor (ie the PID can't position motor - get runnaway) you are better off just reversing the wires to the motor.

    If the POT AND Motor can be positioned OK with PID but move opposite to what you want then you can reverse them in Simtools with a checkbox in the Axis settings.
    • Informative Informative x 2
  4. speedy

    speedy Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,193
    Location:
    Alexandria , Egypt
    Balance:
    7,917Coins
    Ratings:
    +1,285 / 10 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    :cheers...
    fireworks-animated-gif-22-2.gif
  5. speedy

    speedy Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,193
    Location:
    Alexandria , Egypt
    Balance:
    7,917Coins
    Ratings:
    +1,285 / 10 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    For one motor ? ... :sos Does that means if I removed the slashes and used MOTOR2 or 3 instead then uploaded it to Ard. >> will work ?

    #define REVERSE_MOTOR2
    or
    #define REVERSE_MOTOR3
  6. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,643Coins
    Ratings:
    +1,009 / 8 / -1
    Sorry @speedy, no that won't work. The reverse motor was just added ages ago for me to do some experimenting, it was only for one motor I was playing with.

    If you want to do the other motors you need to search through the code and everywhere there is a

    #if def REVERSE_MOTOR1
    ....
    code
    ...
    #end if

    you need to duplicate the block and amend for the other motors.

    Can't you reverse the wires to the motor?
    • Informative Informative x 1
  7. xytras

    xytras Member Gold Contributor

    Joined:
    May 28, 2015
    Messages:
    92
    Location:
    germany
    Balance:
    587Coins
    Ratings:
    +23 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Switching the wires. Looks like my brain had the handbrake on yesterday.
    I was so fixed on the sensors that the simplest thing didn´t came to my mind. motors.gif
    • Winner Winner x 1
  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
    • Like Like x 1
  9. speedy

    speedy Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,193
    Location:
    Alexandria , Egypt
    Balance:
    7,917Coins
    Ratings:
    +1,285 / 10 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform
    Yes I can with normal pot and no with hall effect ...
    Actually using a 1:1 gear would do the trick but less is more ... If I can do with the code

    Q2: Can I make 3 copy of those blocks renameing them for each motor ... then use 3 of those define command at the start to activate/deactivate the required motor ?

    I'm sorry it seems like a dum question that I have to try myself ... but I need to know the cons on the whole code performance if there is ?

    Q3: if OK to Q2 :grin ... then for reversing the motor pot ... can this be added to the Util. as a check box for each motor ?

    Thanks
    Gre:Dedy
    Last edited: Mar 10, 2017
  10. xytras

    xytras Member Gold Contributor

    Joined:
    May 28, 2015
    Messages:
    92
    Location:
    germany
    Balance:
    587Coins
    Ratings:
    +23 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Alright, just burned one of the IMS-1. Damn, not my day. Don´t even know why it burned but it obviously didn´t like the flipping of the motor cables :-/
    Gotta order some new IMS-2B and be more careful then.

    Oh no... the 2B is 12V only ... sh...
  11. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    15,643Coins
    Ratings:
    +1,009 / 8 / -1
    Why does it matter if you have a POT or Hall sensor to reverse the Motor wires?
  12. xytras

    xytras Member Gold Contributor

    Joined:
    May 28, 2015
    Messages:
    92
    Location:
    germany
    Balance:
    587Coins
    Ratings:
    +23 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    It doesn´t matter, though I reversed the wires on the pot when I used pots because the graph in SMC3 remains visually logical. I guess that is where you get easily confused because the graph turns around when you reverse the wires on the motor. And since you cannot reverse the wires on a Hall sensor the reversed graph isn´t avoidable. It is silly but it was a trap for _my_ brain ;-)
    • Informative Informative x 1
  13. Steamcatcher

    Steamcatcher New Member

    Joined:
    Jun 20, 2023
    Messages:
    3
    Occupation:
    Mechanical Engineer
    Location:
    Switzerland
    Balance:
    27Coins
    Ratings:
    +2 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    It looks like a little older post but nevertheless, I hope somebody will write back.

    Only to be certain about the different direction off pot and motor, is it possible to do so? I mean theoretically its doable with code but can it be done with the smc3.ino and the arduino and does it work in the end?

    And yes, I am aware that I should have look on this before building my rig but from a perspective of code - I was certain that it would have this feature.


    (;-D for all the builders that are getting nightmares from the screws - they are only temporally and will be replaced with a key that can handle the force )
    Motor_with_hall_pot.png

    Update: 23.06.2023
    Found the solution in https://www.xsimulator.net/community/threads/motors-reversed.16898/
    Last edited: Jun 23, 2023