NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » Thermo-electric Cooler (TEC) control using Nerdkit - Question

November 13, 2010
by eurquiza
eurquiza's Avatar

Hey,

I'm interested in using the Nerdkit (NK) to control temperature using a thermo-electric cooler (TEC). Varying the voltage on the TEC will control the heat flux.

The problem is that TEC's are sensitive to thermal cycling (fatigue), but a sufficiently high frequency should dampen the cycling to avoid fatiguing the TEC. OK, so I have two questions.

1) If I use Pulse Width Modulation (PWM), how high of a frequency can be achieved with the NK?

2) Is there a way to use the NK to control an analog voltage output? What components would I need?

Any help, thoughts or links to relevant info are appreciated. Many thanks!!! keno

November 13, 2010
by bretm
bretm's Avatar

The fastest PWM using the built-in PWM functionality is Fclk/256. For the Nerdkits 14.7456MHz crystal, that would be 57.6kHz. You can get a little faster with a faster MCU clock but you'd need to change the bootloader code which isn't trivial, or switch the crystal whenever you wanted to program the chip. It might be possible to do a low-precision PWM by manually controlling a pin, but you'd spend all the clock cycles doing doing that and probably wouldn't have time to do anything else. So 57.6kHz is the basic answer.

You can use a second PWM output to generate an analog voltage. Put a low-pass filter on the PWM output to filter out the PWM frequency and you'll be left with a DC voltage proportional to the duty cycle, plus some ripple. This is the easiest solution.

Or you can use multiple pins and an external DAC.

Or you can use multiple pins and a R-2R ladder, followed by a voltage-follower (buffer amplifier) circuit such as an op-amp or a transistor in common-collector arrangement.

November 13, 2010
by carlhako
carlhako's Avatar

bretm just wondering where you get the fastest PWM from the datasheet? From what i gather reading it i can set the pre scaler however i want? eg. timer/counter1 table 15-5 pg 134

Thanks

November 13, 2010
by bretm
bretm's Avatar

The fastest is with prescaler=1 (no prescaler), so the timer runs at 14.7456MHz. To get 8-bit PWM you have the let the counter run from 0 to 255 (it runs with the pin "high" from 0 until output-compare match, and then with the pin "low" from there to 255). So the total period is 256 clock cycles, and the frequency is 14745600/256 = 57600.

Although I've only used 8-bit PWM, my understanding from the datasheet is that if you don't need 8 bits of precision (i.e. you don't need 256 choices of duty cycle) you can go faster--you double the frequency for each bit of precision you give up. E.g. if you only need 16 different duty cycles (4 bit counter) you can get 14745600/16 = 921.6 kHz. For example you can use Timer/Counter0, set WGM2:0 to 7, set OCR0A to 15 so the timer goes from 0 to 15, and use OCR0B to control the duty cycle and pin OC0B as the PWM output pin.

November 14, 2010
by eurquiza
eurquiza's Avatar

That's all very helpful. Thank you very much.

Post a Reply

Please log in to post a reply.

Did you know that signed numbers need to be sign-extended when chaging variable sizes? Learn more...