Shop OBEX P1 Docs P2 Docs Learn Events
Can a dip switch be used as a configuration tool with the bs2sx? — Parallax Forums

Can a dip switch be used as a configuration tool with the bs2sx?

beazleybubbeazleybub Posts: 102
edited 2008-03-04 14:45 in BASIC Stamp
Hi everybody,

I am totally green here so please bear with me if I don't seem to make any sense.

I am developing a circuit that controlls two relays sequentially back and fourth and would really like to set up a dip switch that would allow different configurations of the relays firing order.

A·dip switch would determine if relay one would fire before relay two and if the dip switch was set to a different setting then relay two would fire before relay one.

What I am trying to accomplish is actually a bit more complex than the example I have provided but I hope that I can set up a dip switch that would determine what order the code is executed within my program.

Dip setting one "fire one, two, one, two"
Dip setting two "fire two, one, one, two"
Dip setting three "fire one, two, two, one"

Do I make any sense here? Thanks in advance for any help or direction.

Post Edited (beazleybub) : 2/28/2008 8:26:13 AM GMT

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-02-28 08:51
    beazleybub -

    As you have it shown, there are four sets of two firing stations, will this always be the case?

    If not, how many sets of how many firing stations can there be?

    Although you may be able to use a DIP switch, that may not be the best answer to the problem. The answers you provide will help to determine that.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Genius is one percent inspiration and ninety-nine percent perspiration."

    Thomas Alva Edison
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2008-02-28 09:07
    Sure you can use a dip switch with one side either connected to ground or to +5. There are even little rotary HEX switches that give you 16 choices from 4 pins of the BasicStamp. Any BasicStamp could be used, just have the pins set as inputs and read them as a group.

    Thinking binary - 3 settings can be done with two pins and you have one left over state that is undefined.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PLEASE CONSIDER the following:

    Do you want a quickly operational black box solution or the knowledge included therein?······
    ···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • beazleybubbeazleybub Posts: 102
    edited 2008-02-28 17:47
    Bruce said...
    As you have it shown, there are four sets of two firing stations, will this always be the case?
    Bruce,

    In my example there are only two relays in which dip switches would determine the sequence that they would fire. I did not mean to be confusing about my question it was late and I was nearly passing out.tongue.gif

    What I really meant to ask was just simply can a dip switch be used to control specific routines?



    Kramer said...
    There are even little rotary HEX switches that give you 16 choices from 4 pins of the BasicStamp.

    Kramer,

    Thanks for your input as well but if I used one of those HEX switches I would be creating a monstersmilewinkgrin.gif

    If I connect one of the dip switches legs to ground and the other to an input leg of the interpreter and say I were to use three switches on three legs, how would I code the vars? Could you please give me a little example?

    Thank you both very much for your help and time.
    ·
  • AmaralAmaral Posts: 176
    edited 2008-02-28 18:15
    Beazleybub , dip switches is just single switches, just build a single bridge of resistors for keeping it safe of the state that they are set (high or Low) and monitor the input, using INPUT command, the variable can be a bit for each input, take a look at the Basic Stamp Manual they have it there.

    YES YOU CAN USE Dip Switches as confuguring input for any stamp.


    hope to help

    Amaral
  • beazleybubbeazleybub Posts: 102
    edited 2008-03-03 03:20
    I just wanted to thank everybody for their input on my questions.tongue.gif

    I successfully set up my dip switches ond got them to do as I wanted but I am sure that my code is brutal being that I am new at basic. Outside of html I an a total novice on the basic language so I am working on projects found in the "what is a microcontroller manual"

    I will be needing some coding help in the near future if you guys are willing to assist me.

    I do however have a couple of questions regarding the schematic between bs2 and bs2sx.

    I found the bs2 lite shematic showing the bare essentials for the eeprom and the interpreter showing how you can strip down some of the unnessessary components and can not seem to find the bs2sx lite schematic if one even exists for bs2sx. I found the standard bs2sx shematic and the pinouts look very similar if not the same so my question is·can I use the bs2 lite schematic to set up the bs2sx as a lite version and if so are there any differences? Thanks again! Your pal, Robert


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    What if there was nothing? Nothing is something!

    Post Edited (beazleybub) : 3/3/2008 3:30:07 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-03-03 17:22
    One trick I have used to add configuration DIP switches is to use a shift register (74HC165). Most projects I have done have included at least one SPI device so adding the shift register only required one additional I/O pin and gave me 8 inputs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2008-03-04 14:45
    Sorry I've been slow to reply. You would read three pins using INPUTas a group and then have a lookup table for %000, %001,%010, %011, %100, %101, %110, and %111,

    One way to get them into a group is to have an empty varable be a buffer that starts as %0000000. First. copy pin 1 to the buffer's bit.0, then copy pin 2 to buffer's bit.1, and finally copy pin 3 to buffer's bit.3. Then read the value of the buffer.

    Each value would associate with a different choice. While you have 8 maximun, some could be empty.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PLEASE CONSIDER the following:

    Do you want a quickly operational black box solution or the knowledge included therein?······
    ···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Sign In or Register to comment.