Shop OBEX P1 Docs P2 Docs Learn Events
Okay... Perhaps My Dumbest Question Ever In The Forums — Parallax Forums

Okay... Perhaps My Dumbest Question Ever In The Forums

idbruceidbruce Posts: 6,197
edited 2014-06-28 04:03 in Propeller 1
As I was sitting here designing a layout for a Proto Board, I reached a point where I got stuck. In my defense, I don't believe I have done this type of hookup before, and if I have, I certainly don't remember :)

Anyhow here goes...... Please hold the laughter :)

In another thread, there was a somewhat lengthy discussion about limit switches for various axes, and the best way to wire it up. The best scheme I heard was to wire all limit switches (normally closed) in series and run it to a single pin. Sounded great! That was until I started to design the wiring. Normally open switches are no problem for me, but I don't believe I have ever wired up a normally closed switch to the Propeller. Additionally, I was reading something Peter said about taking VDD off the board for switches, where it could possibly pick up noise or lead to shorts, and I agree. I would prefer to detect if VSS becomes open.

Could someone please provide a schematic for a normally closed switch connected to an IO pin that detects an open ground? Resistor values would also be helpful. Any help will be gratefully appreciated.

Sorry to ask such a stupid question :)
«1

Comments

  • Bill HenningBill Henning Posts: 6,445
    edited 2014-05-23 18:55
    Prop pin, pulled high with say 10k resistor

    daisy chain all the normally closed switches, one end of the chan to GND, the other to the propeller pin (that was pulled high above)

    done :)

    if you are really paranoid, and worried you might program the pin high, add a resistor - say 4k7 - between the daisy chain and the prop pin.
    idbruce wrote: »
    As I was sitting here designing a layout for a Proto Board, I reached a point where I got stuck. In my defense, I don't believe I have done this type of hookup before, and if I have, I certainly don't remember :)

    Anyhow here goes...... Please hold the laughter :)

    In another thread, there was a somewhat lengthy discussion about limit switches for various axes, and the best way to wire it up. The best scheme I heard was to wire all limit switches (normally closed) in series and run it to a single pin. Sounded great! That was until I started to design the wiring. Normally open switches are no problem for me, but I don't believe I have ever wired up a normally closed switch to the Propeller. Additionally, I was reading something Peter said about taking VDD off the board for switches, where it could possibly pick up noise or lead to shorts, and I agree. I would prefer to detect if VSS becomes open.

    Could someone please provide a schematic for a normally closed switch connected to an IO pin that detects an open ground? Resistor values would also be helpful. Any help will be gratefully appreciated.

    Sorry to ask such a stupid question :)
  • jmgjmg Posts: 15,173
    edited 2014-05-23 19:09
    Prop pin, pulled high with say 10k resistor

    ...

    if you are really paranoid, and worried you might program the pin high, add a resistor - say 4k7 - between the daisy chain and the prop pin.
    I would fine tune the values to have Pullup > 4x the series total, (gives better Vil and more noise margin), and add that if you are really, really paranoid (ie a good designer) you would add two resistors, one to each side of the external daisy chain sense wiring.
    That tolerates an external short to (almost) anything and reduces antenna effects.
    Values might be 2k2 , 2k2 and 22k, or 3k3, 3k3 and 47k
  • idbruceidbruce Posts: 6,197
    edited 2014-05-23 21:11
    @Bill and jmg

    Thank you guys so much for such a descriptive answer. Hopefully, I will get it right, but sometimes I can be a numbskull. Okay I think this is the circuitry you both described.

    openground.jpg
    381 x 328 - 9K
  • Bill HenningBill Henning Posts: 6,445
    edited 2014-05-23 21:22
    You are most welcome.

    In the top diaram, move the pullup to the other side of the 4k7 resistor

    sorry, posting from a linux box without eagle on it.
    idbruce wrote: »
    @Bill and jmg

    Thank you guys so much for such a descriptive answer. Hopefully, I will get it right, but sometimes I can be a numbskull. Okay I think this is the circuitry you both described.

    openground.jpg
  • idbruceidbruce Posts: 6,197
    edited 2014-05-23 21:51
    Very cool.


    Thanks again Bill
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-05-23 22:36
    If it's always an input you can put a very large value resistor in series with the Prop and the connector, even 100K is no problem at all. From the connector use a pull-up of around a few K or so, enough to generate a "wetting current" of around a few milliamps for the switches. Use a small 0.1uF cap across the connector input to ground for noise and this also provides a tiny bit more wetting current for when the contacts close again. The pullup can easily go to a much higher voltage as the Prop is very well protected with the 100K and RC delay effects are inconsequential.


    prop ----100k
    connector
    switch
    switch
    ground
    +V
    2K2
    |
    0.1uf
    ground

  • frank freedmanfrank freedman Posts: 1,983
    edited 2014-05-23 22:55
    You could always rip off GE CT table safety switches. They have about 5K across the switch and circuitry to detect the impedance. If the switch circuit fails, it can be detected. If a switch closes, it can be detected.as a collision. Takes a bit more circuitry. You might be able to find more detail how they did it if you download a VCT or HD 750 CT service manual and look at the block diagrams. Uses two comparators to detect the presence of the impedance and one to "see" the switches. Then buffer with the appropriate logic outputs.
  • jmgjmg Posts: 15,173
    edited 2014-05-23 23:44
    Use a small 0.1uF cap across the connector input to ground for noise and this also provides a tiny bit more wetting current for when the contacts close again.

    Wetting current is a good idea, but a cap directly across a switch is not a good idea, as the high peaks can damage the contacts.
    A Cap + resistor to limit to say 10mA peak (330 Ohms) is a good idea.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-05-24 00:04
    Well, I still think there might be other than purely High/Low logic for the limit switches since it seems that you will have extra empty ADC inputs to an MCP3208.

    If you provide a resistance ladder, any switch closure could pull to ground and just one ADC pin might handle telling you exactly which limit switch has been triggered.

    The advantages with this are..

    1. Hall effect switches are open collector... so they naturally pull to ground
    2. An all clear is a Highest voltage state, which will only occur if the system is right.
    3. Frees up Propeller i/o pins for other things.

    The disadvantage might be...

    1. Using the ADC via SPI is a bit slower in responding to actual events than a pure logic High/Low.. more code has to be run to evaluate the condition.

    +++++++++++++++++++++++
    Putting all limit switches in a series that breaks the circuit, won't tell you which limit was hit.

    You can similarly aggregate all open collector sensors, but they won't tell which limit was hit.. either.

    So it is a question of the value of detailed information that decides the approach.

    Using the ADC input and a resistor ladder will provide you all the detail without individual i/o pins or providing another chip (such as an 8 to 3 multiplexer or a parallel to serial shift register).
  • edited 2014-05-24 00:17
    idbruce wrote: »
    @Bill and jmg

    Thank you guys so much for such a descriptive answer. Hopefully, I will get it right, but sometimes I can be a numbskull. Okay I think this is the circuitry you both described.

    openground.jpg

    That circuit will be disabled if any of the switch wire inadvertently becomes grounded. Better to send the signal through all the switches and then back to the sense pin. A low at the sense pin will indicate an open switch, a broken sense wire or a grounded sense wire. Use a 100k pull down at the sense pin.

    Sandy
  • idbruceidbruce Posts: 6,197
    edited 2014-05-24 04:40
    First off.... Thank you all for your kind and informative responses.... and for withholding your laughter :)

    It seems that another a variable has been thrown into the mix.... The connector(s).

    I suppose it would have been wise to include an image and describe my plan a little more in detail. So without further delay, I am now including an image, along with the plan. It is as follows:
    • Each axis will have a normally closed switch, with two wires going back to the Proto Board, and connected to a two pin header.
    • Altogether, there will be three limit switches utilized for X, Y, and Z axes.
    • Additionally, a normally closed E-Stop switch will also be wired in series with the three forementioned limit switches, which also has two wires going back to the Proto Board, and connected to a two pin header.
    • Making a total of four normally closed switches, all connected to the Proto Board, by two pin headers.
    • The length of the harness for each of these switches could range anywhere between (at least for my machine) 18 - 36 inches. However, I will be providing all the details for my plan as open source, so if anyone follows my lead, their harnesses may be much longer or shorter.
    After reading the information provided by Peter Jakacki in another thread, as well as the information provided in the contactor thread, with problems pertaining to glitches, I am certainly concerned about antenna effects and shorts, both for me and anyone that may follow my lead.

    In the image below, you will notice five headers, (1) 13 pin header and (4) 2 pin headers. The 13 pin header is for a Propeller Memory Card, and of course the remaining (4) 2 pin headers are for connecting the three limit swithes and the E-Stop.

    As far as knowing which limit switch was tripped, for small machines, I think this should be readily apparent or at least can be easily determined from examining the machine after a shut down. However, I do want the open circuit to be realized as quickly as possible, so this series of switches will be tied directly to an input pin and monitored by a cog.

    Okay, so now you all know my full intentions, and I apologize for not initially describing my plan in more detail.

    Anyhow, I thank you all so much for your time and input.

    Bruce

    attempt2.jpg
    884 x 675 - 246K
  • D.PD.P Posts: 790
    edited 2014-05-24 09:50
    idbruce wrote: »
    First off.... Thank you all for your kind and informative responses.... and for withholding your laughter :)

    It seems that another a variable has been thrown into the mix.... The connector(s).

    I suppose it would have been wise to include an image and describe my plan a little more in detail. So without further delay, I am now including an image, along with the plan. It is as follows:
    • Each axis will have a normally closed switch, with two wires going back to the Proto Board, and connected to a two pin header.
    • Altogether, there will be three limit switches utilized for X, Y, and Z axes.
    • Additionally, a normally closed E-Stop switch will also be wired in series with the three forementioned limit switches, which also has two wires going back to the Proto Board, and connected to a two pin header.
    • Making a total of four normally closed switches, all connected to the Proto Board, by two pin headers.
    • The length of the harness for each of these switches could range anywhere between (at least for my machine) 18 - 36 inches. However, I will be providing all the details for my plan as open source, so if anyone follows my lead, their harnesses may be much longer or shorter.
    After reading the information provided by Peter Jakacki in another thread, as well as the information provided in the contactor thread, with problems pertaining to glitches, I am certainly concerned about antenna effects and shorts, both for me and anyone that may follow my lead.

    In the image below, you will notice five headers, (1) 13 pin header and (4) 2 pin headers. The 13 pin header is for a Propeller Memory Card, and of course the remaining (4) 2 pin headers are for connecting the three limit swithes and the E-Stop.

    As far as knowing which limit switch was tripped, for small machines, I think this should be readily apparent or at least can be easily determined from examining the machine after a shut down. However, I do want the open circuit to be realized as quickly as possible, so this series of switches will be tied directly to an input pin and monitored by a cog.

    Okay, so now you all know my full intentions, and I apologize for not initially describing my plan in more detail.

    Anyhow, I thank you all so much for your time and input.

    Bruce

    attempt2.jpg

    All the printers I have had experience with have independent limit switches. This allows for "precision" homing for each axis with out the "bump the switch and backoff to home" irregularities. This approach will not work for the Z axis: if you home the Z axis (printer head) then backoff say a few mills above the print deck so the other axis can bump their switches to home themselves (each backing off in turn to close the daisy chain) then as soon as you home the Z axis again to start printing its limit switch is open. Sure you could code the firmware around this but what a mess. I think the MCP23X08/17 GPIO Expanders proposed above will save your design the needed pins so you could have a pin dedicated to each limit switch. Now I only have two years experience with 3 hand build printers and 3 different firmwares so I may be wrong but none of these setups have daisy chained limit switches.

    Replicate/learn/adapt/share from what has been done, get it working, then optimize is my approach.

    Happy to help when the coding in FORTH begins :)
  • idbruceidbruce Posts: 6,197
    edited 2014-05-24 11:06
    D.P.

    The layout I am working on, pertains to standard CNC, as well as 3D printing. The limit switches refered to in this post pertain to over-travel protection devices and will not be used for homing any axis. The layout will also have provisions for (4) normally open switches to be used for homing the axes, with each homing switch going to a seperate channel of an ADC.
  • idbruceidbruce Posts: 6,197
    edited 2014-06-27 16:34
    Previous discussion pertained to the detection of open ground from normally closed limit switches, however the user interface is comprised entirely of tact switches, which are of course 99.99% normally open. Although not standard by any means, I also want to use a tact switch as an E-Stop and as part of the user interface.

    In the illustration below, I have added more circuitry to the previously discussed circuitry. My question is, with the added circuitry, will the pressing of the tact switch act as an open ground to the Propeller, or is this illustration just garbage?

    Tact Open Ground.jpg
    220 x 304 - 9K
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2014-06-27 19:24
    When the switch is open, the IOpin is at about 1/2 of VDD.
    When the switch is closed, the IOpin is at about 90% of VDD.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-06-27 19:54
    idbruce wrote: »
    Previous discussion pertained to the detection of open ground from normally closed limit switches, however the user interface is comprised entirely of tact switches, which are of course 99.99% normally open. Although not standard by any means, I also want to use a tact switch as an E-Stop and as part of the user interface.

    In the illustration below, I have added more circuitry to the previously discussed circuitry. My question is, with the added circuitry, will the pressing of the tact switch act as an open ground to the Propeller, or is this illustration just garbage?

    Tact Open Ground.jpg

    The whole point of a E-stop is that when it fails it stops so there is no advantage in taking an N.O. switch and wiring it to VDD instead of ground in an overly complicated way. Now put a cap across the switch to ground so you can at least detect that there is a connection there so that you e-stop when there is no RC charge time or stop when the input is low.

    I/O
    R
    to switch and cap in parallel
    > gnd

    Or even just pulse it high long enough to fully charge it then a very short pulse low just before you read it while do the trick.
  • idbruceidbruce Posts: 6,197
    edited 2014-06-27 21:09
    Peter

    I did not convey my situation properly. I have one pin assigned to monitor four limit switches, which are normally closed, and one E-Stop, but I want the E-Stop to be a tact switch, which is normally open.

    The following schematic should give you a better idea of what I am attempting to achieve, but I am sure it is not correct.

    New Tact Open Ground.jpg
    620 x 412 - 17K
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-06-27 21:14
    idbruce wrote: »
    Peter

    I did not convey my situation properly. I have one pin assigned to monitor four limit switches, which are normally closed, and one E-Stop, but I want the E-Stop to be a tact switch, which is normally open.

    The following schematic should give you a better idea of what I am attempting to achieve, but I am sure it is not correct.


    It seems wrong, so without the diagram or taking restrictions into account what is it you that really want to do?
    In the meantime I will see if I can glean your intent from your postings.
  • idbruceidbruce Posts: 6,197
    edited 2014-06-27 21:17
    I want to detect an open ground from any of the five switches
  • idbruceidbruce Posts: 6,197
    edited 2014-06-27 21:19
    And.... R3 and R4 are basically carved in stone
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-06-27 21:22
    idbruce wrote: »
    I want to detect an open ground from any of the five switches

    I see, you need to override the limit switches, then perhaps the circuit will do. NO, why have a pull up that doesn't result in a clear high/low?

    How about:
    I/O
    10K
    N1
    1K
    limit----limit
    limit----limit----gnd
    N1
    10K----VDD
    N1----estop---VDD

    EDIT: the 10K can be pretty much any limit value so the one you have is fine and the pullup you have is fine too, same as N1---10K.
  • idbruceidbruce Posts: 6,197
    edited 2014-06-27 21:26
    Peter

    I will need to study your notes, but here is another illustration to show my predicament

    PPB with tact header.jpg
    884 x 675 - 231K
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-06-27 21:32
    idbruce wrote: »
    Peter

    I will need to study your notes, but here is another illustration to show my predicament

    PPB with tact header.jpg

    But as I mentioned you can leave your 2 resistors as they are and the limit switches pull the pin to ground through a 1K resistor while the estop pulls the pin up to VDD directly. So you only need a 1K which is to limit the estop condition current, that's all.

    EDIT: I can't see how your configuration would be set in stone as you say, even on a pcb it wouldn't really be, less so on a proto board.
  • idbruceidbruce Posts: 6,197
    edited 2014-06-27 21:36
    Okay, maybe not set in stone :) I was just tying to avoid touching the proto board with a solder sucker. :)

    I would assume N1 means Net 1.

    Anyhow Peter, thank you very much for taking the time to help me.
  • kwinnkwinn Posts: 8,697
    edited 2014-06-27 21:36
    RE: I want to detect an open ground from any of the five switches

    Not possible since S1 is connected to Vdd. It would always have an open ground.

    With S1 open and and S2-S5 closed you would have about 52% of Vdd on the input pin. If any one of the S2-S5 switches were open it would be 100% of Vdd.

    With S2 closed you would have 100% of Vdd on the pin. All 5 have to be in series to detect an open from any one of them.

    What are you trying to accomplish?
  • idbruceidbruce Posts: 6,197
    edited 2014-06-27 21:45
    What are you trying to accomplish?

    I am setting up a CNC controller.

    The limit switches would detect an overtravel condition and make the machine stop. NC switches

    The E-stop switch would detect an emergency situation and make the machine stop. NO tact switch, part of the user interface.

    If I could find a NC through hole tact switch, this would not be a problem.
  • kwinnkwinn Posts: 8,697
    edited 2014-06-27 22:10
    Do you need to identify which switch is closed?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-06-27 23:32
    So you want two purposes?
    A. detect a switch change condition
    B. detect an open ground condition

    Is that right?

    I suppose that you could use a normally closed switch.
    Have the circuit be grounded at startup through the switch, and when either the switch opens or the ground is broken, the Propeller pin cold go high with a pull-up resistor.

    It seems like using the normally open switch is getting in your way. You could even have all five switches in Paralllel (not series) if you wanted to just use one Propeller i/o pin for all of them.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-06-28 02:35
    idbruce wrote: »
    I am setting up a CNC controller.

    The limit switches would detect an overtravel condition and make the machine stop. NC switches

    The E-stop switch would detect an emergency situation and make the machine stop. NO tact switch, part of the user interface.

    If I could find a NC through hole tact switch, this would not be a problem.


    I didn't think there was a problem at all with what you asked for with 4 NC limit switches in series to ground and the NO E-stop to VDD but if you need a real schematic rather than a description then here it is:

    Screenshot from 2014-06-28 19:31:40.png

    The limit switches will normally pull the I/O to ground or to 1/11 of VDD (same diff) but E-stop when it is pressed will always force the I/O to VDD as will any limit switch that opens because of R2 pullup.
  • idbruceidbruce Posts: 6,197
    edited 2014-06-28 04:03
    @Peter - There are times when it is difficult to express appreciation for the help received in the forum, and the written words of "thank you" just don't seem adequate. This would be one of those times. Words cannot describe the appreciation that I have for your assistance in this situation, but thank you very much. I have not yet learned the language of electronic "typese", so schematics are always appreciated :) By the way, did N1 signify Net 1?

    @kwinn
    Do you need to identify which switch is closed?

    To me, the most important thing is to stop the machine, and the cause can later be determined by examining the machine.

    @Loopy Byteloose
    So you want two purposes?
    A. detect a switch change condition
    B. detect an open ground condition

    Is that right?
    That is correct.

    It seems like using the normally open switch is getting in your way.
    Several hours worth of delay and headache. I could not wrap my brain around this problem. The normally open switch was not my original intention, but an after thought. The E-Stop was originally going to be a simple normally closed switch, until I started toying with the user interface, and wanting to have all similar buttons in one location.

    Yes, the NO switch was getting in the way.
Sign In or Register to comment.