Shop OBEX P1 Docs P2 Docs Learn Events
Triggering multiple videos from RFID — Parallax Forums

Triggering multiple videos from RFID

InteractivesInteractives Posts: 83
edited 2010-12-30 06:08 in BASIC Stamp
Good evening brilliant people. I have been working on a pretty cool project where I use the Parallax RFID reader & tags to trigger videos from a DV-68 video repeater. The video repeater is hard wired to trigger videos with a pretty basic SEROUT command. So far, just using the SEROUT, I have been able to trigger all 13 videos I have. However, when I plug this code into my RFID code, I run into problems. I can only trigger up to 5 videos, then adding new tag data to the code has no effect. You might recognize this code, as it has been largely jacked from the RFID code supplied by parallax. My goal is to have the capability to trigger up to 99 videos, as that is the max capacity for the video repeater. I have tried adjusting the amount of memory allocated to the variables (I tried word-sized) but that seemed to have no effect. Any suggestions?

' =========================================================================
'
' File....... RFID.BS2
' Purpose.... RFID Tag Reader / Used to trigger videos on DV-68
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' =========================================================================
'
[ Program Description ]
'
' Reads tags from a Parallax RFID reader and compares to known tags (stored
' in EEPROM table). Depending on the tag, a video file will be triggered

'
[ Physical Setup ]

'Output to the DV-68 via the TK-68K I/O PIN 15, 188 = 4800 baud
'RFID power (VCC) +5VDC hooked up to RFID reader
'RFID enable I/O PIN 0
'RFID SOUT I/O PIN 1
'RFID ground (GND) -5VDC, or ground.
'DV-68 should share common ground with BS2

'
[ I/O Definitions ]
Enable PIN 0 ' low = reader on
RX PIN 1 ' serial from reader
'Latch PIN 2 ' lock/latch control

'
[ Constants ]
#SELECT $STAMP
#CASE BS2, BS2E
T2400 CON 396 ' reader baud rate
TmAdj CON $100 ' x 1.0 (time adjust)
FrAdj CON $100 ' x 1.0 (freq adjust)

#ENDSELECT
LastTag CON 7 ' number of known tags + 1 #################################
#DEFINE __No_SPRAM = ($STAMP < BS2P) ' does module have SPRAM?
'
[ Variables ]
#IF __No_SPRAM #THEN
buf VAR Byte(10) ' RFID bytes buffer
#ELSE
chkChar VAR Byte ' character to test
#ENDIF
tagNum VAR Nib ' from EEPROM table
idx VAR Byte ' tag byte index
char VAR Byte ' character from table
'
[ EEPROM Data ]
'##########################################################################
Tag1 DATA "04162B8531"
Tag2 DATA "04162B708D"
Tag3 DATA "04162B67B6"
Tag4 DATA "04162B66F7"
Tag5 DATA "04162B8619" 'doesnt work for whatever reason!!
Tag6 DATA "04162B8619"
Tag7 DATA "04162B7625" 'stops working

'
[ Initialization ]
Reset:

HIGH Enable ' turn of RFID reader
'LOW Latch '
'
[ Program Code ]

Main:

LOW Enable ' activate the reader
#IF __No_SPRAM #THEN
SERIN RX, T2400, [WAIT($0A), STR buf\10] ' wait for hdr + ID
#ELSE
SERIN RX, T2400, [WAIT($0A), SPSTR 10]
#ENDIF
HIGH Enable ' deactivate reader

Check_List:

FOR tagNum = 1 TO LastTag ' scan through known tags
FOR idx = 0 TO 9 ' scan bytes in tag
READ (tagNum - 1 * 10 + idx), char ' get tag data from table
#IF __No_SPRAM #THEN
IF (char <> buf(idx)) THEN Bad_Char ' compare tag to table
#ELSE
GET idx, chkChar ' read char from SPRAM
IF (char <> chkChar) THEN Bad_Char ' compare to table
#ENDIF
NEXT
GOTO Tag_Found ' all bytes match!
Bad_Char: ' try next tag
NEXT
Bad_Tag:
tagNum = 0
'GOSUB Show_Name ' print message
PAUSE 1000
GOTO Main
Tag_Found:

'#############################################################################
ON tagNum GOSUB Initialize, Tag_1, Tag_2, Tag_3, Tag_4, Tag_5, Tag_6
GOTO Main
END

'
[ Subroutines ]

Initialize:
DEBUG "Initialize", CR

Tag_1:
DEBUG "Track 001", CR
SEROUT 15, 188, [1]
PAUSE 1000
GOTO Main


Tag_2:
DEBUG "Track 002", CR
SEROUT 15, 188, [2]
PAUSE 1000
GOTO Main

Tag_3:
DEBUG "Track 003", CR
SEROUT 15, 188, [3]
PAUSE 1000
GOTO Main

Tag_4:
DEBUG "Track 004", CR
SEROUT 15, 188, [4]
PAUSE 1000
GOTO Main

Tag_5:
DEBUG "Track 005", CR
SEROUT 15, 188, [5]
PAUSE 1000
GOTO Main

Tag_6:
DEBUG "Track 006", CR
SEROUT 15, 188, [6]
PAUSE 1000
GOTO Main

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2010-12-29 18:17
    I may be wrong here. And if I am I will hear about for sure.
    '
    But I see you using a form of #CASE. This is limited to 16.(Your using a lot of it in #SELECT #CASE for stamp ID)
    '
    I would try IF THEN ELSE statements instead for your DATA with the RFID.
    '
    Again I could be totally off here, so don't lose what you have written.
    '
    I just briefed over your code, And this is the first thing that came to mind.
  • InteractivesInteractives Posts: 83
    edited 2010-12-30 06:08
    Thanks $WMc%, I will give that a try!
Sign In or Register to comment.