INTRO
The original trick "similar" to this one was done by Nikola Tesla to impress the spectators many years ago. At the time, the great inventor had "nothing but" his brilliant ideas to achieve his goal, and thanks to that brilliant ideas we are able to do something like this today using nothing but general purpose electronics worth a couple of dollars.
This project is developed just to make a working hands-on example of integration of a few previously teststed ideas dveloped arround the ATmega8 controller. It is certainly not the simplest concept to achieve the desired function, but it does demonstrate some powerful capabilities of equipement used. Nicola (BTW who I'm proud to have as a neighbour in terms of birthplace - Croatia) would surely be glad to see how his inventions are used today by looking at examples like this.
THE FUNCTION IS...
To achieve a wireless control of former R/C control 4X4 car with a typical Gamepad as a controller. The PC is used in between giving some more upgradeable options, but also for the sake of simplicity.
SYSTEM DIAGRAM
THE PARTS OF THE SYSTEM
GAMEPAD
Any kind of typical "HID compliant" gamepad will be suitable. In this example it was a PS type wireless controller with possibility of analogue axis (not used here)
LAPTOP AND SOFTWARE
A windows 7 laptop with bluetooth adapter is used here. The software to receive gamepad data and guide it to car electronics is NI LABVIEW. More about this beautiful tool later.
SERVO MOTOR
Servo motor is used as a steering mechanism, just like it
would be on a classical car. To see more information of this motor you
may see my other blog posts
like this one.
Servo motor: 9G
Servo Stall Torque at 4.8 V: 1.2 kg/cm (16.7 oz/in)
Servo speed at 4.8 V (no load): 0.12 sec / 60 °
Fitting (mechanically) of servo motor is not an easy task. I made a small crank out of a paperclip and had to carve a lot of plastic. The final result is OK but could be improved for performance.
MAIN MOTOR CONTROL
A PWM cntrol for main motor torque and direction control are used here, directed from the ATmega. The good all in one solution for such a task is the following DC motor driver IC:
L293D. This chip had to be "dead-bug" integrated to existing board.
THE BLUETOOTH CONTROLLER
The connection between the PC and 4x4's ATmega8 board is made by bluetooth UART. For such a task, and if no long distance control is needed, the bluetooth module that one will most probbably use is: BC417143
THE 4X4 ELECTRONICS BOARD:
Last but the most important part is the ATmega8 onboard the 4x4 which controls servo and main motor, and does the processing of bluetooth UART messages. This board is used from my other project (solar controller) so the original PCB is modified to fit in properly and some additional components are added to the board. The one might want to consider using the Arduino (e.g. Nano) for this purpose not to get the hands too dirty.
NI LABVIEW
This great software from National Instruments is used to simplify data reception from gamepad, processing and sending out ti Bluetooth. LABVIEW could be defined as virtual laboratory, but it is also capable to make many other tasks like different forms of control. This powerful platform is typically used connected to laboratory grade I/O boards. But nothing stands in way to interface it with "cheap" but "powerful" world of general purpose microcontrollers!
Working in LABVIEW is simple due to intuitive block-typed interface and great number of online tutorials. Some of these tutorials are useful even if you are not considering using LABVIEW. I highly recommend this software. You can download a trail from
NI site and give it a try.
The following "VI" is the one created in LABVIEW for this project. Note that this VI screen reads only the Y axis of controller. This is done for simplicity of view.
The upper line deals with reading the gamepad data. Y axis analog value is taken and then forwards a special character as a command for final action to ATmega8. For example it will send 0 (do nothing) if analog Y value is not higher than 10(forward) or lower than -10(reverse). Lower line deals with UART protocol which sends the data via Bluetooth com port. The middle part is actually a loop which executes continuously with 100 ms delays. Left side is initialization of GAMEPAD and UART and right side is closing of those once operation is terminated.
THE CONCLUSION
This system is tested successfully and everything worked as expected, so similar systems shall be easy to be built. I'll try to put some more photos/videos when I catch some time.
SOURCE CODES
I was not able (time) to collect all the final versions of my code for all the devices therefore one might have problems using that source. It is however not a very complicated code and presented VI shows the blocks which are used. I'll be happy to answer any question if being asked!