Maestro Servo Controller library
 All Classes Files Functions Variables
Public Member Functions | Static Public Attributes | List of all members
Maestro Class Reference

Main Maestro class that handles common functions between the Micro Maestro and Mini Maestro. More...

#include <PololuMaestro.h>

Inheritance diagram for Maestro:
MicroMaestro MiniMaestro

Public Member Functions

void reset ()
 Resets the Maestro by toggling the resetPin, if a resetPin was given. More...
 
void setTargetMiniSSC (uint8_t channelNumber, uint8_t target)
 Sets the target of the servo on channelNumber using the Mini SSC protocol. More...
 
void setTarget (uint8_t channelNumber, uint16_t target)
 Sets the target of the servo on channelNumber. More...
 
void setSpeed (uint8_t channelNumber, uint16_t speed)
 Sets the speed limit of channelNumber. More...
 
void setAcceleration (uint8_t channelNumber, uint16_t acceleration)
 Sets the acceleration limit of channelNumber. More...
 
void goHome ()
 Sends the servos and outputs to home position. More...
 
void stopScript ()
 Stops the script. More...
 
void restartScript (uint8_t subroutineNumber)
 Starts loaded script at specified subroutineNumber location. More...
 
void restartScriptWithParameter (uint8_t subroutineNumber, uint16_t parameter)
 Starts loaded script at specified subroutineNumber location after loading parameter on to the stack. More...
 
uint16_t getPosition (uint8_t channelNumber)
 Gets the position of channelNumber. More...
 
uint8_t getMovingState ()
 Gets the moving state for all configured servo channels. More...
 
uint8_t getScriptStatus ()
 Gets if the script is running or stopped. More...
 
uint16_t getErrors ()
 Gets the error register. More...
 

Static Public Attributes

static const uint8_t deviceNumberDefault = 255
 The default device number, used to construct a MicroMaestro or MiniMaestro object that will use the compact protocol.
 
static const uint8_t noResetPin = 255
 The default reset pin is no reset pin, used to construct a MicroMaestro or MiniMaestro object that will not have a reset pin.
 

Detailed Description

Main Maestro class that handles common functions between the Micro Maestro and Mini Maestro.

The subclasses, MicroMaestro and MiniMaestro inherit all of the functions from Maestro. The Maestro class is not meant to be instantiated directly; use the MicroMaestro or MiniMaestro subclasses instead.

Definition at line 26 of file PololuMaestro.h.

Member Function Documentation

uint16_t Maestro::getErrors ( )

Gets the error register.

Returns
Two-byte error code.

Returns the error register in two bytes then all the error bits are cleared on the Maestro. See the Errors section of the Maestro User's Guide for more details.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 109 of file PololuMaestro.cpp.

uint8_t Maestro::getMovingState ( )

Gets the moving state for all configured servo channels.

Returns
1 if at least one servo limited by speed or acceleration is still moving, 0 if not.

Determines if the servo outputs have reached their targets or are still changing and will return 1 as as long as there is at least one servo that is limited by a speed or acceleration setting.

See the Serial Interface section in the Maestro User's Guide for more details.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 100 of file PololuMaestro.cpp.

uint16_t Maestro::getPosition ( uint8_t  channelNumber)

Gets the position of channelNumber.

Parameters
channelNumberA servo number from 0 to 127.
Returns
two-byte position value

If channel is configured as a servo, then the position value represents the current pulse width transmitted on the channel in units of quarter-microseconds.

If the channel is configured as a digital output, a position value less than 6000 means the Maestro is driving the line low, while a position value of 6000 or greater means the Maestro is driving the line high.

If channel is configured as an input, then the position value represents the voltage measured. Analog inputs for channels 0-11: their values range from 0 to 1023, representing 0 to 5V. Digital inputs for channels 12-23: their values are exactly 0 or exactly 1023.

See the Serial Interface section in the Maestro User's Guide for more details.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 88 of file PololuMaestro.cpp.

uint8_t Maestro::getScriptStatus ( )

Gets if the script is running or stopped.

Returns
1 if script is stopped, 0 if running.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 120 of file PololuMaestro.cpp.

void Maestro::goHome ( )

Sends the servos and outputs to home position.

If the "On startup or error" setting for a servo or output channel is set to "Ignore", the position will be unchanged.

See the Serial Interface section in the Maestro User's Guide for more details.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 36 of file PololuMaestro.cpp.

void Maestro::reset ( )

Resets the Maestro by toggling the resetPin, if a resetPin was given.

By default this function will do nothing. If the resetPin was specified while constructing the Maestro object, it will toggle that pin. That pin needs to be wired to the Maestro's RST pin for it to reset the servo controller.

Definition at line 16 of file PololuMaestro.cpp.

void Maestro::restartScript ( uint8_t  subroutineNumber)

Starts loaded script at specified subroutineNumber location.

Parameters
subroutineNumberA subroutine number defined in script's compiled code.

Starts the loaded script at location specified by the subroutine number. Subroutines are numbered in the order they are defined in loaded script. Click the "View Compiled Code..." button and look at the subroutine list to find the number for a particular subroutine.

See the Serial Interface section in the Maestro User's Guide for more details.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 48 of file PololuMaestro.cpp.

void Maestro::restartScriptWithParameter ( uint8_t  subroutineNumber,
uint16_t  parameter 
)

Starts loaded script at specified subroutineNumber location after loading parameter on to the stack.

Parameters
subroutineNumberA subroutine number defined in script's compiled code.
parameterA number from 0 to 16383.

Similar to the restartScript function, except it loads the parameter on to the stack before starting the script at the specified subroutine number location.

See the Serial Interface section in the Maestro User's Guide for more details.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 55 of file PololuMaestro.cpp.

void Maestro::setAcceleration ( uint8_t  channelNumber,
uint16_t  acceleration 
)

Sets the acceleration limit of channelNumber.

Parameters
channelNumberA servo number from 0 to 127.
accelerationA number from 0 to 16383.

Limits the acceleration a servo channel’s output value changes.

See the Serial Interface section in the Maestro User's Guide for more details.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 80 of file PololuMaestro.cpp.

void Maestro::setSpeed ( uint8_t  channelNumber,
uint16_t  speed 
)

Sets the speed limit of channelNumber.

Parameters
channelNumberA servo number from 0 to 127.
speedA number from 0 to 16383.

Limits the speed a servo channel’s output value changes.

See the Serial Interface section in the Maestro User's Guide for more details.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 72 of file PololuMaestro.cpp.

void Maestro::setTarget ( uint8_t  channelNumber,
uint16_t  target 
)

Sets the target of the servo on channelNumber.

Parameters
channelNumberA servo number from 0 to 127.
targetA number from 0 to 16383.

If the channel is configured as a servo, then the target represents the pulse width to transmit in units of quarter-microseconds. A target value of 0 tells the Maestro to stop sending pulses to the servo.

If the channel is configured as a digital output, values less than 6000 tell the Maestro to drive the line low, while values of 6000 or greater tell the Maestro to drive the line high.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 64 of file PololuMaestro.cpp.

void Maestro::setTargetMiniSSC ( uint8_t  channelNumber,
uint8_t  target 
)

Sets the target of the servo on channelNumber using the Mini SSC protocol.

Parameters
channelNumberA servo number from 0 to 254.
targetA target position from 0 to 254.

Definition at line 29 of file PololuMaestro.cpp.

void Maestro::stopScript ( )

Stops the script.

Stops the script, if it is currently running.

See the Serial Interface section in the Maestro User's Guide for more details.

The compact protocol is used by default. If the deviceNumber was given to the constructor, it uses the Pololu protocol.

Definition at line 42 of file PololuMaestro.cpp.


The documentation for this class was generated from the following files: