![]() Rename the folder "SonarI2C-master" to "SonarI2C".Download the latest release archive from GitHub and decompress it.If this does not work, you can manually install the library: In the Arduino IDE, open the "Sketch" menu, select "Include Library", then "Manage Libraries.".If you are using version 1.6.2 or later of the Arduino software (IDE), you can use the Library Manager to install this library: two NPN transistors and some resistors to make a NOR gate.The minimum setup to use this usefully requires Īrchiving the original V1 board and no-board prototype instructions here.Archived V1 instructions Alastair Young.Will have to bit-bang the shift register as the SPI overlaps the I2C on all the Tiny chips I'm looking at. And using shift registers allows for daisy chaining for people that want to use silly quantities of sensors. As the sensor headers and the tristate buffers are all on the featherwing added footprint, there is lots of space to do that within the new form factor. For the 8 port I could either go with a more-pins ATTiny or go with shift registers and an ATTiny 841. On the 8 port board that has enough pins to drive the sensors directly, and it will fit in where the PCF8574 is on the feather footprint. This will make it much easier to use with non-Arduino platforms - save me learning how to do hardware interrupts on RPi for instance.Īn ATTiny85 would not have enough pins even to drive a shift register and I2C and retain the reset pin so I'm thinking ATTiny841. This has got my brain clicking that what I should really do is to put an ATTiny on the boards and run the code locally. These are in separate projects for entry into the current hackaday contest. Keeping the ability to be wired standalone. This should make them easier to use for feather adherents, as well as smaller in general. So I'm in the process of redesigning the boards for the featherwing footprint. I am not supporting code on RPi at this time but you are welcome to write your own. There is a tweaked version in my repo to update it for the 2.0 boards, but it's still not my code, and it definitely doesn't work for the X2 16 sensor board i.e. While the board has been proven electrically compatible with the 3.3v raspberry pi (without level shifters), the code out there to support it wasn't written by me but by someone else for the 1.0 boards. Earlier boards used OR logic on the echo and the SonarI2C library. NOTE: The OctoSonar library is for board rev 2.0+. If you need to wait for something to happen or be a certain way for a period of time, save the end time in a variable and check each loop() cycle to see if it is time to end that state. Essentially you want your loop() to never delay(). Google it if you don't know what that is. IMPORTANT: this will work best if your program is written as a "finite state machine". If it is time to poll the next sensor it will do that. The user read functions default to mm, but you can use other units.Ĭall doSonar() every loop(). Sensor data is kept in an array which is cycled through in 50ms steps Record an out-of-range value if no echo completion occurred. ![]() at the end of the 50ms window, whether an echo is received or not, raise the trigger pin, disabling the tri-state buffer.the interrupt routine fires, calculates the echo pulse duration in µs, saves it and then clears the interrupt.the sensor does its thing and ends the echo pulse.the interrupt routine fires, notes the time in micros(), and attaches a new interrupt to watch for the end of the pulse.the sensor does its thing and starts the echo pulse.attach an interrupt to the pin to watch for the beginning of the echo pulse.This starts the sensor's ping cycle and turns on the tri-state buffer so the echo state is now visible at the interrupt pi. Via the I2C expander, drop the trigger pin.In this high state the tri-state buffer output is at high impedance (off). This is contrary to common practice, but works fine as the sensor is triggered by the falling edge, not by the suggested 10us pulse. In idle state, the sensor trigger pin is held high.Wire the outputs of the tri-state buffers to a hardware interrupt pin on the Arduino.Wire the Echo pins to the inputs of the tri-state buffers.Also wire them to the control pins of 74HC125 tri-state buffers. Wire the Trigger pins to PCF8574A expander pins.The concept behind the OctoSonar library is as follows: I2C bus would be the answer, but the bus itself is not fast enough for accurate echo measurement, and the only reference to an I2C library for these in the playground seemed to be broken. There are not enough pins on a basic Arduino to provide 2 pins each to 8 HC-SR04 units.
0 Comments
Leave a Reply. |