|
virtual int | _invokeValueCallback (string value) |
|
double | brakingForce (void) |
|
virtual int | brakingForceMove (double targetPower, int delay) |
|
string | command (void) |
|
double | cutOffVoltage (void) |
|
double | drivingForce (void) |
|
virtual int | drivingForceMove (double targetPower, int delay) |
|
int | failSafeTimeout (void) |
|
double | frequency (void) |
|
double | get_brakingForce (void) |
|
string | get_command (void) |
|
double | get_cutOffVoltage (void) |
|
double | get_drivingForce (void) |
|
int | get_failSafeTimeout (void) |
|
double | get_frequency (void) |
|
Y_MOTORSTATUS_enum | get_motorStatus (void) |
|
int | get_overCurrentLimit (void) |
|
int | get_starterTime (void) |
|
virtual int | keepALive (void) |
|
Y_MOTORSTATUS_enum | motorStatus (void) |
|
YMotor * | next (void) |
|
YMotor * | nextMotor (void) |
|
int | overCurrentLimit (void) |
|
virtual int | registerValueCallback (YMotorValueCallback callback) |
|
virtual int | resetStatus (void) |
|
int | set_brakingForce (double newval) |
|
int | set_command (const string &newval) |
|
int | set_cutOffVoltage (double newval) |
|
int | set_drivingForce (double newval) |
|
int | set_failSafeTimeout (int newval) |
|
int | set_frequency (double newval) |
|
int | set_motorStatus (Y_MOTORSTATUS_enum newval) |
|
int | set_overCurrentLimit (int newval) |
|
int | set_starterTime (int newval) |
|
int | setBrakingForce (double newval) |
|
int | setCommand (const string &newval) |
|
int | setCutOffVoltage (double newval) |
|
int | setDrivingForce (double newval) |
|
int | setFailSafeTimeout (int newval) |
|
int | setFrequency (double newval) |
|
int | setMotorStatus (Y_MOTORSTATUS_enum newval) |
|
int | setOverCurrentLimit (int newval) |
|
int | setStarterTime (int newval) |
|
int | starterTime (void) |
|
| ~YMotor () |
|
void | _clearDataStreamCache () |
|
string | _decode_json_string (const string &json) |
|
string | _download (const string &url) |
|
YDataStream * | _findDataStream (YDataSet &dataset, const string &def) |
|
string | _get_json_path (const string &json, const string &path) |
|
vector< string > | _json_get_array (const string &json) |
|
string | _json_get_key (const string &json, const string &data) |
|
string | _json_get_string (const string &json) |
|
int | _parseEx (yJsonStateMachine &j) |
|
virtual int | _parserHelper (void) |
|
string | _parseString (yJsonStateMachine &j) |
|
string | _request (const string &request) |
|
string | _requestEx (int tcpchan, const string &request, yapiRequestProgressCallback callback, void *context) |
|
void | _throw (YRETCODE errType, string errMsg) |
|
YRETCODE | _upload (const string &path, const string &content) |
|
YRETCODE | _uploadWithProgress (const string &path, const string &content, yapiRequestProgressCallback callback, void *context) |
|
string | advertisedValue (void) |
|
void | clearCache () |
|
string | describe (void) |
|
string | errMessage (void) |
|
string | errorMessage (void) |
|
YRETCODE | errorType (void) |
|
YRETCODE | errType (void) |
|
YFUN_DESCR | functionDescriptor (void) |
|
string | get_advertisedValue (void) |
|
string | get_errorMessage (void) |
|
YRETCODE | get_errorType (void) |
|
virtual string | get_friendlyName (void) |
|
YFUN_DESCR | get_functionDescriptor (void) |
|
string | get_functionId (void) |
|
string | get_hardwareId (void) |
|
string | get_hubSerial () |
|
string | get_logicalName (void) |
|
YModule * | get_module (void) |
|
void * | get_userData (void) |
|
bool | isOnline (void) |
|
YRETCODE | load (int msValidity) |
|
virtual string | loadAttribute (string attrName) |
|
string | logicalName (void) |
|
YModule * | module (void) |
|
virtual int | muteValueCallbacks (void) |
|
YFunction * | next (void) |
|
YFunction * | nextFunction (void) |
|
virtual int | registerValueCallback (YFunctionValueCallback callback) |
|
int | set_advertisedValue (const string &newval) |
|
int | set_logicalName (const string &newval) |
|
void | set_userData (void *data) |
|
int | setAdvertisedValue (const string &newval) |
|
int | setLogicalName (const string &newval) |
|
void | setUserData (void *data) |
|
virtual int | unmuteValueCallbacks (void) |
|
void * | userData (void) |
|
virtual | ~YFunction () |
|
YMotor Class: Motor function interface
Yoctopuce application programming interface allows you to drive the power sent to the motor to make it turn both ways, but also to drive accelerations and decelerations. The motor will then accelerate automatically: you will not have to monitor it. The API also allows to slow down the motor by shortening its terminals: the motor will then act as an electromagnetic brake.
Definition at line 89 of file yocto_motor.h.
YMotor * YMotor::FindMotor |
( |
string |
func | ) |
|
|
static |
Retrieves a motor for a given identifier. The identifier can be specified using several formats:
-
FunctionLogicalName
-
ModuleSerialNumber.FunctionIdentifier
-
ModuleSerialNumber.FunctionLogicalName
-
ModuleLogicalName.FunctionIdentifier
-
ModuleLogicalName.FunctionLogicalName
This function does not require that the motor is online at the time it is invoked. The returned object is nevertheless valid. Use the method YMotor.isOnline() to test if the motor is indeed online at a given time. In case of ambiguity when looking for a motor by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.
If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.
- Parameters
-
func | : a string that uniquely characterizes the motor |
- Returns
- a YMotor object allowing you to drive the motor.
Definition at line 659 of file yocto_motor.cpp.
int YMotor::get_failSafeTimeout |
( |
void |
| ) |
|
Returns the delay in milliseconds allowed for the controller to run autonomously without receiving any instruction from the control process. When this delay has elapsed, the controller automatically stops the motor and switches to FAILSAFE error. Failsafe security is disabled when the value is zero.
- Returns
- an integer corresponding to the delay in milliseconds allowed for the controller to run autonomously without receiving any instruction from the control process
On failure, throws an exception or returns Y_FAILSAFETIMEOUT_INVALID.
Definition at line 542 of file yocto_motor.cpp.
Return the controller state. Possible states are: IDLE when the motor is stopped/in free wheel, ready to start; FORWD when the controller is driving the motor forward; BACKWD when the controller is driving the motor backward; BRAKE when the controller is braking; LOVOLT when the controller has detected a low voltage condition; HICURR when the controller has detected an overcurrent condition; HIHEAT when the controller has detected an overheat condition; FAILSF when the controller switched on the failsafe security.
When an error condition occurred (LOVOLT, HICURR, HIHEAT, FAILSF), the controller status must be explicitly reset using the resetStatus function.
- Returns
- a value among Y_MOTORSTATUS_IDLE, Y_MOTORSTATUS_BRAKE, Y_MOTORSTATUS_FORWD, Y_MOTORSTATUS_BACKWD, Y_MOTORSTATUS_LOVOLT, Y_MOTORSTATUS_HICURR, Y_MOTORSTATUS_HIHEAT and Y_MOTORSTATUS_FAILSF
On failure, throws an exception or returns Y_MOTORSTATUS_INVALID.
Definition at line 133 of file yocto_motor.cpp.
int YMotor::set_brakingForce |
( |
double |
newval | ) |
|
Changes immediately the braking force applied to the motor (in percents). The value 0 corresponds to no braking (free wheel). When the braking force is changed, the driving power is set to zero. The value is a percentage.
- Parameters
-
newval | : a floating point number corresponding to immediately the braking force applied to the motor (in percents) |
- Returns
- YAPI_SUCCESS if the call succeeds.
On failure, throws an exception or returns a negative error code.
Definition at line 242 of file yocto_motor.cpp.
int YMotor::set_cutOffVoltage |
( |
double |
newval | ) |
|
Changes the threshold voltage under which the controller automatically switches to error state and prevents further current draw. This setting prevent damage to a battery that can occur when drawing current from an "empty" battery. Note that whatever the cutoff threshold, the controller switches to undervoltage error state if the power supply goes under 3V, even for a very brief time.
- Parameters
-
newval | : a floating point number corresponding to the threshold voltage under which the controller automatically switches to error state and prevents further current draw |
- Returns
- YAPI_SUCCESS if the call succeeds.
On failure, throws an exception or returns a negative error code.
Definition at line 303 of file yocto_motor.cpp.
int YMotor::set_drivingForce |
( |
double |
newval | ) |
|
Changes immediately the power sent to the motor. The value is a percentage between -100% to 100%. If you want go easy on your mechanics and avoid excessive current consumption, try to avoid brutal power changes. For example, immediate transition from forward full power to reverse full power is a very bad idea. Each time the driving power is modified, the braking power is set to zero.
- Parameters
-
newval | : a floating point number corresponding to immediately the power sent to the motor |
- Returns
- YAPI_SUCCESS if the call succeeds.
On failure, throws an exception or returns a negative error code.
Definition at line 184 of file yocto_motor.cpp.
int YMotor::set_failSafeTimeout |
( |
int |
newval | ) |
|
Changes the delay in milliseconds allowed for the controller to run autonomously without receiving any instruction from the control process. When this delay has elapsed, the controller automatically stops the motor and switches to FAILSAFE error. Failsafe security is disabled when the value is zero.
- Parameters
-
newval | : an integer corresponding to the delay in milliseconds allowed for the controller to run autonomously without receiving any instruction from the control process |
- Returns
- YAPI_SUCCESS if the call succeeds.
On failure, throws an exception or returns a negative error code.
Definition at line 578 of file yocto_motor.cpp.
int YMotor::set_frequency |
( |
double |
newval | ) |
|
Changes the PWM frequency used to control the motor. Low frequency is usually more efficient and may help the motor to start, but an audible noise might be generated. A higher frequency reduces the noise, but more energy is converted into heat.
- Parameters
-
newval | : a floating point number corresponding to the PWM frequency used to control the motor |
- Returns
- YAPI_SUCCESS if the call succeeds.
On failure, throws an exception or returns a negative error code.
Definition at line 425 of file yocto_motor.cpp.
int YMotor::set_overCurrentLimit |
( |
int |
newval | ) |
|
Changes the current threshold (in mA) above which the controller automatically switches to error state. A zero value means that there is no limit. Note that whatever the current limit is, the controller switches to OVERCURRENT status if the current goes above 32A, even for a very brief time.
- Parameters
-
newval | : an integer corresponding to the current threshold (in mA) above which the controller automatically switches to error state |
- Returns
- YAPI_SUCCESS if the call succeeds.
On failure, throws an exception or returns a negative error code.
Definition at line 397 of file yocto_motor.cpp.
YMotor* yFindMotor |
( |
const string & |
func | ) |
|
|
friend |
Retrieves a motor for a given identifier. The identifier can be specified using several formats:
-
FunctionLogicalName
-
ModuleSerialNumber.FunctionIdentifier
-
ModuleSerialNumber.FunctionLogicalName
-
ModuleLogicalName.FunctionIdentifier
-
ModuleLogicalName.FunctionLogicalName
This function does not require that the motor is online at the time it is invoked. The returned object is nevertheless valid. Use the method YMotor.isOnline() to test if the motor is indeed online at a given time. In case of ambiguity when looking for a motor by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.
If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.
- Parameters
-
func | : a string that uniquely characterizes the motor |
- Returns
- a YMotor object allowing you to drive the motor.
Definition at line 542 of file yocto_motor.h.