I'd like to share this little project, comprising of some interesting concepts. After learning a few things about microcontrollers and some peripherals, I wanted to finally create something that can move. Being short of time, I have chosen as simple solution as possible, and that was using one of my son's toys for my project.
Even before I wanted to use computer to program some actions, not only in software. This can also be called a simple robotic project, but let's leave that for some other. If you want to control something "live" with your computer wireless or wired, this is one of the good ways to do it.
You can see it in action, here is the video:
I will present making of and principles in a few steps:
First of all, some technical data if someone is interested:
Used Vehicle: Jeep (Nikko)
Microcontroller: Atmega32 (AVR)
DC Motor driver IC: L293D
Bluetooth module: BC417143
On board LCD: HD47780 20x16
I decided to remove the complete original electronic interface. Original Jeep used 4 1.5 V batteries, taking two series, +3 V and - 3V out for forward and reverse motor direction. I took out only GND and +6V, as I have a special driver IC able to reverse the voltage. Of course, it is also needed to take out two motor leads.
Bluetooth way of communication is chosen becouse it gives a very simple way of communication between devices in both directions. And the magic simple way is called UART. This name is related with serial communication by two wires (Tx Rx). This is used not only on serial RS232 port on computer, but also in industrial communication, with a similar protocol, only the equipement is a little bit more expensive. Bluetooth makes Tx and Rx wireless, not endangering the simplicity. Besides, almost every laptop or mobile phone uses a bluetooth.
I bought a 3.3V BC417143 based Bluetooth module, which I had to prepare for 5V levels used with ATmega32A. I suggest getting already prepared 5 V version.
Motor driver chip is L293D. One IC can handle 2 motors (starting and reversing), and is simple enough and cheap. It had been attached to protoboard on Jeep's hood. I suggest to use some of Reference links below to find out how it works.
In the video, you will see one wire coming out from the Jeep. At that moment I could not get enough power from my batteries, since I need at least 8 V at my regulator to get constant 5 V. Additional battery pack shall be attached to existing 5 V to achieve that, and at the time I could not connect all this so I just used "powerfull" wall adapter to get steady 9V. 12 V battery could also be used.
When everything is assembled, the Robo Jeep looks like this:
I also added HD47780 LCD display to this project only because it helps me to debug while programming, but later I used it do display messages sent from the laptop which is pretty neat. I suggest using such a debugging method, but it is optional.
So first I tested everything without any communication just to see how motor driver works.
Using UART it is possible to send some messages from one side to the other. Transmission is secured and monitored by hardware and works automatically. In this case, bluetooth adapter serves only as a bridge between computer and controller. The same could be done by connecting wires directly to the computer, using USB to UART converter for example. A good way of data can be transmitted this way, but in this project only some characters are sent, or a few words.
Generally, when you have UART ready you can use hyper terminal to send commands from the computer. For example you send F, and it means move forward for a part of second. FFFF would mean move forward a few times and similar. Also some special codes can be used to send message to display like ? Hello word sent means display Hello on LCD. This is the way it is done here. But if you want something nicer than typing commands you can also create a graphical interface. When you don't want to use special compilers like visual studio, you can use this trick: Use VBA - visual basic for aplications. That way I made the interface in Microsoft Power Point using VBA. It looks like this:
VBA programming is not very complicated, but in case like this you do need to find some specfic functions somewhere, or create it yourself.
This is all I will say about this project. It can be infinitely modified and enacted for many functions and purposes. It's purposes is only to demonstrate how this can work, and to relax a bit from some more complicated implementations. And by the way, this is my first blog ever, so I might have written too much, but I hope this is helpful to someone.
DAHRMANITECH - DESIGN WITH MICROCONTROLLERS
EXTREME ELECTRONICS - L293D -- For DC motor control using L293D
EMCELETTRONICA - VBA UART
5. Additional functionallity
Clearly, many additional functions and devices can be added to a project like this. For example, later I connected a servo motor and created a bluetooh controlled ramp (tollgate). My son had a wery neat new toy! Here is the photo:
And this is a nice site for instructions how to use a servo:
EXTREME ELECTRONICS - SERVO
And by the way, servos are really great devices to use with micro controllers. Even the cheapest ones from ebay work nice. I have tried 9G so far, and it's just fine!
vpsus@yahoo.com
On board LCD: HD47780 20x16
1. Disassembly of existing vehicle and preparation works
Not much of a craft, but it is good to have a good vehicle like this one. Here are a few photos from the start:I decided to remove the complete original electronic interface. Original Jeep used 4 1.5 V batteries, taking two series, +3 V and - 3V out for forward and reverse motor direction. I took out only GND and +6V, as I have a special driver IC able to reverse the voltage. Of course, it is also needed to take out two motor leads.
2. Preparing the equipement
For my project's I usually use proto-boards, or specially designed universal board. I made this board myself for other purposes, but anything else with an uC on it can be used. Check out my References chapter at the end for details and interesting sources.The setup in general |
I bought a 3.3V BC417143 based Bluetooth module, which I had to prepare for 5V levels used with ATmega32A. I suggest getting already prepared 5 V version.
Motor driver chip is L293D. One IC can handle 2 motors (starting and reversing), and is simple enough and cheap. It had been attached to protoboard on Jeep's hood. I suggest to use some of Reference links below to find out how it works.
In the video, you will see one wire coming out from the Jeep. At that moment I could not get enough power from my batteries, since I need at least 8 V at my regulator to get constant 5 V. Additional battery pack shall be attached to existing 5 V to achieve that, and at the time I could not connect all this so I just used "powerfull" wall adapter to get steady 9V. 12 V battery could also be used.
When everything is assembled, the Robo Jeep looks like this:
3. Programming, testing, getting it to work
It is preety obvious that this is the hardest part. However, since today there are a great sources online, it is only hard to learn how to use them. AVR is used here, but any other uC might be used for this. I use AVR with free AVR Studio from Atmel. DC motor driver is hardwired to uC with three wires. Two of them determine the direction, and one enables the motor. I also implemented PWM for speed regulation here, but it can also work without it (ON/OFF).I also added HD47780 LCD display to this project only because it helps me to debug while programming, but later I used it do display messages sent from the laptop which is pretty neat. I suggest using such a debugging method, but it is optional.
So first I tested everything without any communication just to see how motor driver works.
4. Communication
Communication with the vehicle is actually the main task of this project. As allready mentioned it is done trough UART. The great thing about it is that UART function is embedded in many devices like micro controllers, computer COM ports, bluetooth devices. That makes using it more simpler, and hardware more usable and stable. Below is the diagram of the way devices are interconnected here.Using UART it is possible to send some messages from one side to the other. Transmission is secured and monitored by hardware and works automatically. In this case, bluetooth adapter serves only as a bridge between computer and controller. The same could be done by connecting wires directly to the computer, using USB to UART converter for example. A good way of data can be transmitted this way, but in this project only some characters are sent, or a few words.
Generally, when you have UART ready you can use hyper terminal to send commands from the computer. For example you send F, and it means move forward for a part of second. FFFF would mean move forward a few times and similar. Also some special codes can be used to send message to display like ? Hello word sent means display Hello on LCD. This is the way it is done here. But if you want something nicer than typing commands you can also create a graphical interface. When you don't want to use special compilers like visual studio, you can use this trick: Use VBA - visual basic for aplications. That way I made the interface in Microsoft Power Point using VBA. It looks like this:
VBA programming is not very complicated, but in case like this you do need to find some specfic functions somewhere, or create it yourself.
This is all I will say about this project. It can be infinitely modified and enacted for many functions and purposes. It's purposes is only to demonstrate how this can work, and to relax a bit from some more complicated implementations. And by the way, this is my first blog ever, so I might have written too much, but I hope this is helpful to someone.
4. References
These references also serve as a thanks to all the great experts from which I learned so much.DAHRMANITECH - DESIGN WITH MICROCONTROLLERS
EXTREME ELECTRONICS - L293D -- For DC motor control using L293D
EMCELETTRONICA - VBA UART
5. Additional functionallity
Clearly, many additional functions and devices can be added to a project like this. For example, later I connected a servo motor and created a bluetooh controlled ramp (tollgate). My son had a wery neat new toy! Here is the photo:
And this is a nice site for instructions how to use a servo:
EXTREME ELECTRONICS - SERVO
And by the way, servos are really great devices to use with micro controllers. Even the cheapest ones from ebay work nice. I have tried 9G so far, and it's just fine!
vpsus@yahoo.com
Nema komentara:
Objavi komentar