One quick thought is that getting the correct serial baud-rate depends on knowing the correct clock frequency. The Baby O has a 20MHz external resonator available for it’s clock, but it may not come set up to use it (I forget). Check the fuses menu on the Baby O (just like checking it on the Orangutan before) and make sure that the “Divide clock by 8 internally” box is unchecked. Also, you should check the fuse (should be third from the bottom on the list) that reads:
“Ext. Crystal Osc.; Frequency 8.0- MHz; Start-up time PWRDWN/RESET: 16K CK/14 CK + 0 ms; [CKSEL=1111 SUT=01]”
Don’t forget to hit program to save the changes. It’s less likely that you could mess up your Baby O with bad fuse settings (i.e. by checking the wrong box) since it has an external clock it can work from. You would NOT want to check that fuse on your big Orangutan though!
If that doesn’t do it I would start debugging by taking both the IR and the radio out of the equation, and just hooking the Baby O directly up to the Orangutan (connect their grounds, and the Baby O’s PD1 to the Orangutan’s PD0). You can also try this slight change to the Orangutan code:
#define F_CPU 8000000//CPU clock
#define BAUD 2400//baud rate for UART
#define MYUBRR (F_CPU/16/BAUD-1)//baud rate variable for UART hardware
#include <avr/io.h>
#include <avr/interrupt.h>
#include "device.h"
#include "lcd.h"
unsigned char newBeaconState=0;
ISR(USART_RX_vect){//USART Byte reieved
newBeaconState=1;
}
void USART_Init(unsigned int ubrr){//Initialize USART hardware & settings for Serial Radio
UBRR0H=(unsigned char)(ubrr>>8);//set buad rate
UBRR0L=(unsigned char) ubrr;
UCSR0B=(1<<RXEN0);//enable reciever
UCSR0B|=(1<<RXCIE0);//enable recieve complete interrupt
UCSR0C=(3<<UCSZ00);//Set frame format for 8bit with 1 stop
}
int main(){
lcd_init(); // this function must be called before any other LCD command
USART_Init(MYUBRR);//Initialize serial USART
lcd_gotoxy(0,0);// go to the start of LCD line 1
lcd_string("Beacon");
sei();//enable global interrupts
while(1){
if(newBeaconState){
newBeaconState=0;
lcd_gotoxy(4, 1); // go to the start of LCD line 2
if(!(UDR0&(1<<PC0))){//north detected, do something
lcd_string("N"); // write a character
}else{
lcd_string("n"); // write a space
}
if(!(UDR0&(1<<PC1))){//east detected, do something
lcd_string("E"); // write a character
}else{
lcd_string("e"); // write a space
}
if(!(UDR0&(1<<PC2))){//south detected, do something
lcd_string("S"); // write a character
}else{
lcd_string("s"); // write a space
}
if(!(UDR0&(1<<PC3))){//west detected, do something
lcd_string("W"); // write a character
}else{
lcd_string("w"); // write a space
}
}
}
return 0;
}
All I’ve done here is replaced the blank spaces that usually get printed to the screen with lower-case characters, so insted of reading " E " the screen would read “nsEw”. With nothing else connected to the Baby O it’s a toss-up as to how the pins will be read, but the second line only gets written to when a serial byte is received by the Orangutan, so if you see any characters on the second line of the display, then you know the Baby O and the Orangutan are talking to each other successfully.
Once that works, you should wire the IR beacon up to PC0-PC3 on the Baby O, and once that works you can try bringing the radios back in.
Of course, let us know how it goes!
-Adam