You are here

ADC Event

ADC module send current voltage to the user-mode application:

  • periodically with predefined repeat interval;

  • when user-defined limits are reached.

For this purpose GPIO-24 adapter sends GPIO_EV_ADC event to your application. The conditions of the event generation are set with GPIO_SET_ADC_CHANNEL_CFG command as described below.

If you do not want to receive events at all:

Set GPIO_ADC_EV_NONE (0x0) value in Bits 7..4: EVENT_CONDITION of Byte 2. The measured voltage can still be retrieved with GPIO_GET_ADC_VAL command.

If you want to receive the event periodically:

Set GPIO_ACD_EV_ALWAYS (0x5) value in Bits 7..4: EVENT_CONDITION of Byte 2. In this case events will be sent periodically with predefined interval. Specify the non-zero interval in Byte 3: REPEAT. The repeat interval is specified in units of 10 ms. That allows to set the interval up to 2550 ms (2.5 s).

If you want to receive the event when user-defined limits are reached:

Specify low and high threshold values in Bytes 4..5: LOW_LSB/LOW_MSB and Bytes 6..7: HIGH_LSB/HIGH_MSB. You can set any value from 0 to 0x3FF as low and high threshold values. 0 corresponds to VRefLow and 0x3FF corresponds to VRefHi voltage.

Use the following expression to calculate the high and low threshold values:

where:

  • Threshold Value – value, that should be specified in Bytes 4..7;

  • VTV – threshold voltage;

  • VRefHi – upper reference voltage;

  • VRefLow – lower reference voltage.

USB-I/O adapter constantly compares current voltage with these threshold values. The event can be generated:

  • when the input voltage descends below the low threshold value:

    Set GPIO_ADC_EV_BELOW (0x1) value in Bits 7..4: EVENT_CONDITION of Byte 2. The low threshold value is specified in Bytes 4..5: LOW_LSB/LOW_MSB.

    You can also configure USB-I/O adapter to send events periodically while the input voltage is below the low threshold value. To do this, specify the repeat interval in Byte 3: REPEAT.

  • when the input voltage rises above the high threshold value:

    Set GPIO_ADC_EV_ABOVE (0x2) value in Bits 7..4: EVENT_CONDITION of Byte 2. The high threshold value is specified in Bytes 6..7: HIGH_LSB/HIGH_MSB.

    You can also configure USB-I/O adapter to send events periodically while the input voltage is above the high threshold value. To do this, specify the repeat interval in Byte 3: REPEAT.

  • when the input voltage exceeds user-defined limits:

    Set GPIO_ADC_EV_OUTSIDE (0x3) value in Bits 7..4: EVENT_CONDITION of Byte 2. The event will be sent when the input voltage descends below the low threshold value or rises above the high threshold value. The low threshold value is specified in Bytes 4..5: LOW_LSB/LOW_MSB. The high threshold value is specified in Bytes 6..7: HIGH_LSB/HIGH_MSB.

    You can also configure USB-I/O adapter to send events periodically while the input voltage is outside user-defined limits. To do this, specify the repeat interval in Byte 3: REPEAT.

  • when the input voltage is within user-defined limits:

    Set GPIO_ADC_EV_INSIDE (0x4) value in Bits 7..4: EVENT_CONDITION of Byte 2. The event will be sent when the input voltage is between the low and high threshold values. The low threshold value is specified in Bytes 4..5: LOW_LSB/LOW_MSB. The high threshold value is specified in Bytes 6..7: HIGH_LSB/HIGH_MSB.

    You can also configure USB-I/O adapter to send events periodically while the input voltage is within user-defined limits. To do this, specify the repeat interval in Byte 3: REPEAT.