Best microcontroller for I/O sensor to laptop for robot?
bulkhead
Posts: 405
I would like to have a microcontroller receive data from various sensors (switch, ultrasonic, etc) as well as control motors and servos, but I would like to have the main program run off of a laptop. I just want the microcontroller to receive the data and send it to the laptop via USB (or serial) and turn on/off motors and servos when the main program running on the laptop gives the command to the microcontroller. My question is, is there a specific microcontroller that would be better suited to do this task than others? I have a javelin stamp right now...would it be feasible to use that?
Also, anyone know any software that would run in windows XP that could do this? Preferably I'd like to program in java or C++. Thanks.
Also, anyone know any software that would run in windows XP that could do this? Preferably I'd like to program in java or C++. Thanks.
Comments
What exactly are you trying to accomplish? Do you need a GUI, or command line? Is this for an actual working application, or a programming exercise?
As for the PC, you can try:
1. Any Java IDE
2. Visual Studio (free Express downloads available, in several languages)
3. Almost any scripting language that supports serial comms
If you want a cool tool to work with on the PC, I recommend Ch from SoftIntegration. It isn't quite C++ (more like C+), but it's capable of quite a bit. Here is the link:
www.softintegration.com
Also, keep in mind that you can also send commands via a terminal program, so unless you have a specific need to develop your own app., you can go this route instead.
I also need some way for the computer to control servos and motors. Possibly the microcontroller could do that too?
I know I can get the javelin to do all of this, but how do I get it to be constantly sending data to a computer and also have it receive commands (such as to turn on a motor or move a servo)? I would probably use a UART with the javelin, but what software would I use for the computer?
So if you were to update a sensor every 1 second, and your microcontroller sees things in terms of microseconds (1/1,000,000th of a second), there is a lot of time in that second. You have to spend time wiaing & switching between tasks, which is essentially all that any computer does.
So, you could use 1 microcontroller, and some fancy programming. You could use multiple microcontrollers, dedicated to certain tasks. Or you could use a micro for the sensors, and a PC for motor control.
If you decide to use a PC for motor control, you could do it directly or indirectly.
Direct control would be sending a command directly from the PC to the motor/motor controller, bypassing the microcontroller. For this, you would need suitable hardware, and a programming environment & software libraries designed for motor control.
Indirect control would be accomplished by sending commands to the microcontroller, and having the microcontroller respond accordingly. So if you sent the number '2', and '2' meant "turn left," the microcontroller would check for a command, receive the command, determine what the command means, and perform the appropriate function. For this option, you could create a GUI application, so that clicking buttons sends commands, or you could send ASCII commands via a terminal program.
The terminal would be the easiest way to start, since you don't have to write a terminal program to begin with. Also, if you have it working via Hyperterm, you can then build an application that basically sends the same commands via a different interface.
Here is a post that I responded to that gives some general suggestions for a similar idea:
http://forums.parallax.com/showthread.php?p=560802
If you were to have the microprocessor summarize some of its data, that may require less bandwidth for communication. Also, there would not be as great an exposure to communication failures. You could also have more time to do cyclical redundancy checks and retransmissions.
In sum, I think that you can delegate a lot of the mundane navigational chores to the micorprocessors, improve the quality of the data going to the laptop while reducing the quanty, and have the laptop do best at what it can do with all its power. Some degree of autonomy allowing communication lapses is a good thing as a mobile device doesn't have to stop mundane, non-critical tasks while waiting for instructions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········