DC Controller Object
- Source:
- See:
-
- Use DC() for object creation.
- Use module:MotorHat/DC~dc#init for object initialization.
Methods
init(cbopt) → {module:MotorHat/DC~dc}
Initialize the DC controller instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cb |
callback |
<optional> |
Optional node style callback for asynch initialization |
- Source:
Returns:
Returns initialized DC controller object (self),
either directly or in second parameter to callback if callback provided to enable chaining.
run(dir, cb)
Starts the motor in the desired direction.
Parameters:
Name | Type | Description |
---|---|---|
dir |
'fwd' | 'back' | Direction of movement. |
cb |
callback | Node style callback. Gets called with cb(err, result) after completion. |
- Source:
runSync(dir)
Starts the motor in the desired direction.
Parameters:
Name | Type | Description |
---|---|---|
dir |
'fwd' | 'back' | Direction of movement. |
- Source:
setFrequency(freq, cb)
Sets the PWM frequency for the DC motor.
This setting affects the frequency at which the PWM chip will work to command the DC motor.
Parameters:
Name | Type | Description |
---|---|---|
freq |
Number | PWM Frequency in Hz. |
cb |
callback | Node style callback. Gets called with cb(err, result) after completion. |
- Source:
setFrequencySync(freq)
Sets the PWM frequency for the DC motor.
This setting affects the frequency at which the PWM chip will work to command the DC motor.
Parameters:
Name | Type | Description |
---|---|---|
freq |
Number | PWM Frequency in Hz. |
- Source:
setSpeed(speed, cb)
Sets DC motor speed.
The speed can be set as a percentage, from 0% to 100%. To change the actual top speed,
the actual voltage supplied to the motor needs to be controlled by hardware (get a higher
voltage source).
Parameters:
Name | Type | Description |
---|---|---|
speed |
number | Relative speed. 0% to 100%. |
cb |
callback | Node style callback. Gets called with cb(err, result) after completion. |
- Source:
setSpeedSync(speed)
Sets DC motor speed.
The speed can be set as a percentage, from 0% to 100%. To change the actual top speed,
the actual voltage supplied to the motor needs to be controlled by hardware (get a higher
voltage source).
Parameters:
Name | Type | Description |
---|---|---|
speed |
number | Relative speed. 0% to 100%. |
- Source:
stop(cb)
Stops the motor.
Doesn't actually brake the motor, just stops applying voltage to it.
Parameters:
Name | Type | Description |
---|---|---|
cb |
callback | Node style callback. Gets called with cb(err, result) after completion. |
- Source:
stopSync()
Stops the motor.
Doesn't actually brake the motor, just stops applying voltage to it.
- Source: