I'm using a Mega with 6 PWM for servos and h-bridges. I have checked on this forum and a couple other places and the results conflict, so for clarification please. I should avoid PWM on pins 4 and 13 on a Mega to not conflict with millis()?
You can use analogWrite() on any pin that supports it to get a PWM signal.
Correct, I'm specifically asking about the millis() PWM timer conflict for the Mega, but I do appreciate your reply.
As long as you use 'analogWrite()' for PWM you can use any PWM pin without interfering with millis().
Note: the Servo library uses an extra timer if you have more than 12 servos. In that case, pins 11 and 12 will not be available for PWM. The 13 other PWM pins will still work.
You don't need PWM pins for hobby servos.
What conflict are you talking about? If you mess with Timer0, then you can affect millis() but not using analogWrite()
I did not know that. Thank you.
Any idea how to rough track the servo without the library? Perhaps just tracking the pulses as interrupts on pins 2, 3, 18, or 19?
Edit: I think I'm headed into wrong-think. Let me adjust my question a bit.
If I have 4 h-bridge PWM pins and 2 servos to add to a Mega and I want to use the servo library, which pins should I connect the servos to, as I can choose any other PWM pins for the h-bridges using analogWrite()?
Why not use the library?
Yup, I misunderstood. I can use the library assign my servo pins, and use any remaining PWM pins with analogWrite() for my h-bridge.
Use any four PWM pins for the h-bridges and any other digital pins for the servos. The MEGA has 15 PWM pins and you don't need more than one per H-Bridge.
The MEGA has 54 Digital pins (15 are PWM). You could add 15 H-Bridges (45 pins, if each has a separate 'enable') and still have pins for 9 servos. Or you could use 12 servos and 14 H-Bridges. Or 24 servos and 10 H-Bridges.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.