Unicoder Functions


Detailed Description

Use these functions apply to the Unicoder universal encoder only.


Typedefs

typedef enum _uc_mode_type UNICODER_MODE
typedef enum _uc_encoder_type ENCODER_TYPE

Enumerations

enum  _uc_mode_type {
  MD_I2C = 0x01, MD_RS232 = 0x02, MD_ASCII_HEX = 0x04, MD_SHORT_RET = 0x08,
  MD_INVERT_SERVO = 0x10, MD_FILTER_PERIOD = 0x20
}
 Unicoder Mode Values. More...
enum  _uc_encoder_type { ET_DEFAULT, ET_QUADRATURE, ET_STEPDIR, ET_COMMUTATION }
 Encoder Types. More...

Functions

NDICMDC_API BOOL NdiCmd_UCSetConstant (int handle, int addr, BYTE const_value)
 Set Constant.
NDICMDC_API BOOL NdiCmd_UCGetConstant (int handle, int addr, BYTE *const_value)
 Get.
NDICMDC_API BOOL NdiCmd_SetMode (int handle, BYTE mode)
 Set Mode.
NDICMDC_API BOOL NdiCmd_GetMode (int handle, BYTE *mode)
 Get Mode.
NDICMDC_API BOOL NdiCmd_GetEncoderMode (int handle, ENCODER_TYPE *enc_type, int *num_bits, BOOL *wide_index, BOOL *ccw)
 Get Encoder Mode.
NDICMDC_API BOOL NdiCmd_SetEncoderMode (int handle, ENCODER_TYPE enc_type, int num_bits, BOOL wide_index, BOOL ccw)
 Set Encoder Mode.
NDICMDC_API BOOL NdiCmd_GetZeroPosition (int handle, int *angle)
 Get Zero Position.
NDICMDC_API BOOL NdiCmd_SetZeroPosition (int handle, int angle)
 Set Zero Position.
NDICMDC_API BOOL NdiCmd_GetPeriod (int handle, int *period)
 Get Period.
NDICMDC_API BOOL NdiCmd_GetTime (int handle, int *the_time)
 Get Time.
NDICMDC_API BOOL NdiCmd_SetTime (int handle, int the_time)
 Set Time.
NDICMDC_API BOOL NdiCmd_GetServo (int handle, int *speed)
 Get Servo.
NDICMDC_API BOOL NdiCmd_SetServo (int handle, int speed)
 Set Servo.
NDICMDC_API BOOL NdiCmd_UCCoast (int handle)
 Unicoder Coast.
NDICMDC_API BOOL NdiCmd_SetCenterPosition (int handle, int center_pos)
 Set Servo Center Position.
NDICMDC_API BOOL NdiCmd_GetCenterPosition (int handle, int *center_pos)
 Get Servo Center Position.
NDICMDC_API BOOL NdiCmd_UCStoreParameters (int handle)
 Unicoder Store Parameters.


Enumeration Type Documentation

Encoder Types.

These values are passed to NdiCmd_SetEncoderMode().

Enumerator:
ET_DEFAULT  Default (quadrature, 1024 transitions per rotation)
ET_QUADRATURE  Quadrature (ChA, ChB 90 degrees out of phase)
ET_STEPDIR  Step and Direction (sign / magnitude)
ET_COMMUTATION  Commutation for brushless DC motors

Unicoder Mode Values.

These values can be bitwise ORed together to form a mode BYTE.

Enumerator:
MD_I2C  readonly; indicates that I2C communications are enabled
MD_RS232  readonly; indicates that RS232 communications are enabled
MD_ASCII_HEX  readonly; indicates that ASCII hex parameters and values are used; otherwise, binary values are used
MD_SHORT_RET  set for OOPIC compatibility (short return values)
MD_INVERT_SERVO  if 1, the servo control pulses will be high for most of the 20ms, and low only for the 0.5 to 2.5 ms portion
MD_FILTER_PERIOD  if 1, turns on a digital filter of the period and velocity measurement; averages edge-to-edge timing every 20ms


Function Documentation

NDICMDC_API BOOL NdiCmd_GetCenterPosition ( int  handle,
int *  center_pos 
)

Get Servo Center Position.

This function retrieves the pulsewidth of the servo output pulse's center or zero position. It is 3067 by default, which corresponds to 1.5ms.

Parameters:
handle an integer WheelCommander handle
center_pos a pointer to an integer specifying pulsewidth in multiples of 489ns
Returns:

NDICMDC_API BOOL NdiCmd_GetEncoderMode ( int  handle,
ENCODER_TYPE *  enc_type,
int *  num_bits,
BOOL *  wide_index,
BOOL *  ccw 
)

Get Encoder Mode.

This function queries the Unicoder for its current operating mode. This includes the nature of its incremental output signals, the number of bits of resolution, the size of the index pulse, and the direction of rotation.

Parameters:
handle an integer Unicoder handle
enc_type a member of the ENCODER_TYPE enumeration
num_bits an integer representing the resolution
wide_index a BOOL indicating that the index pulse is 3 wide rather than 1
ccw a BOOL indicating that the angle increases in a counter-clockwise direction when true
Returns:

NDICMDC_API BOOL NdiCmd_GetMode ( int  handle,
BYTE *  mode 
)

Get Mode.

This function retrieves the current operating mode of the Unicoder encoder.

Parameters:
handle an integer Unicoder handle
mode a BYTE containing an ORing of UNICODER_MODE values, containing the mode returned
Returns:

NDICMDC_API BOOL NdiCmd_GetPeriod ( int  handle,
int *  period 
)

Get Period.

