User`s manual
UC-7408 User’s Manual Programmer’s Guide
5-13
duration
- Not 0
> detect the din event
DIN_EVENT_HIGH_TO_LOW or
DIN_EVENT_LOW_TO_HIGH with
duration. The value of “duration” must be a
multiple of 20 milliseconds. The range of
“duration” is 0, or 40 <= duration <= 3600000
milliseconds. The error of the measurement is
24 ms. For example, if the DIN duration is
200 ms, this event will be generated when the
DIN pin stays in the same state for a time
between 176 ms and 200 ms.
Output: none.
Return: reference the error code.
int get_din_event(int diport, int *mode, long int *duration)
Description: To retrieve the DIN event configuration, including mode
(DIN_EVENT_HIGH_TO_LOW or DIN_EVENT_LOW_TO_HIGH), and the
value of “duration.”
Input:
int diport
- which DIN port you want to retrieve.
- The port whose din event setting we wish to
retrieve
int *mode
- save which event is set.
unsigned long *duration
- the duration of the DIN port is kept in high or low
state.
- return to the current duration value of diport
Output:
mode
DIN_EVENT_HIGH_TO_LOW
(1)
: from high to low
DIN_EVENT_LOW_TO_HIGH(0): from low to high
DIN_EVENT_CLEAR(-1): clear this event
duration
The value of duration should be 0 or 40 <= duration
<= 3600000 milliseconds.
Return: reference the error code.
Special Note
Don’t forget to link the library libmoxalib for DI/DO programming, and also include the header
file moxadevice.h. The DI/DO library only can be used by one program at a time.
Examples
Example 1
File Name: tdio.c
Description: The program indicates to connect DO1 to DI1, change the digital output state to high
or low by manual input, then detect and count the state changed events from DI1.
#include <stdio.h>
#include <stdlib.h>
#include <moxadevice.h>
#include <fcntl.h>