Gas station without pumps

2014 October 19

Summer project 2

Filed under: Uncategorized — gasstationwithoutpumps @ 20:50
Tags: , , , , , ,

In Summer Project, I introduced the project I’ve been working on all summer: a “kit” for making dimmable LED lamps, consisting of

  • a dimmer board that reads a potentiometer and converts it (non-linearly) to a pulse-width-modulated 9V output signal and
  • LED boards that hook up to the two wires of the PWM input signal, and that can be run in parallel,

and I showed the custom desk lamp I made for my son.  That was a fairly quick build, because it needed to be functional, but did not need to be very pretty—my son likes the exposed-wire look.  I asked him today how the lamp has been working out for the past week—he almost always uses it near the lowest setting, since he is either just filling in some shadows in an already lit room, or he is working at his desk while his roommate is sleeping.  In both cases he doesn’t need or want much light.  I suggested unmounting some of the LED boards, to get more control at the low light levels he needs.  Based on the measurements and calculations from the data sheets I did in LED board I-vs-V curve, he should be getting a range of  10–375 lumens from his desk lamp.  With only 3 LED boards, he would have a range of 6–225 lumens. But he likes having 5 shadows, so he turned down the suggestion. I considered changing the firmware for his lamp, to provide lower levels (has has all the equipment and software needed to reprogram it), but it is hard to get a duty cycle lower than 0.2% from the PWM controller.  If he really wants to go to low light levels, he could replace the 9V power supply with a 5V one, but then he’d have a range of 0.008–0.3 lumens, when what he probably wants is 1–40 lumens, which would need a 5.5V supply (not a standard size).  I think that he’ll sometimes need the 200–375 lumen range for task lighting when he is working with something fiddly late at night, so he is probably best off keeping with a full-power lamp.

The other project I mentioned was making a prototype table lamp for my sister, which needs to look a bit nicer, since she is considering making a series of table lamps using stiffened-silk shade.  I’ve now finished a prototype to send her, pictured below:

Here is the lamp, turned off.  The base is a wooden bowl from the thrift store, sanded so that it sits flat.  The upright is a standard brass lamp pipe, and the shade is just folded out of a 0.5m square of paper (the most common fold for making a paper cup).

Here is the lamp, turned off. The base is a wooden bowl from the thrift store, sanded so that it sits flat. The upright is a standard brass lamp pipe, and the shade is just folded out of a 0.5m square of paper (the most common fold for making a paper cup).

When turned on, the lamp produces a modest downward light and illuminates the shade.

When turned on, the lamp produces a modest downward light and illuminates the shade.

The lamp is done except for a knob for the potentiometer for controlling the dimmer. The only knobs I have are too large and industrial looking—I’ve ordered some smaller metal ones via Amazon, but they are being shipped from China, so I’ll probably have to mail my sister the lamp before the knobs get here. It turns out that if you want decorative, rather than ugly plastic, potentiometer knobs, the best source is companies that provide guitar parts.  The knobs for controls on electric guitars come in a wide variety of styles, some of them quite elegant.  (But guitar parts are also a fairly expensive way to get knobs, so make sure that you really like them!)

When I first assembled the lamp, there was a rather nasty flaw in the design, resulting in unintended shadows on the shade:

At first there was an extra shadow in the middle of the shade that I did not like.

At first there was an extra shadow in the middle of the shade that I did not like.

With the shade off, it is easy to see where the extra shadow come from—it is the knurled nut connecting the up-facing LED board to the power wires.

With the shade off, it is easy to see where the extra shadow come from—it is the knurled nut connecting the up-facing LED board to the power wires.

The fix was easy—I just put the screw in from the top of the board, so that there was no large assembly to cast shadows:

Here is a closeup of the top part of the lamp, showing the top LED board facing up with the knurled nut on the back of the board. The two end LED boards face down, again having the knurled nut on the back, along with the heat sink.  I had originally planned to support the shade with the same 10-gauge copper wires that power the boards, but I realized that the cooper would corrode in a humid atmosphere, which might stain the shade, so I made a support out of 1/8" 316L stainless steel welding rod, using a little hot-melt glue to attach pony beads to the ends, so that the rods wouldn't poke holes in the shade.

Here is a closeup of the top part of the lamp, showing the top LED board facing up with the knurled nut on the back of the board. The two end LED boards face down, again having the knurled nut on the back, along with the heat sink.
I had originally planned to support the shade with the same 10-gauge copper wires that power the boards, but I realized that the cooper would corrode in a humid atmosphere, which might stain the shade, so I made a support out of 1/8″ 316L stainless steel welding rod, using a little hot-melt glue to attach pony beads to the ends, so that the rods wouldn’t poke holes in the shade.

The shadows cast by the LEDs with the corrected orientation of the screws is much cleaner than before.

The shadows cast by the LEDs with the corrected orientation of the screws is much cleaner than before.

I still have to write artist-level instructions on how to put together the electronics for a lamp. That will probably require a few more closeups of the lamp (with better lighting), which I’ll take during the week, before shipping the prototype to my sister.

2014 October 5

Summer project

Filed under: Uncategorized — gasstationwithoutpumps @ 19:06
Tags: , , , ,

I’m finally ready to reveal the project I’ve been working on all summer: a “kit” for making dimmable LED lamps.

The idea of the project is to have a flexible set of electronics modules that can be put together in various ways to get quite different lighting fixtures.  I ended up designing around a 9V power supply, and making two custom modules:

  • a dimmer board that reads a potentiometer and converts it (non-linearly) to a pulse-width-modulated 9V output signal.
  • LED boards that hook up to the two wires of the PWM input signal, and that can be run in parallel.

The key thing here is that the LED boards are designed to have roughly constant brightness despite variations in the LEDs or in the IR voltage drop of the wiring.  Each LED board has a constant current circuit and a little heatsink to keep the LEDs cool (they last longer that way, so I went overboard on the heatsink, keeping the LEDs well below their maximum temperature). The boards are designed to put out about 85 lumens of warm-white light at 130mA (dissipating about 1.17W on the board—with a 90% efficient 9V supply, the overall efficiency is about 65 lumens/W).

So far I’ve wired up two of the dimmer boards and tested them at currents of up to 4.8A—the transistors on the board don’t get hot (not even up to body temperature).  I don’t have a dummy load for testing at higher currents, but the board was designed to be able to handle at least 6A.  I paid extra to have the dimmer boards fabricated with 2oz copper (through ITEADstudio), both to reduce resistance on the board and to provide better heat sinking.  I want to be able to use the board in enclosed cases, and I don’t think that there is will be any trouble with that.

I’ve also tested 36 of the 100 LED boards I had made. Because the LEDs are surface-mount devices with big pads, I paid Elecrow to assemble the boards for me.  Their prices came out a little lower than Smart Prototyping for this particular board, but the difference in pricing schemes could make either one be cheaper for a given design. So far 34/36 work (~95%), which is a somewhat lower yield than I had expected for such a simple design with large-pitch components. I’ve not reworked the bad boards yet, but I did a little testing, and the problem seems to be a damaged transistor rather than an obvious soldering problem such as a short or open. I wonder if they were careless about their anti-static protocols, or whether the transistors were damaged before they installed them.

My original goal was to make an LED lighting fixture to replace the old ceiling fan in my breakfast room (using 10–20 of the LED boards, to get 850–1700 lumens), but I’ve not gotten that one done yet, because I got sidetracked into two other related projects:

  • Making a custom desk lamp for my son.
  • Making a prototype table lamp for my sister.

Originally, my son was going to design his own desk lamp to sit on a shelf above his desk, based on the desks we had seen in the dorms at orientation.  But when he moved into the dorm last weekend, he found that the desks in this dorm had no book shelf over the desk. But he really needs a desk lamp, because he lofted his bed over the desk to make more space, so the desk is quite dark.  I decided that I would make him a desk lamp as quickly as I could, designing it on the train home, and sharing sketches with him by e-mail when I got home.  This weekend I threw the project together as quickly as possible, so that I could ship it to him on Monday.

At the back of his desk is a 1″ thick wooden brace for the lofted bed, so I designed the lamp to hook over that brace, with the control box over the desk and LED lamps about 50cm above the desk on 10-gauge copper wire. The LEDs are light enough that the wire alone is enough to support them, though a thicker wire would be a little less wobbly.

Here is a side view of the desk lamp showing the hook for sliding over the bed rail.  I've only populated 4 of the 5 positions for LED boards.

Here is a side view of the desk lamp showing the hook for sliding over the bed rail. I’ve only populated 4 of the 5 positions for LED boards.

Front view of the desk lamp, as it would appear at the back of his desk.  The knob controls the dimmer, and a 9V wall wart provide power on the right side.

Front view of the desk lamp, as it would appear at the back of his desk. The knob controls the dimmer, and a 9V wall wart provide power on the right side.

Because I had to throw this thing together in a hurry, it has a very “homemade” look to it. The box is a cheap wooden craft box from the art supply store, the hook is a piece of masonite glued to a couple of  pieces of  scrap wood I had in the living room. I did not take the time to trim everything to perfect fit, nor to do more than cursory sanding.  I finished the box with Danish oil, but I only had clear oil, and one with a stain included would have looked better.

But the lamp works well. The vertical wires are attached to screws with knurled thumbnuts, and the LED boards to the wires the same way. These give the lamp a certain “steampunk” charm, though there should really be a big knurled brass knob instead of a plastic one to enhance that effect.

Next weekend I plan to try to finish a table lamp for my sister—it needs to look a bit nicer, since she is considering making a series of table lamps using stiffened-silk shades (she makes stiffened-silk bowls, and her customers have been telling her that she needs to make lamps).  I want her to see the artistic possibilities, and she isn’t into the rustic “homemade” look.  I’ll also have to provide her with instructions on how to put together the electronics for a lamp with artist-level instructions. I’ll have put the lamp together, but she’ll need to be able to figure out how to put the same electronics into a different base with different support for a shade. That means not just building the lamp, but explaining how it was built and why certain choices were made, so that she can do her own designs.

I’ll probably detail some of that build in a blog post here, so that I have a record as well as her.

2014 September 20

Improving feedback for fan

Filed under: freshman design seminar — gasstationwithoutpumps @ 12:22
Tags: , , , , , ,

I wanted to look at the step response of the fan and of the heater, so that I could see if I could derive somewhat reasonable control parameters by theory, rather than by cut-and-try parameter fiddling.  Most of the tutorials I’ve looked at give empirical ways of tuning PID controllers, rather than theoretical ones, even ones that use Laplace transforms to explain how PID controllers work and how to determine whether or not the control loop is stable if you are controlling a linear time-invariant system with a known transfer function.

When I first looked at the fan response, I noticed a problem with my tachometer code:

The tachometer gives two pulses per revolution, but the markers used are not perfectly spaced, so I get different estimates of the speed depending which falling-edge-to-falling-edge pulse width I measure.  The difference between the two speeds is about 1.6%.

The tachometer gives two pulses per revolution, but the markers used are not perfectly spaced, so I get different estimates of the speed depending which falling-edge-to-falling-edge pulse width I measure. The difference between the two speeds is about 1.6%.

I rewrote the tachometer code to trigger on all four edges of a revolution, and to record the time at each edge in a circular buffer. This way I can use a full revolution of the fan for determining the speed, but get updated estimates every quarter revolution, available in micros_per_revolution:

volatile uint32_t old_tach_micros[4];  // time of last pulses of tachometer
	// used as a circular buffer
volatile uint8_t prev_tach_index=0;    // pointer into circular buffer
volatile uint32_t micros_per_revolution; // most recent pulse period of tachometer

#define MIN_TACH_PULSE  (100)   // ignore transitions sooner than this many
				// microseconds after previous transition

void  tachometer_interrupt(void)
{   uint32_t tach_micros = micros();

    if (tach_micros-old_tach_micros[prev_tach_index] < MIN_TACH_PULSE) return;
    prev_tach_index = (prev_tach_index+1)%4;  // increment circular buffer pointer
    micros_per_revolution= tach_micros-old_tach_micros[prev_tach_index];
    old_tach_micros[prev_tach_index] = tach_micros;
}

In setup(), I need to set up the interrupt with attachInterrupt(FAN_FEEDBACK_INT,tachometer_interrupt, CHANGE);

I think that this improved tachometer code may be a bit too much for first-time programmers to come up with. Circular buffers use a bunch of concepts (arrays, modular arithmetic) and are likely to cause a lot of off-by-one errors. Interrupts alone were a complicated enough concept for students to deal with. I don’t know whether the improvement in speed measurement would be justifiable in the freshman design course.

The new tachometer code did smooth out the measurements a lot, though, as expected—it reduces the fluctuation in measured speed to about 0.3%, which is limited by the resolution of the micros() timer I’m using on the Arduino board. I then tried recording some step responses, both for upward steps and downward steps. The upward steps are reasonably approximated by an exponential decay (like a charging curve):

The low speed is 724.7 rpm, and the high speed is 6766.3rpm. The exponential fit is not perfect, but it is certainly a good enough approximation for designing a closed-loop system.

The low speed with PWM=0 (always off) is 724.7 rpm, and the high speed with PWM=255 (always on) is 6766.3rpm. The exponential fit is not perfect, but it is certainly a good enough approximation for designing a closed-loop system.

The response to a downward step, however, is not well modeled by a simple exponential decay:

The fan spins down gradually at first (with a time constant about 1.6s), but at low speed the speed changes faster (as if the time constant dropped to about 0.6s).

The fan spins down gradually at first (with a time constant about 1.6s), but at low speed the speed changes faster (as if the time constant dropped to about 0.6s).

Note that the fan slows down much more gradually than it speeds up, which means that it is not a linear, time-invariant system. In a linear system, superimposing a step-up and a step-down would cancel, so the responses to the step up and step down should add to a constant value—the fan most definitely does not have that property.

I was curious whether the difference was just apparent for large steps, or also for small ones, so I tried steps between PWM duty cycles of 100/256 and 160/256:

A small upward step is again quick, with almost the same time constant as before.

A small upward step is again quick, with almost the same time constant as before.

The small downward step is faster than before, though still substantially slower than the upward step of the same size, and with an initially slower response than the final convergence.

The small downward step is faster than before, though still substantially slower than the upward step of the same size, and with an initially slower response than the final convergence.

I’m going to try writing a couple of ad hoc controllers for the fan, to see if they behave better than the PID controller I’ve been using: open-loop control using just  PWM=(setpoint-740)/25; a simple on/off control with a single threshold; hysteresis, using two thresholds instead of 1; PI control with no anti-windup; and a controller that goes to full on or full off when the error is large, to make a quick transition,  switching to approximately the right PWM value,  when the error is small, with PI control thereafter.

I think that the open-loop controller will have a steady, but wrong speed; the  crude on/off controllers will make an audible pulsing of the fan motor; the PI controller will suffer from overshoot when making big steps, and the on/off/PI controller should make nice steps, if I can tune it right.

I implemented all the controllers and ran a test switching between setpoints of 1000RPM and 5000RPM every 30 seconds.  Here are plots of the behavior with different control algorithms:

The PWM values computed by the various control algorithms show the integrator windup problem for PI clearly after the downward transitions—PI takes a long time to recover from the errors during the downward edge.

The PWM values computed by the various control algorithms show the integrator windup problem for PI clearly after the downward transitions—PI takes a long time to recover from the errors during the downward edge.

The mixed algorithm does a very good job of control, with little overshoot.  The simple PI algorithm has substantial overshoot, particularly when the control loop wants a PWM value outside the range [0,255]. Open loop has significant offset and wanders a bit.  On/off control oscillates at about 10hz, and adding hysteresis makes the oscillation larger but slower (about 5Hz).

The mixed algorithm does a very good job of control, with little overshoot. The simple PI algorithm has substantial overshoot, particularly when the control loop wants a PWM value outside the range [0,255]. Open loop has significant offset and wanders a bit. On/off control oscillates at about 10hz, and adding hysteresis makes the oscillation larger but slower (about 5Hz).

The errors for the mixed controller are only about ±0.3% and overshoot or ringing at the transitions <40RPM.  The simple PI controller overshoots by 340RPM and takes 20 seconds to recover from the integrator windup on the downward transition.  The open-loop controller has offset errors of about 1% and a fluctuation of about ±0.7% at the high speed, and an offset of 1% and fluctuations of about ±0.5% at the low speed.  The on/off controller has an offset of  about 0.5% at high speed with fluctuations of ±2%, and an offset of 28% with fluctuations of ±28%.  Adding hysteresis slows down the oscillations, but makes them larger (0.2% offset, fluctuations ±3% at high speed, and 44% offset with fluctuations of ±70% at low speed).The mixed algorithm which uses on/off control for large errors and PI for small errors, with back-calculation of the integral error when switching to the PI controller seems to work very well.  But would I be able to get freshmen to the point of being able to develop that themselves within a 2-unit course?  Probably not, but I might be able guide them through the development in a series of exercises that started with on/off control, then went to modeling and open-loop control, then the PI control, and finally the mixed control.  It would take most of the quarter.

2014 September 17

Putting the heater in a box

Continuing the saga of the incubator project in the recent posts:

On my to-do list for the project

  • Put the whole thing into a styrofoam box, to see whether extra venting is needed to allow things to cool down, and to see how tightly temperature can be controlled. Find a smaller bread board or prototype board to put the controller on—my current bread boards are all 6.5″ long, and the box only has room for 6″, especially since I put the resistor in the center of the 6″×12″ aluminum plate, which just fits the box. I suppose I could drill a couple more holes in the plate and mount the resistor off center, but I rather like the idea of building the controller as an Arduino shield, so that the Arduino + controller is a single unit. Another possibility is to drill a hole in the styrofoam box and run cables through the box for the resistive heater, the fan, and the thermistor. Even if the grounds are connected outside the box, this is only 8 wires. Putting the control electronics outside the box would reduce the clutter in the box and make tweaking easier

    I got this done today, by drilling a hole in the box and soldering long wires onto the resistor and the thermistor, so that all the active electronics could live outside the box. Incidentally, “drilling” did mean using a drill bit, but I held it and turned it with my fingers—styrofoam is so soft and grainy that I feared a power drill would tear out big chunks.

    Here is the interior of the styrofoam box, with the lid open.  The 6"×12" aluminum plate covers the bottom.  The thermistor is on the left, propped up by a rubber foot, the resistor in is the center, and the fan is sitting on a foam pad on the right. (The foam is to reduce noise until I can get the fan proper mounted in a baffle.)

    Here is the interior of the styrofoam box, with the lid open. The 6″×12″ aluminum plate covers the bottom. The thermistor is on the left, propped up by a rubber foot, the resistor in is the center, and the fan is sitting on a foam pad on the right. (The foam is to reduce noise until I can get the fan proper mounted in a baffle.)

    As expected, I can heat up the thermistor fairly quickly, but if I overshoot on the temperature, it takes a very long time for the closed box to cool back down. Cooling off just 1°C took over half an hour.

  • Add some low-pass filtering to the temperature measurement to reduce noise. Just adding 4 measurements in quick succession would reduce the noise and give the illusion of extra precision.

    I did this also. With the box closed, the thermistor reading is fairly stable, with fluctuations of less than 0.1°C (which was the resolution with a single thermistor reading before adding 4 successive reads).

  • The fan controller occasionally has a little glitch where the tachometer either misses a pulse or provides an extra one (I think mainly an extra one due to ringing on the opposite edge).  I could try reducing this problem in three ways: 1) changing which edge I’m triggering on, 2) using more low-pass filtering before the Schmitt trigger in the edge detector, or 3) using median filtering to throw out any half-length or double-length pulses, unless they occur as a pair.  (Hmm, the half-length pulses would occur as a pair, so this might not help unless I go to median of 5, which would be a lot of trouble.)

    I fixed this also, using two techniques:

    1. In the program I have 3 states for the interrupt routine that catches the edges: normally, I check that the edge is within 3/4 to 3/2 of the previously recorded pulse—if so I record it and continue. If it is less than 3/4 as long, I skip it, and change to a skip state. If it is more than 3/2 as long, I skip it and switch to a force state. In the skip state, I ignore the reading and switch to the force state. In the force state, I accept the pulse length (whatever it is), and switch to the normal state. With this state machine, I ignore a double-length pulse or a pair of half-length pulses together.
    2. The rising edge of the pulse from the tachometer is very slow (thanks to the RC filter of the pullup), but the falling edge is sharp. Extraneous pulses are more likely to occur if I trigger on the slow edge rather than fast edge, so I switched the polarity to make sure that I was using the falling edge (which is the rising edge of the output of the Schmitt trigger).

    I think that changing which edge I used made a bigger difference than trying to suppress the erroneous reads digitally. I no longer hear the occasional hiccup where the control algorithm tries desperately to double or half the fan speed because of a misread timing pulse.

  • Improve my anti-windup methods for both thermal and fan controllers, to reduce overshoot.

    I changed from using conditional integration and back calculation of the integration error to using a decay of the integration error based on the difference between the computed PWM setting and the limit when the limits were exceeded. I’m not sure this improved anything though, and it introduces yet another parameter to tune, so I may go back to the previous method. I did play around with the tuning parameters for the fan loop today, and realized that I still don’t have good intuition about the effect of parameter changes. I noticed that the fan control was oscillating a little (small fluctuations around the desired speed, but big enough that I could hear the changes), and I found ways to reduce the oscillations, but at the expense of slower response to step changes.

  • Improve my modeling of the thermal system, so that I can do more reasonable back calculation on setpoint change.

    I still need to do more thinking about the thermal modeling, since it is clear that I can’t afford overshoot when heating (though overshoot during slow cooling is unlikely to be a problem).

