chrisfitech
Posts: 1
Joined: Fri Jun 27, 2014 10:00 am

PiFace Pi4J wrong inputs state when setting values

Fri Jun 27, 2014 1:04 pm

Hello everybody.

I'm currently in a middle of one project based on Raspberry Pi with PiFace board. I'm using Java 8 with Java Fx and Pi4J library.

I think I've found a bug in Pi4J library. Let me describe how it look like.
I have Pi4J board connected like this:

Image
Scenario:

Step 1. For these first two inputs which are shown at the picture above i'm setting from another device low state, constant zero, something around 0,47 volt.

Step 2. With the code:

Code: Select all

piface = new PiFaceDevice(PiFace.DEFAULT_ADDRESS, Spi.CHANNEL_0);
SwitchState switchState = piface.getSwitch(PiFaceSwitch.S1).getState();
I'm getting state "on" which means "low" for both of these two inputs. That's correct.

Step 3. Now, I send constant high state for both inputs, something around 3,15 volt.

Step 4. With the code from step 2 i'm checking again what state have both inputs. First and the second have OFF state which is correct state.

Step 5. Finally, I'm sending low state for both of them at the same time. There's minimal difference between 'falling down' these states so they are not perfectly synchronized.
These two pictures taken from oscilloscope represents what i've said.
Blue line - input 1
Orange line - input 2
In that case orange line 'falls down' slower.

Pi4J library informs:
input 1 state: low (ok)
input 2 state: high (bad)

Image




In that case blue line 'falls down' slower.

Pi4J library informs:
input 1 state: low (bad)
input 2 state: high (ok)

Image


Anyway...oscilloscope shows now low state (ON) for both. Electronic gauge also shows voltage for low state (0,47) for both, but not library. Library shows low state only for just one of them. Low state gets switch which 'falled down' little faster than the other one. The second switch stays with high (OFF) state which is wrong state.
Oscilloscope shows correct values, electronic gauge shows also correct voltages but library don't.

I've checked this state with:

Code: Select all

piface.getSwitch(PiFaceSwitch.S1).getState();
and with this:

Code: Select all

piface.getInputPin(0).getState();
p.s. Situation in step 5 will not happen (both inputs will have correct state) when i've set low state for first input and after that i've set low state for the second one. However, it's important to me to have both of them set at the same time.

I hope that it's not serious (or even) not a bug but maybe i'm not doing (checking) something.

Please, help.

Best regards,
Chris.

Return to “Java”