SN75176 CODE FOR receiver end Basic Stamp is there a better way to write this
sam_sam_sam
Posts: 2,286
Hi EveryOne
This routine seem to work ok·I can turn·ON an LED LIGHT base on the Card Names
I have been working on this all day
Can any one tell if there is an better way to write this routine
' {$STAMP BS2}
' {$PBASIC 2.5}
String···· VAR···· Byte·········· 'VAR space for data
scan:
PAUSE 500
DEBUG CLS, CLS
DO
LOW 1··························· '· low=listen For the SN75176 chip
SERIN 0, 16468, [noparse][[/noparse]string]········ '· SEROUT For the SN75176 chip
DEBUG string
LOOP UNTIL string· =· ("0")····· ' valid Names that are SENT which·end with ("0") [noparse][[/noparse]"Sam 0"] sending end Basic Stamp
IF string <> "s" AND "a" AND "m" THEN
GOTO Sound
ELSEIF string <> "M" AND "O" AND "m" THEN
GOTO Sound
ELSEIF string <> "D" AND "E" AND "b" AND "r" AND "a"· AND "C" THEN
GOTO Sound
ELSEIF string <> "S" AND "a" AND "m" AND "C" AND "a" AND "r" THEN
GOTO Sound
ELSEIF string <> "D" AND "a" AND "v" AND "i" AND "d" AND "C" THEN
GOTO Sound
ELSEIF string <> "K" AND "e" AND "n" AND "C" AND "a" AND "r" THEN
GOTO Sound
ELSEIF string <> "D" AND "E" AND "b" AND "r" AND "a"· AND "N" THEN
GOTO Sound
·ELSEIF string <> "T" AND "r" AND "u" AND "c" AND "k" THEN
GOTO Sound
ELSEIF string <>· "D" AND "E" AND "b" AND "r" AND "a"· AND "K" THEN
GOTO Sound
ELSEIF string <>· "S" AND "a" AND "m" AND "K" AND "e" AND "y" THEN
GOTO Sound
ELSEIF string <>· "S" AND "p" AND "a" AND "r" AND "e" AND "1" THEN
GOTO Sound
ELSEIF string <>·· "S" AND "p" AND "a" AND "r" AND "e" AND "2" THEN
GOTO Sound
ENDIF
Sound:
HIGH 15
PAUSE 4000
LOW 15
GOTO scan
Thanks to Any One that can Help with this routine
The Code Routine for SEND is not done yet i will work on this latter is in the Attachment below
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/2/2007 9:32:32 PM GMT
This routine seem to work ok·I can turn·ON an LED LIGHT base on the Card Names
I have been working on this all day
Can any one tell if there is an better way to write this routine
' {$STAMP BS2}
' {$PBASIC 2.5}
String···· VAR···· Byte·········· 'VAR space for data
scan:
PAUSE 500
DEBUG CLS, CLS
DO
LOW 1··························· '· low=listen For the SN75176 chip
SERIN 0, 16468, [noparse][[/noparse]string]········ '· SEROUT For the SN75176 chip
DEBUG string
LOOP UNTIL string· =· ("0")····· ' valid Names that are SENT which·end with ("0") [noparse][[/noparse]"Sam 0"] sending end Basic Stamp
IF string <> "s" AND "a" AND "m" THEN
GOTO Sound
ELSEIF string <> "M" AND "O" AND "m" THEN
GOTO Sound
ELSEIF string <> "D" AND "E" AND "b" AND "r" AND "a"· AND "C" THEN
GOTO Sound
ELSEIF string <> "S" AND "a" AND "m" AND "C" AND "a" AND "r" THEN
GOTO Sound
ELSEIF string <> "D" AND "a" AND "v" AND "i" AND "d" AND "C" THEN
GOTO Sound
ELSEIF string <> "K" AND "e" AND "n" AND "C" AND "a" AND "r" THEN
GOTO Sound
ELSEIF string <> "D" AND "E" AND "b" AND "r" AND "a"· AND "N" THEN
GOTO Sound
·ELSEIF string <> "T" AND "r" AND "u" AND "c" AND "k" THEN
GOTO Sound
ELSEIF string <>· "D" AND "E" AND "b" AND "r" AND "a"· AND "K" THEN
GOTO Sound
ELSEIF string <>· "S" AND "a" AND "m" AND "K" AND "e" AND "y" THEN
GOTO Sound
ELSEIF string <>· "S" AND "p" AND "a" AND "r" AND "e" AND "1" THEN
GOTO Sound
ELSEIF string <>·· "S" AND "p" AND "a" AND "r" AND "e" AND "2" THEN
GOTO Sound
ENDIF
Sound:
HIGH 15
PAUSE 4000
LOW 15
GOTO scan
Thanks to Any One that can Help with this routine
The Code Routine for SEND is not done yet i will work on this latter is in the Attachment below
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/2/2007 9:32:32 PM GMT
Comments
You should be able to get by with --
There is no string support on the BASIC Stamps. Everything must be dealt with in a byte-by-byte manner.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
The Transmitter's Program --
The Receiver's Program --
So, perhaps, sam_sam_sam, you could take a similar tack, as there is "no string support on the BASIC stamps."·
BS-1's don't exactly·have WAIT.· If you're using a BS2, then you could use WAIT and devise your own·moniker (my term, where I used "Phase") followed by an ID character for each card, instead.
Thanks for your reply in this matter
But from what Chris· is saying i seem to have it writen the best way if i am going to use the SN75176 chip
I will have to look· into how much a set of MAX232/233 Chip are and if they do not cost alot then i may try what
you have writen here in this post
Thanks again for your input in this matter
Thank you Chris for·pointing out·why was having so much trouble writing this routine not knowing that
Chris
Everything must be dealt with in a byte-by-byte manner.
Chris will it be easyer to use··MAX232/233 to do what i want to do then the SN75176
I want to have the Names of the Cards to be on the receiver end·the·one at the House because i going·to use a
LCD Display to·show the Name of the Person at the Gate·and for each person to have a·different TONEs that the Basic
Stamp dose that is why i need to not only show name but·be able to do·some different things with each one
Thanks Chirs and PJ Allen for all of your help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/4/2007 1:26:18 AM GMT
"string" is a byte-sized variable.
In the IF/THEN statements, "string", a single byte,··is being compared "not equal" (<>) to what?
Isn't the Do/Loop cycling through input characters (bytes) until a "0" is received, and then continuing on to the IF/THEN section of code, with "string" set to "0"? (And, is it a numeric 0 [noparse][[/noparse]zero] or the character zero "0" that is terminating the input?)
I.e., how do the multiple-characters (bytes), e.g., "s", "a", "m", ·get compared, each and every one, to "string" (a byte) in this AND-ing fashion?
What am I missing here about PBasic syntax? How do the above program statements work "byte by byte"? Was there some previous thread that contains the context for this project?
PAR
Post Edited (PAR) : 6/4/2007 1:28:58 AM GMT
I don't understand how this program is supposed to work "...seems to work ok...").
·
"string" is a byte-sized variable.
·
In the IF/THEN statements, "string", a single byte,··is being compared "not equal" (<>) to what?
That part i am not sure of ether
Isn't the Do/Loop cycling through input characters (bytes) until a "0" is received Yes
, and then continuing on to the IF/THEN section of code, with "string" set to "0"?
(And, is it a numeric 0 [noparse][[/noparse]zero] or the character zero "0" I do not Know if this is the case or not·that is terminating the input?)
·
I.e., how do the multiple-characters (bytes), e.g., "s", "a", "m", ·get compared, each and every one, to "string" (a byte) in this AND-ing fashion?
When the sam That is the IF statement = [noparse][[/noparse]"S" AND·"a" AND "m"] Then it Flashs the Led
The [noparse][[/noparse]"0"] is only use for the DO LOOP I only want it to something if the [noparse][[/noparse]"0"]· is at the end of the String that is being sent
·
What am I missing here about PBasic syntax? How do the above program statements work "byte by byte"?
Yes from what Chris said in the POST above
· PAR
Thank You for Your reply
What i found out is that you can not send all of the characters··At one time· [noparse][[/noparse]"Sam"]·
That is why this was used [noparse][[/noparse]"S" AND·"a" AND "m" AND "0"] = It is a numeric 0 [noparse][[/noparse]zero]
Now if some one can Tell me·an easyer way to do this i am very open to this but i need to be able to control By card Names
You would only ·receive·two characters and could not control any thing with it
The Demo code for the SN75176 Chip·only sent one character to control an Led
So that is how i came up with this routine
That why i put the "0" at the END of what i want to send from one Stamp to the Other Stamp
Was there some previous thread that contains the context for this project?
·
The Reason I am using this Chip is that in other POST i ask adout talking from one Stamp to onther Stamp That was about 300 feet apart
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/4/2007 2:10:06 AM GMT
MAX232/RS232 isn't required.· Whether the data exchange is·by RS232, or RS422, or some other means is a side issue.··They're just means to an end.· What matters is the SERIN/SEROUT concept/s.
With the 75176: DE (75176 pin 3) must be HI during Transmit [noparse][[/noparse]note·the use of RTS in my example]; /RE (75176 pin 2) and DE (75176 pin3) must be LO to Receive.
Update -- You seem stuck in your "names" approach, so I'll leave it at that.
Thank You For Your Reply
I may drop the Name sending and just use one Letter and have the Name: in the routine
I·just want to see if i could get it to work or not this way if not then i will have to·rethink how i am going to do these
Routines
·Thanks for your ·s that helps alot· s
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
You are not testing for what you think you are. And, your are always going to end up at the "Sound:" portion of your program and to raise pin 15 high for 4 seconds (regardless of whether any of the conditions of your IF statement are TRUE or FALSE).
PAR
·
You want to use the 75176 because it can communicate over several hundred feet of wire, while RS232 is typically only good out to 25 feet. Just be sure to PJ Allen's directions on the DE and /RE pins.
'Luck on your project!
kenjj
Thank You For Your Reply
I am going to try PJ Allen's· ·and see how well this will work for what i am
trying to do
...................................................................................................
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
All i can tell you is that what ever card that i tried i got the card name·in the DEBUG window when the card was scaned
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam