View Full Version : cAsE sEnSiTiVe ?
04-16-2007, 12:00 PM
serout 0,6,["!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,[8,6,9,6],m1:lookup y,[2,4,3,4],m2
serout 0,6,["!PWMM1",2400/(m1*m2),0,2400/(m1*m2),0] ' play note
pause 300:next: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 ?
04-16-2007, 12:09 PM
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.
04-16-2007, 12:21 PM
>but the documentation says nothing about lower case and
>all the command descriptions and examples are upper case.
Just like in the 'PBASIC' manual .....
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 ?
04-16-2007, 12:33 PM
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.
04-16-2007, 12:54 PM
So a "d" is the same as a "D" in PBasic .....
But differant as "data" ?
Like in ASC or something ?
04-16-2007, 01:05 PM
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,[dec x, " ", dec y, 13]
SEROUT 16,84,[dec X, " ", dec Y, 13]
serout 16,84,[DEC x, " ", DEC y, 13]
The following are different:
serout 16,84,["This is a test",13]
serout 16,84,["this is a test",13]
serout 16,84,["THIS IS A TEST",13]
04-16-2007, 01:15 PM
cLeAr aS mUd :)
04-16-2007, 10:10 PM
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.
04-16-2007, 10:55 PM
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)) ...... :)
04-16-2007, 11:02 PM
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.
04-16-2007, 11:18 PM
>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?
04-16-2007, 11:28 PM
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.
04-16-2007, 11:53 PM
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)?
04-17-2007, 12:12 AM
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.
Parallax Tech Support
04-17-2007, 12:25 AM
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.
04-17-2007, 09:34 AM
This (in a way) transcends that.
Only 1 oscillator.
Not neccesarily a squarewave.
Free of the annoying 'refresh pops' of FREQOUT
Way higher frequency than "10 Hz"
Like you say:
Hard to calculate frequency.