Any of the commands that produce a logic high / 1 level will provide approximately 5V on the I/O pin.
The BS2p24 uses an SX microprocessor and Parallax has datasheets available for download that discuss
the amount of current available from an I/O pin or group of I/O pins. The datasheets also show the
I/O pin voltage vs current drain
Look in the PBasic manual under the HIGH, INPUT, LOW, OUTPUT, and TOGGLE commands. Also
look at the descriptions of the DIRS, INS, and OUTS predefined memory locations.
Note that an I/O pin is not a power source although it can typically supply up to maybe 30ma
Generally, you have to communicate from a PC using serial I/O. Somehow, you're asking your PBasic code to send the RFID tag numbers to the PC. You have to ask your PBasic code to set the I/O pins HIGH or LOW. For example, say that whenever your Stamp receives an "A", it returns the last RFID code read or something else to indicate that nothing was read since the PC asked previously. You'd add additional codes "B" and "C" to set some I/O pin HIGH or LOW respectively. If you want multiple I/O pins, you could use a digit like 0 to 7 to represent 3 I/O pins and the numeric value received is copied to the 3 I/O pins as a group.
Mike Green said...
You'd add additional codes "B" and "C" to set some I/O pin HIGH or LOW respectively. If you want multiple I/O pins, you could use a digit like 0 to 7 to represent 3 I/O pins and the numeric value received is copied to the 3 I/O pins as a group
You can ask the stamp to set the pins high and tell it what pins to set high like Mike said but you can't TELL it to set pins high as far as I know.
Hmm, I think I'm making a bit of progress now, all I needed to do was put mscomm1.output=x
Then x will be going to my stamp and there's where I'm stuck!
So I went to do abit of searching and I found this
Somebody said...
'code by Shaun Wilson July 2/99
'This code recieves a (1)on or (0)off state send from
'your PC using Visual Basic 5 and controls the state of
'pin 0
datain var byte 'contains a 0 or a 1
pin con 16 'stamps dedicated serial input pin
baud con $4054 '9600 baud
again:
serin pin,baud, [noparse][[/noparse]datain]
if datain = "1" then on
if datain = "0" then off
goto again
on:
high 0 'make pin 0 high
goto again
off:
low 0 'make pin 0 low
goto again
So I guess with my BS2p24 I would write something about the SIn pin but I have no idea what to do with it since I'm not too hot with pbasic
Post Edited (Freezepop) : 12/20/2007 7:08:49 AM GMT
You virtually have it all. Shaun Wilsons code is set up for a BS2 so you would need to·change the baud constant·to that of·a BS2p, that would be from $4054 to $40F0.
again:
serin pin,baud, [noparse][[/noparse]datain]
if datain = "11" then 1on
if datain = "10" then 1off
if datain = "21" then 2on
if datain = "20" then 2off
goto again
1on:
high 1 'make pin 1 high
goto again
1off:
low 1 'make pin 1 low
goto again
2on:
high 2 'make pin 2 high
goto again
2off:
low 2 'make pin 2 low
goto again
I'd probably use select case and a subroutine but this is the idea.
Eh I'm not too good with this, I basically copied all of shaun's code into my own which has the RFID tag reader code in it.
But it says that serin is in used and I have completely no idea how to go around it any help?
Sorry about this but I'm really not used to using PBASIC yet
Somebody said...
' {$STAMP BS2p}
' {$PBASIC 2.5}
'
[noparse][[/noparse] Program Description ]
'
' Reads tags from a Parallax RFID reader and displays ID to debug screen
'
[noparse][[/noparse] Revision History ]
'
[noparse][[/noparse] I/O Definitions ]
Enable PIN 0 ' low = reader on
RX PIN 1 ' serial from reader
'
[noparse][[/noparse] Constants ]
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T2400 CON 396
#CASE BS2SX, BS2P
T2400 CON 1021
#ENDSELECT
Baud CON T2400
LastTag CON 3
#DEFINE __No_SPRAM = ($STAMP < BS2P) ' does module have SPRAM?
'
[noparse][[/noparse] Variables ]
#IF __No_SPRAM #THEN
buf VAR Byte(10) ' RFID bytes buffer
#ELSE
Char VAR Byte ' character to test
#ENDIF
tagNum VAR Nib ' from EEPROM table
idx VAR Byte ' tag byte index
number VAR Word
'
[noparse][[/noparse] Initialization ]
Reset:
HIGH Enable ' turn of RFID reader
'
[noparse][[/noparse] Program Code ]
Main:
LOW Enable ' activate the reader
#IF __No_SPRAM #THEN
SERIN RX, T2400, [noparse][[/noparse]WAIT($0A), STR buf\10] ' wait for hdr + ID
#ELSE
SERIN RX, T2400, [noparse][[/noparse]WAIT($0A), SPSTR 10]
#ENDIF
HIGH Enable ' deactivate reader
number = 0
Display_Tag:
FOR idx = 0 TO 9 ' scan bytes in tag
GET idx, Char ' read char from SPRAM
number = number + char
NEXT
number = number * 8
DEBUG DEC number," "
DEBUG CR
PAUSE 500
GOTO main ' repeats code
'code by Shaun Wilson July 2/99
'This code recieves a (1)on or (0)off state send from
'your PC using Visual Basic 5 and controls the state of
'pin 0
datain VAR Byte 'contains a 0 or a 1
PIN CON 16 'stamps dedicated serial input pin
baud CON $4054 '9600 baud
again:
SERIN PIN,baud, [noparse][[/noparse]datain]
IF datain = "1" THEN ON
IF datain = "0" THEN off
goto again
Take the part of the code that lights the pins when it gets input from the pc and just work with that until you get it working. Then add another part of the code until you have the whole thing working. Let us know how it goes. Good luck.
Comments
The BS2p24 uses an SX microprocessor and Parallax has datasheets available for download that discuss
the amount of current available from an I/O pin or group of I/O pins. The datasheets also show the
I/O pin voltage vs current drain
Look in the PBasic manual under the HIGH, INPUT, LOW, OUTPUT, and TOGGLE commands. Also
look at the descriptions of the DIRS, INS, and OUTS predefined memory locations.
Note that an I/O pin is not a power source although it can typically supply up to maybe 30ma
The only thing in my PBASIC code is asking my reader module to get the tag numbers >.>
So the main thing I should be asking is how do I use VBASIC to communicate with my STAMP
Post Edited (Freezepop) : 12/20/2007 3:30:48 AM GMT
Generally, you have to communicate from a PC using serial I/O. Somehow, you're asking your PBasic code to send the RFID tag numbers to the PC. You have to ask your PBasic code to set the I/O pins HIGH or LOW. For example, say that whenever your Stamp receives an "A", it returns the last RFID code read or something else to indicate that nothing was read since the PC asked previously. You'd add additional codes "B" and "C" to set some I/O pin HIGH or LOW respectively. If you want multiple I/O pins, you could use a digit like 0 to 7 to represent 3 I/O pins and the numeric value received is copied to the 3 I/O pins as a group.
what I'm asking is there anyway using VB to tell the STAMP to activate one of it's IO pin.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Jeff T
Then x will be going to my stamp and there's where I'm stuck!
So I went to do abit of searching and I found this
So I guess with my BS2p24 I would write something about the SIn pin but I have no idea what to do with it since I'm not too hot with pbasic
Post Edited (Freezepop) : 12/20/2007 7:08:49 AM GMT
Jeff T.
I'd probably use select case and a subroutine but this is the idea.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
But it says that serin is in used and I have completely no idea how to go around it any help?
Sorry about this but I'm really not used to using PBASIC yet
Jeff T.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
"PIN" became a reserved word as of PBASIC 2.5. Use some other variable name, and the problem will disappear.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
And Franklin, I want to make this code work, it has to control the RFID reader and the activation of 1 of the other pins to a 5 volt via datain by VB
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen