In this article, we'll show how to enable the GPIs and set up an ROSpec for triggering.
On the Speedway Revolution reader, all of the general purpose inputs are disabled by default. You must enable any GPIs you want to use for triggering with the SET_READER_CONFIG message.
static void Set_ReaderConfig() { MSG_ERROR_MESSAGE msg_err; MSG_SET_READER_CONFIG msg = new MSG_SET_READER_CONFIG(); // Create a one-element array to hold the GPI configuration // We are only enabling one GPI in this example msg.GPIPortCurrentState = new PARAM_GPIPortCurrentState[1]; msg.GPIPortCurrentState[0] = new PARAM_GPIPortCurrentState(); // Enable GPI port #1 msg.GPIPortCurrentState[0].GPIPortNum = 1; msg.GPIPortCurrentState[0].Config = true; MSG_SET_READER_CONFIG_RESPONSE rsp = reader.SET_READER_CONFIG(msg, out msg_err, 2000); if (rsp != null) { // Success Console.WriteLine(rsp.ToString()); } else if (msg_err != null) { // Error Console.WriteLine(msg_err.ToString()); } else { // Timeout Console.WriteLine("Timeout Error."); } }
This message should be sent before you add your ROSpec. Once the GPI has been enabled, you can configure your ROSpec to use it as a start and stop trigger. Please note: The code sample below only shows the settings that pertain to GPI triggering. It is not a complete ROSpec.
// ROBoundarySpec // Specifies the start and stop triggers for the ROSpec msg.ROSpec.ROBoundarySpec = new PARAM_ROBoundarySpec(); // GPI start trigger // The reader will start reading tags when GPI 1 goes high msg.ROSpec.ROBoundarySpec.ROSpecStartTrigger = new PARAM_ROSpecStartTrigger(); msg.ROSpec.ROBoundarySpec.ROSpecStartTrigger. ROSpecStartTriggerType = ENUM_ROSpecStartTriggerType.GPI; msg.ROSpec.ROBoundarySpec.ROSpecStartTrigger. GPITriggerValue = new PARAM_GPITriggerValue(); // GPI port #1 msg.ROSpec.ROBoundarySpec.ROSpecStartTrigger. GPITriggerValue.GPIPortNum = 1; // Trigger state = true (high) msg.ROSpec.ROBoundarySpec.ROSpecStartTrigger. GPITriggerValue.GPIEvent = true; // GPI stop trigger // The reader will stop reading tags when GPI 1 goes low msg.ROSpec.ROBoundarySpec.ROSpecStopTrigger = new PARAM_ROSpecStopTrigger(); msg.ROSpec.ROBoundarySpec.ROSpecStopTrigger.ROSpecStopTriggerType = ENUM_ROSpecStopTriggerType.GPI_With_Timeout; msg.ROSpec.ROBoundarySpec.ROSpecStopTrigger.ROSpecStopTriggerType = ENUM_ROSpecStopTriggerType.GPI_With_Timeout; msg.ROSpec.ROBoundarySpec.ROSpecStopTrigger. GPITriggerValue = new PARAM_GPITriggerValue(); // GPI port #1 msg.ROSpec.ROBoundarySpec.ROSpecStopTrigger. GPITriggerValue.GPIPortNum = 1; // Trigger state = false (low) msg.ROSpec.ROBoundarySpec.ROSpecStopTrigger. GPITriggerValue.GPIEvent = false; // No timeout msg.ROSpec.ROBoundarySpec.ROSpecStopTrigger. GPITriggerValue.Timeout = 0;
If case you want to change the debouce settings:
MSG_SET_READER_CONFIG msg = new MSG_SET_READER_CONFIG(); PARAM_ImpinjGPIDebounceConfiguration debounce = new PARAM_ImpinjGPIDebounceConfiguration(); debounce.GPIDebounceTimerMSec = 50; debounce.GPIPortNum = 1; msg.AddCustomParameter(debounce);
Note: Setting GPI Debounce to zero effecitvely disables debounce.
Comments
Article is closed for comments.