Making servo and SRF05 share an output pin

srf-servo-pin-sharing.bas (1101Bytes)

I just noticed that a servo and a SRF05 range finder's trigger might be able to share an output pin on Picaxe 28x1 (should work on other models too). It should be possible because "the servo command starts a pin pulsing high for length of time pulse (x0.01 ms) every 20ms" (manual2 / servo command). In other words servo positions between 75 and 225 cause pulses lengths between 750 and 2250 μs. That's long enough pulses to SRF05 that requires at least a pulse length of 10 μs.

The only thing that I thought could mess things up was SRF05's ability to cope with continuous pulsing. Because SRF05's echo pulse length varies from 100 μs to 25ms (with 30ms timeout) there's going to be trigger pulses during the measurement. I wasn't sure if SRF05 can handle it so I tried it to see what happens.

Here's a picture of my setup (click for bigger image):

srf05-servo-pin-sharing-01.jpg

Servo is connected to project board in the “usual way” to the output pin 0 through a 330Ω resistor. SRF05’s trigger pin is connected directly to output pin 0 and echo pin is connected to input pin 0.

I did some quick testing with the attached code and it seems to be working just fine. The down side of course is that SRF05 is now measuring all the time and so it’s consuming extra power. Nice thing is that you don’t have to do pulsout. Just read the value with pulsin and you’re done :slight_smile:

Be warned: I really haven’t tested this thing thoroughly so there might be some issues I haven’t noticed. Try it out and see if it works for you :slight_smile:

 

that is cool! :slight_smile: what about

that is cool! :slight_smile: what about servo and SRF in one pin mode all on one pin? :slight_smile:

All-in-one solution would be

All-in-one solution would be nice but probably not possible. “Servo pins” are output only on 28x1 and SRF05 echo signal would screw up the servo signal anyway :frowning:

 

Nice work!

I think this is definately useful on smaller PIC’s as they often have a shortage of pins :slight_smile:

 

Keep it up!