Danny,
In the other thread where you posted the serial output from the programmer a lot of the bytes you received look like they were received at a baud rate that is 2x too fast. For example, the binary pattern for the byte 0xF8 sent on asynchronous serial, including the start bit and the stop bit, is:
0xF8 = 000011111
^ ^
start stop bit
Patterns like that are suspicious because the bits seem to be in identical pairs.
I suggest decreasing your baud rate by half (from 9600 to 4800) and seeing if the data starts making sense. Also, make sure your programmer’s ground is connected to the LANC’s ground if you haven’t already.
If you can’t figure out how to debug the serial output between the Baby Orangutan and the LANC controller and you’re not sure what baud rate to use, your project is going to be very difficult.
Regarding implementing one-wire bidirectional asynchronous serial communication with the Baby Orangutan:
The processor (ATmega48/168/328p) on the Baby Orangutan has a hardware UART that can receive serial bytes on PD0/RX and send serial bytes on PD1/TX. The Pololu AVR Library has a section called OrangutanSerial that allows you to use the UART. If you connect the LANC’s ground to the Baby Orangutan’s ground and the LANC data to PD0, you should be able to receive bytes just fine using OrangutanSerial (assuming you know what baud rate the LANC controller is transmitting at). You should do some experiments just trying to receive bytes from the LANC controller and make sure that works.
The difficulty is that you need to be able to send bytes on PD0, which is not supported by the UART or OrangutanSerial. Therefore, when you need to send a byte to the LANC controller, instead of using OrangutanSerial functions you need to do something special. Here is an (untested) function I wrote that disables the UART receiver, which allows you to use OrangutanDigital to control PD0. Then it sends a byte on PD0 at approximately 9600 baud.
function serial_send_on_pd0(char data)
{
set_digital_input(IO_D0, PULL_UP_ENABLED);
UCSR0B &= ~(1<<RXEN0); // disable UART receiver
// Send the start bit
set_digital_output(IO_D0, LOW);
delay_us(104);
// Send the data bits, least-significant first.
for(unsigned char i=0; i < 8; i++)
{
// Send one data bit
if (data & 1) { set_digital_input(IO_D0, PULL_UP_ENABLED); }
else { set_digital_output(IO_D0, LOW); }
data >>= 1; // prepare to send the next data bit by shifting char's bits to the right
delay_us(104);
}
// Send the stop bit
set_digital_input(IO_D0, PULL_UP_ENABLED);
delay_us(104);
UCSR0B |= (1<<RXEN0); // enable UART receiver
}
Whenever you need to send a response to the LANC controller, you would call the function instead of the sending functions in OrangutanSerial.
-David