I am using an Attiny 261 mcu. I have an analog to digital input with a variable 0-5 vdc pot. The result is left adjusted. Secondly I am using Timer1 for PWM (phase and frequency correct). COM1D1 and COM1D0 is set to 01 (clear on compare). OCR1C (Top count) is set to ob11111111. The analog ADCH is continuously being read into OCR1D. Also the clock is 8M with a prescaler of 8.
It seems to work by adjusting the pot causing the duty cycle to increase and decrease. In this case I am lighting an led. However as you increase from 0 to 5vdc the light gets brighter then dimmer. Then it seems to reverse its direction. There seems to be a consistent middle region where it works but I can't understand why it jumps around and seems to reverse direction. Some times as you decrease it it will jump to full on.
Not sure what is going on.
Thanks for any help.
It seems to work by adjusting the pot causing the duty cycle to increase and decrease. In this case I am lighting an led. However as you increase from 0 to 5vdc the light gets brighter then dimmer. Then it seems to reverse its direction. There seems to be a consistent middle region where it works but I can't understand why it jumps around and seems to reverse direction. Some times as you decrease it it will jump to full on.
Not sure what is going on.
Thanks for any help.