Shop OBEX P1 Docs P2 Docs Learn Events
Problem reading limit switches — Parallax Forums

Problem reading limit switches

Jim C.Jim C. Posts: 8
edited 2010-11-21 18:25 in BASIC Stamp
I am using a BS1 to control a home built garage door opener. I went with a Stamp because I wanted to read a pulse encoder and determine if the door had stopped before tripping the full travel limit switches. The program is very simple but I have a problem with the speed of the program. The door runs on for several hundred milliseconds after the limit switched are made. If I bypass the encoder code [pulse in] then the door stops instantly. So it appears as though the code to read the encoder and detect if there are no pulses is very slow. Did I write it wrong or is this normal?

Here is the code:

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2010-11-09 17:23
    Jim C. wrote: »
    I am using a BS1 to control a home built garage door opener. I went with a Stamp because I wanted to read a pulse encoder and determine if the door had stopped before tripping the full travel limit switches. The program is very simple but I have a problem with the speed of the program. The door runs on for several hundred milliseconds after the limit switched are made. If I bypass the encoder code [pulse in] then the door stops instantly. So it appears as though the code to read the encoder and detect if there are no pulses is very slow. Did I write it wrong or is this normal?

    Here is the code:
    '
    You have stated RPM = W3 for a SYMBOL,But You use W2 in Your code.(typo)
    '
    Try
    " SYMBOL RPM = W2 "
    '
    I would send W2 to the DEBUG window with out the MAX 590 and look at its value.

    I don't have a BS1 to try this out on,So its trial and error.
    '
    Hope this helps.
    '
    P.S.-Next time save Your code as a "txt" file. This is what the BSnxxx Stamp editor uses.This will make it easier for other's to take a quick look at Your code and give You some feed-back on it.
  • ercoerco Posts: 20,256
    edited 2010-11-10 14:38
    @$WMc%: Good call on W2/W3.

    @Jim: You are using PULSIN to read your encoder, which will give you the duration of a high pulse on pin7 IIRC. If your encoder isn't hooked up properly and working, then the Stamp will just sit there and wait up to 655 ms, per http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv21.pdf

    That may explain your overshoot. Make sure your encoder is getting a good signal into your stamp.

    And I don't need to tell you that DEBUG statements slow program execution to a crawl on a BS1.
  • Jim C.Jim C. Posts: 8
    edited 2010-11-21 18:25
    erco wrote: »
    @$WMc%: Good call on W2/W3.

    @Jim: You are using PULSIN to read your encoder, which will give you the duration of a high pulse on pin7 IIRC. If your encoder isn't hooked up properly and working, then the Stamp will just sit there and wait up to 655 ms, per http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv21.pdf

    That may explain your overshoot. Make sure your encoder is getting a good signal into your stamp.

    And I don't need to tell you that DEBUG statements slow program execution to a crawl on a BS1.

    Well you put me in the correct direction. The problem was the pulses going to the BS-1. I put a scope on them and they were erratic. So I cleaned them up and now all is well. I would guess that the Stamp just went out to la la land with the erratic pulse train. Thanks for the tip.
    Jim
Sign In or Register to comment.