Friday 15 May 2015

c - PID feedback & Position Controller with DC motor/encoder -


I have a hard time getting both PID response and positioning to run at the same time < P> I think to calculate RPM:

  1. Start the timer and count the encoder pulses using an interval.
  2. Use some simple math to convert RPM to
  3. Reset the Variables and Reset.

    I can calculate RPM but then I can call only my PID controller after calculation (though I want to wait to get a better resolution.) It is a very dirty code, is there any easy way or something that I am missing?

    Information about my application: I am programming with ATML ATmega328P with DC motor / dual magnetic encoder ~ 600 pulses per revolution (After GearHide ) I want to call GoToTarget (#) and go to motor position while updating PID parameters. Apart from this, it should go both ways.

    Your speed calculation timer and your pid loop timer should be the same thing - no different.

    Do not speed up RPMs to change time and resolution dislikes; If the timer is periodic at the right time - and it should be for a stable PID - then the pulse count for speed is directly proportional , and PID does not care about the units - Which can be adjusted for the value of coefficient If you want to keep your set-point speed in real-world units, then that is used instead of pulse-per-pid-duration Equal number of variables Get your answer.

    Your loop should look like this;

     For  (;;) {WaitTimer (); Pulses = pulse_gate - previous_pulsecount; Previous_pulse_count = pulse_count; Control = pad (pulses); motor control ) ; }   

    Then you need only one obstacle to calculate the pulses - it does not need to do any calculation, just to increase a counter - and possibly block the timer Based on the implementation of WaitTimer () and whether it is multi-threaded or not.

    Also keep in mind that if the shared variable pulse_count is not atom, you need to disable the interrupt while reading it (the best wrapped in the function), and it will need Unstable .

No comments:

Post a Comment