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?

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • 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?

This reply was deleted.

Activity

DIY Robocars via Twitter
RT @_JonMyer: 🚨Attention DeepRacer's including #UndergroundDeepRacer🚨 Check our our LIVE stream that including @IAM_dbro Take a few moments…
Wednesday
DIY Drones via Twitter
RT @MarvelmindMaxim: Extreme precision for 60 swarming robots. #marvelmind #autonomousrobotics #robotics #swarmrobotics #rtls #ips #indoor…
Aug 3
DIY Drones via Twitter
RT @MarvelmindMaxim: Precise (±2cm) tracking for racing boats and autonomous boats. Works outdoor and indoor. #autonomous #AutonomousVehic…
Aug 3
DIY Drones via Twitter
RT @MarvelmindMaxim: Helping PixHawk folks to fly autonomous quadcopters using PX4 and ArduPilot. https://marvelmind.com/drones/ Equally suitab…
Aug 3
DIY Robocars via Twitter
RT @chr1sa: The @DIYRobocars @donkey_car virtual AI car race is starting in 15 minutes! Watch it live on Twitch https://www.twitch.tv/mossmann3333 htt…
Aug 1
DIY Robocars via Twitter
RT @chr1sa: Don't miss our monthly @DIYRobocars @donkey_car virtual AI car race tomorrow at 10:00am PT live on Twitch. Head-to-head racing…
Jul 31
DIY Robocars via Twitter
RT @sparkfun: Our completed tutorial on building an @NVIDIA Jetson Nano-powered @Sphero RVR gets your bot up and running via teleoperation…
Jul 30
DIY Robocars via Twitter
RT @SmallpixelCar: Freeway test https://t.co/4V5tV9lhIP
Jul 29
DIY Robocars via Twitter
Very small autonomous cars racing, thanks to an overhead camera: https://control.ee.ethz.ch/research/team-projects/autonomous-rc-car-racing.html
Jul 29
DIY Robocars via Twitter
Jul 29
DIY Robocars via Twitter
Jul 29
DIY Robocars via Twitter
RT @chr1sa: Don't miss our virtual AI car race this Saturday! Real developers + virtual cars =🏎️🏎️🏎️ Head-to-head battles with thrills, sp…
Jul 28
DIY Robocars via Twitter
Jul 27
DIY Robocars via Twitter
RT @usashirou1: Jetson nano by Isaac Kaya #jetson https://t.co/Mu1N0CyQkN
Jul 23
DIY Robocars via Twitter
RT @GPUsolution: JetRacer mady by Iflytek company #JetsonNANO #Nvidia https://t.co/MimTymIwge
Jul 23
DIY Robocars via Twitter
RT @openmvcam: I love this: Mega or Mini? Image Classification on the 1MB OpenMV Cam H7 by Ish Ot Jr. in OpenMV, Edge Impulse, Internet of…
Jul 23
More…