SIN pin 16
willthiswork89
Posts: 359
ive been reading the syntax help guide and the code
sData·· VAR···· Byte
Main:
· SERIN 16, 16780, [noparse][[/noparse]WAIT("XYZ"), DEC sData]
· END
doesnt work, actually none of it works when i use the DEC modifier the only time ive gotten it to continue what when i did
sData VAR Byte
Main:
SERIN 16,16780,[noparse][[/noparse]sData]
END
why doesnt it work when i use the dec formatter? im using a homework board for tests because it doesnt matter if i ruin it.
sData·· VAR···· Byte
Main:
· SERIN 16, 16780, [noparse][[/noparse]WAIT("XYZ"), DEC sData]
· END
doesnt work, actually none of it works when i use the DEC modifier the only time ive gotten it to continue what when i did
sData VAR Byte
Main:
SERIN 16,16780,[noparse][[/noparse]sData]
END
why doesnt it work when i use the dec formatter? im using a homework board for tests because it doesnt matter if i ruin it.
Comments
I doubt the DEC formatter has anything to do with it. As I remember, SIN (pin port 16) uses a fixed baud rate of 9600.
Thus, if you are actually sending at 2400 baud, the Stamp will essentially be receiving garbage, and the WAIT("XYZ") will NEVER make a match. Therefore, your example one will NOT work, and example two WILL work, but it will be receiving garbage. The proof of what I suspect is to add the following line to the second example program:
DEBUG sData
Was garbage printed?
The solution is to transmit and receive at 9600 baud, if you are going to use the SIN pin (pin port 16).
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
SEROUT 1\0, 24660, 1000, 2000, No_Permission, [noparse][[/noparse]"SLOWLY!"]
Editor error is "Expected a label?"
the thing for serout says
SEROUT TPIN{\FPIN},Baud Mode,{Pace,}{Timeout, TLabel,}[noparse][[/noparse]Output Data]
SEROUT 1\0, 24660, 1000, 2000,No_Permission,[noparse][[/noparse]"SLOWLY"]
its highlighting the 2000 for some reason....
I guess you skimmed over this caveat in the PBASIC Help File when you were reading it:
"Pace is an optional variable/constant/expression (0 - 65535) that determines the length of the pause between transmitted bytes. NOTE: Pace cannot be used simultaneously with Timeout."
Pacing makes no sense when flow control is being used. One or the other, but not both.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
PBASIC has no string comparison facility, thus you must check it one character at a time. If this is a "system" of your own design, limit the "commands" to a single character, and you'll have no problems.
OTOH. if you are only seeking certain POSITIONAL parameters within a fixed character string, check out the SKIP formatter. If this is the case and you need an example, just ask.
Your technical service support bill is really mounting up this month
Regards,
Bruce Bates
just kidding
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
IF(serStr(0) = "L" AND serStr(1) = "E" AND serStr(2) = "D") THEN
DEBUG CR,"GREEN or RED: "
SERIN 16,16468,Bad_Data, [noparse][[/noparse]WAIT("!"),STR serStr\9\"!"]
IF(serStr(0) = "R" AND serStr(1) = "E" AND serStr(2) = "D") THEN
LEDm = 1
LEDp = 0
ELSEIF(serStr(0) = "G" AND serStr(1) = "R" AND serStr(2) = "E")THEN
LEDm = 0
LEDp = 1
ENDIF
ENDIF
IF(serStr(0) = "P" AND serStr(1) = "I" AND serStr(2) = "E") THEN
FREQOUT Piezo,2000,3000
ENDIF
RETURN
thats what i came up with, any revisions you guys can think of would be appreciated, its not for any project thats big im just trying to understand whats going on here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
You may need to have your glasses prescription checked, as you're OBVIOUSLY NOT READING THE REPLIES WE ARE LEAVING FOR YOU! This is CERTAINLY a "system of your own design" so I leave you with this, which I already said:
"If this is a "system" of your own design, limit the "commands" to a single character, and you'll have no problems."
Sorry, Kevin, but I've run out of patience. I'm sure others will be happy to help you. In the nearly 10 years I've helped folks on this Stamp List, this is the FIRST TIME I've thrown in the towel. Perhaps that will give you something to think about.
Regards,
Bruce Bates
Post Edited (Bruce Bates) : 8/10/2006 4:46:20 PM GMT
Take a look at the SELECT ... CASE instruction.
SELECT Operator
CASE "F" ' Check for forward
GOTO FWD_Rtn
CASE "R" ' Check for reverse
GOTO REV_Rtn
etc
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Please correct this thinking if wrong:
1. an Rx pin is always in a mode to receive, or it can be instructed to go into a mode to receive
2. the Rx pin must be programmed to receive either 1 byte or a fixed number of bytes at a time, or any number of bytes that may include some method to terminate the process.
3. if a string is to be received, it has to have an array specified as in VAR serSTR[noparse][[/noparse]20] BYTE , which allocates 20 bytes to the temp storage of the string, how it is stored I don't know, top to bot, bottom to top? If you receive a string, but ONLY want to look at one particular byte, you say serStr(0) if you want to deal with the first byte received in the string? serSTR(1) for the second byte stored in the array?
4. if a string is rec'd again, it replaces the previous string, your older data is gone forever, unless you write it to a new location in ram, or eeprom for future?
5. a byte can be represented either as a letter or number as below, or as binary $0000011? or hex $0F etc
6. the method to receive the byte is a high>low transistion follwing some space of time called a start bit?
7. what if a string is not the full arrays size then what? it just stored in the first X slots?
Check_Packet:
IF(serStr(0) = "L" AND serStr(1) = "E" AND serStr(2) = "D") THEN
DEBUG CR,"GREEN or RED: "
SERIN 16,16468,Bad_Data, [noparse][[/noparse]WAIT("!"),STR serStr\9\"!"]
IF(serStr(0) = "R" AND serStr(1) = "E" AND serStr(2) = "D") THEN
LEDm = 1
LEDp = 0
ELSEIF(serStr(0) = "G" AND serStr(1) = "R" AND serStr(2) = "E")THEN
LEDm = 0
LEDp = 1
ENDIF
ENDIF
IF(serStr(0) = "P" AND serStr(1) = "I" AND serStr(2) = "E") THEN
FREQOUT Piezo,2000,3000
ENDIF
RETURN
' {$PBASIC 2.5}
serStr VAR Byte(10) ' Make a 10-byte array
LEDm PIN 15
LEDp PIN 14
Piezo PIN 0
OUTPUT LEDm
OUTPUT LEDp
DO
DEBUG CLS
serStr(9) = 0 ' Put 0 in last byte
SERIN 16, 16468,Bad_Data, [noparse][[/noparse]WAIT("!"),STR serStr\9\"!"]
GOSUB Check_Packet
LOOP
Bad_Data:
DEBUG CR, "Bad data Received! Timing out!"
STOP
Check_Packet:
IF(serStr(0) = "L" AND serStr(1) = "E" AND serStr(2) = "D") THEN
DEBUG CR,"GREEN or RED: "
SERIN 16,16468,Bad_Data, [noparse][[/noparse]WAIT("!"),STR serStr\9\"!"]
IF(serStr(0) = "R" AND serStr(1) = "E" AND serStr(2) = "D") THEN
LEDm = 1
LEDp = 0
ELSEIF(serStr(0) = "G" AND serStr(1) = "R" AND serStr(2) = "E")THEN
LEDm = 0
LEDp = 1
ENDIF
ENDIF
IF(serStr(0) = "P" AND serStr(1) = "I" AND serStr(2) = "E") THEN
FREQOUT Piezo,2000,3000
ENDIF
RETURN
basically my SERIN wait for a ! then it listens for what ever up to 9 letters each one is stored in the array, either it comes to nine or another ! and it will stop so
!LED!
will make it continue on with the program storing LED in the array serStr
then it goes and checks the data in the packet sent and decides what its telling the stamp to do.