Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Using the Maxbotix LV-MaxSonar in Serial Mode


  • Please log in to reply
3 replies to this topic

#1 Paul

Paul

    Member

  • Members
  • PipPip
  • 14 posts

Posted 28 October 2010 - 11:12 PM

Continuing with my Robotics project it became time to integrate a Maxbotix LV-MaxSonar sensor for purposes of collision avoidance. I started working with the MaxSonar last month as one of my first Netduino projects. At that time I used the "DistanceClass" originally posted by Crispin. This class uses the analog output of the MaxSonar and once I got it running, with a little extra help from Crispin who reponded to my post regarding a perlplexing analog problem, I discovered what a great many other people have discovered: the analog output is very easy to use but it tends to be somewhat noisy, i.e. when measuring the distance to a fixed object while the sensor is stationary the repoted distance can vary by several inches for an object only a couple of feet away. I tried adding the capacitor/resistor circuit recommended by Maxbotix in their FAQs but it didn't seem to make a meaningful difference. So, I decided to see what the serial output would look like. The Maxbotix spec sheet's description of serial output is a bit cryptic on first reading, at least it was to me. After some searching around the internet regarding RS232 standards, etc. I finally understood that the serial output of the MaxSonar was an inverted serial datastream: in "RS232 speak" a 0 is represented by a postive voltage and a 1 by a negative voltage. Maxbotix's implemenation of the RS232 standard is a little non standard in that a 0 is represented by Vcc and a one is represented by Vss. So the obvious thing was that I needed to invert the serial output of the MaxSonar. A little more research brought me to the Texas Instruments CD4049UB CMOS Hex Inverting Buffer. Simply put: a 1 bit on an input pin is a 0 bit on the "companion" output pin and vice versa. The CD4049UB actually provides six pairs of input output pins - for a $1.49 I figured I have nothing to loose, other than $1.49. Given that the digital ports on the Netduino are 5 volt tolerant I wired the MaxSonar Vcc and the CD4049UB Vcc to the Netduino 5v output. I wired the MaxSonar Tx pin to input pin 14 of the CD4049UB and ran a wire from its companion output pin 15 to the Netduino Com 2 serial input. The Netduino Com 2 serial output I ran to a USB port on my PC using a FTDI adapter. The serial communications are run under the SerialPortHelper class originally posted by Hari. After a lot of rechecking of my wiring, things are getting very crowded on the breadboard my little robot is being built on, I powered up and ran the whole thing in debugging mode. I was very pleasantly surprised that on the first try the screen on my FUNterm terminal program was steadly refreshing with "R" followed by a distance reading in inches just like the MaxSonar spec sheet said it would. It would seem that the serial output is almost completely noise free. I kept both the MaxSonar and a target stationary and except for a moment or two when I bumped the table and the cat decided to investigate things, the reading was constant. Attached is a piece a screen shot showing the ouput of the MaxSonar when measuring a target 12 inches away. Unfortunately after several seconds of letting the MaxSonar run I got a buffer overflow exception, not really unexpected. Next step is to spend time with the rewrite of the SerialPortHelper class suggested by Corey Kosak. Also, there are another five pairs of inverter inputs/outputs available on the CD4049UB - multiple MaxSonars!?

Attached Files



#2 Kushal Mukherjee

Kushal Mukherjee

    New Member

  • Members
  • Pip
  • 1 posts

Posted 20 January 2012 - 03:24 PM

Thanks Paul for the writeup. I will try to implement the serial output via the MaxSonar sensor and post my successes and challenges. Thanks Again

#3 chevi99

chevi99

    Member

  • Members
  • PipPip
  • 19 posts

Posted 22 June 2014 - 09:55 PM

hi I'm having troubles with my mb 1260 i purchase from maxbotix. i basically want to build an obstacle detector. but can't seem to get a library for this sensor to work for me. Pls i need help tnx

chevi99



#4 chevi99

chevi99

    Member

  • Members
  • PipPip
  • 19 posts

Posted 22 June 2014 - 09:55 PM

Continuing with my Robotics project it became time to integrate a Maxbotix LV-MaxSonar sensor for purposes of collision avoidance. I started working with the MaxSonar last month as one of my first Netduino projects. At that time I used the "DistanceClass" originally posted by Crispin. This class uses the analog output of the MaxSonar and once I got it running, with a little extra help from Crispin who reponded to my post regarding a perlplexing analog problem, I discovered what a great many other people have discovered: the analog output is very easy to use but it tends to be somewhat noisy, i.e. when measuring the distance to a fixed object while the sensor is stationary the repoted distance can vary by several inches for an object only a couple of feet away. I tried adding the capacitor/resistor circuit recommended by Maxbotix in their FAQs but it didn't seem to make a meaningful difference. So, I decided to see what the serial output would look like. The Maxbotix spec sheet's description of serial output is a bit cryptic on first reading, at least it was to me. After some searching around the internet regarding RS232 standards, etc. I finally understood that the serial output of the MaxSonar was an inverted serial datastream: in "RS232 speak" a 0 is represented by a postive voltage and a 1 by a negative voltage. Maxbotix's implemenation of the RS232 standard is a little non standard in that a 0 is represented by Vcc and a one is represented by Vss. So the obvious thing was that I needed to invert the serial output of the MaxSonar. A little more research brought me to the Texas Instruments CD4049UB CMOS Hex Inverting Buffer. Simply put: a 1 bit on an input pin is a 0 bit on the "companion" output pin and vice versa. The CD4049UB actually provides six pairs of input output pins - for a $1.49 I figured I have nothing to loose, other than $1.49. Given that the digital ports on the Netduino are 5 volt tolerant I wired the MaxSonar Vcc and the CD4049UB Vcc to the Netduino 5v output. I wired the MaxSonar Tx pin to input pin 14 of the CD4049UB and ran a wire from its companion output pin 15 to the Netduino Com 2 serial input. The Netduino Com 2 serial output I ran to a USB port on my PC using a FTDI adapter. The serial communications are run under the SerialPortHelper class originally posted by Hari. After a lot of rechecking of my wiring, things are getting very crowded on the breadboard my little robot is being built on, I powered up and ran the whole thing in debugging mode. I was very pleasantly surprised that on the first try the screen on my FUNterm terminal program was steadly refreshing with "R" followed by a distance reading in inches just like the MaxSonar spec sheet said it would. It would seem that the serial output is almost completely noise free. I kept both the MaxSonar and a target stationary and except for a moment or two when I bumped the table and the cat decided to investigate things, the reading was constant. Attached is a piece a screen shot showing the ouput of the MaxSonar when measuring a target 12 inches away. Unfortunately after several seconds of letting the MaxSonar run I got a buffer overflow exception, not really unexpected. Next step is to spend time with the rewrite of the SerialPortHelper class suggested by Corey Kosak. Also, there are another five pairs of inverter inputs/outputs available on the CD4049UB - multiple MaxSonars!?

hi I'm having troubles with my mb 1260 i purchase from maxbotix. i basically want to build an obstacle detector. but can't seem to get a library for this sensor to work for me. Pls i need help tnx

chevi99






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.