Problem with BAP and Parallax SoundPAL

My 1st post on this excellent forum :slight_smile: So the short and sweet question is has anyone successfully interfaced the Parallax SoundPal to the Basic Atom Pro (BAP)?

I have a BAP on a breadboard configured pretty much the same way as the Bot Board II (BB2). I have a 5v power supply and a direct serial interface with COM1 on my PC. 1st I loaded the Traffic Light test program from the BAP Syntax Manual using 3 coloured (yes I’m English) LED. The LEDs are on P0, P1 and P2. This worked fine, so I believe the BAP and serial interface are working OK.

I then successfully interfaced my Parallax Ping to P4 and loaded the sample program by Jim Frye from this Forum. As I have few options for displaying any output results I have used my 3 LED to display a binary value indicating the value of WDIST as it goes around the loop.

This removed the need to run in Debug Mode and use DEBUG statements, which didn’t seem to work for me, it kept timeing out.

BTW I have 30 years experience with software (From firmware on Intel 8086 to C# on a PC), but only a year with a CH3-R. Hector works fine, but he needs some eyes so I can make him automonous and some sound effects. I also have some electronics experience as a hobby when I was a teanager. When I didn’t have internet access!

I am now trying to interface a Parallax SoundPAL to my BAP breadboard. The Parallax site isn’t much help because they have a vested interest in their Basic Stamp processor and it seems a little mean to post questions about making it work with a BAP. I have translated the Parallax SoundPAL Basic Stamp sample code to Basic Atom. BUT it does not work, not a squeak.

baud      CON  NO9600		' Normal, Open Collector, 9600 baud
reset     CON  NO1200		' Normal, Open Collector, 1200 baud

Pause 10
Gosub DoReset

' The "=" loads the following zero terminated sequence into its RAM
' and the "!" executes the loaded sequence.
' The C_1 etc are constants (not shown) defining various notes (pitch) or the duration (e.g. half).
SEROUT P3, baud, "=", C_1, D_1, E_1, F_1, G_1, A_1, B_1, half+C_2, 0, "!"]

End

DORESET:
    REPEAT UNTIL P3   ' Wait until SoundPAL has powered up
    SEROUT P3, reset,[0]   ' Funge to send a 7.5 ms low pulse
RETURN

I have not checked the [0] sent at 1200 baud (NO1200) results in a 7.5 ms low pulse, but how critical can the duration be?! 9 low bits at 1200 baud. How do they get 9 low bits with 8-bits data and no parity? I’m not sure, but it probably has something to do with those start/stop bits?!

I know it comes out of the DoReset loop using my LEDs to indicate progress. I don’t have an ocilloscope to check the output on P3. I was about to investigate if the quoted string “=” is zero terminated on the Basic Atom Pro, but not on the Basic Stamp. There is nothing in the manual that indicates that this is the case. The SoundPAL documentation is quite adament that the output to the SoundPAL should be open collector. The SEROUT should be positive logic, any baud between 9600 and 19200 (?), 8-bits and no parity. I’ve even tried IO9600 i.e. inverted logic, but that made no difference. It explains that the SEROUT is used in DoRest in place of PULSOUT because the PULSOUT leave the output pin in an output state, while the SEROUT is configured open collector and a ‘slow’ zero pulse is output.

Any thoughts/suggestions much appreciated,
JackRabbit

PS I got the BAP, Ping and SoundPAL via Active Robots in the UK.

Just a note, debug mode slows down everything enough that if you tried using it with the ping sensor it’s unlikely you could read back the signal after starting the pulse(eg the return would be faster than getting ot the next command).

Have you tried I instead of N? Also have oyu looked at the serial oine with a scope? Do you see anything? Is there a builtin pullup on the SoundPAL? If not I think you will have to add an external pullup. Open drain outputs only drive low. They float high which means without the pullup they never go high. It’s mainly for use when talking to multipl devices on the same serial bus. A 0 should produce a MARK(for the start bit) and 9 SPACEs(8 data bits and the stop bit). I would not recommend using that as a delaying method or accurate method of outputing a pulse though. There is no gauruntee our serout commands will have the same overhead as the BasicStamp. If you need an accurate pulse sent you should use the pulsout command instead.

Thanks for your observations.

Yes I tried IO9600 as well as NO9600.

The SoundPAL documentation says it has a weak internal pullup of 20K-50K.

The SoundPAL documentation also says the ‘reset pulse’ needs to be ‘2ms or more’. So I guess it isn’t very critical about the duration.

The SoundPAL documentation also has an explanation why SEROUT is used to send the reset pulse instead of PULSOUT - something to do with PULSOUT leaving the iopin in an output state! After you have sent a sound sequence to the SoundPAL you can poll to see when it is complete using a SERIN.

I’m afraid I don’t have an osciloscope, but one is starting to sound very useful :slight_smile: I might be able to borrow one and see what is going on. Watch this space.

You didn’t pick up on the quoted strings being terminated with a zero or not in the Basic Atom Pro. So I guess the question is - what does SEROUT iopin, NO9600, "="] actually send, just the “=” character? I have a ‘C’ background and quoted strings have a terminating zero?

Yes, the “=” in the serout would just send the equals character. No NULL would be appended.

I’m afraid in this case Prallax is counting on a certain amount of delay caused by there command that we can’t garuntee. However after a pulseout command is executed, the serin after it would set the pin to be an input again so I’m not really understaning why they did what they did.