This function returns the elapsed time between the previous two transitions of the encoder's incremental signals. The unit of time is the Unicoder's own internal timebase, nominally in multiples of 489ns (+/- 2%).

Parameters:
handle an integer Unicoder handle
period an integer indicating the elapsed time between encoder transitions
Returns:

NDICMDC_API BOOL NdiCmd_GetServo ( int  handle,
int *  speed 
)

Get Servo.

This function returns the current pulsewidth deviation, or 0x8000 if RC servo pulses are currently turned off.

Parameters:
handle an integer WheelCommander handle
speed an integer specifying pulsewidth delta from 1.5ms
Returns:

NDICMDC_API BOOL NdiCmd_GetTime ( int  handle,
int *  the_time 
)

Get Time.

This function returns the current system time, in multiples of 489ns. This is useful to calibrate velocity and other time-dependent measurements, using the main robot controller's more accurate crystal-controlled clock. The clock inside the Unicoder encoder is accurate to +/- 2%, so velocity and period measurements are likewise limited in accuracy.

Parameters:
handle an integer Unicoder handle
the_time an integer indicating the system time in multiples of 489ns.
Returns:

NDICMDC_API BOOL NdiCmd_GetZeroPosition ( int  handle,
int *  angle 
)

Get Zero Position.

This function queries the Unicoder for the angle relative to the factory default at which the index pulse and user angle origin begin.

Parameters:
handle an integer Unicoder handle
angle an integer representing the number of encoder positions from 0 to 1023 (0 is the default)
Returns:

NDICMDC_API BOOL NdiCmd_SetCenterPosition ( int  handle,
int  center_pos 
)

Set Servo Center Position.

This function sets the pulsewidth of the servo output pulse's center or zero position. It is 3067 by default, which corresponds to 1.5ms.

Parameters:
handle an integer WheelCommander handle
center_pos an integer specifying pulsewidth in multiples of 489ns
Returns:

NDICMDC_API BOOL NdiCmd_SetEncoderMode ( int  handle,
ENCODER_TYPE  enc_type,
int  num_bits,
BOOL  wide_index,
BOOL  ccw 
)

Set Encoder Mode.

This function allows you to change the Unicoder's current operating mode. This includes the nature of its incremental output signals, the number of bits of resolution, the size of the index pulse, and the direction of rotation.

Parameters:
handle an integer Unicoder handle
enc_type a member of the ENCODER_TYPE enumeration
num_bits an integer representing the resolution
wide_index a BOOL indicating that the index pulse is 3 wide rather than 1
ccw a BOOL indicating that the angle increases in a counter-clockwise direction when true
Returns:

NDICMDC_API BOOL NdiCmd_SetMode ( int  handle,
BYTE  mode 
)

Set Mode.

This function allows you to change the current operating mode.

Parameters:
handle an integer Unicoder handle
mode a BYTE containing an ORing of UNICODER_MODE values, containing the mode to be set
Returns:

NDICMDC_API BOOL NdiCmd_SetServo ( int  handle,
int  speed 
)

Set Servo.

This function enables production of an RC servo control pulse on TP2, with the specified deviation in multiples of 489ns from the center pulsewidth of 1.5ms. In this mode, the encoder should be set to sign/magnitude mode, as the ChB/DIR line is shared with TP2 through a 1K resistor, and is sampled only on edges of the servo control pulse. Useful values are in the range of +/- 2048, corresponding to +/- 1ms.

Parameters:
handle an integer WheelCommander handle
speed an integer specifying pulsewidth delta from 1.5ms
Returns:

NDICMDC_API BOOL NdiCmd_SetTime ( int  handle,
int  the_time 
)

Set Time.

This function allows you to change the current system time, in multiples of 489ns.

Parameters:
handle an integer Unicoder handle
the_time an integer indicating the system time in multiples of 489ns.
Returns:

NDICMDC_API BOOL NdiCmd_SetZeroPosition ( int  handle,
int  angle 
)

Set Zero Position.

This function allows you to change the angle of the Unicoder's index pulse and the amount to shift the user-accessible angle by.

Parameters:
handle an integer Unicoder handle
angle an integer representing the number of encoder positions from 0 to 1023 (0 is the default)
Returns:

NDICMDC_API BOOL NdiCmd_UCCoast ( int  handle  ) 

Unicoder Coast.

This function stops any current motion, and sets the servo into low power mode. It is now safe to use modes other than sign/magnitude.

Parameters:
handle an integer WheelCommander handle
Returns:

NDICMDC_API BOOL NdiCmd_UCGetConstant ( int  handle,
int  addr,
BYTE *  const_value 
)

Get.

This function retrieves a byte from the flash constants area.

Parameters:
handle an integer Unicoder handle
addr an integer address in the flash
const_value a pointer to a BYTE, containing the value read
Returns:

NDICMDC_API BOOL NdiCmd_UCSetConstant ( int  handle,
int  addr,
BYTE  const_value 
)

Set Constant.

This function lets you directly access the constants stored in Flash in the Unicoder. This is for advanced users only. The functions NdiCmd_GetMode(), NdiCmd_GetI2CAddr(), and so forth, are easier to use.

Parameters:
handle an integer Unicoder handle
addr an integer indicating the address in the flash constants area
const_value a BYTE indicating the value to write to addr
Returns:

NDICMDC_API BOOL NdiCmd_UCStoreParameters ( int  handle  ) 

Unicoder Store Parameters.

This function writes any user-modifiable constants to flash.

Parameters:
handle an integer WheelCommander handle
Returns:


Generated on Mon Mar 2 17:01:02 2009 for Nubotics Device Interface DLL by  doxygen 1.5.5