Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Help with Teensy 3.2 and a 3-way switch to read on a single analog pin

  1. #1

    Help with Teensy 3.2 and a 3-way switch to read on a single analog pin

    So as a follow on from my last help request here, I am having another issue.
    Not really sure if it's separate or was the actual cause of my last post or not.

    Anyway, I have 2x 3-way switches, 1MD6T1B5M1QE (DPDT, on-on-on), labelled as 3W-L and 3W-R on my schematic.
    Click image for larger version. 

Name:	Teensy RC 2.2 Schemtic.jpg 
Views:	25 
Size:	131.4 KB 
ID:	12478 Click image for larger version. 

Name:	Switch closeup.JPG 
Views:	21 
Size:	49.0 KB 
ID:	12474 Click image for larger version. 

Name:	3 way switch function.JPG 
Views:	24 
Size:	70.4 KB 
ID:	12476 Name:  3 way switch mechanics.JPG
Views: 107
Size:  14.1 KB
    Here's a pic of my schematic---------------------close up of the switch pins on my pcb----------switch functions highlighted in yellow-----------Switch geometry
    here's is a link to the live schematic

    I have the pins connected like this:
    Click image for larger version. 

Name:	Switch wiring.JPG 
Views:	22 
Size:	45.0 KB 
ID:	12477

    L-3.3 comes from 3.3V1 on the teensy.
    When I have the switch in the position 1, I get 0V out on my PCB signal wire coming out of my switch going into teensy (to read as analog)
    The problem is that when I move the switch to another position, my 5V voltage regulator drops to 1.3V, causing my teensy to stop working.

    In position 2, the analog voltage signal that goes into the teensy is 0.27V
    In position 3, the analog voltage signal that goes into the teensy is 0.13V

    As soon as I put the switch back to position 1, everything functions correctly again.

    So I know I've done something wrong, but im not sure what. Hoping somebody might be able to point me in the right direction

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,818
    Not making a lot of sense of your drawing - description suggests you are grounding the supply in one switch position, but if trying to get three states out of a switch I'd wire-

    3.3V
    1.7V from a voltage divider
    0v

    Alternatively enable the teensy pin pullup and leave one switch contact open, on with ~10k to gnd and on on gnd, same deal with the other three contacts being tied together and connected to the teensy.

    to one row of switch contacts and tie the other three together and send them off to the teensy read pin. So you have three voltages, and which one gets connected to the teensy depends on the switch position - also check if the switch is make before break since that can be all sorts of fun if pairs can get connected during switch movement.

  3. #3
    On my PCB, I have 2 10k resistors for my voltage divider. The switch is just wired directly to the PCB, as shown on the sketch.
    I do believe I've grounded something, just can't figure out where. Im sure it has something to do with the way im wiring up the switch.

    The way I designed it was to get the 3.3, 1.7, and 0V. It just isn't working that way.

    Quote Originally Posted by GremlinWrangler View Post
    Not making a lot of sense of your drawing - description suggests you are grounding the supply in one switch position, but if trying to get three states out of a switch I'd wire-

    3.3V
    1.7V from a voltage divider
    0v

    Alternatively enable the teensy pin pullup and leave one switch contact open, on with ~10k to gnd and on on gnd, same deal with the other three contacts being tied together and connected to the teensy.

    to one row of switch contacts and tie the other three together and send them off to the teensy read pin. So you have three voltages, and which one gets connected to the teensy depends on the switch position - also check if the switch is make before break since that can be all sorts of fun if pairs can get connected during switch movement.

  4. #4
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,818
    What is supposed to happen when the switch is in the middle position. Looking at the layout as drawn, both 2 and 5 are both connected to Gnd, and if switch is set to connect 3 to 2 that closes a path from +v to gnd.

  5. #5
    Quote Originally Posted by GremlinWrangler View Post
    What is supposed to happen when the switch is in the middle position. Looking at the layout as drawn, both 2 and 5 are both connected to Gnd, and if switch is set to connect 3 to 2 that closes a path from +v to gnd.
    Would you have a suggestion on how to wire the switch up to have a Vin, GND, signal. With the signal wire to read 0V, 1.65, 3.3V in the 3 positions of the switch?
    This picture is what I currently have.
    Click image for larger version. 

Name:	3 way switch wiring.jpg 
Views:	14 
Size:	41.2 KB 
ID:	12484
    The 3 pictures on the left are how the switch works. The picture on the right shows how I have it wired up.

    I also have the same switch in an on-of-on variation too if that helps.

  6. #6
    I think I know what I've done wrong.
    I need to swap the signal and ground wires around.

  7. #7
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,818
    Yes, drawn out that way it's much clearer, and swapping gnd and signal around will do what you want.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •