Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Files | Defines | Functions | Variables

Servo Controller
[Mindsensors]

Files

file  NXTServo-driver.h
 

Mindsensors NXTServo Sensor Driver.


Defines

#define NXTSERVO_I2C_ADDR   0xB0
#define NXTSERVO_CMD   0x41
#define NXTSERVO_POS_CHAN1   0x42
#define NXTSERVO_POS_CHAN2   0x44
#define NXTSERVO_POS_CHAN3   0x46
#define NXTSERVO_POS_CHAN4   0x48
#define NXTSERVO_POS_CHAN5   0x4A
#define NXTSERVO_POS_CHAN6   0x4C
#define NXTSERVO_POS_CHAN7   0x4E
#define NXTSERVO_POS_CHAN8   0x50
#define NXTSERVO_SPEED_CHAN1   0x52
#define NXTSERVO_SPEED_CHAN2   0x53
#define NXTSERVO_SPEED_CHAN3   0x54
#define NXTSERVO_SPEED_CHAN4   0x55
#define NXTSERVO_SPEED_CHAN5   0x56
#define NXTSERVO_SPEED_CHAN6   0x57
#define NXTSERVO_SPEED_CHAN7   0x58
#define NXTSERVO_SPEED_CHAN8   0x59
#define NXTSERVO_QPOS_CHAN1   0x42
#define NXTSERVO_QPOS_CHAN2   0x44
#define NXTSERVO_QPOS_CHAN3   0x46
#define NXTSERVO_QPOS_CHAN4   0x48
#define NXTSERVO_QPOS_CHAN5   0x4A
#define NXTSERVO_QPOS_CHAN6   0x4C
#define NXTSERVO_QPOS_CHAN7   0x4E
#define NXTSERVO_QPOS_CHAN8   0x50
#define NXTSERVO_MIN_POS   500
#define NXTSERVO_MAX_POS   2500
#define NXTSERVO_MID_POS   1500

Functions

bool NXTServoSetSpeed (tSensors link, ubyte servochan, ubyte speed, ubyte address)
bool NXTServoSetPos (tSensors link, ubyte servochan, int position, ubyte speed, ubyte address=NXTSERVO_I2C_ADDR)
bool NXTServoQSetPos (tSensors link, ubyte servochan, ubyte position, byte speed, ubyte address=NXTSERVO_I2C_ADDR)
int NXTServoReadVoltage (tSensors link, ubyte address=NXTSERVO_I2C_ADDR)

Variables

tByteArray NXTSERVO_I2CRequest
tByteArray NXTSERVO_I2CReply

Detailed Description

Servo Controller


Define Documentation

#define NXTSERVO_CMD   0x41

Servo command register

Definition at line 43 of file NXTServo-driver.h.

#define NXTSERVO_I2C_ADDR   0xB0

NXT Servo I2C device address

Definition at line 40 of file NXTServo-driver.h.

#define NXTSERVO_MAX_POS   2500

Servo maximum pulse width in uS

Definition at line 77 of file NXTServo-driver.h.

#define NXTSERVO_MID_POS   1500

Servo centered pulse width in uS

Definition at line 78 of file NXTServo-driver.h.

#define NXTSERVO_MIN_POS   500

Some other defines. Servo minimum pulse width in uS

Definition at line 76 of file NXTServo-driver.h.

#define NXTSERVO_POS_CHAN1   0x42

Servo channel 1 position (low byte)

Definition at line 46 of file NXTServo-driver.h.

#define NXTSERVO_POS_CHAN2   0x44

Servo channel 2 position (low byte)

Definition at line 47 of file NXTServo-driver.h.

#define NXTSERVO_POS_CHAN3   0x46

Servo channel 3 position (low byte)

Definition at line 48 of file NXTServo-driver.h.

#define NXTSERVO_POS_CHAN4   0x48

Servo channel 4 position (low byte)

Definition at line 49 of file NXTServo-driver.h.

#define NXTSERVO_POS_CHAN5   0x4A

Servo channel 5 position (low byte)

Definition at line 50 of file NXTServo-driver.h.

#define NXTSERVO_POS_CHAN6   0x4C

Servo channel 6 position (low byte)

Definition at line 51 of file NXTServo-driver.h.

#define NXTSERVO_POS_CHAN7   0x4E

Servo channel 7 position (low byte)

Definition at line 52 of file NXTServo-driver.h.

#define NXTSERVO_POS_CHAN8   0x50

Servo channel 8 position (low byte)

Definition at line 53 of file NXTServo-driver.h.

#define NXTSERVO_QPOS_CHAN1   0x42

