Shop OBEX P1 Docs P2 Docs Learn Events
cAsE sEnSiTiVe ? — Parallax Forums

cAsE sEnSiTiVe ?

hitswarehitsware Posts: 156
edited 2007-04-17 02:34 in BASIC Stamp
serout 0,6,[noparse][[/noparse]"!PWMSS",240] ' initialize outputs
y var nib:x var nib:fr var byte:m1 var byte:m2 var byte
play:for x=0 to 3:for y=0 to 3
lookup x,[noparse][[/noparse]8,6,9,6],m1:lookup y,[noparse][[/noparse]2,4,3,4],m2
serout 0,6,[noparse][[/noparse]"!PWMM1",2400/(m1*m2),0,2400/(m1*m2),0] ' play note
pause 300[noparse]:next:[/noparse]next:goto play
' listening off of pin 12 on a BS2 stacked with a PWMPAL
' if I reduce the !PWMSS to !pwmss it runs but without sound ?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-16 05:09
    That's interesting, but the documentation says nothing about lower case and all the command descriptions and examples are upper case.
    I'm sure the PWMPAL is ignoring commands that don't start with "!PWM" all in upper case.
  • hitswarehitsware Posts: 156
    edited 2007-04-16 05:21
    >but the documentation says nothing about lower case and
    >all the command descriptions and examples are upper case.

    Just like in the 'PBASIC' manual .....
    BUT !
    Most all of the commands (seems to me) are 'case insensitive'
    (I debugged the code above 1 command @ a time and the caps on the pwmss was what threw it)
    For some reason this seems an exception ?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-16 05:33
    The command strings that are sent to the PWMPAL are data, very different from the statements in PBasic.
    You are right about that part. PBasic is not case sensitive, but the content of strings is kept exactly as written.
  • hitswarehitsware Posts: 156
    edited 2007-04-16 05:54
    So a "d" is the same as a "D" in PBasic .....
    But differant as "data" ?
    Like in ASC or something ?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-16 06:05
    It's a little confusing with all the quotes, but, in PBasic, 'd' is the same as 'D' in keywords and variable names. Anything in double quotes is copied exactly as written into the interpretive code so the following are all the same:
    serout 16,84,[noparse][[/noparse]dec x, " ", dec y, 13]
    SEROUT 16,84,[noparse][[/noparse]dec X, " ", dec Y, 13]
    serout 16,84,[noparse][[/noparse]DEC x, " ", DEC y, 13]
    
    


    The following are different:
    serout 16,84,[noparse][[/noparse]"This is a test",13]
    serout 16,84,[noparse][[/noparse]"this is a test",13]
    serout 16,84,[noparse][[/noparse]"THIS IS A TEST",13]
    
    
  • hitswarehitsware Posts: 156
    edited 2007-04-16 06:15
    cLeAr aS mUd [noparse]:)[/noparse]
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-04-16 15:10
    What Mike is saying is:

    The "CODE" -- the PBasic code you use, like "SEROUT" -- is compiled and interpreted by the PBasic IDE. The PBasic IDE is not case sensitive.

    The "DATA" -- the stuff you send to the pwmpal by using the SEROUT statement -- well, it depends on the pwmpal software what it makes of that. And apparently the pwmpal software IS case sensitive.

    So, when you're trying to determine if case matters, you have to look at the platform -- the PBasic IDE, or the pwmpal -- that's trying to make sense of it.
  • hitswarehitsware Posts: 156
    edited 2007-04-16 15:55
    O.K. I think I got it. The data (stuff inside the quotes) is read by the PWMPAL but has no bearing on what the stamp is doing. That's why the program still runs (sans any error message) but the PWMPAL doesn't respond (at least in the expected fashion (since it is case sensitive)).
    BTW.... Do you know what chip is used on the PWMPAL ?
    Seems like (if one wanted) you could hook it directly to the pc serial port and run it without the stamp. Say from QBasic ? Not that I would (just out of curiousity (hopefully without killing the cat)) ...... [noparse]:)[/noparse]
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-16 16:02
    I haven't looked recently, but it's either a PIC or an SX. I wouldn't hook it directly to a PC serial port unless you would like to destroy it, but you could use a MAX232 or equivalent and a pair of inverters and it would work very nicely from QBasic.
  • hitswarehitsware Posts: 156
    edited 2007-04-16 16:18
    >it's either a PIC or an SX

    Then the way (that say) the SOUND command works on the BS1
    (program halts during 'duration')
    Is software rather than hardware dependent?
    I.E. could the same chip be used both on a Stamp and a PWMPAL?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-16 16:28
    All of the statements on the BS1 and BS2 are "software dependent". There's no special purpose hardware
    other than a timer. The PWMPAL is the same way. All of the serial I/O and the PWM stuff is done in software.
    I haven't looked at the PWMPAL lately, but it probably uses a PIC since that's what Parallax was using when
    the PWMPAL was first developed (as far as I remember). The BS1 and BS2 use a PIC and all of the subsequent
    models use the SX.
  • hitswarehitsware Posts: 156
    edited 2007-04-16 16:53
    So (again out of curiousity (the PWMPAL is pretty handy)), is there any way (in PBasic) to make 4 pins run as 4 separate squarewave oscillators (with separate frequencies) and have the program proceed (while the oscillators keep running)?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-04-16 17:12
    Hello,

    The PWMPAL uses the SX20 to generate the PWM output via software. All the functions, including the serial communication are done via software. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-16 17:25
    There is no way for a Stamp to make 4 pins run as 4 separate squarewave oscillators with separate frequencies and have the program proceed (with the oscillators running) with the possible exception of very low frequencies (maybe 10Hz or lower) and with very poor accuracy. I can't emphasize enough that the Stamp is a single threaded interpreter. It can only do one PBasic operation at a time. The only way a Stamp can control several servos and a sensor or two is due to the fact that the servos require a brief (0.5ms to 2.5ms) control pulse every 20ms or so and, with 3 servos at 2.5ms max. pulse width, that leaves perhaps 12ms to do something else briefly (like use a PING once) before needing to send another control pulse.
  • hitswarehitsware Posts: 156
    edited 2007-04-17 02:34
    http://forums.parallax.com/forums/default.aspx?f=6&m=182300

    This (in a way) transcends that.
    Only 1 oscillator.
    Not neccesarily a squarewave.
    BUT !
    Free of the annoying 'refresh pops' of FREQOUT
    AND !
    Way higher frequency than "10 Hz"
    BUT !
    Like you say:
    Hard to calculate frequency.
Sign In or Register to comment.