Raspberry Pi is very popular. The site already has a lot of articles on the creation of various projects based on it. As soon as it became available for sale, I also immediately wanted to buy one. Model B was purchased (with another 256Mb of memory) and accessories for it. And, naturally, I wanted to design something on its base. There was a desire to work with GPIO and use it as a controller. It was then that the idea to make a controlled car on wheels.
')
Iron part
The first thing on ebay was found the chassis for the future model. Each wheel has a separate engine. The design cost $ 33 and came to me by mail in a disassembled form. The production, naturally, is Chinese, so I had to work with a needle file so that the parts fit into the grooves.
Part of the components was bought on dx.com. The site turned out to be very convenient and inexpensive, I was pleasantly surprised by a good selection of different pieces on it, and free delivery to Ukraine came in handy. A dozen 2700mAh batteries and several chargers for them were also ordered there.
As a controller for engines, a motherboard based on the L298N chip was purchased.
One such board allows you to control two electric motors with different directions of movement. I decided to do with one such board and connected two left and two right engines in pairs. When you turn on all engines, depending on the direction of rotation, the machine goes forward or backward. To turn left, only the two right engines are turned on, while turning right - only two left engines.
Power to the engines is supplied through this controller. 6 batteries of 1.2 volts each were used.
Further, the problem with the autonomous power supply of the Raspberry Pi was solved. For this purpose, a similar block of 6 batteries was also used. Power to the board is connected via a DC-DC converter based on the LM2596 chip.
To connect the board to the network, the Edimax EW-7811UN Wi-Fi adapter was used. It is recommended as compatible hardware at elinux.org/RPi_VerifiedPeripherals , commercially available, small in size and easy to configure.
Software part
Now go to the software part. All code used in the project was written in C.
In the process of controlling the engines, GPIO0 - GPIO3 connectors are used, which are directly connected to the controller. The following order of signals to the controller is used:
To work with GPIO, a very convenient wiringPi library is used. Information on how to install it in the system and API can be found here - projects.drogon.net/raspberry-pi/wiringpi . The library also contains utilities with which you can initialize and signal the GPIO output without programming.
The code that signals the GPIO output looks like this:
... pinMode(0, OUTPUT); digitalWrite(0, 1); ...
In this case, a signal is output to the GPIO 0 output.
Next was the initial testing of the machine.
The next step was to write a server that accepts the connection from the client, receives and executes motor control commands. The protocol is quite simple: “Forward” - forward, “back” - back, “stop” - stop, “left” and “right” - turn off the left or right engines (depending on the direction), “quit” - close the connection with the client.
And finally about the client. To control the machine from a remote console, I considered the computer keyboard uninteresting. I decided that it should be controlled from the tablet, the idea spied in the game NFS Undercover.
The client was written for the Playbook using the Native SDK. On the official website there are enough examples and documentation to understand the platform. The SDK is installed along with the Eclipse-based QNX Momentics IDE. The most difficult part for me was creating the user interface with OpenGL ES, since I had never worked with graphics before. Images of controls were found on the Internet. The interface is very simple - launched the program, entered the IP address of the Raspberry Pi, connected to the server (switch at the top right of the screenshot) and drove off.
In the middle of the screen - switch forward, stop, back. When you tilt the tablet to a certain angle to the left or right, the commands are sent to turn left or right, respectively.
And, actually, the video showing the machine in action.
Immediately, there was a shortage of the chassis - the grip was not very good, and at the turns the wheels happened to slip. And I didn’t immediately like the design with rigidly fixed individual axes. I wanted to change the chassis for something more serious.
The cat, by the way, is also interested in projects based on the Raspberry Pi.