User`s manual

70 www.rabbit.com Applications Programming
Some automatically generated pin groups are created in your design-specific library. These groups are
listed below:
Some of these groups are used in sample programs to make them operate on any given RabbitFLEX
BL300F design.
6.3.4 Analog Input and Output
Note that your analog inputs and outputs have been factory calibrated. To modify your calibration, use the
flexAnaInCalib() and flexAnaOutCalib() functions. These functions are demonstrated in the
anain_calibrate.c and anaout_calibrate.c sample programs.
To achieve greater accuracy with analog inputs, you can use the analog input averaging functionality. The
tradeoff for greater accuracy is that the analog input channels will be less responsive to change. The fol-
lowing formula is used to compute the running averages:
avgnew = (1-α)avgold + α * anain
The alpha value must be between 0.0 and 1.0, and determines the accuracy/responsiveness tradeoff. A low
alpha value will result in higher accuracy but slower responsiveness, whereas a high alpha value will result
in lower accuracy but faster responsiveness.
To set the alpha value for a specific analog input, use the flexAnaInAverageSetting() function.
Then use the flexAnaInAverage() and flexAnaInVoltsAverage() or
flexAnaInmAmpsAverage() functions to read the averaged values.
6.3.5 RS-232
Use the serMode() function to set up your serial ports before using them. serMode() takes a parame-
ter: 0 means to use 3-wire serial ports, and 1 means to use a 5-wire serial port. Note that your design must
support your selected serial mode. serMode() should be called after your serXopen() function(s),
where X represents the particular serial port you are using.
6.3.6 Keypad
All keypad functions begin with “flexKey.”
To use the keypad software support, you must first initialize the keypad. Use the flexKeyInit() func-
tion. Here is an example:
flexKeyInit(&flex_keypad);
Pin Group Pin Group Members
_flex_pins_digin[] All digital inputs
_flex_pins_digout[] All digital outputs
_flex_pins_diginout[] All bidirectional pins
_flex_pins_anain[] All analog inputs
_flex_pins_anaout[] All analog outputs