Fez Panda II with Maxbotix' Maxsonar

Hello,

I have been searching for an answer without much luck. I have a Fez Panda II, and a XL-MaxSonar-AE4.

Here is the datasheet for the maxsonar: http://www.maxbotix.com/documents/MB1240-MB1340_Datasheet.pdf

As the documentation describes, I connected the pin 4 (RX) to the COM2 Output, Pin 5 (TX) to the COM2 Input, the V+ to 5V output, and the GND to ground.

I have the code in the main:


UART = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
UART.Open();
UART.DataReceived += new SerialDataReceivedEventHandler( ReceiveSerial );

And the interrupt for reading:


        public static void ReceiveSerial(Object sender,	SerialDataReceivedEventArgs e){
            int size = UART.BytesToRead;
            byte[] bytes = new byte[size + 4]; //4 extra to be safe

            int read = UART.Read(bytes, 0, bytes.Length);

            for (int i = 0; i < read; i++ )
            {
                Debug.Print(bytes[i].ToString());
            }
        }

The Maxbotix documentation says: “The output is an ASCII capital R, followed by three ASCII character digits representing the range in centimeters up to a maximum of 765, followed by a carriage return (ASCII 13).”

The ASCII value of “R” is “82”. But the console outputs:


...
76
0
76
0
76
0
76
0
76
...

And the “82”, nor the “13” is nowhere to be seen.

Am I doing something wrong? Thanks.

is a problem. you’re reading past the end of the buffer. also, the datasheet says you have to set pin1 high to read serial. Are you?

For what it’s worth - I’ve got a Maxbotic connected to my Domino with the analog connection with decent success.

There’s user submitted code to use this in the TinyCLR code site:

Just another option, it may not work for your needs.

Randomhall: From my understanding, SerialPort.Read would just fill the necessary bytes, and return the number of bytes it has written to the buffer. My fear is if new bytes have arrived since reading the number of bytes available. In any case, I have removed the “safety” bytes, and the problem persists.

Also, the datasheet says: “When Pin 1 is open or held high, the Pin 5 output delivers asynchronous serial”, and it looks like in either open, or held high, it still seems not to work.

mhectorgato: Yeah, the sensor does work with just using analog connection; I just figured it would be less interference by using serial.

Thank you both for your time.

76 in hex is the letter “L”. Does that have any relevance to the sensor? Sounds like a setup issue to me.

I maybe wrong, but I think the serial output signal of the Maxbotix sensor is inverted. You will need an inverter stage between Maxbotix and Panda.
The datasheet says RS232 format with TTL level. You can connect the Maxbotix directly to an RS232 transceiver. Without RS232 transceiver an inverter is needed.

[quote]Pin 5 - (TX) When Pin 1 is open or held high, the Pin 5 output delivers
asynchronous serial with an RS232 format, except voltages are 0-Vcc.
The output is an ASCII capital R, followed by three ASCII character
digits representing the range in centimeters up to a maximum of 765,
followed by a carriage return (ASCII 13). The baud rate is 9600, 8 bits,
no parity, with one stop bit. Although the voltage of 0-Vcc is outside the
RS232 standard, most RS232 devices have sufficient margin to read 0-
Vcc serial data. If standard voltage level RS232 is desired, invert, and
connect an RS232 converter such as a MAX232.[/quote]

Hm. Interesting.

RobotFreak, how would I go about implementing the inverter with the Panda?

Thanks.

A NPN transistor and 2 resistors should do the job. See the attached schematic