Dear all
I have connected a XBEE S2 module on a industrial machine with electromechanical counter. I catch the output signal with igital IO of Xbee S2 and I count the pulse on a remote computer.
my xbee input signal is very clean: https://www.amazon.fr/clouddrive/share/DmoVKjF4PwTJGZ8RjyEjK8L5zbXSEwZWKdSAJH0vtNx?v=grid&ref_=cd_ph_share_link_copy
My problem is that my total on the remote computer is more high than the total on the electromechanical counter : for 100 pulse, around 4 pulse differences.
Here's the java code of my IO Listener :
// Register a listener to handle the samples received by the local device.
localDevice.addIOSampleListener(new IIOSampleReceiveListener() {
@Override
public void ioSampleReceived(RemoteXBeeDevice remoteDevice, IOSample ioSample) {
state=ioSample.getDigitalValue(IOLine.DIO4_AD4).getName();
Date dNow=new Date();
//delta_time=actual_time-previous_time;
if (previous_state=="Low" && state=="High") {// && delta_time>5000) {
totalQty++;
//System.out.println("actual_time-previous_time="+delta_time);
SimpleDateFormat sdf = new SimpleDateFormat ("yyyy.MM.dd ; HH:mm:ss");
System.out.println(REMOTE_NODE_IDENTIFIER + ";"+sdf.format(dNow) + ";" + totalQty);//ioSample.getDigitalValue(IOLine.DIO4_AD4));
try {
writer.write(REMOTE_NODE_IDENTIFIER + ";"+sdf.format(dNow) + ";" + totalQty+"\n");
writer.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}//ioSample.getDigitalValue(IOLine.DIO4_AD4));
previous_state="High";
//}
}
if (previous_state=="High" && state=="Low" ) previous_state="Low";
}
});
} catch (XBeeException e) {
e.printStackTrace();
localDevice.close();
System.exit(1);
}
}
Somebody has some idea ?