I'm attempting to integrate an HC-SR04 sonar range finder into my APM 1.x quadcopter rig. It doesn't really fit into the model used for the other sonar drivers as it doesn't have a analog proportional voltage output, instead it uses a trigger and pulse width. I have three ideas on how to deal with this problem within the Ardupilot/APM framework but I'd really like to run it by someone who knows the system better than me.
My three ideas:
1. Find a interrupt capable pin that is either currently unused or which can be repurposed and use that to set the global sonar_alt asynchronously (I consider this to be the best solution if the hardware is available). I've poked through the forums and looked at the schematics, but I'm still uncertain as to whether there is an appropriate pin I could use.
2. build a simple integrator/buffer circuit to translate the time domain pulse into a voltage so the device can be made compatible with the Maxsonar drivers. I don't like this solution because it would require both a trigger pin and a clear pin, though I'm sure there's some creative way I could turn it into a one-wire device with some extra jiggery.
3. add another controller to the mix (so I can implement (1), potentially with many devices) and access the device via i2c. This is probably the easiest way out, but seems like overkill. I have a few digistump digisparks on order which would probably be ideal for this role, but I have a couple of weeks to wait for them. I could slap an Uno on top of my stack for testing... actually, there's no reason I can't do that now, so I guess this should be my first iteration.
Any feedback would be appreciated. Is there another, perhaps simpler, solution I'm overlooking? Is there a way to use a PWM pin to read the pulse width? Has someone already done this and simply evaded my search attempts?