Many people purchased our two types of Mecanum Omni wheel robot car from following link:
Above robot cars are controlled by Arduino. Actually the robot car can also be controlled by Raspberry Pi.
In this lesson we will tell you how to use Raspberry Pi 3 python programming language to control the Mecanum wheel car.
If you have installed the Arduino Mecanum robot car lesson 1, please keep all the installation except following change:
There are two pcs of Model X boards in Arduino kit. Please remove JUST ONE pc Model-X and replace it with a Model Pi board.
Model Pi and Model X are almost same, but Model Pi have USB 5V output which can power raspberry Pi. So we only need one pc Model Pi board and keep another Model X board in the chassis.
The purchase link of Model-Pi board is https://osoyoo.store/products/model-x-l298n-motor-driver-board-for-raspberry-pi?variant=31322165313647
The installation tutorial of Model-Pi is in https://osoyoo.com/2020/03/01/python-programming-tutorial-model-pi-l298n-motor-driver-for-raspberry-pi/ , actually it is exact same as Model X. Just let you know your Raspberry Pi can get power from its USB port.
After replacing the Model X with Model-Pi and Arduino with Raspberry Pi, the car will look as following:
1) Connect Front L298N(Model X) module to front 2 motors as following:
2) Connect Model-Pi L298N module to 2 motors in the back as following:
3)Connect two L298N Motor drivers control ports to Raspberry Pi GPIO ports
Raspberry Pi to Rear Model-Pi board
|Raspberry Pi||Real Model-Pi|
|Pin 16(GPIO 23)||IN1|
|Pin 18(GPIO 24)||IN2|
|Pin 13(GPIO 27)||IN3|
|Pin 15(GPIO 22)||IN4|
|Pin 12(GPIO 18)||ENA|
|Pin 33(GPIO 13)||ENB|
Raspberry Pi to Front Model-X board
|Raspberry Pi||Front Model-X|
|Pin 40(GPIO 21)||IN1|
|Pin 38(GPIO 20)||IN2|
|Pin 36(GPIO 16)||IN3|
|Pin 32(GPIO 12)||IN4|
If you don’t know the GPIO PIN location in Raspberry Pi, check following pin map:
now turn on the battery box and make sure Raspberry Pi and Model Pi board both have LED turned on.
use putty(in windows) or ssh command(in linux or MacBook) to connect raspberry pi, then type following two commands:
Your two motors will make following movement
At beginning: car move forward
Then car move backward
then car turn left
then car right turn
then car make right parallel shift
then car make left parallel shift
finally car will make some X direction movement
you can download the python code from https://osoyoo.com/driver/mecanum/mecanum-pi.py
We have written detail comments in above python code to help you understand the working principal of motors.
DownLoad Url osoyoo.com