I want to do some kind of PID project. Although the project's purpose is totally academic (audience = me, then perhaps post as a tut somewhere), it must be practical (as opposed to a simulation) and within the scope of the hobbyist. Practical means it must be do-able with hobbyist stuff, and not need a power station of its own to run. Desktop size is good. So room heating is out, since that is physically big, requires mains power and has expensive heaters, coolers, blowers and such.
I'm thinking speed control of a DC motor would be good:
Speed's relatively simple to measure with some kind of encoder or Hall effect
it did not tall me much to I looked into how to control the speed and position of brushed DC motors. (converting them to servos)
I looked into rotary encoders this gave me more of an understanding off how pid works as I found it was a practical way to use pid, and it was easy to do, to get it going for a start it was just copy and paste, but to get it correct you have to change values but with all the examples out there it made it easy to work out what to do.
it took a bit of searching to find good examples but once I found them I was able to work out what I needed to do.
Controlling temperature is a better place to start. Motor speed adds at least one issue temperature does not have (stalling). And, you will learn, PID theory varies from PID application by all the nagging real world issues you have to deal with.
In college we used a low value resistor for the heating element duct taped to a thermocouple. PWM works well for resistive heating elements. Really the only risk is smoking the resistor. At one penny the cost to replace it is low. This kind of heating control scales up beautifully. It's essentially what I use to control a several kilowatt heating element.
Once you have that working, add a second loop controlling a fan to provide cooling. Then you get to learn why cascade control is so very important!
I just remembered that my old Magician chassis motors have an slotted encoder plate, and I just checked that the opto-isolators that I have fit perfectly, so I'll start there.
See pic.
I have looked into rotary encoders recently- see here- so I'm good to go.
That's also a good one.... I hadn't thought of heating with a simple resistor, I was picturing something like a tea-urn or a cooking hotplate, both mains powered.
What resistor would be good there then CB? And what voltage would be best?- I have 5 and 12 on my bench. The only thermocouple I have is one my Fluke meter, I guess I'd need to buy one and don't they need amplification?- or do they come as a module? I'll scour Sparkfun and Pololu.
edit.... my local supplier has a TC and an Adafruit breakout, but I'm loath to spend that money for a largely academic reason. I already have motors with encoder disk thingies, and opto-interrupters so I think I'll go with those for now. Thanks CB.
I bought a cheap Canon printer in a Charity shop recently and took it apart - hoping it might have small stepper motors. Instead it had cheap DC motors and optical encoders. One was a long strip for the horizontal movement and the other was a transparent circular diskabout 65mm diameter with very fine axial lines printed around its circumference.
One of the things on my TO DO list (long list) is to see how much control is possible with a DC motor and encoder. In particular I wonder is it possible to make it reliably stop at a specific position like a stepper motor. I presume some form of PID would be needed to make that happen.
By the way, in the printer the encoder disk was fixed to a wheel that was geared down from the motor by (guess 20:1). However the horizontal drive with a similar encoder (though in a long strip) was driven directly from the motor.
JimboZA:
That's also a good one.... I hadn't thought of heating with a simple resistor, I was picturing something like a tea-urn or a cooking hotplate, both mains powered.
Naw. Start small. That way if something goes wrong, the smoke is easily cleared from the house. #
What resistor would be good there then CB? And what voltage would be best?- I have 5 and 12 on my bench.
You want to drive as much current as possible through the resistor without it being damaged. What small value resistors do you have lots of? And what is the wattage?
The only thermocouple I have is one my Fluke meter, I guess I'd need to buy one and don't they need amplification?- or do they come as a module? I'll scour Sparkfun and Pololu.
A thermocouple is not required. Anything that can accurately measure about 20 degrees F above your room temperature will work well. We used thermocouples because that's what the professor gave us. I used thermocouples with the big heaters because that's what the customer needed.
# A colleague from a previous life worked on an automated rivet gun that was used to assemble jet fighter wings. The machine ran along a 20+ foot rail, was about 8 feet tall, and weighed about a half-ton. The person who prepared the PID loop that controlled the machine's position along the rail made a sign mistake. When the machine was turned on for the first time, the PID loop tried moving the rivet gun into position. From the PID loop's perspective, the rivet gun appeared to be moving away from the correct position so the motor was accelerated. And accelerated. And accelerated. Until the rivet gun left the end of the track and smashed through a brick wall. The military brass there for the demonstration was not pleased. With PID loops, little mistakes can have big consequences! Start small.
That's what you get from awarding contracts to the lowest bidder
The real moral of that story is not to let the client anywhere near the product until it's been tested.....
I'll go with rotary encoders for now, seeing as I have all the hardware.
(To answer your question though, I've got most of a Sparkfun resistor kit left, 1/4W carbon film from 0R to 1M, so pick a value (except 0 of course). I also have an LM35.... would a resistor heat that up? I've got some thermal tape).
JimboZA:
(To answer your question though, I've got most of a Sparkfun resistor kit left, 1/4W carbon film from 0R to 1M, so pick a value (except 0 of course).
I also have an LM35.... would a resistor heat that up?
Strap a 100 ohm resistor to it, apply five volts to the resistor, wait about a minute, measure the temperature. If the temperature is several degrees above room temperature # you should have enough difference to work with. If not repeat the experiment with two 100 ohm resistors wired in parallel (1/2 watt; 50 ohms).
# It should feel warm to the touch. If not skip the temperature measurement.
A home made sous vide system seems like a suitable application for some PID experiments, with the added benefit that once you get it working you get to eat the results!