Shop OBEX P1 Docs P2 Docs Learn Events
Best microcontroller for I/O sensor to laptop for robot? — Parallax Forums

Best microcontroller for I/O sensor to laptop for robot?

bulkheadbulkhead Posts: 405
edited 2006-06-23 15:18 in General Discussion
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.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-06-22 19:45
    Any BS2 or the Javelin Stamp should work just fine. You can write programs in Java for Windows that can send and receive data from the Stamp via a serial port. The USB BOE has a built-in USB to serial converter that looks like a standard serial port to Windows. You can use the DEBUG and DEBUGIN statements with the BS2 to communicate via this serial port. I don't know offhand what you need to have a Javelin Stamp use the same port. If you want to make your own control board, you can use any of the many FTDI USB to serial adapters for the laptop communications channel.
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-06-22 19:56
    As long as you understand that you have 2 computers (micro & PC), and each needs to run it's own program, there is no reason that you can't program the micro to perform certain tasks when it receives certain commands from the PC.

    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.
  • bulkheadbulkhead Posts: 405
    edited 2006-06-23 00:52
    I am trying to build an autonomous vehicle that would receive sensor input from various systems. I would like the microcontroller to handle the simple sensors such as bump switches, ultrasonic, or IR, but I would like the navigation to be controlled by a PC or laptop. I want to leave room for other devices such as a gps or possibly a vision system that can be done using a computer but not a microcontroller.

    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?
  • bennettdanbennettdan Posts: 614
    edited 2006-06-23 01:26
    Well I use VB2005 express to talk to my stamps com port. You will have to build your own program with some type of programming software like VB,C++, Java to handle the com port communication between the stamp and PC on your serial port.For what you want to do is to make the stamp a slave device and handle all the code in your pc right? You still have to write a stamp program to recieve the data and send the data to the PC.
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-06-23 02:16
    As long as you stay within the limits of whatever microcontroller you choose, you can do sensors and servos at the same time. The trick is that when say "constantly updating", there is really a time gap.

    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
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-06-23 15:18
    I find it interesting that you want the laptop to do the control while the Javalin or BS2 would merely do sensing. At some point your serial link may be come a bottleneck.

    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."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Sign In or Register to comment.