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

Motors going back and forth really fast

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by Sam Neall, Aug 13, 2020.

  1. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,062
    Location:
    London
    Balance:
    7,665Coins
    Ratings:
    +240 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    How does it track if you run a sine wave ?

    I wonder if your motor drivers are giving you full pulse width instead of reduced pwm
  2. Sam Neall

    Sam Neall Member

    Joined:
    May 14, 2019
    Messages:
    129
    Balance:
    230Coins
    Ratings:
    +19 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    When the Feedback is not at the target yet and is lagging behind slightly, the motors move very smooth. However when they overlap, there is slight twitching. It just seems like twitching happens whenever the two lines meet. Is the pulse width something I can change in the describe software for the sabertooth driver? It would make sense that the driver could be causing it considering the issue is that it is over reacting to slight feedback noise.
  3. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,062
    Location:
    London
    Balance:
    7,665Coins
    Ratings:
    +240 / 6 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    Can you get a scope on the motor wires and see what is going on ?
  4. Sam Neall

    Sam Neall Member

    Joined:
    May 14, 2019
    Messages:
    129
    Balance:
    230Coins
    Ratings:
    +19 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform

    you can hear the motors initially going up. Then when they reach the center position they start twitching.
  5. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    15,507
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    113,908Coins
    Ratings:
    +9,121 / 46 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    My thoughts are that there is likely an isolation/hardware issue, if following the SMC3 tutorial does produce the expected results.

    Are you using wiper motors and if so are they ground isolated: https://www.xsimulator.net/community/faq/wiper-motor-mandatory-ground-isolation.25/

    Have you swapped out a pot to test if one is faulty?

    Does a single motor work a expected?
  6. Sam Neall

    Sam Neall Member

    Joined:
    May 14, 2019
    Messages:
    129
    Balance:
    230Coins
    Ratings:
    +19 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    I am using wheelchair motors so there is no need for ground isolation.

    I have tried a different potentiometer today and it gives the same feedback response as the ones currently attached to the motor.

    I was wrong when I said the single motor was working. The issue is that there is twitching when the feedback and target lines overlap and it has to make micro adjustments. In the sine wave test, the feedback line was slightly lagging behind the target line because I was using a lower PWM and it couldn’t catch up. Although the motor appeared to work fine in the first test, when I put the PWM to a sufficient amount and the lines came closer, there was twitching with the sine wave test.

    To be clear, the motor is driven completely fine and smooth until the lines overlap.

    If you look at the sample picture I provided, the PWM seems to be caused by very tiny noise in the feedback line. Every time the feedback line dips by a small amount the PWM goes up like 100 steps and vice versa. It just seems to be overreacting and I can’t seem to find any way to tone it down.
  7. Sam Neall

    Sam Neall Member

    Joined:
    May 14, 2019
    Messages:
    129
    Balance:
    230Coins
    Ratings:
    +19 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    @Gadget999 here’s a more accurate reading with the DeScribe software. Would these readings show that the driver isn’t outputting reduced PWM? It seems like it is jumping to high amperages for very short periods of time which would explain the twitching.
  8. PMK

    PMK Member Gold Contributor

    Joined:
    Jun 12, 2018
    Messages:
    34
    Location:
    Australia
    Balance:
    147Coins
    Ratings:
    +5 / 0 / -0
    You could be getting interference over your pot wires. Try braiding/twisting the 3 wires together and putting a ferrite choke on them close to the Arduino. You could could also use shielded cabling. Try moving the Arduino and pot wires away from any high current wires that run to the motors.

    It's also important to note that a high derivative gain in your PID tuning will introduce this instability if you have noise in your potentiometer readings. Is it possible to reduce your D gain? You might need to reduce P and D together to get similarly damped motion. It may also be worth removing any integral gain as the integral gain is generally used for steady state errors and if there's any noise or deadzone in your feedback you'll "hunt" for a zero positon.

    I used to get this rattling sound in my motors but managed to remove 90% of it by reducing my D gain and making sure my pot wires were twisted with a ferrite choke and away from any of the motor wires.

    I run my setup with JRKs and they have the option to sample a number of readings and take the average of 128, 256, etc, samples for the feedback reading for the PID period, is that possible with your Arduino setup? I think my JRK is setup for a 5ms PID period and takes the average of 128 samples in that period as the feedback reading to help smooth noise in the signal.
    Last edited: Aug 20, 2020
  9. PMK

    PMK Member Gold Contributor

    Joined:
    Jun 12, 2018
    Messages:
    34
    Location:
    Australia
    Balance:
    147Coins
    Ratings:
    +5 / 0 / -0
    Also, how are you tuning your PID values? 100, 40, 40 seem a little odd from my experience with tuning for positional control. Have you tried tuning the PID using the Ziegler Nichols method?
  10. Sam Neall

    Sam Neall Member

    Joined:
    May 14, 2019
    Messages:
    129
    Balance:
    230Coins
    Ratings:
    +19 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    I have tried shielded cable in the past and it hasn't done anything. I tried the magnet clips as close as I could get them to the Arduino pins and it didn't seem to change anything either.

    Setting I to zero and reducing the PWM min seemed to get rid of 60% of the twitching so thank you so much.

    There is still and audible rumble though. If I reduce the PWM min and P a lot, it goes away completely. However at this point because of the low P value, the motor is very inaccurate. It doesn’t want to drive through low distances. With the PWM min I have to set it way below what the PWM min should actually be. While I haven’t noticed any positioning differences with low PWM min, I have heard that it is bad to set it at inaccurate values.

    All the I parameter does for me is make the motors jump very hard every second like a low frequency twitch. S does not stop the twitches with I by the way it just smooths them out.

    D has not made any difference at all for some reason. FPID division just makes the rumbling happen at a lower frequency as it should. I am not sure why but deadzone makes medium (about 15 notches high) spikes in the PWM every second or so and doesn't help.

    Is there anything that I’m not considering and is there any combination of settings that you know of that would get rid of the rumble for entirely?

    You can hear the rumbling in a quiet room but it’s not anywhere near loud enough to be heard over a game. I’m not as much worried about the audibility of it as I am worried about saving the motors from unnecessary wear.

    The 100, 40, 40 was from another persons settings that worked for them. At one point they worked for a base setting for my setup that I fine tuned. The reason I didn’t upload the fine tuned settings that were working on my simulator is because I lost them in an attempt to try and fix the twitching before I made a thread.

    I am currently trying to understand the Ziegler Nichols method haha. I will get back to you if I figure it out and it fixes the issue completely. Up until now I have just been tuning the PID by looking and listening to the motors.
  11. PMK

    PMK Member Gold Contributor

    Joined:
    Jun 12, 2018
    Messages:
    34
    Location:
    Australia
    Balance:
    147Coins
    Ratings:
    +5 / 0 / -0
    Ziegler Nichols you basically set your PID to 0.
    Demand a step from the motors. (I'm not sure how to do this with SMC3). Just send a command to go from 50% to 75% position instantly if that makes sense?

    Increase your P gain until the sim is oscilating back and fourth but not going absolutely crazy.
    Your P gain should now be at a value so that when you demand that step from the motors it rocks back and fourth. (Marginally stable)

    [​IMG]

    Increase your derivative gain so your step response looks something like the stable curves.

    Copying PID values from different sims and physical setups is generally a bad idea since there's so many different variables that change your system response.

    I've usually found that with positional control my D gain is larger than my P gain.


    It may be worth playing with the Ks setting as that basically acts as a filter over the D gain which can help with smoothing noise issues.

    I don't use SMC3 so can't help with any specifics such as the PWM frequencies etc sorry.
    • Agree Agree x 1
  12. PMK

    PMK Member Gold Contributor

    Joined:
    Jun 12, 2018
    Messages:
    34
    Location:
    Australia
    Balance:
    147Coins
    Ratings:
    +5 / 0 / -0
    It might also be worthwhile trying to set your PWMmin to 0 and PWMmax to 255. That should give you full PWM resolution and isn't dangerous as long as your're running your motors and power-supply in spec. I don't really see an issue with setting your PWMmin to 0, it just means you might get a slightly slower response for small motions but it also means everything should be less twicthy.
    • Like Like x 1
  13. Sam Neall

    Sam Neall Member

    Joined:
    May 14, 2019
    Messages:
    129
    Balance:
    230Coins
    Ratings:
    +19 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    I played around with the Ziegler Nichols method and I can’t seem to get the motor to oscillate. I followed the exact directions and no amount of P seems to get the motor to oscillate.

    I kept working with my method of just messing around with settings and seeing what happens and I’ve gotten to a point where the rumbling can barely be heard at all. Since you’re saying it’s ok have the PWM min at zero, I think the problem is solved. If I were to raise the PWM min there would be rumbling again.

    If the low PWM min causes problems in the future, I will definitely give it the Ziegler Nichols method another try so that the PWM min can be raised without twitching.