Serial communication between Baby Orangutan and Arduino Pro

Dear all,

I need to establish a serial communication between a Baby Orangutan and a Arduino Pro mini. For each microcontroller I use its own libraries! My first goal is to connect the arduino RXD and TXD pins to orangutan TXD and RXD pins respectively and transmit a single byte!

So far nothing. I am new to both microcontroller devices so any help in this matter would be greatly appreciated.

For the arduino I use the following code:

void setup() {
  // initialize both serial ports:
  Serial.begin(9600);

}

void loop() {
    int inByte = 79;
    Serial.print(inByte, DEC); 
  
}

For the orangutan I try te read the data as follows:

#include <pololu/orangutan.h>

// A global ring buffer for data coming in.  
char buffer[100];

// A pointer to where we are reading from.
unsigned char read_index = 0;

char read_next_byte()
{
	char ret=0;
	while(serial_get_received_bytes()!=read_index)
	{
		ret = buffer[read_index];
		read_index ++;
		if(read_index >= 100)
			read_index = 0;
	}
	return ret;
}


/////////////////////////////////////////////////////////////////////

int main()
{	
	DDRC = 0x01;
	// start receiving data at 9.6 kbaud
	serial_set_baud_rate(9600);
	serial_receive_ring(buffer, 100);
	PORTC|=_BV(0);

	while (1)
	{
	// wait for a Data
		char Data = read_next_byte();
		//unsigned char Data= serial_get_received_bytes();

		if (Data == 79)
			PORTC&=~_BV(0);
	}
	return 0;
}

I have connected an indication LED to PC0 on the BabyO to verify the data transmition.

Please help,

Akis

You will need to connect the ground line of the Baby Orangutan to the ground line of the Arduino Pro. Have you done that?

-David

Hello.

I don’t think you’re transmitting what you think you’re transmitting. You should look into what the Arduino serial print methods do, but I believe using the “DEC” parameter results in transmitting the ASCII decimal representation of the number, which would transmit the bytes: { ‘7’, ‘9’ }. To transmit the byte 79, I think you need to use call:

Serial.print(inByte, BYTE);

Though I’m not that familiar with Arduino serial methods, so you might want to check the accuracy of what I’m saying!

- Ben

I had an accident with my power supply this morning and the Arduino downloader is off… So it might take a wile to verify your solution… In any case thank you in advance and I will keep you posted…

Akis

Hi again,

Unfortunately I couldn’t receive any byte even when I used the “Serial.print(inByte, BYTE);” command. The grounds are connected ok…

Any other ideas?

Akis

In a previous post, you said you have the USB AVR Programmer. I recommend changing the baud rate to 1000 and using the SLO-scope on the programmer to watch the signal on the Arduino’s TX line. This will let you determine if the problem is on the Arduino side or the Orangutan side. You will need to connect the programmer’s “A” line to the Arduino’s TX line, and connect the programmer’s ground to your system as well (the 6-pin ISP cable works).

I also recommend adding a delay in the Arduino’s loop because if you turn the Orangutan on after the Arduino, and the Arduino is in the middle of sending a byte and it never stops sending bytes, this could be the problem.

-David

Hello,

I have the Orangutan USB programmer PGM02A/B and not the USB AVR programmer PGM03A. This means that my programmer does not have the “A” and “B” lines…

Any ideas?

Akis

Hello again,

It finally worked with the “Serial.print(inByte, BYTE);” command :). I have to admit that it was my mistake mainly (I was transmitting from the wrong pins in Arduino…).

Thank you very much from all your help!

Akis