What is the transfer function of smc04a?

Hello, i’m using smc04a to control a dc 12V motor rotation system with feedback. Input and feedback setting are analog (0-5V potentiometer).

i need to analyse this system (response time, overshoot,etc.) under different PID parameters with block diagram in MatLAB. So, how about the transfer function of smc04a?

Below is my system block diagram:

R(s) : analog input (0-5V)
E(s) : error
G(s) : smc04a PID transfer function (i want to know this transfer function )
U(s) : motor output
M(s) : motor transfer function
A(s) : motor rotation angle
K(s) : pontentiometer character
B(s) : analog feedback (0-5V)

On the user’s guide page.5. The “error” is 0-5V only. But the “output” is 0-12V(input power). What is the relation between “error” and “output” in smc04a?

Not that I won’t be impressed if the Pololu crew has a big list of transfer functions of their various controllers lying around, but the basic PID functions, along with how the gains are calculated from the numbers you specify, are in the user’s guide (at least they are for the scm04b, which is what I can see online right now).

Carnegie Mellon University and the University of Michigan (what a coincidence!) have put together a great set of Controls Tutorials for Matlab (with or without Simulink) including a module on PID control, which covers generating the transfer function from the PID gains, then modeling the PID controlled system in Matlab.

Doing this you’re modeling a descrete time system as a linear time system, but in the end Matlab simulates it computationally anyway, so in general it all works out. The tutorials were written for Matlab 5, but they’re still good, and I hope they help!

-Adam

P.S. I can’t speak definitively about the error/output relationship, but I would assume that the “input” is, as you say, 0V-5V, but scaled from 0 to 1024 by the 10-bit A/D converter of the PIC16F876A (the design could also be using an 8-bit converter, someone from Pololu will have to answer that).

I would also assume that the “output” is actually the PWM duty cycle of the motor controller, so it’s a fraction of the input voltage.

But then again, when you assume…

Hello,

I don’t have much to add to Adam’s great response (thanks!); I can just mention a few other factors without knowing how to model their effects. The internal math is done after 10-bit A/D, which means the error is an 11-bit number. You can set the PWM frequency to approximately 1.25 kHz, 5 kHz, or 20 kHz, and how that actually ends up affecting your motor will be a function of your motor. You can also limit the integral term from getting too big (it always has some limit), and the rate at which the PID calculation updates the motor is also adjustable. There’s also the acceleration parameter that limits how quickly the PWM duty cycle can rise to the value specified by the PID calculation.

- Jan

Thanks a lot for your replies. :smiley:

I know the basic PID controller design.

I don’t understand that the motor is being controlled by “motor output” (in my case is a DC12V voltage). But after PID controller process the error (assume it is call “U”). How to effect the “motor output” by “U”?

Is it necessary to use A/D calculation ?

As my figure shown on the top, what i need to add between G(s) and M(s)?

Thank you

Aah, yeah, that isn’t quite specified is it. In your diagram, U(s) should be multiplied by some coefficient that reduces the PID function output to a duty cycle (fraction) of the motor input voltage.

So the input to the motor in your case would be: U(s)*12V/X

Jan will have to answer what X is, but it’s probably either 2^10 (hardware PWM on the PIC16F876A) or 2^16 (16 bit timer/counter used for software PWM, which is my guess, since the error is already 10 bit!). Or it could just be some other arbitrary number. Jan?

-Adam

The output PWM resolution is 10-bit. (The math inside uses many more bits, but once the PID calculation result is beyond 1023, the motor just gets full power.)

- Jan

so the block diagram is like this?

R(s) : analog input (0-5V)
E(s) : error
G1(s) : PID transfer function, G(s)=(Kp)+(Ki)/s+(Kd)s, Kp=252^1, Ki=122^4, Kd=25*2^1 (Kp,Ki,Kd valve is come from user’s guide default value)
G2(s) : 12/2^10
M(s) : motor transfer function
A(s) : motor rotation angle
K(s) : pontentiometer character
B(s) : analog feedback (0-5V)

Looks good to me, so long as you remember that you’re modeling the motor controller as if it were a continuous (i.e. analog) controller, when in fact it’s a discrete time step system. There’s nothing wrong with this (definitely how I would do it), especially if you’re using a big 12V motor (its rotational inertia should help smooth everything out). You may notice a closer match to your predicted system behavior as you speed up the PWM cycle time.

-Adam