Servo channel 1 quick position

Definition at line 66 of file NXTServo-driver.h.

#define NXTSERVO_QPOS_CHAN2   0x44

Servo channel 2 quick position

Definition at line 67 of file NXTServo-driver.h.

#define NXTSERVO_QPOS_CHAN3   0x46

Servo channel 3 quick position

Definition at line 68 of file NXTServo-driver.h.

#define NXTSERVO_QPOS_CHAN4   0x48

Servo channel 4 quick position

Definition at line 69 of file NXTServo-driver.h.

#define NXTSERVO_QPOS_CHAN5   0x4A

Servo channel 5 quick position

Definition at line 70 of file NXTServo-driver.h.

#define NXTSERVO_QPOS_CHAN6   0x4C

Servo channel 6 quick position

Definition at line 71 of file NXTServo-driver.h.

#define NXTSERVO_QPOS_CHAN7   0x4E

Servo channel 7 quick position

Definition at line 72 of file NXTServo-driver.h.

#define NXTSERVO_QPOS_CHAN8   0x50

Servo channel 8 quick position

Definition at line 73 of file NXTServo-driver.h.

#define NXTSERVO_SPEED_CHAN1   0x52

Servo channel 1 speed

Definition at line 56 of file NXTServo-driver.h.

#define NXTSERVO_SPEED_CHAN2   0x53

Servo channel 2 speed

Definition at line 57 of file NXTServo-driver.h.

#define NXTSERVO_SPEED_CHAN3   0x54

Servo channel 3 speed

Definition at line 58 of file NXTServo-driver.h.

#define NXTSERVO_SPEED_CHAN4   0x55

Servo channel 4 speed

Definition at line 59 of file NXTServo-driver.h.

#define NXTSERVO_SPEED_CHAN5   0x56

Servo channel 5 speed

Definition at line 60 of file NXTServo-driver.h.

#define NXTSERVO_SPEED_CHAN6   0x57

Servo channel 6 speed

Definition at line 61 of file NXTServo-driver.h.

#define NXTSERVO_SPEED_CHAN7   0x58

Servo channel 7 speed

Definition at line 62 of file NXTServo-driver.h.

#define NXTSERVO_SPEED_CHAN8   0x59

Servo channel 8 speed

Definition at line 63 of file NXTServo-driver.h.


Function Documentation

bool NXTServoQSetPos ( tSensors  link,
ubyte  servochan,
ubyte  position,
byte  speed,
ubyte  address 
)

Tell the servo to move to the specified position using the specified speed. This uses the Quick Position register which is less accurate. It only accepts values from 50 to 250

Parameters:
linkthe NXTServo port number
servochanthe servo channel to use
positionthe position to move the servo to
speedthe amount to increase the position by every 24ms
addressthe I2C address to use, optional, defaults to 0xB0
Returns:
true if no error occured, false if it did

Definition at line 154 of file NXTServo-driver.h.

int NXTServoReadVoltage ( tSensors  link,
ubyte  address 
)

Get the voltage level of the battery pack.

Parameters:
linkthe NXTServo port number
addressthe I2C address to use, optional, defaults to 0xB0
Returns:
the voltage of the battery pack or -1 if an error occurred
Examples:
NXTServo-test1.c.

Definition at line 179 of file NXTServo-driver.h.

bool NXTServoSetPos ( tSensors  link,
ubyte  servochan,
int  position,
ubyte  speed,
ubyte  address 
)

Tell the servo to move to the specified position using the specified speed.

Parameters:
linkthe NXTServo port number
servochanthe servo channel to use
positionthe position to move the servo to
speedthe amount to increase the position by every 24ms
addressthe I2C address to use, optional, defaults to 0xB0
Returns:
true if no error occured, false if it did
Examples:
NXTServo-test1.c.

Definition at line 123 of file NXTServo-driver.h.

bool NXTServoSetSpeed ( tSensors  link,
ubyte  servochan,
ubyte  speed,
ubyte  address 
)

Set the speed register for the specified servo. This is the amount to increase the current position by every 24ms when the servo position is changed.

Note: this is an internal function and should not be called directly.

Parameters:
linkthe NXTServo port number
servochanthe servo channel to use
speedthe amount to increase the position by every 24ms
addressthe I2C address to use, optional, defaults to 0xB0
Returns:
true if no error occured, false if it did

Definition at line 103 of file NXTServo-driver.h.


Variable Documentation

Array to hold I2C reply data

Definition at line 89 of file NXTServo-driver.h.

Array to hold I2C command data

Definition at line 88 of file NXTServo-driver.h.