Shop OBEX P1 Docs P2 Docs Learn Events
Maintained input — Parallax Forums

Maintained input

StarManStarMan Posts: 306
edited 2004-11-12 02:09 in BASIC Stamp
Hi,

This is my first post.· I'm very new to this.· I'm a mechanical engineer with very little electronics experience.

I would like to build a custom board with a 24 pin socket to accept a BS2.· After programming the BS2 I will install it on the board and ship it to the end user.· I want to give the end user a choice of four pause times, one of which·will be contained within a DO LOOP.· The choice will be made once and then the board will be installed in a junction box in the wall.· The user will be able to change the pause times only by opening the junction box to access the board.· I plan to use either jumpers or DIP switches on pins·0·and 1.· Once the pause time is set in the program, the DO LOOP runs continuously until the power is turned off.

And now my question.· If I pull the two pins down with pulldown resistors and the user switches one or both of them high, will this fry anything?· Will there be a current draw the whole time the power is on or can I disconnect the pins with a command once the pause time is set.

I've done a fair amount of reading so far but perhaps I need to do more.· Please advise.

Thanks,

Chris Isaacson

·

Comments

  • BeanBean Posts: 8,129
    edited 2004-11-11 01:18
    Instead of connecting the switches to +, connect the switches to another pin (lets say pin 2).
    Normally make pin2 an input (so there will be no current even if the switches are closed).
    When you want to read the switches, make pin2 an output and set it high, then read the switches and set pin2 back to an input.

    Hope that makes sense.
    ············ 470Ohm···· · \
    Pin 0·----\/\/\/\--+--o ·\---- Pin 2
    ························|
    ······················· |-\/\/\/\-- GND
    ····························· 10K
    ············ 470Ohm···· · \
    Pin 1·----\/\/\/\--+--o ·\---- Pin 2
    ························|
    ······················· |-\/\/\/\-- GND
    ····························· 10K
    The 470 Ohms resistor is just for insurance.

    Bean.

    Post Edited (Bean) : 11/11/2004 1:22:24 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-11-11 01:22
    Chris (Nice name!),

    ·· You can easily do what you're asking...If you connect DIP switches to 2 pins, and have them pulled low with say, 10K resistors, and the DIP switches tied high, then when the DIP switches are open, the pins will read as 0, when closed, the pins will read as 1.· Using a little advanced thought, you could tied the switches to a pin group so that the port can be read as a variable.

    ·· For example, if you used P0 & P1 (You would have to pull P2 & P3 low for this to work) then you could use code like:

    Delay = INA
    

    Delay would equal 0, 1, 2 or 3, depending on the state of the 2 switches.· 4 possibilities.· Then you could assign your PAUSE variable based on the returned value.

    As for the pulldown resistors, they will draw very little current.· Will this help?



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • StarManStarMan Posts: 306
    edited 2004-11-11 02:55
    Wow!· Thanks for the quick reply.

    Clarification: Pins 2 thru 15 are being used.· If I had more pins I would use them as well but I don't want to upgrade to another BS.

    Any other suggestions that use only 2 pins?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-11 03:54
    You won't "fry" anything by putting 5 volts on a pin·unless you make that pin an output low. If you want to be really safe in your design (we all make programming errors), you can insert a 220-ohm resistor inline with the pin. We do this on our educational boards ... and it's pretty cheap insurance.

    The attached diagram is for an active-low input; just change the pull-up to a pull-down (to Vss) to make it active-high.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 11/11/2004 3:56:25 AM GMT
    290 x 284 - 4K
  • StarManStarMan Posts: 306
    edited 2004-11-11 05:34
    Thanks Jon.· I have enough to go with now.· I'll get comfortable with this on a breadboard before finalizing my design.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2004-11-11 05:49
    Starman -

    The two pin solution is to hang your 8 position (8 bit) DIP switch off of a 74HC165 8-bit parallel-in, serial-out shift register, and use SHIFTIN to grab all 8 bits with one command. Bring +5V to each element of the DIP switch thorugh an appropriate resistor, and the other side of the DIP switch goes directly to the input pins of the 74HC165. The serial pins (clock and data) of the 74HC165 go directly to the two Stamp pins you've chosen to use.

    If you find the need for more DIP switch input, there are also 16-bit (and more!) shift registers available.

    Regards,

    Bruce Bates
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-11-11 23:42
    Actually, the code example I provided will still work even if the other pins are in use by doing the following...
    Delay = INA & %0011
    

    This will mask the bits from P2 & P3 off the value.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • StarManStarMan Posts: 306
    edited 2004-11-12 01:47
    O.K.· I am way out of my comfort zone now.· I'll do some reading and experimenting and get back with you.

    Chris Isaacson
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-11-12 02:09
    I'm sorry, sometimes my explanations are not User Friendly despite my best attempts...Perhaps Jon or someone can translate this...sad.gif



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
Sign In or Register to comment.