Interrupt driven sensors; HC-SR04 rangefinder; implementation questions


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?

Views: 1290

Reply to This

Replies to This Discussion

Hi David,

I am also interested in that subject.

I think it could be possible to adopt the code used in MegaPirateNG for range sensor, but I don't know how specify the board ports and what will be usable to connect the sensor.

I am waiting to receive the sensor to test it in CRIUS AIO and then try to use with APM 2.0

Had you made some advance in the subject?

I'm also have some HC-SR04 laying around here. Do you made any advance ? I can help with the coding :D

Reply to Discussion

RSS

Groups

Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service