Interface Arduino to SoundPAL or ColorPAL????

Does anybody know how to interface an Arduino board to a SoundPAL or ColorPAL by Parallax corp.?

The SoundPAL docs specify that the circuit is to be Open-Collector and discuss how to do that for a Basic Stamp. I have learned before when interfacing it to the Propeller that you basically write code to send your bits serially to a pin only you set the DIRA register instead of the OUTA register when your write your data. Does anybody know how to do this for an Arduino board?

I tried to write a piece of code to do it like the Propeller which I pasted in below. Should I be using another method or is there just a bug somewhere in my code??? (*Note: Yes, I know, I posted this to the Parallax Forum also…)

// First attempt at using SoundPAL with Arduino board

#define PAL_PIN 1
#define BAUD 9600

#define IS_DEVICE_READY 0x3F
#define DEVICE_IS_READY 0xFF
#define START_QUEUE 0x3D
#define END_OF_QUEUE 0x00
#define PLAY_QUEUE 0x21
#define PLAY_ROM_SEQ 0x01
#define REPEAT_CODES 0x02
#define END_REPEAT 0x03

int bitTime;

void setup()
{
bitTime = 1000000 / BAUD;
}

void loop()
{
byte noteBuffer[10];

noteBuffer[0] = START_QUEUE;
noteBuffer = PLAY_ROM_SEQ;
noteBuffer = 0xAF;
noteBuffer = END_OF_QUEUE;
PlayNotes(&noteBuffer[0]);
}

void PlayNotes(byte *aBuffer)
{
byte aNote;

byte n = 0;
do
{
aNote = aBuffer[n++];
txChar(aNote);
}
while (aNote != 0);
}

void txChar(byte aChar)
{
word newChar = (aChar | 0x0100) << 2;
int t = 1;

do
{
newChar = ~(newChar >> 1) & 0x01;
if (newChar > 0)
pinMode(PAL_PIN, OUTPUT);
else
pinMode(PAL_PIN, INPUT);
delayMicroseconds(bitTime);
}
while (t++ < 10);
}

Should I be using another method

As the SoundPAL unit communicates with normal asynchronous communications you would be better off using software serial.

http://www.arduino.cc/en/Tutorial/SoftwareSerial

Well I can't use the Standard Serial stuff because the SoundPAL is open-collector interface and I only have one wire to send on which can never be raised high when the pin is an output according to the specs. This is why I am changing the pin from input to output as this is the method of doing open-collector on the Propeller chip and perhaps others... I appreciate the reply though...

because the SoundPAL is open-collector interface

I looked for that but didn't see it. That should not be a problem as it is a 5V device simply connect it to an arduino pin. An requirement for an open collector input is only normally needed if the source or destination device operates at different voltages.

If you must have an open collector input to the device simply use two transistors one after the other, or use two of the buffers in something like a 74LS05, Remember to put a pull up after the first transistor or buffer but not the second.

I've also been struggling with this and I've had no luck with software serial even though it looks like it should be pretty straightforward. Has anyone gotten this working and can you share your approach?

Thanks,

P