Shop OBEX P1 Docs P2 Docs Learn Events
controlling interference — Parallax Forums

controlling interference

mike_1234mike_1234 Posts: 21
edited 2005-12-01 17:25 in BASIC Stamp
Does anyone have suggestions as to how to control emf fields?

My stamp has 13 inputs, (just reading if a switch is·high or low) is there anyway i can
prevent the other inputs from picking up the status of the other inputs

thanks

Mike

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-30 22:27
    Are you using pull-ups (active-low) or pull-downs (active-high) on your inputs?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • mike_1234mike_1234 Posts: 21
    edited 2005-11-30 23:35
    active high
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-01 00:33
    Then on each of your inputs you should have a 10K resistor between the I/O pin and ground. Do you?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • mike_1234mike_1234 Posts: 21
    edited 2005-12-01 01:06
    yuppers
  • mike_1234mike_1234 Posts: 21
    edited 2005-12-01 01:07
    in the manual if you look at the button function i have my circuit exactly how they show it
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-01 01:42
    Can you post your code?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • mike_1234mike_1234 Posts: 21
    edited 2005-12-01 16:08
    sure.. also can you tell me how to control my switch bounce

    '{$STAMP BS2pe}
    '{$PBASIC 2.5}

    RD_E2PROM_Switch PIN 14

    Input_Pins_0_13 VAR INS


    Value_To_Store VAR Nib
    Stored_Value VAR Nib
    WR_E2PROM_Addr VAR Word
    RD_E2PROM_Addr VAR Word

    Initialize:
    WR_E2PROM_Addr = 0
    INPUT RD_E2PROM_Switch

    DO
    GOSUB Chk_Inputs
    LOOP
    END

    Chk_Inputs:
    PAUSE 100
    IF (Input_Pins_0_13 <> 0) THEN GOSUB Convert_Decimal '<> means NOT EQUAL
    IF (RD_E2PROM_Switch = 1) THEN GOSUB RD_E2PROM
    RETURN

    Convert_Decimal:
    IF (Input_Pins_0_13 = 1) THEN
    Value_To_Store = 0
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 2) THEN
    Value_To_Store = 1
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 4) THEN
    Value_To_Store = 2
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 8) THEN
    Value_To_Store = 3
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 16) THEN
    Value_To_Store = 4
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 32) THEN
    Value_To_Store = 5
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 64) THEN
    Value_To_Store = 6
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 128 ) THEN
    Value_To_Store = 7
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 256) THEN
    Value_To_Store = 8
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 512) THEN
    Value_To_Store = 9
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 1024) THEN
    Value_To_Store = 10
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 2048) THEN
    Value_To_Store = 11
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 4096) THEN
    Value_To_Store = 12
    GOSUB WR_E2PROM
    ENDIF

    IF (Input_Pins_0_13 = 8192) THEN
    Value_To_Store = 13
    GOSUB WR_E2PROM
    ENDIF
    RETURN


    WR_E2PROM:
    STORE 8
    WRITE WR_E2PROM_Addr, Value_To_Store
    WR_E2PROM_ADDR = WR_E2PROM_Addr + 1
    RETURN

    RD_E2PROM:
    STORE 8
    DEBUG "E2PROM CONTENTS", CR, CR
    FOR RD_E2PROM_Addr = 0 TO WR_E2PROM_Addr
    READ RD_E2PROM_Addr, Stored_Value
    GOSUB Send_To_Display
    NEXT
    RETURN

    Send_To_Display:
    DEBUG "Location ", DEC RD_E2PROM_Addr, " = ", DEC Stored_Value, CR
    RETURN
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-01 16:50
    The problem is that you "Chk_Inputs" subroutine does no debouncing -- it's probably contact bounce that you're having troubles with. Download our "StampWorks" book; it has a project on scanning and debouncing multiple inputs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • mike_1234mike_1234 Posts: 21
    edited 2005-12-01 17:19
    ok thanks
  • Vern GranerVern Graner Posts: 337
    edited 2005-12-01 17:25
    mike_1234 said...
    Does anyone have suggestions as to how to control emf fields? My stamp has 13 inputs, (just reading if a switch is high or low) is there anyway i can
    prevent the other inputs from picking up the status of the other inputs?
    There's some good discussion about how to reduce false triggers (usually contact bounce related) in this thread in the ParallaxEFX forum:

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

    And also some information on maximum switch distance and some alternative switch strategies in this thread:

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

    Hope that helps!

    smile.gif

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    
Sign In or Register to comment.