このライブラリは模型用のDCモータをmbedで直接制御します。 モータは正転、反転動作が可能です。 モータの回転速度は可変できます。 This library is directly controlled by a DC motor for model mbed. Motor forward rotation, inversion operation is possible. The motor speed is adjustable.
Dependents: adxl335_motor_direction
DcMotorDirectDrive Class Reference
Dc motor direct drive class. More...
#include <DcMotorDirectDrive.h>
Public Member Functions | |
DcMotorDirectDrive (PinName pwmPin, PinName referencePin) | |
Create a eight dot matrix led array object connected to the specified DigitalOut pin. | |
void | DcMotorDirectDrive_main (float request) |
Data set to the seven segment LED display. |
Detailed Description
Dc motor direct drive class.
Example:
//============================================ // DcMotorDirectDrive Library Example // // This program controls the motor 3. // Repeat the forward and reverse motor. // Continuously varies the rotational speed of the motor. // // <schematic> // // motor1,2,3 : mabuchi motor RF-300C-11440 DC3V 18mA 2200rpm) // __ // p21(pwmOut) ---------| | motor1 // | |-- // p22(digitalOut) ---------|__| // // __ // p23(pwmOut) ---------| | motor2 // | |-- // p24(digitalOut) ---------|__| // // __ // p25(pwmOut) ---------| | motor3 // | |-- // p26(digitalOut) ---------|__| // //============================================= #include "mbed.h" #include "DcMotorDirectDrive.h" // pwm pin // | // | reference pin // | | DcMotorDirectDrive motor1(p21, p22); DcMotorDirectDrive motor2(p23, p24); DcMotorDirectDrive motor3(p25, p26); DigitalOut led1(LED1); DigitalOut led4(LED4); Timer timer; // data change timer int main() { float siji = 1.0f; // motor output (+1.0 -> ... -> +0.5 -> -1.0 -> ... -> -0.5 -> +1.0) uint8_t fugo = 0; // 0 : normal rotation, 1 : reverse rotation timer.start(); while(1) { // After 100[ms] to start the process if(timer.read_ms() >= 100){ timer.reset(); if(fugo == 0){ // Normal rotation // siji = +1.0 -> +0.5 siji -= 0.005; if(siji < 0.5f){ fugo = 1; siji = -1.0f; } } else{ // Reverse rotation siji += 0.005; if(siji > -0.5f){ fugo = 0; siji = +1.0f; } } // Outputs a control instruction to the motor motor1.DcMotorDirectDrive_main(siji); motor2.DcMotorDirectDrive_main(siji); motor3.DcMotorDirectDrive_main(siji); // rotation display if(siji > 0.5){ // normal rotation led1 = 1; led4 = 0; } else{ // reverse rotation led1 = 0; led4 = 1; } } } }
Definition at line 136 of file DcMotorDirectDrive.h.
Constructor & Destructor Documentation
DcMotorDirectDrive | ( | PinName | pwmPin, |
PinName | referencePin | ||
) |
Create a eight dot matrix led array object connected to the specified DigitalOut pin.
DC motor direct drive object connected to the specified DigtalOutput pin.
- Parameters:
-
pwmPin PwmOut pin to connect to. pwm pin (p21 - p26) referencePin DigitalOut pin to connect to. Reference power supply pin (p5 - p30)
Definition at line 18 of file DcMotorDirectDrive.cpp.
Member Function Documentation
void DcMotorDirectDrive_main | ( | float | request ) |
Data set to the seven segment LED display.
- Parameters:
-
float request motor output request (-1.0 - 0.0 - 1.0) -1.0 to 0.0 : Reverse rotation, 0.0 : stop, 0.0 to +1.0 : normal rotation
Definition at line 34 of file DcMotorDirectDrive.cpp.
Generated on Fri Jul 15 2022 07:36:22 by 1.7.2