Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok so if I understand you, all of the hardware is done already? </p> <p>So, your system has a command input that is a current level in amperes (specified by say a double precision floating point number in software) and the output of the controller is a voltage that controls hardware that draws current, your plant is the circuit and the feedback is probably an 8, 10 or 16 bit number - either signed or unsigned depending on your A/D. </p> <p>So your system looks like this:</p> <p><a href="http://steves-wiki.wikispaces.com/file/view/control_diagram.jpg/64043668">alt text http://steves-wiki.wikispaces.com/file/view/control_diagram.jpg/64043668</a></p> <p>Your quickest and dirtiest approach is probably PID control. You can brush up on the basics with <a href="http://en.wikipedia.org/wiki/PID_controller">this Wikipedia article</a> and there are some hints on implementation in this <a href="http://www.embedded.com/2000/0010/0010feat3.htm">embedded.com article</a>. </p> <p>In a nutshell you want to compute the error of the system which in your example is the Current command - Current Feedback. Make sure everything is in the same units, hopefully Amperes. Then, after your error is calculated you have to correct it with a command. In your system that is the voltage command to your voltage-controlled current source. With PID, the command is calculated by multiplying the error, the integral of the error, and the derivative of the error by gains and summing the result. The gains are the tricky part. The OTHER tricky parts are: making sure your units are consistent, making sure the timing is proper, and the correct integration/derivative calculation. </p> <p>In your system you have many units: error is Amps, the command is Volts, which turns into Amps, then the current use is Amps which is reported as Volts which gets turned into either a signed or unsigned integer which has to be scaled back into Amperes to make the error proper. You'll have lots of variables, make sure you can keep track of what physical unit applies to each.</p> <p>The control algorithm is hard real-time and has to run at a dedicated rate. I would recommend at least 100Hz (computations every 10ms). Electronic circuits move quickly - not like electromechanical systems. You may need a higher rate to stay on top of things. But it has to be hard real time - that means consistent. You may not even be able to get away with software timers. </p> <p>Integration and derivative calculations are tricky but there are only so many ways to do them. The most basic algorithm is the rectangle rule - it's dumb but it will probably work. If you need to be more precise use trapezoidal rule. Check the algorithms out <a href="http://en.wikipedia.org/wiki/Numerical_integration">here</a>. Most likely you won't use derivative control - it tends to make things unstable and isn't needed in most systems. You ought to be fine with integral+proportional control. </p> <p>There are lots of pitfalls but this should get you started. If you've had a background in control theory then it should all come back to you. Once the framework is in place you'll spend a lot of time tuning the proportional and integral gains - that's the meat of the job. If this still seems like too much math for you, well, sorry - this is about as simple as it gets for controls. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload