EP-0108
DockerPi Motor Board(A) SKU:EP-0108
Description
DockerPi Motor Board(A) is a DockerPi series expansion board.It can control two 12V DC motors.
DockerPi Motor Board(A) can be used in Raspberry Pi.You could communicate with it by opening I2C.
DockerPi Motor Board(A) can be used only one,but it still can be stacked with other DockerPi expansion board.
If you need to run for a long time ,we recommend that you use our DockerPi Power expansion board to provide more power.
Features
- DockerPi Series
- Programmable
- Control directly(without progarmming)
- Extend GPIO Pins
- Two DC 12V motors
- Can stack with other stack board
- Independent of the mainboard hardware (require I2C support)
Specification
Official Compatibility Test
Not only support the following development boards, other development boards can be compatible if they have I2C peripherals. (Note: some software changes may be required)
Platform | DockerPi Motor Board | Notes |
---|---|---|
Raspberry Pi All Platform | √ | Not Include CM Series & EOL Platform |
Gallery
Package Includes
Register Map
Register Address | Function | Value |
---|---|---|
0x01 | Set Motor 1 speed | Set Motor 1 speed Low 8 bit |
0x02 | Set Motor 1 speed | Set Motor 1 speed High 8 bit |
0x03 | Set Motor 2 speed | Set Motor 2 speed Low 8 bit |
0x04 | Set Motor 2 speed | Set Motor 2 speed High 8 bit |
0x05 | Set Motor 1 count | Set Motor 1 count Low 8 bit |
0x06 | Set Motor 1 count | Set Motor 1 count High 8 bit |
0x07 | Set Motor 2 count | Set Motor 2 count Low 8 bit |
0x08 | Set Motor 2 count | Set Motor 2 count High 8 bit |
0x09 | Set status of Direction | Set Motor 1 and Motor 2 Direction |
0x0A | Now Motor 1 speed | Now Motor 1 speed Low 8 bit |
0x0B | Now Motor 1 speed | Now Motor 1 speed High 8 bit |
0x0C | Now Motor 2 speed | Now Motor 2 speed Low 8 bit |
0x0D | Now Motor 2 speed | Now Motor 2 speed High 8 bit |
0x0E | Now Motor 1 count | Now Motor 1 count Low 8 bit |
0x0F | Now Motor 1 count | Now Motor 1 count High 8 bit |
0x10 | Now Motor 2 count | Now Motor 2 count Low 8 bit |
0x11 | Now Motor 2 count | Now Motor 2 count High 8 bit |
0x12 | Now status of Direction | Now status of Direction |
0x13 | Enable | Enable data write |
Configuring I2C(Raspberry Pi)
Run sudo raspi-config and follow the prompts to install i2c support for the ARM core and linux kernel
Go to Interfacing Options
then I2C
Enable!
Done!
Direct control wtihout programming(Raspberry Pi)
Program in language C(Raspberrry Pi)
- Create a new file named:Motor.c and paste following codes:
#include <stdio.h> #include <stdint.h> #include <wiringPi.h> #include <wiringPiI2C.h> //MOTOR_DRIVER Address #define DEVICE_ARRD 0x18 //Set the speed value of MOTOR_DRIVER #define MOTOR_DRIVER_SPEED_SET_1 500 #define MOTOR_DRIVER_SPEED_SET_2 1000 //Set the status of MOTOR_DRIVER #define MOTOR_DRIVER_DIRECTION_STATUS 0x01 //The functions of MOTOR_DRIVER #define MOTOR_DRIVER_SPEED_1_L 0x01 #define MOTOR_DRIVER_SPEED_1_H 0x02 #define MOTOR_DRIVER_SPEED_2_L 0x03 #define MOTOR_DRIVER_SPEED_2_H 0x04 #define MOTOR_DRIVER_COUNT_1_L 0x05 #define MOTOR_DRIVER_COUNT_1_H 0x06 #define MOTOR_DRIVER_COUNT_2_L 0x07 #define MOTOR_DRIVER_COUNT_2_H 0x08 #define MOTOR_DRIVER_DIRECTION 0x09 #define MOTOR_DRIVER_SPEED_NOW_1_L 0x0a #define MOTOR_DRIVER_SPEED_NOW_1_H 0x0b #define MOTOR_DRIVER_SPEED_NOW_2_L 0x0c #define MOTOR_DRIVER_SPEED_NOW_2_H 0x0d #define MOTOR_DRIVER_COUNT_NOW_1_L 0x0e #define MOTOR_DRIVER_COUNT_NOW_1_H 0x0f #define MOTOR_DRIVER_COUNT_NOW_2_L 0x10 #define MOTOR_DRIVER_COUNT_NOW_2_H 0x11 #define MOTOR_DRIVER_DIRECTION_NOW 0x12 #define MOTOR_DRIVER_ENABLE 0x13 int main(void) { int device_addr; int i = 0; device_addr = wiringPiI2CSetup(DEVICE_ARRD); if (device_addr < 0) printf("Extend board Can not be initialized, please enable I2C and try again!\n", device_addr); if (MOTOR_DRIVER_SPEED_SET_1 <= 255) printf("Now the speed of MOTOR_DRIVER_1 is: %d\n" ,(int)(wiringPiI2CReadReg8(device_addr,MOTOR_DRIVER_SPEED_1_L))); else printf("Now the speed of MOTOR_DRIVER_1 is: %d\n" ,(int)((wiringPiI2CReadReg8(device_addr,MOTOR_DRIVER_SPEED_NOW_1_H) << 8 | wiringPiI2CReadReg8(device_addr,MOTOR_DRIVER_SPEED_1_L)))); if (MOTOR_DRIVER_SPEED_SET_2 <= 255) printf("Now the speed of MOTOR_DRIVER_2 is: %d\n" ,(int)(wiringPiI2CReadReg8(device_addr,MOTOR_DRIVER_SPEED_2_L))); else printf("Now the speed of MOTOR_DRIVER_2 is: %d\n" ,(int)((wiringPiI2CReadReg8(device_addr,MOTOR_DRIVER_SPEED_NOW_2_H) << 8 | wiringPiI2CReadReg8(device_addr,MOTOR_DRIVER_SPEED_2_L)))); if (((wiringPiI2CReadReg8(device_addr,MOTOR_DRIVER_DIRECTION_NOW) & 0x01) == 0x01)) printf("Now the direction of MOTOR_DRIVER_1 is:CW\n"); else printf("Now the direction of MOTOR_DRIVER_1 is:CCW\n"); if (((wiringPiI2CReadReg8(device_addr,MOTOR_DRIVER_DIRECTION_NOW) & 0x02) == 0x02)) printf("Now the direction of MOTOR_DRIVER_2 is:CW\n"); else printf("Now the direction of MOTOR_DRIVER_2 is:CCW\n"); wiringPiI2CWriteReg8(device_addr,MOTOR_DRIVER_SPEED_1_L,(MOTOR_DRIVER_SPEED_SET_1 & 0xff)); wiringPiI2CWriteReg8(device_addr,MOTOR_DRIVER_SPEED_1_H,(MOTOR_DRIVER_SPEED_SET_1 >> 8)); wiringPiI2CWriteReg8(device_addr,MOTOR_DRIVER_SPEED_2_L,(MOTOR_DRIVER_SPEED_SET_2 & 0xff)); wiringPiI2CWriteReg8(device_addr,MOTOR_DRIVER_SPEED_2_H,(MOTOR_DRIVER_SPEED_SET_2 >> 8)); wiringPiI2CWriteReg8(device_addr,MOTOR_DRIVER_ENABLE,DEVICE_ARRD); }
Compile!
gcc Motor.c -lwiringPi -o Motor
Exec It!
./Motor
Progarm in language Python(Raspberry Pi)
Progarm in language java(Raspberry Pi)
FAQ
Keywords
Motor,DockerPi