Reading GPIO5

  • My module is a GM862-QUAD-PY Version 6.04.604


    I try to read the state of a switch, so far without success.


    My program sets the direction and than loops in reading the GPIO5 and writing to the serial port.
    ---------
    import GPIO
    import SER


    a = SER.set_speed(`9600`)
    c = GPIO.setIOdir(5, 0, 0)


    while 1:
    b = SER.send(`test `)
    a = GPIO.getIOvalue(5)
    if a != 0:
    b = SER.send(`on `)
    else:
    b = SER.send(`off `)
    d = SER.sendbyte(0x0d)
    d = SER.receive(10)
    b = SER.send(d)


    ---------


    I connected like this:
    +--- PWRCTL pin 6
    |
    +-+
    |R| 47 kOhm
    |1|
    +-+
    |
    +--- GPIO5 pin 5
    |
    o
    /
    o
    |
    +--- GND pin 1


    But I always get:
    test off


    No matter wether the switch is open or closed.


    Did I miss something?

  • In the EZ10-QUAD-PY_Prod_Descr_r0.pdf on page 14 there is an example mentioned:
    "Example input circuit (e.g. to detect a 12-V signal or a passive contact),"


    A passive contact is what I wanted to detect, but I can`t find the Example circiut.

  • Following script is workin correctly:


  • This is almost the same skript. Only my spaces where lost and I used SER.receive(10) to wait a second and you use MOD.sleep(10).
    Unfortunatly the same result.


    How about the circuit? How did you test it?


    When I change the skript to GPIO 4 I get alway "test on" (with GPIO 5 alway "test off").
    When I insert the plug for the firmware update and use GPIO 4 I also get "test on".


    Shall I send the TER-GX 110S back, to check if it is not broken?

  • With the same circuit as yours but 47K resistor to PWRCTL not to pin 6.
    Maybe your RJ11 plug/wiring isn`t make contact?

  • But I have a 47k resistor between pin 5 and pin 6.
    I think pin 6 is PWRCTL.


    How did you connect your resistor? Which pins?


    I also tried pin 2 and pin 6 for GPIO 4.

  • Pin 6 is not PWRCTL which is 2.8V but VMOD 3.8V. I worked on PCB to hook to PWRCTL but you are fine with a divider on VMOD.


    Again, be sure your plug is making good contact.

  • I use now GPIO 4 (pin 2).


    I have only a 47k resistor between pin 2 and pin 6 and GPIO.getIOvalue(4) gets 1.


    Than I take the plug for firmware update (pin 1 and pin 2 connected) and get also 1.


    When I use pin 5 instead of pin 2 (GPIO5) I get always 0.


    What is the expected result? What do you get?
    What pin is PWRCTL if not 6?

  • Ups, the last postings are overlapped.


    So my mistake is that pin 6 has 3.8V and not 2.8V?


    Can I use 2 resistors for that? Or something else?


    +--------- pin 6
    |
    R 28 kOhm
    |
    o
    /
    o
    |
    +--------- pin 5
    |
    R 10 kOhm
    |
    +--------- pin 1


    Why is pin 6 providing 3.8 V and not 2.8 V?

  • Better put the switch to short the lower resistor rather than break the upper branch. Your values for resistors are not good, it gives you 1V only on pin 5.


    Is 3.8V because this is what was intended to be - don`t know why are you thinking that is PWCTRL - is VMOD!

  • So it should be like this?
    +--------- pin 6
    |
    R 10 kOhm
    |
    +--------- pin 5
    |
    o
    /
    o
    |
    R 28 kOhm
    |
    +--------- pin 1


    I would like to know, if bigger or smaller resistors are recommended.
    Like 100k and 280k or 100 and 280. I know only about the relation of the two resistors.


    I guess 3.8V is for running LEDs not for exotic applications like mine :-)


    Maybe the idea was, it is simpler to lower the voltage than to raise it.

  • No, put the switch in parallel with the resistor from pin 5 to 1.
    With this combination of values you have 2.8V on pin 5 when switch is off, is ok.
    The current draw is 0.1mA, low enough.


    If you think this is exotic ...

  • Now I use the following circuit:
    +------- pin 6 VMOD
    |
    R 10 kOhm
    |
    +-+----- pin 2 GPIO4
    | |
    o |
    / R 28 kOhm
    o |
    | |
    +-+----- pin 1 GND


    (I don`t get the HRC Code "Code" working)



    But same result, always GPIO.getIOvalue(4) delivers 1.
    Even when I insert the firmware update plug. That should be low (pin1 and pin2 connected)?


    I opened the case, there are four jumper behind the AUX jack.
    When I turn the module so that the AUX jack is top right, the topmost jumper is the only one that is closed.
    Is this right?

  • A nice try, but no help. Thanks for the help.


    I called Round Solutions for a replacement, this will take 2 weeks but is fine for me.


    Again many thanks for your help byteworks and sorry for my bad humour, when things were not working.