Arduino Engineering Kit: CP3.3 - MECHATRONICS: DC Motor
June 30, 2022
Run DC Motor
- Connect the Arduino board to the carrier with the correct direction
- Connect the dc motor with gear to carrier:
| DC Motor with gear |
carrier |
| M+ (black) |
M1+ |
| M- (red) |
M1- |
| VCC (brown) |
[empty] |
| OUTB (blue) |
HA1 |
| OUTA (purple) |
HB1 |
| GND (green) |
GND |
- Ensure the toggle on the carrier is at "off" side
- Plug in the usb port -> We should see green light on Arduino board and orange light on carrier
- Turn on the toggle
a = arduino() to initialize the Arduino board
carrier = motorCarrier(a) to initialize the carrier
dcm = dcmotor(carrier, "M1") to assign the dc motor at M1 port to dcm
dcm.start() to start the controller, the motor will not be triggered because the speed is 0
dcm.Speed = 1 to assign a value (between -1 and 1) to speed
dcm.stop() to stop the controller
enc = rotaryEncoder(carrier,1) to initialize the encoder of the motor at port 1
readCount(enc) to read the encoder count buffer
- run
readCount(enc) and get the value
- manually trun the magnatic disk full rotation
- run
readCount(enc) and get the value again.
- the diff of 2 values will be 12. Which means every "1" value is 30 degree of rotation.
resetCount(enc) to reset