Skip to content

Intermittent incorrect button value latch #4

@scm6079

Description

@scm6079

I'm experiencing an interesting problem with this library -- in testing I'm receiving intermittent invalid readings of input states showing the first input button continuously depressed when it is not. This is similar to what I would expect in a hardware problem of a floating input (e.g. input resistors NOT pulling the input high). HOWEVER, this only occurs with the C library, not the python library leading me to believe this is a software issue not an issue with the PiFace. No hardware is attached to the piface digital - this is using it "out of the box".

I put together a couple very simple tests to confirm. You must rapidly depress and release the first input button very rapidly to observe the failure (sometimes many dozen attempts are necessary for a failure).

Sample Python Control Test Case (FUNCTIONAL, no problems)

#!/usr/bin/env python3
from time import sleep
import pifacedigitalio
pifacedigitalio.init()
pfd = pifacedigitalio.PiFaceDigital()

while(True):
        print(pfd.input_pins[0].value)
        sleep(.01)

Sample C Failure Case

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "pifacedigital.h"

int main( int argc, char *argv[] )
{
    uint8_t inputs;
    int hw_addr = 0;

    pifacedigital_open(hw_addr);

    while(1) {
        inputs = pifacedigital_read_reg(0x11, hw_addr );
        printf("Inputs: 0x%x\n", inputs);
        usleep(10000);
    }

    pifacedigital_close(hw_addr);
}

Once failed, you will observe an output stuck at 0xfe instead of 0xff.

Inputs: 0xfe
Inputs: 0xfe
Inputs: 0xfe
...

The issue does not clear - even after waiting - but will clear with an additional button press. I did reproduce the issue with an externally wired momentary push button switch as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions