arielnh56 / SonarI2C

Arduino library supports many HC-SR04 sensors via I2C bus and hardware interrupt
MIT License
26 stars 3 forks source link

code licensed for modification? #1

Closed anoff closed 7 years ago

anoff commented 7 years ago

Hi @arielnh56,

stumbled upon your project trying to figure out how I can attach multiple HCSR04s to my arduino. Your solution looks quite sophisticated. Would love to implement something similar. I was wondering if you could add a license to your repository that clears use/modification of your solution.

What I want to see is if the Sonar works without the additional NOR hardware if you wire them as pictured here: https://github.com/ajfisher/nodebots-hcsr04/blob/master/docs/img/backpack_ping_bb.png Is there any reason you opted for separated pins?

/andreas

arielnh56 commented 7 years ago

I thought I stuck the MIT license on it. That was my intent. I will check and rectify as needed.

Tying trig and echo together may work for one sensor, but cannot work for multiple, as you would also tie all the trigs together and they would all go off at once. I'm not sure how reliable the pin-tying is between different batches of these sensors - they seem to vary a lot in design and component count.

If you mean run the echoes back to the pin expander chip, you would get the individual indexing. You could then run the chip's INT pin back to the hardware interrupt pin to get the accurate timing, though you would also need to reset the interrupt in the chip after the start and finish of each echo pulse (another 2 I2C interactions). That might work, and would reduce the component count.

On Tue, Mar 7, 2017 at 12:28 PM, Andreas Offenhäuser < notifications@github.com> wrote:

Hi @arielnh56 https://github.com/arielnh56,

stumbled upon your project trying to figure out how I can attach multiple HCSR04s to my arduino. Your solution looks quite sophisticated. Would love to implement something similar. I was wondering if you could add a license to your repository that clears use/modification of your solution.

What I want to see is if the Sonar works without the additional NOR hardware if you wire them as pictured here: https://github.com/ajfisher/ nodebots-hcsr04/blob/master/docs/img/backpack_ping_bb.png Is there any reason you opted for separated pins?

/andreas

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arielnh56/SonarI2C/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AFGOQVolLwvc8PVtI-aTt-YtLYcUErRVks5rjb4JgaJpZM4MV_CG .

arielnh56 commented 7 years ago

https://www.tindie.com/products/arielnh56/octosonar-connect-8-x-hc-sr04-to-arduino/

in case you didn't see that :-)

On Tue, Mar 7, 2017 at 3:07 PM, Alastair Young alastair@redhunter.com wrote:

I thought I stuck the MIT license on it. That was my intent. I will check and rectify as needed.

Tying trig and echo together may work for one sensor, but cannot work for multiple, as you would also tie all the trigs together and they would all go off at once. I'm not sure how reliable the pin-tying is between different batches of these sensors - they seem to vary a lot in design and component count.

If you mean run the echoes back to the pin expander chip, you would get the individual indexing. You could then run the chip's INT pin back to the hardware interrupt pin to get the accurate timing, though you would also need to reset the interrupt in the chip after the start and finish of each echo pulse (another 2 I2C interactions). That might work, and would reduce the component count.

On Tue, Mar 7, 2017 at 12:28 PM, Andreas Offenhäuser < notifications@github.com> wrote:

Hi @arielnh56 https://github.com/arielnh56,

stumbled upon your project trying to figure out how I can attach multiple HCSR04s to my arduino. Your solution looks quite sophisticated. Would love to implement something similar. I was wondering if you could add a license to your repository that clears use/modification of your solution.

What I want to see is if the Sonar works without the additional NOR hardware if you wire them as pictured here: https://github.com/ajfisher/nodebots-hcsr04/blob/master/docs /img/backpack_ping_bb.png Is there any reason you opted for separated pins?

/andreas

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arielnh56/SonarI2C/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AFGOQVolLwvc8PVtI-aTt-YtLYcUErRVks5rjb4JgaJpZM4MV_CG .

arielnh56 commented 7 years ago

I read up a bit on this. Trig and Echo on the HC-SR04 have 10K pullups, and the Echo is low in idle state - so it is forced low by the device. If you feed this directly to the Trig pin it will fight against your trig pulse. The control pin high will drive current directly into the Echo pin low. I don't think that would be a good thing. While it can probably be overcome by an Arduino pin which can source >20mA, the PCF8574 would probably fail to generate a recognizable pulse, as it can only source 0.1mA.

I did see some references to tying a resistor between the two pins (which would weaken the impact of the low echo, and limit the current drawn from the trig pulse), and another reference to also removing the pullup on the trig pin.

http://www.cascologix.com/2015/09/19/hc-sr04-ping-sensor-hardware-mod/

I don't want to be supplying something that requires folks to be unsoldering teensy smd components from manufactured parts, so whatever circuitry is needed to make this reliable needs to be on the board, not mods in the sensors themselves.

Another approach would be to use the MCP23008 expander which can source 25mA on the pins. Connect that to trig and connect to echo with a resistor - that might do it.

anoff commented 7 years ago

Agreed the hardware modding of a HCSR04 is also something I don't really want to do. Didn't know you sell those PCBs. I was mostly to lazy to solder stuff together - my electrical training was 10 years ago 😁 That's why I was thinking of implementing something with the unified T/E pins on a arduino nano/pro-mini.

I saw the tutorials of johnny5 using the sensor that way. Some arduino examples even use the arduino pulseIn feature to measure the return pulse which works quite well. I assume the pulseIn is blocking though but since you go sequentially through all the sonars it shouldn't be an issue.

Anyway, thanks for the link to your PCB I'll just order one to try it out :) (You should put it on the readme)

arielnh56 commented 7 years ago

new code release adds MIT license stuff, as well as some improvements in out-of-range handling. there seems to be a wide variety of behavior between different manufacturer when an echo is not recieved. The spec sheets say 37ms, my logic analyser says 200ms, and some common "not good" units never bring the echo down at all and need power cycled or the pin forced down in some way.

I have some of these "not good" ones and have some success with adding an LED and series restistor between Echo and GND. This gives and activity light, and my guess is it bleeds off some charge from a capacitor somewhere and allows the infinite pulse to come down.