-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Hello,
I am trying to read impulsions from input on AB Electronics IO PI Plus card.
Using ReadPort can take up to 45 milli seconds.
I need 2 ms to be able to count impulsions (this is coming from a liquid volume reader (debitmeter)).
I am trying on both rapsberry pi and bananapi. It seems a bit better on raspberry, but not much (up to 30 ms).
Is it faster to read pins one by one instead of ports as a whole?
Here are some extracts of my code (note I mved out some variables to reduce Garbage Collect in an attempt to improve performances):
List baps = new List();
private byte[] byteArrayReturnValue = new byte[1];
// Init busses and ports:
baps.Add(new BusAndPort() { IOPi = Iopi20, Port = 1 });
baps.Add(new BusAndPort() { IOPi = Iopi21, Port = 0 });
baps.Add(new BusAndPort() { IOPi = Iopi21, Port = 1 });
foreach (BusAndPort busAndPort in baps)
{
busAndPort.IOPi?.ReadPortWithoutNew(busAndPort.Port, byteArrayReturnValue);
busAndPort.LastValue = byteArrayReturnValue[0];
}
public void ReadPortWithoutNew(byte port, byte[] returnValue)
{
CheckConnected();
switch (port)
{
case 0:
helper.ReadI2CByteWithoutNew(i2cbus, GPIOAArray, returnValue);
return;
case 1:
helper.ReadI2CByteWithoutNew(i2cbus, GPIOBArray, returnValue);
return;
default:
throw new ArgumentOutOfRangeException(nameof(port));
}
}
internal void ReadI2CByteWithoutNew(I2cDevice bus, byte[] register, byte[] returnValue)
{
bus.WriteRead(register, returnValue);
}
Thank you
Metadata
Metadata
Assignees
Labels
No labels