PWM signal

Hi everyone out there,
I have been having a little trouble seeing something with the PWM motor controller…I am using a PI control scheme but I need a way to convert the output of the controller…which is a motor speed…to convert into some PWM value to send to the motor so i can correct the error…

Can anyone offer some assistance on this please?

Thanks in advance…

I don’t quite understand your question. Are you referring to the motor controller that converts the PWM signal to the 2-wire cable that goes to the motor? To do any part of a PID loop, you need to have sensor feedback to give you the error, then use that error to define what the motor value should be at the end of that cycle of the PID loop.

The vex wiki says:

There are lots of other threads on PID control methods.
Here is some assistance, your words suggest misunderstanding of the system:

(ref: “convert the output of the controller…which is a motor speed” )
If the output of the controller were actually the speed,
the PID would usually not be necessary.
You’d tell the controller to deliver speed X and that is what you would get.

What actually happens is

  • you provide a value from -127 to +127 to SetMotor command
  • which cpu outputs as a servo style PWM signal to motor controller #29
  • the #29 turns into 50Hz PWM -100% to 0 to +100% duty cycle power pulses to the DC motor
  • the motor reacts against the torque load per the current vs torque curve diagram

– which all means that setting +127 “full speed” will get you ~100 rpm on a standard vex motor with no load, and lower rpm at higher loads.

If you want to control the rpm with PID feedback, you need some way to measure the rpm.

Perhaps robot_N was referring to getting EMF (Electromotive Force) feedback from the motor to the motor controller.
EMF Feedback or sensorless feedback is where a running motor stops quickly, and then is allowed to back-feed the controller as a generator, which then measures the voltage and calculates the speed of the motor. You could use that information in a PID Control Loop as your input source to make sure some motor is turning at a constant speed. I think it would be really neat if that could be done in VEX, as it may provide a more accurate system of measurement than would otherwise be possible using optical encoders.
Here’s some neat documents that define EMF Feedback (or Back EMF):


http://www.ijnmt.com/JournalPapers/Vol2No2/Vol2No2P4.pdf

well what i did in terms of feedback…is that within a second I’m reading the encoder counts…so I will be comparing that with a setpoint that I set in the code…

Great! Just apply some coding, and you have everything you need. …
oh no… i’ve caught the period replication virus… through this thread… and now my shift key… doesnt…work…either…

HaHa, that’s funny, we need to lighten up a little bit on the board so thanks for that. My shift key is OK, BUT NOW MY CAPS LOCK IS STUCK :frowning:

I did not realize that I used that many periods. I think that’s a habit of mine o.O

Anyways, thanks for your advice though.