Shop OBEX P1 Docs P2 Docs Learn Events
Using the SoundPAL with a Propeller chip — Parallax Forums

Using the SoundPAL with a Propeller chip

MacoreMacore Posts: 41
edited 2009-12-12 03:12 in Accessories
Is it possible to use the SoundPAL with a Propeller chip? Will the SoundPAL run at 3.3V?
How can I do Serial I/O to the control pin without raising the output pin high?
For use with the Basic Stamp it says use SEROUT in an Open Collector mode.... What is this and how do I do that with
the propeller?

Thanks,
David

Sorry if this should go to the Propeller chip forum, I couldn't decide which was more appropriate so I put it here...

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

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-12-11 02:54
    Is it possible to use the SoundPAL with a Propeller chip?

    Yes!

    Will the SoundPAL run at 3.3V?

    Yes, but it will be louder at 5V, and it's okay to power it from 5V when used with the Prop.

    How can I do Serial I/O to the control pin without raising the output pin high? For use with the Basic Stamp it says use SEROUT in an Open Collector mode.... What is this and how do I do that with the propeller?

    The SoudPAL has a built-in pullup that pulls the input high when it's not being driven low. You emulate open collector mode by keying DIRA with your data, rather than OUTA.
    ________________

    Attached is a SoundPAL demo program for the Prop, along with an object that you can use in your own programming.

    -Phil
  • MacoreMacore Posts: 41
    edited 2009-12-11 23:19
    Cool beans!

    Thanks Phil, I was wracking my brains on that open collector thing, glad the answer is so simple!

    -David

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Often the joy is not so much in the having, its in the building...
  • MacoreMacore Posts: 41
    edited 2009-12-12 00:41
    OK, I looked at the .spin object attached to the post and have a couple questions:

    1) If using the SoundPAL with 5volt supply and the propeller chip should I not have a series resistor between the control pins?

    Code extracted from your object:
    PUB sendbyte(txbyte) | time
    txbyte := (txbyte | $300) << 2 'Set up character with start and stop bits.
    time := cnt 'Set initial time.
    repeat 11 'Send 11 bits total.
    waitcnt(time += BaudClock) 'Wait for next bit time.
    dira[noparse][[/noparse]IOPin] := ((txbyte >>= 1) & 1 == 0)'Send next bit via dira.

    2) I see that the sendbyte routine takes the byte to be sent adds 2 bits and rotates it as below:
    bbbbbbbb => 11bbbbbbbb00 for a total of 12 bits being changed by the code.
    Yet with a repeat 11 as used above only the first 11 bits will be sent and the last bit will be left rotated into the LSB but not sent from txbyte? Am I reading this code right? Why is this?
    Also, what purpose do the 2 zero bits placed on the front of txbyte serve?
    Finally, are you complimenting the bit sent because of using DIRA and not OUTA? (and just curious why == instead of NOT or !)?
    I noticed from looking at a basic "serial" object for the propeller that its sendbyte routine is the same except it uses only $100 on the byte set-up and a repeat loop of 10. It does not compliment the bit sent to OUTA either. I see the similarity but seems there is the same problem with the LSB not being sent.

    Serial communication protocol is not one of my strong suits, so I appreciate any answers you can give to help me understand whats going on here better...

    Thanks very much,
    -David

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Often the joy is not so much in the having, its in the building...
  • MacoreMacore Posts: 41
    edited 2009-12-12 01:10
    Hmm, I see that >>= is not a pre or post operator... Its just pre. So in the code above my question is invalid.
    Actually it is the LSB that is "thrown away" by the first >>= as it goes through the repeat 11 and in fact the last bit added onto txbyte with the | $300 is sent. So the two bits placed in front of txbyte, one is thrown away and the other is the "start" bit? Why is this bit not a 1?

    Now doubly uncertain about the == 0 though. According to the manual I would get 0 == 0 is true and 1 == 0 is false, false is 0 and true is -1... In other languages true is just non-zero usually a 1. Is the -1 in spin truly -1? wouldn't that be $ff then sent to DIRA?

    Thanks for your answers, I am new to spin and trying to adjust my 30+ years of C and Assembler to its nuances.
    -David

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Often the joy is not so much in the having, its in the building...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-12-12 02:55
    1) If using the SoundPAL with 5volt supply and the propeller chip should I not have a series resistor between the control pins?

    No series resistor is necessary. The SoundPAL will never drive its I/O pin high, and its pullup is too wimpy to cause any trouble.

    2) Is the -1 in spin truly -1? wouldn't that be $ff then sent to DIRA?

    Yes, true really is -1 == $ffff_ffff. However, since dira in that assignment is subscripted, only the pin indicated by the subscript is affected.

    -Phil
  • MacoreMacore Posts: 41
    edited 2009-12-12 03:06
    OK, I think I get this... The SoundPAL is pulling its control pin high... as does the Send Pin on a normal serial bus. So the "start" bit has to be a zero (low) so the device knows to start listening for the data bits. You are using == to compliment the output bit because for a output bit of zero you need to pull the control pin low by setting the DIRA for that pin to be an ouput, when it is an input the pin is pulled high by the SoundPAL. It doesn't really matter what value is used $ff or 1 or whatever, as long as its not zero the DIRA port bit will be set to high. I also see that using a ! operator (while it would have worked) is not a good choice to change boolean logic in spin cause it is a bitwise operator only.

    So I think that answers all my questions, LOL... Only one final thing: I notice the "simple" serial object used to talk to the Parallax LCD display used ony one stop bit where you used two for the SoundPAL. The data sheet for the SoundPAL only mentioned it was 8 data bits and no parity... So, how did you know to use two? I see a lot of sensors use a serial protocol to talk with is one bit more typical with these devices than two? How can one tell which it is if the data sheet does not specify?

    Thanks again for your time, please correct me accordingly if I have incorrectly stated anything in the posts above as I have struggled to work this out in my head.
    -David

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Often the joy is not so much in the having, its in the building...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-12-12 03:12
    I like to use two stop bits in case the receiving micro needs extra time to to buffer the data it's just received and/or to synchronize to the next start bit.

    -Phil
Sign In or Register to comment.