Shop OBEX P1 Docs P2 Docs Learn Events
Detect when Propeller Pin is grounded — Parallax Forums

Detect when Propeller Pin is grounded

Luis_PLuis_P Posts: 246
edited 2011-08-12 20:47 in Propeller 1
I have a 10K resitor connected to one of the Pins on the Propeller and a switch to close to ground. How can detect when the swich ground the resistor?

P19
\/\/\/\
\.
GND
10k switch

Comments

  • LeonLeon Posts: 7,620
    edited 2011-08-10 12:23
    The resistor should be pulling the pin up to 3.3V, with the switch grounding the pin when it is pressed.
  • Luis_PLuis_P Posts: 246
    edited 2011-08-10 12:54
    Leon wrote: »
    The resistor should be pulling the pin up to 3.3V, with the switch grounding the pin when it is pressed.

    Well that is my problem, the same switch is connected to another circuit, if I use +Voltage then I have problems. There is a way that not involved +3.3V ?
  • LeonLeon Posts: 7,620
    edited 2011-08-10 12:57
    Schematic?
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-08-10 13:14
    And where is the part of the other circuit you mentioned? That's the most important part for finding out what your possibilities are.
  • Luis_PLuis_P Posts: 246
    edited 2011-08-10 13:17
    Leon wrote: »
    Schematic?

    See Schematic. If I pull the resistor to +3.3V then my other unit has problemsSchem.bmp
  • TubularTubular Posts: 4,717
    edited 2011-08-10 13:28
    Luis_P, you could try Beau's recent "one pin sigma delta" and see how it goes. See thread here
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2011-08-10 13:38
    If mux-74 pin 1 is a high impedance input, then a charge-and-test could work.
    dira[[19]~~  ' make pin output high for a few µs to charge the gate & stray capacitance
    outa[19]~~
    dira[19]~   ' if switch is closed, the gate capacitance discharges
    IF ina[19] == 0
        ' switch is closed
    

    The gate capacitance can typically hold its charge for 10ms or more, provided there are no leakage paths.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-08-10 13:55
    I'd expect that a mux-74 with a high impedance does not really make sense if there are no other connections than the switch. Is pin 1 possibly having an internal pullup resistor?

    You still do not give the whole picture! What's the MUX-74? Do you have a datasheet? What's the supply voltage?
  • Luis_PLuis_P Posts: 246
    edited 2011-08-10 14:29
    MagIO2 wrote: »
    I'd expect that a mux-74 with a high impedance does not really make sense if there are no other connections than the switch. Is pin 1 possibly having an internal pullup resistor?

    You still do not give the whole picture! What's the MUX-74? Do you have a datasheet? What's the supply voltage?

    See new Schem. The MP3 tigger 3.3-5V, active low inputs with internal pull-ups connected to pins of MUX-74HC4067SMD when the resistor is grounded then play an MP3 file. Schem2.bmp
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-08-10 14:56
    At Sparkfun there is a schematic of the MP3 Trigger, so why don't you simply give a link instead of drawing your own version - which seems to be wrong. Pin 1 is used as output as far as I can see. Pins 2 -9 and 16-22 then have a 100 Ohm resistor each.

    What do you want to do with the propeller?

    What would make sense from my point of view is, read signals from PIN 1 together with PIN 10-14. This way you can find out which track has been selected.
  • Luis_PLuis_P Posts: 246
    edited 2011-08-10 15:06
    MagIO2 wrote: »
    At Sparkfun there is a schematic of the MP3 Trigger, so why don't you simply give a link instead of drawing your own version - which seems to be wrong. Pin 1 is used as output as far as I can see. Pins 2 -9 and 16-22 then have a 100 Ohm resistor each.

    What do you want to do with the propeller?

    What would make sense from my point of view is, read signals from PIN 1 together with PIN 10-14. This way you can find out which track has been selected.

    Ok calm down. I know is not pin 1 it just to give an idea of the circuit. I need the propeller detect when the triggers are pull to ground thats all.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-08-10 15:21
    I'm not upset, so why should I calm down???

    Most guys here are very much willing to help. But giving the right advice is much easier if the original post is of good quality. In your case we could have given some better help if you would have given a link to the real schematic and a description of what you want to do in the end. (Which is still not clear)

    Do you want to find out the state of all the triggers or are you only interested in one?

    Find out which of the 16 switches has been closed with only using 5 pins of the microcontroller is exactly the purpose of the 4067. The cypress microcontroller changes pins 10,11,13,14 periodically to address one of the switches. pin 1 together with the pullup of the cypress uC will then show you if it's closed or not.

    So, you can connect pin 1 with a propeller pin and if it goes low, you read pins 10-14 (also connected to the propeller) to find out which switch has been closed.
  • Luis_PLuis_P Posts: 246
    edited 2011-08-10 16:17
    If that involved to solder on the Mp3 trigger IC, I can't do it, I don't have that option.
    When any of the trigger pins is pull up to ground I want the propeller to detect and send a message to my ipod to play a video.
    I have no problem to communicate the propeller with the ipod so don't get into that...
    Gracias
  • desikodesiko Posts: 18
    edited 2011-08-10 19:33
    Hi, Luis

    Looking at the 4067 data sheet I think the mux is internally
    pulled up by a current source. If you connect the prop's ground
    to the mp3 trigger's ground and have the prop sensing pin set as an
    input I think you can just read the state. Zero means that
    switch is closed and one means open. Just don't connect to
    the grounded side of switch :smile:

    Good luck

    Desiko
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-08-10 20:56
    without an additional look at the datasheet i don't believe that an analog mux will add a pullup to the signal lines!

    Furthermore i believe that you can add a pullup on propeller side without any problems for the circuit and replace the resistor going to the switch with a wire - as long as you don't add a bug to your propeller program.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-08-10 21:07
    By the way ... are the switches included? Are the switches simple on/off pushbuttons or are they alternating switches? then you can connect the “input “of the switch with ground, one “output “ with the circuit and the other “output “ with a pullup and the propeller pin. You'd then receive an active high signal when the button is pushed.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-08-11 02:18
    as you want to detect the switch-state the propeller-IO-pin is configured as input and will draw only a very low current.

    So if you don't have the io-pin connected over the 10k-resistor what voltages do you measure at that point where the 10k-resistor is connected
    to the switch.

    Voltage if switch is is opened?
    Voltage if switch is closed?

    GND
    Switch---Y----100 Ohm
    mux74

    GND
    Voltagemeter----Y

    Do you have a possability to simulate closing the switch by bridging the two contacts of the switch through external wires?
    If yes please measure the current if you bridge the switche's contacts with the wires

    GND---X----Switch---Y----100 Ohm
    mux74
    X
    Amperemeter
    Y

    To state the obvoius:
    Did you connect the ground of the MP3-trigger with the ground of the propeller?

    keep the questions coming
    best regards

    Stefan
  • Luis_PLuis_P Posts: 246
    edited 2011-08-11 08:39
    desiko wrote: »
    Hi, Luis

    Looking at the 4067 data sheet I think the mux is internally
    pulled up by a current source. If you connect the prop's ground
    to the mp3 trigger's ground and have the prop sensing pin set as an
    input I think you can just read the state. Zero means that
    switch is closed and one means open. Just don't connect to
    the grounded side of switch :smile:

    Good luck

    Desiko

    I think I will try this. How do I read the state of a pin on the propeller again?
    A sensing pin is what I was looking for. If the normally open push button is pressed then the pin=0 if open pin=1.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-08-11 09:12
    Luis_P wrote: »
    I think I will try this. How do I read the state of a pin on the propeller again?...


    Luis,
    have a look here at entry #2:
    http://forums.parallax.com/showthread.php?133280-Please-Need-help-with-button&p=1021081&viewfull=1#post1021081
  • desikodesiko Posts: 18
    edited 2011-08-12 20:47
    Luis_P wrote: »
    I think I will try this. How do I read the state of a pin on the propeller again?
    A sensing pin is what I was looking for. If the normally open push button is pressed then the pin=0 if open pin=1.

    Hi, Luis

    If you have a Parallax Demo board here is a really simple piece of code to try.
    Pin 0 is the input. It's state will be echoed to the LED on P16.

    Hope you find it helpful,

    Desiko

    ''Test program: echo pin input state to output
    ''Pin assignments work for Parallax Demo Board
    ''LED on P16 will light based on logic state on P0
    
    CON
    
      _clkmode        = xtal1 + pll16x           ' Feedback and PLL multiplier
      _xinfreq        = 5_000_000                ' External oscillator = 5 MHz
    
    PUB myInputTest
    
        dira[0]  := 0                            ' make P0 an input
        dira[16] := 1                            ' make P16 an output
                                                 
        repeat
    
           outa[16] := ina[0]                    ' Echo P0 input to P16 ouput   
    
Sign In or Register to comment.