ElizabethTeaches / PrecisionServo

ATTiny library for controlling one or multiple servos
Creative Commons Zero v1.0 Universal
13 stars 3 forks source link

Interference with pulseIn function #3

Open jkallend opened 2 years ago

jkallend commented 2 years ago

I want to read an input pulse on PB1, modify/massage it, and then output the modified pulse on PB0 to a servo using PrecisionServo.

The output works fine and gives very precise servo pulses, however PrecisionServo seems to screw up the pulseIn( , ) function.

ATtiny85 running at 1MHz.

Any suggestions?

Tjstretchalot commented 2 years ago

Are you able to produce a minimal example or share some of the code that goes into this? In particular, do you know of any particular pulse sequences (after massaging) that don't get the desired response?

jkallend commented 2 years ago

A simple use of pulseIn (xxx,HIGH); to read a servo input from a servo tester, reverse it (yyy=3000-xxx) and output it using precision servo results in continual twitching of the servo. Servo tests OK, precision servo works OK with a "sweep" sketch.


John Kallend Professor Emeritus Department of Mechanical, Materials and Aerospace Engineering Department of Physics IIT, Chicago

On Fri, May 6, 2022 at 6:02 PM Timothy Moore @.***> wrote:

Are you able to produce a minimal example or share some of the code that goes into this? In particular, do you know of any particular pulse sequences (after massaging) that don't get the desired response?

— Reply to this email directly, view it on GitHub https://github.com/ElizabethTeaches/PrecisionServo/issues/3#issuecomment-1120065685, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO6OKKKYT3YFDC4BRZOG4WLVIWQGTANCNFSM5UGHW2FQ . You are receiving this because you authored the thread.Message ID: @.***>

Tjstretchalot commented 2 years ago

To confirm, do you have a voltage regulator in the circuit? For example, L7805CV

jkallend commented 2 years ago

No.


John Kallend Professor Emeritus Department of Mechanical, Materials and Aerospace Engineering Department of Physics IIT, Chicago

On Sun, May 8, 2022 at 10:43 AM Timothy Moore @.***> wrote:

To confirm, do you have a voltage regulator in the circuit? For example, L7805CV

— Reply to this email directly, view it on GitHub https://github.com/ElizabethTeaches/PrecisionServo/issues/3#issuecomment-1120440999, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO6OKKKG4LAA5DS3W3E6RPLVI7OI7ANCNFSM5UGHW2FQ . You are receiving this because you authored the thread.Message ID: @.***>

Tjstretchalot commented 2 years ago

From when we were testing without a voltage regular the servo can behave very unexpectedly, and one of those things we saw was the type of twitching you describe. This is particularly exacerbated when running from battery, since the voltage from the battery will change based on its capacity (google a battery charge voltage graph or battery capacity voltage graph), and will change based on the temperature

I would strongly encourage burning off some of the electricity to get a more stable voltage via a linear voltage regulator and seeing if that helps with the twitching. linear regulators are very cheap (under a dollar) and absolutely worth it

Watch out though - linear voltage regulators can only step down the voltage by increasing resistance, so ensure that the input voltage is higher than the target voltage. For example, target 5v with a 6v battery. You know you're overdoing it if the regulator gets too hot, and under-doing it if you don't get a consistent voltage off a voltmeter