User manual

Chapter 4: PowerDAQ Software (SDK)
83
Method G. Combining Analog and Digital
subsystems
See SDK Examples
SimpleTest.dpr
The tricky part of combining digital and analog operations is the event
handling. The PowerDAQ API has two sets of function to solve this.
The first way is to set up all subsystem operations in a one thread and
create an event using _PdSetPrivateEvent(…). This function creates a
single event that is set when any subsystem needs attention. Note that
each active subsystem events should be sequentially retrieved and
processed. To release a event object use _PdClearPrivateEvent(…).
The second way is to set up each subsystem operation in a separate
thread. You can create separate event objects for each subsystem using
_PdAInSetPrivateEvent(…), _PdAOutSetPrivateEvent(…),,
_PdDInSetPrivateEvent(…),,_PdUctSetPrivateEvent(…),.
When one or another subsystem needs an attention, the appropriate
event is set. Subsystem thread wake up on WaitForSingleObject(…),
,Win32 API calls and processes event as described above. To release
event objects use appropriate _PdxxxClearPrivateEvents(…).
Averaging and inertial filters. Use averaging to
increase resolution and reduce noise. For applications
where the DC value is crucial, consider using an inertial
filter. This filter can be better described as an averaging
window over an array of averages. Each time you
calculate the average value of the frame you put it into
an array of averages replacing the oldest one. Then your
program calculates the average value of the array of
averages and uses it as a final value.
TIP