I’m trying to read from a LV-Maxsonar-EZ0 using the serial interface.
I have connected the wires correctly and I have placed an overlay in uart2.
The problem is the data I’m reading from the sensor. I can only get garbage, but its not completely wrong because the data changes according to the distance to obstacle.
The datasheet for the sensor can be found here: datasheet.
I searched google for a day and couldn’t find anything…
Someone posted in a raspberry pi forum that the problem is the meaning of 1s and 0s, but I changed active_low to 1 and I got the same.
I’m not very proficient with electronics, so I might take some time following instructions.
Nonetheless all the help will be welcome.
what board do you use and what OS?
your datasheet says that VCC is +5V and the TX pin also work in 0-VCC range. If you use beaglebone it accepts only 3.3V, however there can be options
Hi, thank you for quick reply,
I’m using a BeagleBone and Ubuntu 12.04.
I have the TX connected to p9_22, which is uart2 RX.
I guess I did some mistake answering back there =P
It is in UART_RX.
I search the internet and found that maybe I’m getting the inverted messages, all the 1s as 0s and the 0s as 1s.
I believe my blog post http://blog.lemoneerlabs.com/post/Hearing-aids will solve your issue. You need to build an actual inverter (or buy an IC to do it for you).
As an addendum, the circuit in my post would work at 3.3 V as well.
At risk of asking the obvious, have you double checked you’re putting out serial data? Your datasheet requires the BW pin to be floating or low to output out serial data, otherwise it puts out pulse data on the same pin.
Before you try the inverter approach, maybe just put a multimeter on the Tx pin on the device - it should be high (ie 3.3V) most of the time. If it’s transmitting once per second, NMEA0183-style, even then the voltage should be closer to 3.3V than GND. If it’s closer to GND, then you’ll need to invert it.
I’m working with a whole stack of NMEA0183 devices and assuming they’re properly functioning, the only thing you can really get wrong are baud rate, inverted signal, wrong pin (tx instead of rx, in which case you hear nothing) or software config error. For software, I just use screen - “screen /dev/ttyO2 9600” - rather than minicom or any of the other scripts. Much easier.
If you contact MaxBotix or check the specs on the Pololu page http://www.pololu.com/product/723/ you can see it has the following outputs
- Three interfaces (all are active simultaneously):
- Serial output: asynchronous, logic-level, inverted, 9600 bps 8N1
- Analog output: (Vcc/512) / inch (10 mV/inch when input voltage Vcc = 5 V)
- Pulse width output: 147 μs/inch
I posted a link to my blog below. I experienced this problem a couple years ago when I first started with MaxBotix sonars. The datasheet isn’t 100% clear, but the serial signal is inverted. That is what the person in the RPi forum meant about the meaning of the 1s and 0s. You cannot simply flip the received data because the whole stream is inverted (to include start bits, etc.). You need to invert everything. In my post you will find a simple circuit made of 2 resistors and a transistor that will invert the signal for you. If you prefer, you can purchase a hex inverter to accomplish the same thing.
I hope it helps you. To save you from finding my other posts, here is the link http://blog.lemoneerlabs.com/post/Hearing-aids
Thank you Matthew, you confirmed what I didn’t want to xD
I switched to analog for now.