Shop OBEX P1 Docs P2 Docs Learn Events
Debugin — Parallax Forums

Debugin

cpetrocpetro Posts: 3
edited 2006-08-08 17:34 in BASIC Stamp
Hello everyone.· I was wondering if I could get some help on a project I am working on.· I am into home automation and I wanted a way to tell the system who was home or not.· I decided to do this by using RFID.· The project is completed and works very well.· It works as follows:
The BS2 holds the variables for each user's home or away status.· Swipe RFID card and the Basic Stamp toggles between home and away for each user.· Sends user's name and home or away to an lcd, and also sends the appropriate command out the serial port to the automation compouter.· The automation computer also holds these variables and the software's rules use these variables to turn off the house on last one out, and turn it on when someone comes home and sets user preferences when only 1 of us is home.· I also have touchscreens around the house for control.· Since I only have 1 RFID device at 1 door if you enter through another door you have to log in through the touchscreen.
·
So I wanted the computer to update the· variables in the Basic Stamp if someone used a touchscreen instead of the RFID, so everything stays in sync.· Here is where I am stuck.· I· have used the DEBUGIN command and this works in testing, but it seems the BS waits for the DEBUGIN input until it continues on with the code which means if no one uses the touchscreen it is still waiting for input and the RFID code never gets executed.
Is there a way to have my RFID code loop and wait for a tag but simultaneously be listening for commands from the computer's serial port?· Either the BS2 can't do this or it is due to my lack of programming skills.· If I had to bet I'd pick the latter.
Thanks,
Chris

Comments

  • willthiswork89willthiswork89 Posts: 359
    edited 2006-08-06 00:37
    im not sure that the BS2 has the capability of multithreading, of course im still a beginner but i know you can POLL for things, try looking at that in the PBASIC help file.. someone else may have a little more info for you cpetro!
  • FranklinFranklin Posts: 4,747
    edited 2006-08-06 00:46
    DEBUGIN is a special instance of serin. serin can be more powerful in that it can use any pin for input. there is a timeout feature (someone else will have to address that as I am new to this) that will time out the cerin/debugin command if there is no input in the timeout time specified.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-08-06 03:50
    Try something like this:

    ' This is only pseudocode

    Main:
    DO
    GOSUB check_touchscreen
    GOSUB check_rfid
    LOOP
    END

    check_rfid:
    ' Your RFID code goes here
    RETURN ' make sure the return statemernt is here

    check_touchscreen:
    ' Your TOUCHSCREEN code goes here
    RETURN ' make sure the return statemernt is here


    Use SERIN instead of DEBUGIN, and set a timeout duration for the SERIN cmd.

    You can test your code using the debug terminal on PIN16, then just change your pin definition for your touchscreen.
  • cpetrocpetro Posts: 3
    edited 2006-08-07 19:31
    Thanks for the replies.· I had actually thought that I should use SERIN instead of DEBUGIN, but was confused on how to do this.· After playing with some examples from the manual and taking Kevin Wood's advice I was able to write working code that did what I want.· I just used the timeout feature for both the rfid and the touchscreen info.· It seems the timeout should be short (500ms) so the program·alternates between·each routine quickly, or you end up having to hold the rfid tag for a couple of seconds if it is in its check touchscreen routine.· Works real good, now time to make the graphics.

    Kevin Wood, are you K-WOOD from the Cinemar forums?· If so then, I am using this to display everything in MainLobby, through the GenericSerial plugin.· This is pretty cool.

    Thanks for the help,
    Chris
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-08-07 23:46
    Chris,

    No, I'm not that K-WOOD. I Googled my name once and found out that it's more common than I expected.

    Out of curiosity, I took a look at the Cinemar website, and it looks like some neat stuff.
  • cpetrocpetro Posts: 3
    edited 2006-08-08 17:34
    Kevin,

    Ok, I thought that you might be the sane person since you answered the automation related question.· I know a few guys over there have made automation related basic stamp projects.
    Anyway, thanks for the help, much appreciated.

    Take Care,
    Chris
Sign In or Register to comment.