November 10, 2024, 12:44:45 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


prop2 with multiple rfid readers to activate one relay

Started by cdwaynew, May 16, 2016, 07:11:17 AM

Previous topic - Next topic

Lanuti

2.5 amp
and no measurable voltage drop at end of chain


I have surrounded with aluminum foil and

going back to the other day when the prop2 was too hot, I pulsed the power to the RFID readers
and they all work but not at the same time.



I tried a separate power supply to RFID readers  and run an enable wire back to each reader IT works 70%
But that means dropping from 8 readers to 7 readers or there is no output for a trigger left


Steve

JackMan

Quote from: Lanuti on June 18, 2016, 08:06:57 PM
2.5 amp
and no measurable voltage drop at end of chain


I have surrounded with aluminum foil and

going back to the other day when the prop2 was too hot, I pulsed the power to the RFID readers
and they all work but not at the same time.



I tried a separate power supply to RFID readers  and run an enable wire back to each reader IT works 70%
But that means dropping from 8 readers to 7 readers or there is no output for a trigger left


Steve
Not sure I understand that last part. Getting back to the 5V supply, if it works for 7 readers but not 8, maybe it's underpowered even though it says 2.5A.

livinlowe

According to parallax docs, the maximum current draw of 1 RFID reader is 200 mA. So 8 should pull a maximum of 1.6 A. Figure 20% error still gives a maximum of 1.92 A. Cant respond as to the actual cause of his problems though :(
Shawn
Scaring someone with a prop you built -- priceless!

Lanuti

I finally have it working.

They were interfering with each other

Running with enable wire so readers turning on and off
also noted that if a RFID tag is exactly in the middle of the antenna it will not read.
Running 7 instead of 8 - giving the 8th slot as a freebee.
This allows output on 14 & 15 for lights and lock.

Running a separate power supply for the RFID readers is key to keeping the prop2 cool. 

Will post pictures after stain and poly dry.

I have 3 small questions?

1. I would like to add a sound when the puzzle is solved like Taa-Daa

2. In the dubug window when it posts "No Tag"  how do I add a second column where it post the wrong  RFID tags number - This would be helpful when adding new tags.

3. In the "Valid tag List" is there a way to have Tag1 Be {ID-a) or (ID b)
This would be nice so can have a back up RFID tag in case the Item breaks and the person running the escape room wouldn't have to reprogram the puzzle


Thanks for everyone's help

Steve


JackMan

Quote from: livinlowe on June 19, 2016, 01:23:09 PM
According to parallax docs, the maximum current draw of 1 RFID reader is 200 mA. So 8 should pull a maximum of 1.6 A. Figure 20% error still gives a maximum of 1.92 A. Cant respond as to the actual cause of his problems though :(

Correct, but the point I was trying make is that the stated rating on all power supplies isn't always true. I've had some that were labeled 5A and were lucky to output 2A continuous.

bsnut

Quote from: JackMan on June 19, 2016, 07:41:02 PM
Quote from: livinlowe on June 19, 2016, 01:23:09 PM
According to parallax docs, the maximum current draw of 1 RFID reader is 200 mA. So 8 should pull a maximum of 1.6 A. Figure 20% error still gives a maximum of 1.92 A. Cant respond as to the actual cause of his problems though :(

Correct, but the point I was trying make is that the stated rating on all power supplies isn't always true. I've had some that were labeled 5A and were lucky to output 2A continuous.
To add Jack's point, it wouldn't be idea to use a old computer power supply (12VDC/5VDC) which handle a large amp draw on both the 12V and 5V sides.

Now you mentioned that you wanted to do more, I would suggest that you step it to the HC-8. The HC-8 can run the scenes, read RFID tags, and other inputs that you need for these rooms.

BTW, good job in getting it to work.
William Stefan
The Basic Stamp Nut

livinlowe

Quote from: JackMan on June 19, 2016, 07:41:02 PM
Quote from: livinlowe on June 19, 2016, 01:23:09 PM
According to parallax docs, the maximum current draw of 1 RFID reader is 200 mA. So 8 should pull a maximum of 1.6 A. Figure 20% error still gives a maximum of 1.92 A. Cant respond as to the actual cause of his problems though :(

Correct, but the point I was trying make is that the stated rating on all power supplies isn't always true. I've had some that were labeled 5A and were lucky to output 2A continuous.
Ahh, I see. Good point
Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

It's easy to get discouraged, especially when you try to create a big project in one fell swoop.

Suggestions:
-- take a step back; problems are usually simple
-- when using external power supply, its ground MUST be connected the Prop-2 ground
-- Parallax RFID readers need about 100 mA -- you should double this: 8 x 0.100 x 2 = 1.6A (use 2A) (suggested for 5v supply)
-- get ONE reader working, then start adding others
Jon McPhalen
EFX-TEK Hollywood Office

Lanuti

Thanks to Jon and all the other that have responded and helped.

Quick code question

1. In the dubug window when it posts "No Tag"  how do I add a second column where it will post the "wrong"  RFID tags number - This would be helpful when adding new tags and debugging the program.

2. In the "Valid tag List" is there a way to have Tag1 Be (ID-a) or (ID-b)
This would be nice so can have a back up RFID tag in case the Item breaks and the person running the escape room wouldn't have to reprogram the puzzle


Thanks

Steve

JonnyMac

Post your final code and I'll modify it with notes.
Jon McPhalen
EFX-TEK Hollywood Office

Lanuti

Jon
Thanks for all you do ----

' =========================================================================
'
'   File...... rfid_multi-tag.bs2
'   Purpose...
'   Author.... JonnyMac
'   E-mail....
'   Started...
'   Updated... 16 MAY 2016
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------


Lock              PIN     15                      ' OUT 15 controls Green Light at the END
RedLight        PIN     14                      ' OUT 14 Red light at beginning


RFID6E          PIN     13                       ' Reader #6 enable pin
RFID6S          PIN     12                       ' Reader #6 serial pin

RFID5E          PIN     11                       ' Reader #5 enable pin
RFID5S          PIN     10                       ' Reader #5 serial pin


RFID4E          PIN     9                         ' Reader #4 enable pin
RFID4S          PIN     8                         ' Reader #4 serial pin

RFID3E          PIN     7                         ' Reader #3 enable pin
RFID3S          PIN     6                         ' Reader #3 serial pin

RFID2E          PIN     5                         ' Reader #2 enable pin
RFID2S          PIN     4                         ' Reader #2 serial pin

RFID1E          PIN     3                         ' Reader #1 enable pin
RFID1S          PIN     2                         ' Reader #1 serial pin

RFID0E          PIN     1                         ' Reader #0 enable pin
RFID0S          PIN     0                         ' Reader #0 serial pin


' -----[ Constants ]-------------------------------------------------------

LastTag         CON     6                               ' 7 readers (0..6)
NoTag           CON     $FF

UnlockBits      CON     %1111111                ' correct tags all readers


IsOn              CON     1                               ' for active-high in/out
IsOff              CON     0

Yes                CON     1
No                 CON     0

T2400            CON     396                           ' baud for RFID readers


' -----[ Variables ]-------------------------------------------------------

tagIdx            VAR     Byte                    ' RFID Reader 0-6 total 7
tagNum          VAR     Byte                    ' Tags in data base
buf                 VAR     Byte(10)
success           VAR     Byte
idx                 VAR     Byte                    ' RFID Tag read
char               VAR     Byte


' -----[ Initialization ]--------------------------------------------------



Reset:
  OUTH = %00000000 : OUTL = %00000000           ' clear all
  DIRH = %00000000 : DIRL = %00000000            ' set outputs

  FOR tagIdx = 0 TO LastTag                                  ' disable all readers
    HIGH (tagIdx * 2) + 1                                       ' make enable pin high
  NEXT




' -----[ Program Code ]----------------------------------------------------

Main:

  HIGH RedLight

  success = %0000000                                      ' clear found tags

  FOR tagIdx = 0 TO LastTag                              ' scan all readers
    DEBUG CRSRXY, 0, tagIdx, "Reader ", DEC1 tagIdx, ": "
    GOSUB Scan_Reader
    IF (tagNum < $FF) THEN
      DEBUG STR buf\10
      IF (tagNum = tagIdx) THEN
        success = success | (1 << tagIdx)
        DEBUG " ******"
      ELSE
        DEBUG CLREOL
      ENDIF
    ELSE
      DEBUG "No Tag", CLREOL
    ENDIF
  NEXT

  DEBUG CRSRXY, 0, LastTag+2
  DEBUG "Correct tags: ", BIN7 success

  IF (success = UnlockBits) THEN
    LOW RedLight
    HIGH Lock
    PAUSE 50000

  ELSE
    LOW Lock
    HIGH RedLight
  ENDIF

  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

' Pass the reader # to scan in tagIdx
' If tagNum is 0..LastTag on return, known tag was found
' If tagNum is $FF then reader had no tag, or tag not in database


Scan_Reader:
  LOW (tagIdx * 2) + 1                                              ' enable reader

  SERIN (tagIdx * 2), T2400, 250, Not_Found, [WAIT($0A), STR buf\10]

Check_List:
  FOR tagNum = 0 TO LastTag                                   ' scan through known tags
    FOR idx = 0 TO 9                                                 ' scan bytes in tag
      READ (tagNum * 10 + idx), char                         ' get tag data from table
      IF (char <> buf(idx)) THEN Bad_Char                  ' compare tag to table
    NEXT
    GOTO SR_Exit                                                      ' all bytes match!

Bad_Char:                                                                ' try next tag
  NEXT

Not_Found:
  tagNum = NoTag                                                   ' no tag, or bad #

SR_Exit:
  HIGH (tagIdx * 2) + 1                                            ' disable reader
  RETURN


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------


Tag0            DATA    "480069D1E4"            ' valid tags
Tag1            DATA    "480069DACD"
Tag2            DATA    "480068C391"
Tag3            DATA    "480069CF1C"
Tag4            DATA    "480069C3F4"
Tag5            DATA    "480069BBAA"
Tag6            DATA    "480069D109"
Tag7            DATA    "480069C475"

JonnyMac

Give this a whack. Adding the secondary tags list complicates things, so I restructured the code to make it as clear to deal with as I could.

' =========================================================================
'
'   File...... rfid_multi-tag_v2.bs2
'   Purpose...
'   Author.... JonnyMac
'   E-mail....
'   Started...
'   Updated... 29 JUN 2016
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

Lock            PIN     15                      ' OUT 15 controls Green Light at the END
RedLight        PIN     14                      ' OUT 14 Red light at beginning

RFID6E          PIN     13                      ' Reader #6 enable pin
RFID6S          PIN     12                      ' Reader #6 serial pin

RFID5E          PIN     11                      ' Reader #5 enable pin
RFID5S          PIN     10                      ' Reader #5 serial pin

RFID4E          PIN     9                       ' Reader #4 enable pin
RFID4S          PIN     8                       ' Reader #4 serial pin

RFID3E          PIN     7                       ' Reader #3 enaBLE pin
RFID3S          PIN     6                       ' Reader #3 serIAL pin

RFID2E          PIN     5                       ' Reader #2 enaBLE pin
RFID2S          PIN     4                       ' Reader #2 serIAL pin

RFID1E          PIN     3                       ' Reader #1 enaBLE pin
RFID1S          PIN     2                       ' Reader #1 serIAL pin

RFID0E          PIN     1                       ' Reader #0 enaBLE pin
RFID0S          PIN     0                       ' Reader #0 serIAL pin


' -----[ Constants ]-------------------------------------------------------

LastTag         CON     6                       ' 7 readers (0..6)
NoResponse      CON     $FF                     ' no response from reader
NewTag          CON     $FE                     ' tag not known by pgm

UnlockBits      CON     %01111111               ' correct tags all readers

IsOn            CON     1                       ' for active-high in/out
IsOff           CON     0

Yes             CON     1
No              CON     0

T2400           CON     396                     ' baud for RFID readers


' -----[ Variables ]-------------------------------------------------------

tagIdx          VAR     Byte                    ' RFID Reader 0-6 total 7
tagNum          VAR     Byte                    ' Tags in data base
buf             VAR     Byte(10)
success         VAR     Byte
idx             VAR     Byte                    ' RFID Tag read
char            VAR     Byte

addr            VAR     Word


' -----[ Initialization ]--------------------------------------------------

Reset:
  FOR tagIdx = 0 TO LastTag                     ' loop through readers
    HIGH (tagIdx * 2)                           ' set serial to idle state
    HIGH (tagIdx * 2) + 1                       ' disable reader
  NEXT


' -----[ Program Code ]----------------------------------------------------

Main:
  LOW Lock                                      ' lock it up
  HIGH RedLight                                 ' show locked state

  success = %0000000                            ' clear found tags

  ' scan all readers

  FOR tagIdx = 0 TO LastTag
    DEBUG CRSRXY, 0, tagIdx, "Reader ", tagIdx + "0", ": "
    GOSUB Scan_Reader

    IF (tagNum = NoResponse) THEN
      DEBUG "No Tag", CLREOL
      GOTO Next_Reader
    ENDIF

    DEBUG STR buf\10, CLREOL

    addr = ATag0                                ' check A list
    GOSUB Validate_Tag
    IF (tagNum <= LastTag) THEN
      success = success | (1 << tagIdx)
      DEBUG " (A)"
      GOTO Next_Reader
    ENDIF

    addr = BTag0                                ' check B list
    GOSUB Validate_Tag
    IF (tagNum <= LastTag) THEN
      success = success | (1 << tagIdx)
      DEBUG " (B)"
      GOTO Next_Reader
    ENDIF

    ' we have a tag but it's not in either list

    DEBUG "(unknown)"

Next_Reader:
  NEXT

  DEBUG CRSRXY, 0, LastTag+2
  DEBUG "Correct tags: ", BIN7 success

  IF (success = UnlockBits) THEN
    HIGH Lock
    LOW RedLight
    PAUSE 50000
  ENDIF

  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

' Pass the reader # to scan in tagIdx
' -- tagNum set to NewTag if tag was presented
' -- tagnum set to NoResponse if no tag presented

Scan_Reader:
  LOW (tagIdx * 2) + 1                          ' enable reader
  PAUSE 10

  SERIN (tagIdx * 2), T2400, 500, No_Reader, [WAIT($0A), STR buf\10]
  tagNum = NewTag                               ' we have a tag
  GOTO SR_Exit

No_Reader:
  tagNum = NoResponse

SR_Exit:
  HIGH (tagIdx * 2) + 1                         ' disable reader
  RETURN

' -------------------------------------------------------------------------

' put base tag list address in addr

Validate_Tag:
  FOR tagNum = 0 TO LastTag                     ' scan through known tags
    FOR idx = 0 TO 9                            ' scan bytes in tag
      READ (addr + (tagNum * 10 + idx)), char   ' get tag data from table
      IF (char <> buf(idx)) THEN Bad_Char       ' compare tag to table
    NEXT
    GOTO VT_Exit                                ' tag found in list

Bad_Char:
  NEXT

  tagNum = NewTag                               ' tag not found in list

VT_Exit:
  RETURN


' -----[ User Data ]-------------------------------------------------------

ATag0           DATA    "0415148F26"            ' valid tags group A
ATag1           DATA    "480069DACD"
ATag2           DATA    "480068C391"
ATag3           DATA    "480069CF1C"
ATag4           DATA    "480069C3F4"
ATag5           DATA    "480069BBAA"
ATag6           DATA    "480069D109"
ATag7           DATA    "480069C475"

BTag0           DATA    "0415148E0C"            ' valid tags group B
BTag1           DATA    "480069DACD"
BTag2           DATA    "480068C391"
BTag3           DATA    "480069CF1C"
BTag4           DATA    "480069C3F4"
BTag5           DATA    "480069BBAA"
BTag6           DATA    "480069D109"
BTag7           DATA    "480069C475"
Jon McPhalen
EFX-TEK Hollywood Office

Lanuti

Thanks Jon for all your help
Puzzle has come together nice
When beta testing the puzzle a bug came up

Reader 0 can have Atag3 and
Reader 2 can have Atag5  etc

as long as the tag is read and anywhere on the list A or B it clears it.
Not Tag1 linked to reader 1

the dual list is great so I can have a backup prop in case one is dropped or LOST

your most recent modification of the code finds the RFID tags very rapidly  - though not specific Match tag to reader.
and your previous code which is RFID reader specific is much slower and has a harder time reading RFID tags??

many thanks again to you, John and the rest of the forum support helping me build this puzzle

Steve

JonnyMac

I'm happy we could be of service.

It's important to remember <gets on soap box> that programming is a technical art, and that the artist improves with every brush stroke <steps down from soap box>. I love programming, and am always looking for ways to improve code -- it's just my nature. George Lucas said that movies are never finished, they're simply abandoned. I think programs fall into that as well.

Hopefully, the code make sense to you (or will soon) and you can hack it t do other fun things with your props.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Okay, here's an update after our phone call.

Caveat: I'm on the road without a Prop-2, readers, or tags. Still, the changes are minor, the code compiles, and I'm confident this will work.

I renamed the old Validate_Tag to Find_Tag because that's what it does: it searches through an entire list. The new Validate_Tag subroutine only looks at the tag that corresponds to the reader #. This should be faster, too.

' =========================================================================
'
'   File...... rfid_multi-tag_v3.bs2
'   Purpose...
'   Author.... JonnyMac
'   E-mail....
'   Started...
'   Updated... 29 JUL 2016
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

Lock            PIN     15                      ' OUT 15 controls Green Light at the END
RedLight        PIN     14                      ' OUT 14 Red light at beginning

RFID6E          PIN     13                      ' Reader #6 enable pin
RFID6S          PIN     12                      ' Reader #6 serial pin

RFID5E          PIN     11                      ' Reader #5 enable pin
RFID5S          PIN     10                      ' Reader #5 serial pin

RFID4E          PIN     9                       ' Reader #4 enable pin
RFID4S          PIN     8                       ' Reader #4 serial pin

RFID3E          PIN     7                       ' Reader #3 enaBLE pin
RFID3S          PIN     6                       ' Reader #3 serIAL pin

RFID2E          PIN     5                       ' Reader #2 enaBLE pin
RFID2S          PIN     4                       ' Reader #2 serIAL pin

RFID1E          PIN     3                       ' Reader #1 enaBLE pin
RFID1S          PIN     2                       ' Reader #1 serIAL pin

RFID0E          PIN     1                       ' Reader #0 enaBLE pin
RFID0S          PIN     0                       ' Reader #0 serIAL pin


' -----[ Constants ]-------------------------------------------------------

LastTag         CON     6                       ' 7 readers (0..6)
NoResponse      CON     $FF                     ' no response from reader
NewTag          CON     $FE                     ' tag not known by pgm

UnlockBits      CON     %01111111               ' correct tags all readers

IsOn            CON     1                       ' for active-high in/out
IsOff           CON     0

Yes             CON     1
No              CON     0

T2400           CON     396                     ' baud for RFID readers


' -----[ Variables ]-------------------------------------------------------

tagIdx          VAR     Byte                    ' RFID Reader 0-6 total 7
tagNum          VAR     Byte                    ' Tags in data base
buf             VAR     Byte(10)
success         VAR     Byte
idx             VAR     Byte                    ' RFID Tag read
char            VAR     Byte

addr            VAR     Word


' -----[ Initialization ]--------------------------------------------------

Reset:
  FOR tagIdx = 0 TO LastTag                     ' loop through readers
    HIGH (tagIdx * 2)                           ' set serial to idle state
    HIGH (tagIdx * 2) + 1                       ' disable reader
  NEXT


' -----[ Program Code ]----------------------------------------------------

Main:
  LOW Lock                                      ' lock it up
  HIGH RedLight                                 ' show locked state

  success = %0000000                            ' clear found tags

  ' scan all readers

  FOR tagIdx = 0 TO LastTag
    DEBUG CRSRXY, 0, tagIdx, "Reader ", tagIdx + "0", ": "
    GOSUB Scan_Reader

    IF (tagNum = NoResponse) THEN
      DEBUG "No Tag", CLREOL
      GOTO Next_Reader
    ENDIF

    DEBUG STR buf\10, CLREOL

    addr = ATag0                                ' check A list
    GOSUB Validate_Tag
    IF (tagNum = tagIdx) THEN
      success = success | (1 << tagIdx)
      DEBUG " (A)"
      GOTO Next_Reader
    ENDIF

    addr = BTag0                                ' check B list
    GOSUB Validate_Tag
    IF (tagNum = tagIdx) THEN
      success = success | (1 << tagIdx)
      DEBUG " (B)"
      GOTO Next_Reader
    ENDIF

    ' we have a tag but it's not in either list

    DEBUG "(no match)"

Next_Reader:
  NEXT

  DEBUG CRSRXY, 0, LastTag+2
  DEBUG "Correct tags: ", BIN7 success

  IF (success = UnlockBits) THEN
    HIGH Lock
    LOW RedLight
    PAUSE 50000
  ENDIF

  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

' Pass the reader # to scan in tagIdx
' -- tagNum set to NewTag if tag was presented
' -- tagnum set to NoResponse if no tag presented

Scan_Reader:
  LOW (tagIdx * 2) + 1                          ' enable reader
  PAUSE 10

  SERIN (tagIdx * 2), T2400, 500, No_Reader, [WAIT($0A), STR buf\10]
  tagNum = NewTag                               ' we have a tag
  GOTO SR_Exit

No_Reader:
  tagNum = NoResponse

SR_Exit:
  HIGH (tagIdx * 2) + 1                         ' disable reader
  RETURN

' -------------------------------------------------------------------------

' Find tag in a list
' -- put base tag list address in addr

Find_Tag:
  FOR tagNum = 0 TO LastTag                     ' scan through known tags
    FOR idx = 0 TO 9                            ' scan bytes in tag
      READ (addr + (tagNum * 10 + idx)), char   ' get tag data from table
      IF (char <> buf(idx)) THEN Bad_Char       ' compare tag to table
    NEXT
    GOTO FT_Exit                                ' tag found in list

Bad_Char:
  NEXT

  tagNum = NewTag                               ' tag not found in list

FT_Exit:
  RETURN


' -------------------------------------------------------------------------

' Validate tag for specific reader
' -- tagIdx is reader #
' -- put base tag list address in addr

Validate_Tag:
  addr = addr + (tagIdx * 10)                   ' point to tag for reader
  FOR idx = 0 TO 9                              ' scan bytes in tag
    READ (addr + idx), char                     ' get tag data from table
    IF (char <> buf(idx)) THEN No_Match         ' compare tag to table
  NEXT
  tagNum = tagIdx                               ' match!
  GOTO VT_Exit

No_Match:
  tagNum = NewTag                               ' tag not found in list

VT_Exit:
  RETURN


' -----[ User Data ]-------------------------------------------------------

ATag0           DATA    "0415148F26"            ' valid tags group A
ATag1           DATA    "480069DACD"
ATag2           DATA    "480068C391"
ATag3           DATA    "480069CF1C"
ATag4           DATA    "480069C3F4"
ATag5           DATA    "480069BBAA"
ATag6           DATA    "480069D109"
ATag7           DATA    "480069C475"

BTag0           DATA    "0415148E0C"            ' valid tags group B
BTag1           DATA    "480069DACD"
BTag2           DATA    "480068C391"
BTag3           DATA    "480069CF1C"
BTag4           DATA    "480069C3F4"
BTag5           DATA    "480069BBAA"
BTag6           DATA    "480069D109"
BTag7           DATA    "480069C475"
Jon McPhalen
EFX-TEK Hollywood Office