Still on my list with no progress:

  • Consider using a PID controller for the temperature to get faster response without overshoot.  (If I can reduce the noise problem.)
  • Design and build baffling for the fan to get better airflow in the box. I’ve made a little paper and wire baffle, to get better air flow over the resistor, but I’ve not done the full baffling to get good airflow in the box.
  • Figure out how to get students to come up with workable designs, when they are starting from knowing nothing. I don’t want to give them my designs, but I want to help them find doable subproblems. Some of the subproblems they come up with may be well beyond the skills that they can pick up in the time frame of the course. The more I work on this project, the more I realize that I and the students will have to be happy with them having explored the options, without getting all the problems solved.

I want to add to the list today:

  • Add changes to the cumulative error term whenever KP or TI are changed, to keep the PWM output the same after the changes—currently changing any of the control loop parameters adds a huge disturbance to the system.
  • Separate the control algorithm better from the rest of the code, so that I can use the same code base and quickly switch between different control algorithms: on/off, on/off with hysteresis, proportional control, proportional control with offset, PI control, PI control with anti-windup variants, PID control.
  • Add an option for recording the response of the system over a long time, so that I can plot input and output of the system with gnuplot. This would be nice for the fan control loop, but I think it will be essential for the temperature control loop.
  • Research control algorithms other than PI and PID, particularly for asymmteric systems like the temperature control, where I can get fairly quick response to the inputs when heating, but very slow response when cooling.

2014 September 15

Controlling the heater and fan

Here is the circuit for the heater and fan that I’ve been developing for incubator project for the freshman design course:

    Here is the circuit I've been using for playing with control loops. (The 74HC14N Schmitt trigger inverter does not have an enable input, but SchemeIt has a very limited and idiosyncratic set of schematic symbols, so I used the closest one.)

Here is the circuit I’ve been using for playing with control loops. (The 74HC14N Schmitt trigger inverter does not have an enable input, but SchemeIt has a very limited and idiosyncratic set of schematic symbols, so I used the closest one.)

Yesterday and this morning, when I was developing the controller software for the fan and resistive heater, I ran into a lot of problems with overshoot when changing the setpoints. For the fan controller I wrote One thing that helped was not accumulating integral error when the PWM signal was pinned at the lowest or highest values.”  I also switched to using RPM rather than pulse duration as the measured variable, because RPM is nearly linear with the PWM input (RPM approximately 24.1 PWM + 878). Another thing “that helped was to make a guess at the target PWM setting when the setpoint was changed (using d RPM/ d PWM =24 and the current PWM setting and RPM value), then setting the cumulative error to what it would be in steady state at that PWM. I then set the PWM to five times as far from current PWM as the target PWM to make the transition as fast as possible without increasing overshoot, making sure to clip to the legal 0..255 range.”  Because I have a reasonable model for RPM as a function of PWM, it was easy to estimate what the target PWM should be so that the cumulative error from the integrator would set the PWM value correctly once the error dropped enough that the desired PWM value was no longer pinned at the limits.

Today I decided to do a little reading to find out what other people have done about the problem of the controller overshooting when the actuator hits its limits.  It turns out that the phenomenon is know as “integrator windup“, and the two solutions I came up with are standard solutions.  Turning off the error accumulation when the actuator is at its limit and more movement in that direction is desired is known as “conditional integration” and guessing the correct setting for the cumulative error on setpoint change is a form of “back calculation”.  There are more sophisticated forms of back calculation that I might want to try implementing.  (I found a better explanation of the anti-windup scheme, which I might base my next implementation on—basically it gradually reduces the cumulative error to 0 as long as the desired setting for the actuator is past its limits.)

