Temperature controlled fan using ATtiny13A

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
I have ATtiny13, for which I painstakingly built a evaluation board, along with it I also built a simple driver using TIP122 to drive a 12V DC fan.

I take temperature reading using LM35DT and feed it to ADC on tiny and I want to control fan speed depending on temperature.

I thought I could just use the PWM and control the fan speed.

Now when I start to program my attiny I realize there is no ICR register and its a 8-bit timer.

Can you suggest a way to generate a PWM and vary the duty cycle using the ATtiny13A's 8-bit timer?

PS: Timer have become a nightmare for me. More I read more I get confused :P.

Thanks,
K

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why do you think you need and ICR to do PWM?
Assuming you connected your driver to pin PB0 or PB1, th e OC0A or OC0B outputs, just configure T0 to pwm mode, I would use a low freq for controlling a fan, and enable the OC0n pin for output, then set the fan speed using the OCR0n register. There are some great timer tutorials in the tutorial forum!

jc

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Tiny13A has a Timer/Counter #0 which is able to be run in PWM mode.

The output would be on the Output Compare #0 A or B Pin, to drive your transistor driver for the fan.

For the 8-Pin PDip Tiny13A one would do something like:

Pin 1 PB5 Reset\ Leave it alone, or tie it to a reset circuit, (R/C, PB Switch).
Pin 2 PB3 ADC input for your sensor, or available.
Pin 3 PB4 ADC input for your sensor, or available.
Pin 4 Ground
Pin 5 PB0 OC0A, PWM output, or available
Pin 6 PB1 OC0B, PWM output, or available
Pin 7 PB2 ADC input for your sensor, or available.
Pin 8 V+

I would suggest you use an available "extra" pin for an LED to help with debugging, or as a "HeartBeat" Led.

I would suggest you connect an LED to the PWM output to make it easier to test / debug your code, prior to connecting / installing the transistor.

Don't forget to put a small By-Pass cap, 0.1 uF, across the V+/Ground pins of the micro, as close to it as possible.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks For your responses, I never considered using mode 1, i was always looking at mode 5.
mode one gives me access to control the duty cycle
whereas mode 5 gives me control to modify the PWM frequency at run time. By the way is there any use of modifying PWM frequency at run time?

Thanks,
K

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

By the way is there any use of modifying PWM frequency at run time?

That's where mode 5 comes in to play. The way it differs from mode 1 is that TOP is set by OCRA rather than being fixed at 0xFF. This means the frequency is variable but you lose A as a possible output channel (so you must use pin6 - channel B as the output).

Just out of interest why would a fan need the frequency to be varied? Surely you just vary the duty?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Quote:

Just out of interest why would a fan need the frequency to be varied? Surely you just vary the duty?

Pardon if I was not be very clear with my question but what i meant to ask was,
What are possible application of a PWM signal with variable frequency?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

What are possible application of a PWM signal with variable frequency?

Fair enough question, I guess.

One reason to use a PWM setup with a "variable top"--ability to change the frequency by changing the AVR timer's TOP value for that mode--might be to obtain a particular PWM frequency that is not conveniently obtainable using clock prescaler and fixed TOP. It may not necessarily be adjusted during operation.

From an old post on this site

Quote:
I am trying to design a very simple Function generator application wherein I can change the frequency and duty cycle from 15Khz to 45Khz in steps of 100Hz. And duty cycle from 10 percent to 90 percent.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.