Atmega328p - Serial communication, not able to transmit

We are using Baby Orangutan B-328 and trying to connect it with PC using serial cable (RS-232). We have used pins pd0 and pd1.

We are able to receive commands from PC to 3PI but 3PI is not able to send data/commands to PC. We do get some random data sometimes when we send more than 2 bytes using pololu serial transmitter.

#include <pololu/orangutan.h>  


int main()
{
	serial_set_baud_rate(19200);
	serial_set_mode(SERIAL_CHECK);
while (1) {
    char message[4] = {0xC1, 0xC2, 0xC5, 0xC7};
	serial_send_blocking(message,4);
	serial_check();
	}
}

We have verified that PC is able to send commands to 3PI using a modified version of serial slave (3PI starts and stops movement on PC commands).

Hello,

Are you using some kind of circuit to convert between RS-232 voltages and the TTL levels on the 3pi? How exactly is everything connected?

-Paul

Paul, thanks for quick reply.

Good guess, we are not using any circuit in between.

Initially we tried to interface using Xbee wireless module in which we were able to send data from PC to 3PI but not vise versa. We keep trying by making adjustments in program and finally connect RS-232 directly as an troubleshooting step. We got same results in both cases.

Can you please point me to a reference for in between circuit? Is that also required for Xbee?

Hello.

You’re really asking for destroying your electronics when you don’t pay attention to voltage levels. You should do a search for something like “RS-232 adapter circuit” to learn more.

How are you programming your Orangutan and 3pi? If you’re using our programmer, there’s a USB-to-serial adapter built in, so you can use that. It’s already at 5V TTL levels, so you don’t need any other adapter, and the PC side will still look like a COM port.

For the Xbee, you should look at the specifications for its I/O lines. They’re probably not RS-232 levels. If they are running at 3.3V, you might need some adapter to 5V signals, too, but a lot of things that run on 3.3V are 5V tolerant. So, you have to check for your particular devices.

- Jan

Thanks Jan, I will try working with Pololu USB programmer. I hope, my babay Orangutan is not already dead or faulty. Any way of testing it?

You can test it by seeing if the I/O lines work.

- Jan

Thank you.

Instead of connecting to RS-232 of Xbee adapter I connected I/O pins directly to Xbee IC and it works perfectly.