The temperature controller has been harder for me to tune, for several reasons:

  • The response time is very long.  Instead of oscillating around 5Hz, the period seems to be more like 90 seconds.  This means that it takes a long time to see whether an adjustment to the parameters makes a difference.
  • The temperature at the thermistor is dependent on the temperature at the resistor.  The thermal mass and thermal resistance act like an RC circuit (with temperature analogous to voltage, and power dissipated analogous to current).  Adjusting the power to the resistor via PWM changes the rate at which the temperature increases.  It also changes the eventual equilibrium temperature, but the PWM control is more directly of the rate of temperature change.
  • The heatsink and resistor continue to warm the air and the measuring thermistor even after all power to the resistor is cut off, so there is a big danger of overshoot whenever the setpoint temperature is increased.
  • The control is asymmetric—dumping 40W of power into the resistor heats it up fairly fast, but heat is only slowly dissipated when power is turned off.  Running the fan fast helps a little here, slowing down the temperature rise and speeding up the cool down, but once I put the whole thing in a closed box, it will be very difficult to cool things off if the box gets too warm.  This makes overshoot in the positive direction  a serious problem.
  • The temperature measurements are only about 0.1°C resolution, and the noise on the ADC is about ±4LSB, so it will be difficult to get tight temperature control, even with a perfectly tuned controller.
  • I don’t have a simple model of what the steady-state thermistor temperature will be given the PWM input, so I’ve had difficulty coming up with a guess about the eventual PWM value for resetting the cumulative error on a setpoint change.  I have a model for the resistor temperature in still air, but the fan makes a huge difference, both in the thermal resistance (and so both the equilibrium temperature and time constant of the resistor heating) and in the coupling between the resistor and the thermistor.

I still have a lot of things left over from a couple of days ago, and I’ve added some new things to the list.

  • Put the whole thing into a styrofoam box, to see whether extra venting is needed to allow things to cool down, and to see how tightly temperature can be controlled. I’ve put stuff in the box, but I can’t close the box with the stuff sticking out, so it doesn’t really count.
  • Design and build baffling for the fan to get better airflow in the box. I’ve made a little paper and wire baffle, to get better air flow over the resistor, but I’ve not done the full baffling to get good airflow in the box.
  • Figure out how to get students to come up with workable designs, when they are starting from knowing nothing. I don’t want to give them my designs, but I want to help them find doable subproblems.  Some of the subproblems they come up with may be well beyond the skills that they can pick up in the time frame of the course. The more I work on this project, the more I realize that I and the students will have to be happy with them having explored the options, without getting all the problems solved.
  • Find a smaller bread board or prototype board to put the controller on—my current bread boards are all 6.5″ long, and the box only has room for 6″, especially since I put the resistor in the center of the 6″×12″ aluminum plate, which just fits the box.  I suppose I could drill a couple more holes in the plate and mount the resistor off center, but I rather like the idea of building the controller as an Arduino shield, so that the Arduino + controller is a single unit.
  • Another possibility is to drill a hole in the styrofoam box and run cables through the box for the resistive heater, the fan, and the thermistor.  Even if the grounds are connected outside the box, this is only 8 wires. Putting the control electronics outside the box would reduce the clutter in the box and make tweaking easier.
  • Add some low-pass filtering to the temperature measurement to reduce noise.  Just adding 4 measurements in quick succession would reduce the noise and give the illusion of extra precision.
  • The fan controller occasionally has a little glitch where the tachometer either misses a pulse or provides an extra one (I think mainly an extra one due to ringing on the opposite edge).  I could try reducing this problem in three ways: 1) changing which edge I’m triggering on, 2) using more low-pass filtering before the Schmitt trigger in the edge detector, or 3) using median filtering to throw out any half-length or double-length pulses, unless they occur as a pair.  (Hmm, the half-length pulses would occur as a pair, so this might not help unless I go to median of 5, which would be a lot of trouble.)
  • Improve my modeling of the thermal system, so that I can do more reasonable back calculation on setpoint change.
  • Consider using a PID controller for the temperature to get faster response without overshoot.  (If I can reduce the noise problem.)
  • Improve my anti-windup methods for both thermal and fan controllers, to reduce overshoot.
« Previous PageNext Page »

%d bloggers like this: