Hi,
I am trying to set up a link between an AVR microcontroller and a PC. I need the PC to send signals to set the input pins high/low, and also so the microcontroller can send the values of its output pins back to the PC for analysis.
Initially I would like to do this using cables to simplify things, but later on if it is possible, I am keen to use a wireless link for the two-way communication. I have had a look at some products that seem to do this sort of thing, but I am confused as to what exactly they do. Any suggestions for what products are available for what I am trying to do, or how I can make one myself?
Thanks very much!
you could wire the PC’s parallel port wires to the microprocessor’s I/O port. With Windows XP you’ll need special software for your PC program to manipulate the parallel port bits - as inputs or outputs.
Alternatively, if the goal is to move information from the micro to the PC, I’m sure you know that the serial port is an easy way.
Hi ejohns85,
The simplest way to setup communication between your microcontroller and pc is through serial. All you need is a micro, a max232 and a db9 serial cable. If you give me more info on what you want your project to do and what kind of hardware you’re using such as which microcontroller, I can give you more detailed info.
As to wireless link, bluetooth is the easiest way to go. Its almost like having a serial cable.
Cheers
Hey,
The microcontroller I am using is the ATmega32. The max232 converts from 5V TTL to the correct level for a PC, right? So would I attatch it at the PC end of the serial cable?
In my project, I am trying to read in pixel data from a video camera, analyse it and then send out control commands to the micricontroller which is on a mobile robot. There will be two input lines on the microcontroller that need to be controlled from the PC, which are to control two motors on the robot. If the serial data is just a long stream of 1s and 0s, how can I convert this so that it sets the two microcontroller inputs to be 1s or 0s? For example, can I configure it so that sending 00 on the serial linke would set both microcontroller inputs to 0, sending 10 would set the first to 1 and second to 0, and so on? How would the microcontroller know where the start of each “packet” of 2 bits is?
Also, do you happend to know what C code I need to write to be able to send this data along the serial link from the software I am writing?
Thanks a million!!
ejohns85:
Hey,
The microcontroller I am using is the ATmega32. The max232 converts from 5V TTL to the correct level for a PC, right? So would I attatch it at the PC end of the serial cable?
Yes. Be sure to get TXD and RXD correct. It’s confusing.
In my project, I am trying to read in pixel data from a video camera, analyse it and then send out control commands to the micricontroller which is on a mobile robot. There will be two input lines on the microcontroller that need to be controlled from the PC, which are to control two motors on the robot. If the serial data is just a long stream of 1s and 0s, how can I convert this so that it sets the two microcontroller inputs to be 1s or 0s? For example, can I configure it so that sending 00 on the serial linke would set both microcontroller inputs to 0, sending 10 would set the first to 1 and second to 0, and so on? How would the microcontroller know where the start of each “packet” of 2 bits is?
reading pixel data from a camera: That camera is connected to the PC? I'll assume yes based on what you said.
So you could arrange a “protocol” for the PC to send commands to the AVR via the serial port connection. On the serial port, you’d send one byte of 8 bits from the PC to the AVR. The AVR would get that byte and interpret the 8 bits in the manner that your protocol says. Example, you could send a binary 00000001 or 00000011; each of these are the 8 bits of a byte. Another way is to send a byte as an text (ASCII) character. You can devise a protocol of commands like “A” means turn both on and “B” means turn both off, and “C” means toggle a certain bit. And so on getting more elaborate. You can have the protocol have error checking so that the AVR can ignore or reject data that arrived corrupted, say, later you use wireless which is error prone.
Also, do you happend to know what C code I need to write to be able to send this data along the serial link from the software I am writing?
C code - start with learning how to write a PC program to send data on the serial port. VIsual Basic 6 is an easy to learn PC langage. Many other choices. Connect the PC’s serial port in loopback (pins 2,3 shorted) so the PC program can send data to itself. Next, learn how to write a serial I/O program for the AVR. The Avrfreaks project libraries and tutorials have many, many examples. And I and other will help. Get this generic program for the AVR to talk to the PC program. Then on to robotics control.
Thanks a million!!
Hi,
The project that you describe is considerably large depending on your knowledge of microcontroller, programming, and robotics.
First off you should try the communication between your micro and pc.
http://booksbybibin.14.forumer.com/viewtopic.php?t=119
is a great step by step instruction of this.
After you understand this, finding the C code to write to serial line is not too hard. There are lots of example out there. I personally have done it with java. I’ve built a wireless, internet control robot. Java was the easiest to interface with the web.
Hey, I am looking for the max232 chip I need, but there are so many!
http://www.rapidonline.com/productinfo. … leno=67368
Which one do I need?
ejohns85:
Hey, I am looking for the max232 chip I need, but there are so many!
http://www.rapidonline.com/productinfo. … leno=67368
Which one do I need?
I use the MAX202 for 5 V operation and the MAX3232 for 3.3 V. The MAX202 will actually work OK at 3.3V I’ve found, although it is out of spec.
Leon