Cerbuino Bee - Unreliable AnalogInput reading?


I own several GHI mainboards like Panda II, Ceberus and Cerbuino Bee.
I just bought a Maxbotix XL MB7092 sensor (http://www.maxbotix.com/documents/MB7052-MB7092_Datasheet.pdf) which I like to attach to the Cerbuino Bee. The MB7092 provides several ways to obtain the distance. It’s having a RS232 output and it can output the distance as a pulse. It also have an analog output.

Since the RS232 output is kind of inversed, .NET MF is unable to read the proper serial output without additional components (which is a pity…).

I am a newbee to micro controllers as I usually develop PC applications and websites in .NET. So, I am not familiar with terms like ‘held high’ or ‘leave open’ (needed to get the pulse working)… So I decided to use the (non preferred method) analog output of the sensor to obtain the measured distance. However, I am experiencing in my opinion an unreliable AnalogInput voltage reading.

When I use a old-fashion voltage meter to measure the voltage difference between the analog output of the sensor and the Gnd of the Cerbuino I measure for instance 242 mV, which divided by 3.2 (which is stated in the datasheet to be used when attached to 3.3V) is the distance to the next obstacle. If I however use the AnalogInput of the Cerbuino Bee and I do not change the position of the sensor, it will report 290, sometimes more then 300 mV, resulting in a wrong distance.
If I measure one of the analog inputs and disconnect the sensor, it will still read +/- 250 mV without anything connected…

Are these boards not suitable to measure mV in a reliable way?
If not, can someone help me to get one of the other ways to obtain the distance working?

Thanks in advance!


@ Jaap - This issue has been logged, and is awaiting verification.

Hi Jaap,

Leave Pin4 unconnected for continuous sampling. Is Pin 1 connected to GND for analog mode?

Firstly, it looks like the serial should work (it’s called TTL serial when the voltage swings between GND and VCC, 3.3V in your case). It can be normal or inverted (idle high or low). It is not RS232, despite what MaxBotix may say. What do you see if you break on the DataReceived event of the serial port? You should get data back in ASCII format like “R423” for 423cm.

Analog done accurately is hard. You need to use a very low noise 3.3V power supply (low ripple). Also, when you connect the sensor, use twisted pair cabling. 1 pair for the power supply and 1 pair for the analog output (connect the GND together at the sensor). You need to minimise common mode noise (Common-mode signal - Wikipedia). Use thicker cabling than you think you need because the power draw on the Sensor is very peaky - 50mA while measuring then 2.1mA while idle. As far as I’m aware GHI does not provide anyway to separately power the ADC circuit on the MCU, so you’re stuck with whatever ripple is on the power supply. An ADC works by comparing the input voltage (from your sensor) to a known voltage (VRef, or 3.3V in this case). If the 3.3V is changing, then the comparison will change as well.

You can test the ADC conversion by getting 2 resistors, say 10k each, putting them in series between VCC and GND and connecting the center point to an analog input. The voltage you read should be VCC/2. (If you take the 2 resistors from the same batch then you don’t need to worry too much about tolerances).

When you measure your analog signal you must do it as close as possible to the MCU, so put your probes as close as possible to where the MCU is reading the voltage. Also, what does your meter say when you measure the 3.3V? What power supply are you using?

Also try connecting the anaolg input to VCC and GND and see what the MCU reports as the voltage. Note that is it generally unreliable to measure the voltage on an ADC input with nothing connected…

The datasheet says that the distance is VCC/1024 per cm. This is ~3.223mV/cm. So if you read 1000mV, the distance is ~310cm.

Hi Byron,

Thanks for your response!

Pin 4 is unconnected. Pin 1 is not connected to GND, since it has only affect on the output of Pin 5 (serial data or pulse width).

Regarding to the serial connection:
I did already work a lot with the serial connections in .NET MF and already tried it. I do receive data from the sensor, but it is invalid. The capital R is received as byte 43, the carriage return is not constant and is dependent on the returned distance. As far as I can conclude the Cerbuino (or just.NET MF?) is unable to read the inversed TTL signal, meaning that the start and stop bits also are not received correctly and therefor the sent ‘datagrams’ are not recognized correctly and are depending on the previous ‘datagram’.

The capital R is constantly 43. When I set something before the sensor, I do expect the message R020, since distances between 0 and 20cm are reported as 20cm. The received serial data in bytes 43 - 6 - 103 - 178 - 30. This message is constantly. You should expect that 30 is the carriage return. If the sensor however measure a distance > 20cm, the 6, 103, 178 are changing but the 30 also. As said, I guess it’s because the serial start and stopbits are also inverted which causes the SerialPort class to interpret the received data incorrectly. From what I have Googled, I need a CD4049BU hex inverting buffer (Obstacle Avoidance - It's Not As Easy As I Thought - Software and microcontrollers - Pololu Forum) to convert the 0 to 1’s and vice versa.
This component isn’t that expensive, but it’s a pity that I need it…

Regarding to the analog input:
If I read your response I am not very hopeful that I can get his working on a reliable way. I did already expect it and that’s why I did like the ‘RS232’ feature of this sensor :slight_smile:

I have connected the 3,3 volt to the A0 interface and did get values between 3293.55mV and 3296.78mV.
I am using the USB power or and external power supply, which is a very basic Alecto switching power supply. But I don’t want to be dependent on only ‘good’ power supplies…

Since this sensor also supports sending it’s measured distance as a pulse: can someone help me getting this to work on the Cerbuino?
Regarding to the specs, I have to make Pin1 low to get the pulse on Pin5 working. Does this mean that I should connect Pin1 to the GND?

Thanks in advance!


Hi Jaap,
You are correct - you can’t invert the RX hardware on the Cortex. So no go there without the extra hardware.

For Pulse In see Netduino and Ping))) Ultrasonic Sensor? - Netduino 2 (and Netduino 1) - Netduino Forums as a start

you said

[quote]Pin 1 is not connected to GND, since it has only affect on the output of Pin 5 (serial data or pulse width).

Just remember that common GND reference voltages are essential at all times - so without a doubt, you need GND on the module and GND on your mainboard connected, if you don’t have them already.

You then asked about pulse width, and yes GND is equivalent to LOW so that’s what you’d need to do if you want to use pulse width.

The sensor is connected to the 5V output of the Cerbuino and thus also the GND from the Cerbuino is used.

The pulse method did also not having the desired result, so I decided to order a ‘Hex inverting buffer’ (http://nl.rs-online.com/web/p/buffers/5190287/).
I have received this component today and used a breakboard to connect the parts together. Now I am able to read the serial output!

Thanks for the replies!

@ Jaap - If this issue has been resolved, please mark the appropriate message as the correct answer. Thank you.

@ James, looks like Jaap’s own answer is the correct one, but you can’t mark your own posts as the answer, I believe?

Since Byron is totally right, I have marked his post as answer :slight_smile: