Shop OBEX P1 Docs P2 Docs Learn Events
RFID Parallax Module and a DS1302 And different routine for each card — Parallax Forums

RFID Parallax Module and a DS1302 And different routine for each card

sam_sam_samsam_sam_sam Posts: 2,286
edited 2006-07-01 18:14 in BASIC Stamp
Hi everyOnne

I am at it again with a New Project Idea

I want take RFID Card # and access a different routine for each card

This is an example of code that i want to use for two different RFID Cards

Card # 1

IF ((minutes = 0) AND (seconds = 1)) THEN
HIGH 13
ENDIF
IF ((minutes = 15) AND( seconds = 0)) THEN
LOW 13
ENDIF

Card # 2

IF ((minutes = 0) AND (seconds = 1)) THEN
HIGH 13
ENDIF
IF ((minutes = 30) AND( seconds = 0)) THEN
LOW 13
ENDIF

RFID reader and a DS1302 clock chip

Can this be done ? and (if this can be done)

Could you PLEASE give an example on how to this

THANKS to any one that show me how to this
Please let know if this can be done

Sam

Post Edited (sam_sam_sam) : 5/8/2006 10:05:09 PM GMT

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-09 02:33
    What will determine if an RFID tag is placed during this time you are looking for.· That event only happens twice in one day and if you're looking for a tag at that time chances are slim unless someone is holding the tag there waiting for that time.· Perhaps I am not getting what you're trying to do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Tom WalkerTom Walker Posts: 509
    edited 2006-05-09 12:53
    sam_sam_sam,
    If I am understanding you correctly, you can accomplish this by taking any of the "standard" RFID demo code and after the read (you should be able to figure out where in the code this is), use a LOOKDOWN, CASE or IF-THEN construct to decide where to go for each card. Each one of your segments (Card #1, Card #2) will end up being a subroutine that gets called by the appropriate card.

    Now, based on your previous messages, you really need to go through the "What's a Microcontroller?" text and get a better understanding of how a program is intended to flow...before asking "well, how do I do that?". I understand that sometimes the best teacher is example, but you need to really understand "why" you do certain things to really get effective use out of your investment...otherwise, each project becomes another cycle of asking "how"...without ever really getting the satisfaction of figuring it out, and the knowledge that, with time, you can work it out for yourself...

    <philosopher_mode=OFF>

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2006-05-10 12:34
    Tom Walker

    Thank you for your reply

    The problem i was having was i did now what the label was in the code to use

    But i did figuring it out that " TAG NUM = What ever # "
    Was what·i need to use

    TO·use a LOOKDOWN, CASE or IF-THEN construct to decide where to go for each card. Each one of your segments (Card #1, Card #2) will end up being a subroutine that gets called by the appropriate card.


    Now i do go through the "What's a Microcontroller?"· my problem is understanding how to use
    the examples to do what i want to do and you are right
    But i do understand it better with examples i just learn it better that way

    Please for give for that

    ·I know that is MY Problem

    Thank YOU for helping in this matter

    This is what i was able to come up with
    PLEASE tell me if i have the Right Idea or not ( This· dose work )

    Sam
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2006-05-10 12:35
    Chris

    Thanks for for your reply

    Sam········ smile.gif
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-10 14:11
    Your welcome, except I still don't know exactly what you're trying to do.· Instead of posting code, why not explain the sequence of events you're trying to have happen so at least we know what it is you're trying to accomplish.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2006-05-10 16:08
    Chris

    Lets says what i want to is take this CARD # 1
    and use this routine


    "0F026079ED" is Card #1

    IF mins = $00 AND secs =$00 THEN
    HIGH Relay
    ENDIF


    IF mins = $15 AND secs =$00 THEN
    LOW Relay
    ENDIF

    And use this routine for this CARD # 2


    "0F02782A89" is Card #2


    IF mins = $00 AND secs =$00 THEN
    HIGH Relay
    ENDIF


    IF mins = $30 AND secs =$00 THEN
    LOW Relay
    ENDIF

    And So On................

    What i want to do is to use different CARD #
    To have Different TIME routine

    Thanks For Your HELP Chris


    Sam
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-10 16:10
    I'm sorry I am just not getting it...Is there·someone else who understands and could please explain in text what he is trying to do?


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-10 16:17
    Okay, let's get some clarification...One of the other Techs suggested that possibly you're trying to scan tags, and when you get a tag it activates a relay and starts a timer for certain amount of time.· After that time has elapsed you turn the relay off.· If this is correct then the reason I didn't get that is because you are showing me code that tests for mins=0 and secs=0, not resetting the time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • SSteveSSteve Posts: 808
    edited 2006-05-10 16:21
    Something like this should work. I don't have an RFID reader but I hope this will get you going in the right direction. For example, if the card IDs are longer than a WORD, you won't be able to use a simple IF/THEN.

    Card1ID        CON    ' put card 1's ID here
    Card2ID        CON    ' put card 2's ID here
    
    DO
      GOSUB Read_Card_ID
      IF cardID=Card1ID then
        GOSUB Process_Card_1
      ELSEIF cardID = Card2ID then
        GOSUB Process_Card_2
      ENDIF
    LOOP
    
    Read_Card_ID:
      ' This routine reads a card and stores the card's ID in the variable cardID
    RETURN
    
    Process_Card_1:
      IF mins = $00 AND secs =$00 THEN
        HIGH Relay
      ELSEIF mins = $15 AND secs =$00 THEN
        LOW Relay
      ENDIF
    RETURN
    
    Process_Card_2:
      IF mins = $00 AND secs =$00 THEN
        HIGH Relay
      ELSEIF mins = $30 AND secs =$00 THEN
        LOW Relay
      ENDIF
    RETURN
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-10 16:33
    Okay,

    ·· We have calrification...After a phone conversation this is what we have...

    1) Scan A Tag (branch to a given routine based on the tag number.· To do this you could use the RFID code and change the display name section to an ON tagNum BRANCH Routine1, Routine2, Routine3, etc.

    Routine1:
    ··mins=$00
    ··secs=$00
    · GOSUB Set_Time
    ··HIGH Relay
    · DO
    ····GOSUB Get_Time
    ··· IF mins=$15 AND secs=$00 THEN EXIT
    · LOOP
    · LOW Relay
    · GOTO Start
    ·

    Once the desired time was reached you would branch back to the beginning to wait for the next tag.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2006-05-10 16:50
    Chris and SSteve

    Thanks Now i know what you are talking about

    Thank You For All Of Your Help

    Sam
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2006-05-10 21:38
    Chris

    Thank You for helping understand how to use the ON GOSUB
    I have not use this command before BECAUSE i did NOT understand how to use it

    Syntax: ON Offset GOSUB Address1, Address2, ...AddressN

    IF (value = 0) THEN GOSUB Case_0
    IF (value = 1) THEN GOSUB Case_1
    IF (value = 2) THEN GOSUB Case_2


    Here is what i came up with and it works VERY GOOD

    THANK YOU FOR ALL YOUR HELP Chris



    Sam

    Post Edited (sam_sam_sam) : 5/10/2006 9:41:04 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-11 02:48
    Actually the command I mentioned was·BRANCH tagNum, label1, label2, label3, etc.· But you can do it that way too.· But I think I had the syntax wrong earlier because you mentioned the ON GOSUB earlier.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2006-05-11 12:14
    Chris

    Thank YOU for your reply

    I was not sure how to write this command

    BRANCH tagNum, label1, label2, label3,

    Thank You for helping me to understand how to use this command

    Sam
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-11 14:58
    Sam,

    ·· The syntax and examples are listed in the Help File in the Stamp Editor as well as the BASIC Stamp Manual.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2006-06-30 17:34
    Hi, Everyone

    I am still working on this project i need some help with this problem that i have
    when i was taking the project board and putting it in the case one of the wires
    on DS1302 chip broke loose and i did not see that it had broke loose

    So the power relay came ON like it was supost to but the clock was not running

    So the way i had code writen in CARD_READER_TIMER.bs2 it would turn ON the Relay
    if the clock was NOT RUNNING

    'So i add this line so that if the DS1302 is not running it will not turn ON the Relay At START UP
    IF mins = $00 AND secs =$05 THEN
    HIGH Relay

    What i want to know is there a way to keep track of the timer and if it STOPS RUNNING that
    it turns OFF the RELAY

    Can this be done and if it can be done how would you write the the code routine
    Thanks to anyone that can help with this


    Routine1:
    mins=$00
    secs=$00
    GOSUB Set_Time

    IF mins = $00 AND secs =$05 THEN 'So add this line
    HIGH Relay

    DO
    GOSUB Get_Time
    IF mins=$15 AND secs=$00 THEN EXIT
    LOOP
    LOW Relay
    GOTO Start

    Sam
  • FranklinFranklin Posts: 4,747
    edited 2006-06-30 17:55
    Sam, If you have some time for a test you could check seconds twice in a minute (or less) and if they are the same the clock is not running.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2006-06-30 20:49
    Hi, Franklin and Every One Else

    Franklin

    You Said this

    If you have some time for a test you could check seconds twice in a minute and if they are the same the clock is not running.

    I understand what you are talking about

    I thought about check Seconds To A Minute

    But i do not how to write it

    How would i TEST Second Twice in a Minutes

    Can you give an example of how to do that or where i can find an example of how to it

    I want to learn how to this
    I have two or three project that i will need to have this SAFETY Built in to Code so that if the Clock dose not run it will not turn ON The Relay

    I will also need to learn how to put in a SAFETY KILL SWITCH in one project that i will be working on soon also with the Clock Not Running Safety

    So THANK YOU FOR ANY HELP that you can give in this matter and THANK YOU for you TIME

    Sam
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2006-07-01 18:14
    Hi, Every One

    I·have move this new problem that i am having to this Post

    ·DS1302 Is there a way to keep track of the timer if it is running

    http://forums.parallax.com/showthread.php?p=594278

    Sam
Sign In or Register to comment.