Go Down

Topic: Servo8Bit not working on ATtiny45 (Read 131 times) previous topic - next topic

wornoutflipflops

Mar 20, 2017, 03:25 am Last Edit: Mar 20, 2017, 03:57 am by wornoutflipflops
I'm using the tiny45 for a project where I have to read two ADC's and control an LED and a servo. I'm using the Servo8Bit library and configured the ATtiny at 8MHz internal.

The first ADC value controls the LED brightness and the second ADC value is compared with a threshold to decide whether to actuate the servo (angle is predetermined).

When I tested this on the Arduino MEGA board using the standard Servo.h library, everything worked fine.
Even on the ATtiny, the ADC's and PWM's work perfectly when I read the analog inputs and output the same voltage on the PWM pins. But everything stops working when i #include the "Servo8Bit.h". Even the LED stops glowing and servo is dead.
Just using the preprocessor directive renders the tiny45 dead. And comes back alive when I remove it.

So I guess I've missed something in the procedure, or there's a problem in the library.
edit: Library source - http://www.cunningturtle.com/servo8bit-library-version-0-6-released/
#warning Timer 2 not finished (may not be present on this CPU)

DrAzzy

Is that library specifically meant for the tiny x5 series? The timers available on the x5 are significantly different from those available on other attiny boards.

Also - whenever you use any servo library, it's going to take out some of the PWM outputs (1 or 2 on the x5 series, depending on whether it uses timer0 (which will also take out millis() ) or timer1 (which is totally unlike timer1 on any other AVR micro other than the tiny x61 series)
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

wornoutflipflops

Thanks for the reply..
I am not using the PWM's simultaneously so had ruled that out. I detach the Servo as soon as it's scope is out, on every iteration of void loop.
So I think it's the compatibility issue as you've said. Can you suggest a good servo library for the 45? With the detach function operational?
#warning Timer 2 not finished (may not be present on this CPU)

wornoutflipflops

I was going through the forum for similar topics and found a couple of libraries for the tiny45, so I downloaded them and tested. One of them, Servo8Bit2 seems to work. No problems till now.


Thanks for the help.
#warning Timer 2 not finished (may not be present on this CPU)

Go Up