Measurement Control Cycles

Index | Device Driver Model | Measurement System Wizard

Once you have created device drivers for your measurement instruments, you are ready to build HTML data acquisition applications. Typical purpose of such application is to synchronize several devices with different response time, perform data averaging, control signal commutation and sweep (or scanning).

Control cycle diagrams

When you run Measurement System Wizard discussed in the last part of this article, you implicitly select one of four types of universal measurement control cycles. To better understand DHTML code produced by this wizard, look at four simplified diagrams shown below:

Figure 1 - general device synchronization cycle

Fig. 1. General device synchronization cycle (both scanner and commutator devices are NOT used).

On this diagram, TriggerDevices procedure is called when user clicks Run or Point button to start measurements. It calls Trigger method for all device drivers. After all devices have invoked OnData event, ProcessOnData procedure calls ProcessReadout which, in turn, performs data averaging (data averaging cycles are divided by AverageDelay timeouts) and, finally, calls AddPoint procedure that calculates values of columns to be inserted into DM2003 data window by averaged device channel values. After MainDelay timeout, the cycle loops. Notice that some elements at the diagram (ones that have yellow background) involve time delays - that is, appropriate procedures are called using window.SetTimeout() that defers actual code execution for given timeout value.

Figure 2 - scanner (sweep) synchronization cycle

Fig. 2. Scanner (sweep) synchronization cycle (only scanner device is used).

Unlike general device synchronization cycle from previous diagram, in this case AddPoint calls ScanStep procedure. The latter checks whether scanning is active, sends appropriate command to the scanner device and calls TriggerDevices after ScanDelay timeout. Synchronous sweep implemented by this type of cycles allows to provide stable measurement conditions since the moments of taking signal readout always divided from scanning steps by equal time intervals.

Figure 3 - Synchronization cycle with commutation

Fig. 3. Synchronization cycle with commutation (only commutator device is used).

Signal commutation is essential requirement for many data acquisition applications, that's why abstract commutation was implemented in this measurement control cycle (see Fig. 3). After averaging data, ProcessReadout calls ChangeState procedure which is responsible for commutation control. Every state change is followed by relaxation timeout (StateDelay). At the last state of commutation sequence, this procedure invokes AddPoint as in the previous types of cycles.

Figure 4 - Synchronization cycle with commutation and sweep

Fig. 4. Synchronization cycle with commutation and sweep (both scanner and commutator devices are used).

The diagram shown above is the most versatile type of control cycles. In fact, this is a combination of two previous cycles. After commutator device has switched all states and AddPoint procedure has calculated current data point, next cycle is started from ScanStep procedure.

Default and custom code templates

Each type of control cycles discussed above is based on special code template used by Measurement System Wizard, default templates are installed along with other sample files. You can use them to create your own templates so that DAQ applications generated by this wizard can be easily customized. For example, you can add your own UI controls and algorithms that may be utilized in all applications created from this template.

Template technology uses special tags formatted as follows: <#tagname>, where tagname - any unique identifier. When wizard processes template, it replaces those tags by actual values entered by the user. Full set of tag names listed in the table below:

author title datawindowtitle codepage emwidth
path width triggerdevices dimstatecodes channelslist
function devices initializedevices deltacolumns fixdevices5
closedevices xcolumn setupcolumnlabels dimreadyflags statecodes
recordpoint ycolumn processreadout1 processreadout2 addpoint
expsettings displays manualwincontrol processreadout3 commdevice
scandevice appletid expstatecodes scanchannel