Go Down

### Topic: PID motor control through a motor shield (Read 1 time)previous topic - next topic

#### ASAProckyy

##### May 30, 2019, 12:23 pmLast Edit: May 30, 2019, 12:25 pm by ASAProckyy
Hello everyone,

This is my first question on this platform.

I am making a prototype for a cheetah like robot, but I am running into a problem which I can't seem to find an answer for on the internet.

I'll try to explain myself as best as possible to avoid confusion and to avoid being an annoying newbie.

concise question:

A PID control returns an (analog) output based on an error measured by the encoder on the motor. This output should drive the motor through a Adafruit motor shield V2. But this shield doesn't work on analogwrite commands but rather on ''run(FORWARD)'' and ''setSpeed(speed)'' commands.
How can I run this configuration with the PID control?

further information
PID control: PID_V1 (standard library)

This is how I have to adres the motor:

*If I for got information to answer this question please let me know*
*If my question was to vague let me know and I will rephrase it*

#### wildbill

#1
##### May 30, 2019, 12:57 pm
The PID library takes an input and calculates an output for you. It has no idea what that output means, nor what you are controlling.

You can constrain the library (at least in the one I've used) to keep that output in whatever range you desire.

So tell the library to constrain the output to the range of speeds you can give the motor and use it directly to set speed.

If you need to go forward and back, set it to twice that and for the lower half of the range set the motor to backwards, the upper half to forwards. You'll need to do a little math to calculate the speed setting in this case.

#### soceraso

#2
##### Jun 03, 2019, 11:29 pmLast Edit: Jun 03, 2019, 11:31 pm by soceraso
Going off wildbill, you will probably need to find/solve for an equation of the form "speed = m*pid_output + b" where m and b are constants..

Also, what is your control objective? This PID Tuning Guide argues that knowing the control objective is the single most important piece of information in designing and implementing an effective control strategy.

Are you using the PID to control the position of an arm? Like, what are you trying to do? If it is position control, then using servo motors might better suit the project.
Smash that "Add Karma" button if you've liked this post.

Go Up