April 29, 2024, 08:59:10 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Prop-2 Controlled Escape Room Puzzle

Started by JonnyMac, March 29, 2017, 08:42:03 AM

Previous topic - Next topic

JonnyMac

March 29, 2017, 08:42:03 AM Last Edit: March 29, 2017, 08:43:41 AM by JonnyMac
A few years ago John B. picked up a set of mini Egyptian canopic jars from eBay and thought it would be fun to create an Escape Room prop demo for Transworld. It, too, was a hit because it showed those who want to build their own puzzles exactly how the electronics work.

Parts:
-- EFX-TEK Prop-2 Controller
-- Parallax RFID Reader (4x)
-- RFID tags (4x)

We made custom harnesses for the RFID readers using wires with pre-crimped F-F terminals. You can find wires and shells here:

-- https://www.pololu.com/category/39/cables-and-wire


' =========================================================================
'
'   File...... efx_canopic_jars.bs2
'   Purpose...
'   Author.... JonnyMac, EFX-TEK
'              Copyright (c) 2017 EFX-TEK
'   E-mail.... team@efx-tek.com
'   Started...
'   Updated... 22 MAR 2017
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

RX3             PIN     15                      ' no ULN, SETUP = UP or OUT
RX3E            PIN     14
RX2             PIN     13
RX2E            PIN     12
RX1             PIN     11
RX1E            PIN     10
RX0             PIN      9
RX0E            PIN      8

LOCK            PIN      5                      ' mag-lock control


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

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

Yes             CON     1
No              CON     0

Enabled         CON     0                       ' for active-low enable
Disabled        CON     1


#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T1200       CON     813
    T2400       CON     396
    T4800       CON     188
    T9600       CON     84
    T19K2       CON     32
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T1200       CON     2063
    T2400       CON     1021
    T4800       CON     500
    T9600       CON     240
    T19K2       CON     110
    T38K4       CON     45
  #CASE BS2PX
    T1200       CON     3313
    T2400       CON     1646
    T4800       CON     813
    T9600       CON     396
    T19K2       CON     188
    T38K4       CON     84
#ENDSELECT

SevenBit        CON     $2000
Inverted        CON     $4000
Open            CON     $8000

Baud            CON     T2400                   ' for Parallax RFID


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

flags           VAR     Byte
hasTag         VAR      flags.BIT0

found           VAR     Byte
tag             VAR     Byte                    ' tag to read (0..3)
epin            VAR     Byte                    ' enable for RFID
rxpin           VAR     Byte                    ' rx for RFID
rfid            VAR     Byte(10)                ' tag buffer
idx             VAR     Byte                    ' character index
char            VAR     Byte                    ' character

addr            VAR     Word


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

Power_On:
  HIGH Lock

Reset:
  OUTH = %01010101
  DIRH = %01010101

  DEBUG CLS, "Canopic Jars", CR


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

Main:
  found = %0000                                 ' clear all positions
  FOR tag = 0 TO 3                              ' loop through readers
    GOSUB Get_Tag                               ' read tag (if present)
    DEBUG "Tag ", DEC1 tag, " : "
    IF (hasTag = YES) THEN
      DEBUG STR rfid\10, CR                     ' show tag id
      GOSUB Validate_Tag                        ' check for match
    ELSE
      HIGH Lock
      DEBUG "No", CR
    ENDIF
  NEXT

  IF (found = %1111) THEN                       ' all found?
    DEBUG "Open Sesame!", CR
    LOW Lock
    PAUSE 10000
    GOTO Reset
  ENDIF

  PAUSE 250
  GOTO Main


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

' Set tag to 0..3 before calling

Get_Tag:
  hasTag = No                                   ' assume no tag
  epin = 8 + (tag * 2)                          ' convert tag # to IO
  LOW epin                                      ' activate RFID
  rxpin = epin + 1
  SERIN rxpin, Baud, 500, GT_Exit, [WAIT($0A)]  ' look for header
  SERIN rxpin, Baud, [STR rfid\10]              ' read tag string
  hasTag = Yes

GT_Exit:
  HIGH epin
  RETURN

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

' Set tag to 0..3 before calling

Validate_Tag:
  found.LOWBIT(tag) = 0                         ' assume not found
  FOR idx = 0 TO 9                              ' loop through tag bytes
    READ (tag * 10 + idx), char                 ' get byte from ee
    IF (char <> rfid(idx)) THEN VT_Exit         ' abort if no match
  NEXT
  found.LOWBIT(tag) = 1                         ' found! mark it

VT_Exit:
  RETURN


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

' must be replaced with your tags

Tag0            DATA    "140041F5E2"
Tag1            DATA    "13001511E6"
Tag2            DATA    "1400415BFF"
Tag3            DATA    "140040F98A"


Jon McPhalen
EFX-TEK Hollywood Office