go away spammer

Author Topic: Problems using LV-MaxSonar serial with Axon  (Read 3213 times)

0 Members and 1 Guest are viewing this topic.

Offline pafTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Problems using LV-MaxSonar serial with Axon
« on: November 11, 2009, 09:10:07 AM »
Can someone provide help with this problem?

I'm using a LV-MaxSonar-EZ3 connected to an Axon.  I have no problems using the analog output of the sonar, but wish to use the serial to obtain greater accuracy.  According to the datasheet from Maxbotix, the sonar sends a 'R' followed by the measurement in inches and then by the carriage return (ASCII 13).  When I connect the serial output of the sonar to the Axon, I do not get an 'R' or a CR.  Using this code:

int snr = 0;
while(1)
{
 snr=uart0GetByte();
 if (snr != -1)
 {
 rprintf("%d\r",snr);
};

I get:
43
103
102
100
121
(which is repeated)

I would expect to get an 82 (ASCII value of R) as the first value and a 13 (ASCII value of CR) as the last value.

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Problems using LV-MaxSonar serial with Axon
« Reply #1 on: November 11, 2009, 10:00:08 AM »
The datasheet for the sonar module shows that it's UART tx output is inverted in order to provide a logic level approximation to RS232. The UART on the Axon isn't expecting this and thus won't decode the data properly. Try to add an inverter between the two to rectify the situation.

It may be possible to fix this in code on the Axon but it is likely to be awkward since there may be data mangling issues due to missing (inverted) start/stop bits.

Offline pafTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: Problems using LV-MaxSonar serial with Axon
« Reply #2 on: November 11, 2009, 10:27:36 AM »
Thanks for the advice.  However, I'm new to all of this.  Could you point me to some resources on how to add an inverter?

Thanks!

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Problems using LV-MaxSonar serial with Axon
« Reply #3 on: November 11, 2009, 03:32:22 PM »
An inverter IC. Look it up, it'll take seconds to wire, really.

Also, you defined snr as an int but you're expecting a char value. :P

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Problems using LV-MaxSonar serial with Axon
« Reply #4 on: November 11, 2009, 05:42:03 PM »
The Wikipedia Inverter page >HERE< is quite good. As a suggestion for an IC have a look at (google) a datasheet for the 74HC04.

You should have no problems as there are only four connections to make - Input, output, power and ground. Input will be the Tx output from your sensor, output will go to your Axon Rx pin, power and ground will be those used on the Axon.

 


Get Your Ad Here

data_list