Shop OBEX P1 Docs P2 Docs Learn Events
Using SoundPAL or ColorPAL with Arduino board — Parallax Forums

Using SoundPAL or ColorPAL with Arduino board

MacoreMacore Posts: 41
edited 2010-03-30 06:12 in General Discussion
Does anybody know how to interface an Arduino board to a SoundPAL or ColorPAL?

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 Arduino 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[noparse][[/noparse]10];

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

void PlayNotes(byte *aBuffer)
{
byte aNote;

byte n = 0;
do
{
aNote = aBuffer[noparse][[/noparse]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);
}

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Often the joy is not so much in the having, its in the building...

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-03-28 17:52
    Have you tried the simple_serial method? I think that's what it is called.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • MacoreMacore Posts: 41
    edited 2010-03-28 21:29
    I saw that while I was looking at Libs and stuff, I will look at it... Thanks!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Often the joy is not so much in the having, its in the building...
  • MacoreMacore Posts: 41
    edited 2010-03-30 05:57
    Well I can't use the 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...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Often the joy is not so much in the having, its in the building...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-30 06:12
    Take a look at this thread: http://forums.parallax.com/showthread.php?p=890024. There you will find a schematic that shows how to connect a 2-pin serial port with a non-open-drain output to the ColorPAL (and SoundPAL).

    -Phil
Sign In or Register to comment.