Control multiple servos and use PWM pins for other application?

Hi,

I am currently working on a hexapod project which consists of 20 servos and an ultrasonic range finder.
Based on my understanding, Arduino Due can support multiple servos if use the Servo library: Arduino - Servo. However, by doing so it will disable the analogWrite function of the PWM pins.
Since I am only using 20 servos, I only needs 2 Timers. In this case, can I use some of the PWM pins for my ultrasonic range finder?
If yes, how can I know which PWM pin is using which Timer? Is there any documents that I could refer to?
If no, does it mean that I have to use separate servo controller to free up the the PWM pins on Due?

Appreciate if someone could help me to sort my doubt out. Thanks.

What ultrasonic rangefinder are you using?

On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10,

This leaves 4 other PWM pins unaffected.

Hi groundfungus,
Thanks for your reply.

groundfungus:
What ultrasonic rangefinder are you using?

I am using the HC-SR04 as shown in the link below.

groundfungus:
This leaves 4 other PWM pins unaffected.

Would you mind to explain how did you figure out which PWM pins are unaffected? Honestly speaking, I am a bit confuse with the SAM3X datasheet.

One TLC5940 can control 16 servos using 4 or 5 SPI pins

The HC-SR04 rangefinder does not need PWM pin to operate. Any digital pins can be used for trig and echo.
Sorry, I am not familiar with the Due board and spoke out of turn about the number of PWM pins.

raschemmel:
One TLC5940 can control 16 servos using 4 or 5 SPI pins

Thanks for your suggestion. I will consider this solution if I have no enough pins for my sensors.

groundfungus:
The HC-SR04 rangefinder does not need PWM pin to operate. Any digital pins can be used for trig and echo.
Sorry, I am not familiar with the Due board and spoke out of turn about the number of PWM pins.

If I didn't get you wrongly, you are trying to hint me that I can do it using delay. Right?

I don’t know why you would use delay() in code to read an hcsr04. You would pulse the trigger pin HIGH for a minimum of 10 microseconds and then use pulseIn() to measure the time that the echo pln is HIGH. There are lots of places to get example code to interface these rangefinders. http://www.nick-horne.com/2013/08/29/arduino-hc-sr04-ultrasonic-range-finder/