1. 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!
  2. 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
  3. 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

Motion chair arduino simulator. Problem with pots?

Discussion in 'New users start here - FAQ' started by bartez81, Dec 3, 2013.

  1. bartez81

    bartez81 i like amps

    Joined:
    Feb 11, 2012
    Messages:
    40
    Location:
    Kraków
    Balance:
    72Coins
    Ratings:
    +14 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN6, Arduino, JRK, Motion platform
    Hello
    I just try to finish wiper motor simulator. Im using typical arduino code. I have a little problem with potentiometers i think. In simulation and in AXIS , DOF move test arm mounted on wiper move sometimes like in feaver up and down and stops on right position. What i heve to do to fix it? Or where i should looking? And i thing right axis works faster than left...
    I have to modify the Arduino code? Both engines settings are the same. This is probably the last issue of the platform I have left. I'm using a 10k ohm potentiometer without move limiter.
    Regardzz
  2. Ads Master

    Ads Master

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
  3. bartez81

    bartez81 i like amps

    Joined:
    Feb 11, 2012
    Messages:
    40
    Location:
    Kraków
    Balance:
    72Coins
    Ratings:
    +14 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN6, Arduino, JRK, Motion platform
    [​IMG] my sim visualisation.
  4. bartez81

    bartez81 i like amps

    Joined:
    Feb 11, 2012
    Messages:
    40
    Location:
    Kraków
    Balance:
    72Coins
    Ratings:
    +14 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN6, Arduino, JRK, Motion platform
    there

    Attached Files:

  5. tombo

    tombo Active Member

    Joined:
    Oct 5, 2013
    Messages:
    269
    Location:
    Germany
    Balance:
    2,353Coins
    Ratings:
    +244 / 2 / -0
    My Motion Simulator:
    DC motor, Arduino
    Hi,
    for motor speed fix maybe take a look here
  6. bartez81

    bartez81 i like amps

    Joined:
    Feb 11, 2012
    Messages:
    40
    Location:
    Kraków
    Balance:
    72Coins
    Ratings:
    +14 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN6, Arduino, JRK, Motion platform
    It looks like arduino first use axis 1 and second axis later. 2 sec diference.

    Wysyłane z mojego GT-I9000 za pomocą Tapatalk 2
  7. eaorobbie

    eaorobbie Well-Known Member Staff Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,582
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    19,889Coins
    Ratings:
    +1,658 / 22 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Whos code you are using.
  8. bartez81

    bartez81 i like amps

    Joined:
    Feb 11, 2012
    Messages:
    40
    Location:
    Kraków
    Balance:
    72Coins
    Ratings:
    +14 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN6, Arduino, JRK, Motion platform
    I attached arduino code. Last problem is uneven engines work. One axis works faster than other but its not engine problem.Regards

    Attached Files:

    • AR.txt
      File size:
      9.2 KB
      Views:
      541
  9. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,063
    Location:
    Marseille - FRANCE
    Balance:
    18,885Coins
    Ratings:
    +1,962 / 20 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Hi bartez81!

    - This code is used successfully by 10 people nowadays... so you will have to investigate further!
    Here some hints for you:
    - Did you try to switch left and right motor ?
    - Did you try to switch left and right potentiometer ?
    - Is your power supply strong enough ?
    - How is your wiring ? Can you post actual pictures of your setup and wiring?
    - What is your setup of Simtools? and Windows COM port? and Arduino IDE? Can you post screenshots?​

    - Why did you remove the credits?
    Mat
  10. Historiker

    Historiker Dramamine Adict Staff Member Moderator Gold Contributor

    Joined:
    Dec 16, 2010
    Messages:
    1,930
    Occupation:
    Retired
    Location:
    Michigan USA
    Balance:
    9,463Coins
    Ratings:
    +1,820 / 13 / -1
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform, 6DOF
    I thought that code looked familiar, I too am using the original code successfully on my 2DoF platform.
  11. bartez81

    bartez81 i like amps

    Joined:
    Feb 11, 2012
    Messages:
    40
    Location:
    Kraków
    Balance:
    72Coins
    Ratings:
    +14 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN6, Arduino, JRK, Motion platform
    Hello RacingMat.
    I'm very glad you took care of my problem, you are my hero. I'll start from the end :) Credits have been removed because clean code is easer to study im not a programmer and it is not easy for me to understand and modify its parameters. They return to his place. Im sorry for that, it never happend again. I rise form 20 to 40
    {
    int Tol=40; // no order to move will be sent to the motor if the target is close to the actual position

    and now axis moves are much better now.
    On xsim works superb so wiring should be ok. About power supply yes this may be the cause. I have 12v 12,5 amp PS form LED lights.

    Bartez

    Attached Files:

  12. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,063
    Location:
    Marseille - FRANCE
    Balance:
    18,885Coins
    Ratings:
    +1,962 / 20 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Okay!
    - you can try with a car battery in parallel of your PSU
    - you can lower Tol even to zero: it should not be a problem. Your motors may just vibrate/flickering too much.

    Mat
  13. eaorobbie

    eaorobbie Well-Known Member Staff Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,582
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    19,889Coins
    Ratings:
    +1,658 / 22 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Dynamic Speed control is not the best code to use for position control, would result in lot better motion if a true pid code was used.
    • Like Like x 1
  14. RufusDufus

    RufusDufus Well-Known Member

    Joined:
    Jul 21, 2013
    Messages:
    681
    Location:
    Adelaide Australia
    Balance:
    13,980Coins
    Ratings:
    +962 / 7 / -1
    Hi @RacingMat and @bartez81,

    I was just having a look at the code you are using and you may? get better performance with the following few lines of code change…

    FROM:

    Code:
    // PID : calculates speed according to distance
    pwm=195;
    if (gap>50)  pwm=215;
    if (gap>75)  pwm=235;
    if (gap>100)  pwm=255;
    pwm=map(pwm, 0, 255, 0, pwmMax);  //adjust the value according to pwmMax for mechanical debugging purpose !
    
    TO:

    Code:
    Int FullPowerGap = 100;  // experiment with value - 300 to 500 may be more suitable.
    Int pwmMin = 100;  // Set the minimum PWM duty required to ‘get the motors moving’  experiment with this value.  (Must be less than pwmMax)
    
    // P Only control loop : calculates speed according to distance to target position
    gap=constrain(gap,Tol,FullPowerGap);  // Sets the minimum and maximum error used to calculate PWM duty
    pwm=map(gap,Tol,FullPowerGap,pwmMin,pwmMax);  // PWM is proportional to position error (ie. (P) term of typical PID loop)
    This essentially gives you a PID process loop with Ki=0 and Kd=0

    I would also suggest that Tol = 20 is way too high… Of course this is dependent on your individual setup but if you don’t have much slack in your mechanical design this should be no more than 1 or 2. I am running with 0 in my system. A gap setting of 20 is nearly 4% of your full travel and is likely to make the movement quite jerky.
    • Like Like x 2
  15. eaorobbie

    eaorobbie Well-Known Member Staff Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,582
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    19,889Coins
    Ratings:
    +1,658 / 22 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Sweet well done, would be nice if a D can be added , we have found that can sharpen the movement quite a lot, as in movement to the end zone is a nice sharp stop with fast motions. Jrks use this to great effect.
    Nice find didn't dawn on me to use the map function to work the P out, cool.
    Makes the code a lot better for all. Thanks.
    And agree this takes this one step away from being a dynamic speed controller like the K8055 was and brings it into the PID World.
    Cool, I am impressed how quickly the Ard is growing up.:thumbs
  16. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,063
    Location:
    Marseille - FRANCE
    Balance:
    18,885Coins
    Ratings:
    +1,962 / 20 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Hello
    @RufusDufus: the code is indeed a "// P only control loop"
    i'll add this in the comment line ;-) Thanks

    Your formula gives a purely linear growth and should bring nearly same results.
    In fact, I deliberatly chose to have steps in speed growth rather than being proportionnal ;-)
    (having experimental trials of kind of ramps).

    You have done a far more complex and wonderful job with your arduino: i'll have a try at your code as soon as possible! Congratulations

    @eaorobbie: Thanks. Yes, when I found how to use the map function, it was a good find!

    Here another example of map function, using raw data to enter a switch case routine:[​IMG]
  17. eaorobbie

    eaorobbie Well-Known Member Staff Member SimTools Developer Gold Contributor

    Joined:
    May 26, 2009
    Messages:
    2,582
    Occupation:
    CAD Detailer
    Location:
    Ellenbrook, Western Australia
    Balance:
    19,889Coins
    Ratings:
    +1,658 / 22 / -2
    My Motion Simulator:
    2DOF, DC motor, JRK, SimforceGT, 6DOF
    Yes I use the Map function in a lot of the code I write, just never thought of simplifying the the P in PID that way, done quickly in one line.
    Normally done in about 5 - 6 lines of code including the error check. I normally write an adaptive pid tuning so the code can change the pid on the fly as its needed, same as what the Jrk does. Ards getting closer over time, but sorry in movement resolution and feel the Jrk still leaves it for dead , shame they are so dear.
    This should bring your code out of the dark ages and you sim wont be moving like a K8055 sim any more.
  18. bartez81

    bartez81 i like amps

    Joined:
    Feb 11, 2012
    Messages:
    40
    Location:
    Kraków
    Balance:
    72Coins
    Ratings:
    +14 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN6, Arduino, JRK, Motion platform
    I'm not a programmer. And i had errors after code change.
  19. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,063
    Location:
    Marseille - FRANCE
    Balance:
    18,885Coins
    Ratings:
    +1,962 / 20 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Hello!

    What is the exact error you got?

    Did you try the steps in message #8?