Shop OBEX P1 Docs P2 Docs Learn Events
garage door with RFID — Parallax Forums

garage door with RFID

buckedup169buckedup169 Posts: 8
edited 2012-12-17 14:13 in BASIC Stamp
so I've tried this a couple of times and its still not right. I have and RFID and 4 tags. i have the tags labeled Car A-D and my outputs labeled Door D-A all i am trying to do is when car A (tag 1) passes the RFID door A will go high (output 15), and then so on with the other 3 tags. i posted this on here once and someone did get back to me and got it close to working but not completely(attached, Garage door), i worked on it a little bit and got it closer i think(attached, Garage door2). I hope someone can get back to me and help me out.

thank you for your time and i hope to hear from someone :)

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-12-03 15:44
    It helps for you to describe how your device is supposed to behave (partly done) and how it actually behaves. This is much more helpful than trying to guess from your code.
  • buckedup169buckedup169 Posts: 8
    edited 2012-12-03 19:20
    thank you Mike ... So as Tag A passes by the RFID output 15 will go high, when it passes by the RFID again output 15 will go low. and this cycle will continue. as Tag B passes by the RFID output 14 will go high, when it passes by the RFID again output 14 will go low. and the cycle continues. as Tag C passes by the RFID output 12 will go high, when it passes by the RFID again output 12 will go low, and the cycle will continue. as Tag D passes by the RFID output 11 will go high, when it passes by the RFID again output 11 will go low, and the cycle will continue

    so what works and what doesn't work? well on screen it tell me which tag has passed by (Tag A, B, C, or D) but as far as the outputs going high and low well that is the problem i am having :( i hope this better helps somene

    thanks again
  • SapphireSapphire Posts: 496
    edited 2012-12-03 21:35
    The problem is in your SELECT...CASE statement.
      SELECT tagNum                         ' get tag number
        CASE 1
          IF tag1=1 AND DoorA=0 THEN HIGH 15
          IF tag1=1 AND DoorA=1 THEN LOW 15
        CASE 2
          IF tag2=1 AND DoorB=0 THEN HIGH 14
          IF tag2=1 AND DoorB=1 THEN LOW 14
        CASE 3
          IF tag3=1 AND DoorC=0 THEN HIGH 12
          IF tag3=1 AND DoorC=1 THEN LOW 12
        CASE 4
          IF tag4=1 AND DoorD=0 THEN HIGH 11
          IF tag4=1 AND DoorD=1 THEN LOW 11
      ENDSELECT
    
    

    Assuming the DoorA is closed and tag1 is read, you set pin 15 high. But that is DoorA, and on the very next statement, you check if DoorA is 1 and make pin 15 low. So you are opening and closing the door so fast you can't see it. You need to modify the CASE statements so that the door is opened if it is currently closed and closes if it is currently open for each tag read.

    Try this to see if it gives you the results you want:
      SELECT tagNum                         ' get tag number
        CASE 1
          IF tag1=1 THEN TOGGLE DoorA
        CASE 2
          IF tag2=1 THEN TOGGLE DoorB
        CASE 3
          IF tag3=1 THEN TOGGLE DoorC
        CASE 4
          IF tag4=1 THEN TOGGLE DoorD
      ENDSELECT
    
    
  • buckedup169buckedup169 Posts: 8
    edited 2012-12-04 21:39
    Thanks Sapphire The toggle command did not work but I think you may be on to something do you think there is something else I need add to make it work?
  • SapphireSapphire Posts: 496
    edited 2012-12-05 16:44
    Add the following line in the Initialization section:
    DIRD = $F                ' set DoorA - DoorD as output
    

    And remove the IF statements from the CASE...SELECT. You are comparing an address to 1 which will never be true.
     SELECT tagNum                         ' get tag number
        CASE 1
          TOGGLE DoorA
        CASE 2
          TOGGLE DoorB
        CASE 3
          TOGGLE DoorC
        CASE 4
          TOGGLE DoorD
      ENDSELECT 
    

    What do you have connected to DoorA - DoorD?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-12-06 15:27
    You should follow-up in your original thead in the future so that others have the previous history to help get them caught up. I provided you with code that should have worked, however I did not see a follow-up to that thread to say if it did or did not. You said it is close, but don't indicate in what way it is not working, which would help us to be able to help you. Please let me know how the original code did not work.
  • buckedup169buckedup169 Posts: 8
    edited 2012-12-09 19:14
    Thank you so much Sapphire i will get into my lab and try this tomorrow I am sorry I am now getting back to you on this I was not around my computer all weekend, and I have a Resistor to LED's for now hooked up for Garage door A-D, and also every time i try a different program i hook up the DMM, but the LED's will later be replaced be 5V ice cube relays so i can integrate this with an Automated Logic LGR controller..

    Chris i am sorry i tried replying to my orginal post but every time i tried i got some type of service error. and the problem with the program you gave me well on screen it tell me which tag has passed by (Tag A, B, C, or D) but as far as the outputs going high and low.. that part did not work .

    i just want to say i am sure glad there is good people to lend a helping hand thank you all so much it means a lot!!
  • buckedup169buckedup169 Posts: 8
    edited 2012-12-10 07:30
    Chris & Sapphire

    So I used your program Chris because it reads the tags slower than the one i made. however i used sapphire's toggle idea and it works 75%, it works almost as its suppose to. Car A (Tag1) turns on and off output 15, Car B (Tag2) turns on and off output 14, Car C (Tag3) turns on and off output 12, but Car D (Tag4) comes up Unauthorized. when i tried to that Unauthorized and Name 0 out of the program what happened was.... Tag1 readas car B and turned on and off output 15, Tag2 read as Car C and turned on and off output 14, Tag3 read as Car D and turned on and off output 12, and Tag4 came up as Car A and did not turn on and off any outputs.... i hope this is a good explination and is an easy fix thank you two very much for your help so far i am getting really excited about this project.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-12-10 09:48
    Not sure what you mean...the program I posted works exactly as you specified minus the fact that I didn't add Tag4/Name4. That is why the last tag didn't work, you have it add it. My example was designed to show you how the program could be modified to do what you wanted it to do. I just added tag4/name4 to my program and as I scan each tag the appropriate I/O pin goes high/low and the tag name is printed to the DEBUG screen. Any other card causes an unathorized message and doesn't activate the output.

    You would not want to remove the unauthorized tag routine from the program because then the program would always allow a tag. It needs to handle cases where the tag is wrong or the answer will always be right. I did not look at the toggle version you specify, however I did just test the code I have and it is working with 4 tags and could be expanded. However since you only specify 4 outputs I won't go past that. This attached version is verified. Not sure about it being slower...I used the demo code as a template to create this. The demo code plays a tone causing a small delay, however that command could be commented out. To use the attached code simply enter your tag data for Tag1-Tag4.
  • buckedup169buckedup169 Posts: 8
    edited 2012-12-17 14:13
    so it finally works i would like to thank Chris and Sapphire. i posed the final program for anyone to view or if they need itthis is it!!!!!!.bs2
Sign In or Register to comment.