AOCfg Scaling

INT8U AOCfgScaling(INT8U n, void (*fnct)(AIO *paio), void *arg);

AOCfgScaling () is used to specify a scaling function to be executed when the analog output channel is updated. The scaling function allows you to apply further processing before updating an analog output. You don't need to call this function if your analog output channel doesn't need a scaling function. In this case, the .AlOScaleln field will simply be copied to the .AlOScalingOut field by AOUpdate () (see code).

Arguments n is the desired analog output channel. Analog output channels are numbered from 0 to AIO_MAX_AO -1.

fnct is a pointer to the scaling function that will be executed when the analog output channel is updated, fnct sets the value of .AIOScaleFnct in Figure 10.14. fnct must be written to receive a pointer to the analog I/O data structure called AIO as follows:

arg is a pointer to any arguments or parameters needed for the scaling function, arg sets the value of .AIOScaleFnctArg in Figure 10.14. This argument can be used to specify specific options about the scaling being performed.

Return Value

AOCfgScaling () returns 0 upon success and 1 if the analog output channel you specified is not within

Notes/Warnings

The scaling function is assumed to take its input from paio->AIOScaleIn and produce its result in paio->AIOScaleOut.

Example void main (void) {

AOCfgScaling{0, ActLin, (void*)0);

/* Linearize actuator function */

paio->AIOScaleIn is the input value to the scaling function. paio->AIOScaleOut is where the scaling function will place the result. paio->AIOScaleFnctArg in this case is not used but could be made to tell ActLin() the type of actuator to linearize.

INT80 AOSet (INT8U II, FP32 val);

This function is used by your application software to set the value of the analog output channel. The value you set the channel to is specified in engineering units. In other words, if your analog output channel has been configured to control the position of a valve in percent then, you would pass the desired percentage of position you desire (a number between 0.0 and 100.0).

Arguments n is the desired analog output channel. Analog output channels are numbered from 0 to AIO_MAX_AO -1.

val is the desired value for the analog output channel and is specified in engineering units. Return Value

AOSet () returns 0 upon success and 1 if the analog output channel you specified is not within 0 and

Notes/Warnings

None

Example void Task (void *pdata) {

valve = Get desired value position from user; AOSet(0, (FP32)valve);

Was this article helpful?

0 0

Post a comment