Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Computer to electrical Device

  1. Oct 1, 2008 #1
    Lets say I want to controle something like a robot but I want to controle it through the computer via a usb or printer plug. If the computer is plugged into the microcontroller do I still have to put the microcontroller In a PIC Programmer or can I program it wile its hooked up via the usb or printer plug ...

    How does the computer "Talk" to the Microcontroller does it send singnals and the microcontroller will decode it and do the command you want it to do.

    as you can see I,am new to electrical enegineering and I know even less about how a microcontroller works thanks guys

    Edit: And do I Really need a microcontroller if it is connected to the computer can I controle the device directly from the computer
     
    Last edited: Oct 1, 2008
  2. jcsd
  3. Oct 2, 2008 #2

    MATLABdude

    User Avatar
    Science Advisor

    It might be possible to leave your chip plugged into the programmer (if you could fit your breadboard / PCB onto it, and it were hacked to communicate, instead of program), but the preferred method is to make use of the onboard communications peripheral. The majority of microcontrollers (ones meant for hobby use) have on-board serial (though you'll need a voltage level converter--something like a MAX232), allowing you to communicate with it via a serial port (without having to reprogram it).

    There are also micros with USB serial built-in (it looks like a standard serial port with the right drivers), but FTDI makes a line of USB-TTL serial converters (from chips to modules) that have really good driver support under just about every OS (again, looks like a standard serial port). They even have prototype-suitable DIP (Dual Inline Package) evaluation boards (UM232R, and DLP-USB232M-G):
    http://www.ftdichip.com/

    Using a microcontroller is probably the easiest and most flexible way of controlling a device. If you were to avoid a micro, you'd still need (some) hardware to interpret commands from your computer (unless you were only looking for it to do a few things). That's why they're in practically everything. The easiest way to get started with this micro stuff is to:
    1) Get a micro (e.g. PIC, or ATMEL, stick to the more popular models if you have 0 experience), and a programmer for it,
    2) Get a C compiler for it (unless you already know assembly)--may also need to pick up a C programming book,
    3) Built the "bare bones" reference design, and PERUSE THE DATASHEET!
    4) Start programming--it'll take you a while to figure out the tool chain (how to get your simple "Hello world" or blinker program compiled, onto your micro, and then doing what you want it to do). You'll probably be forced to reread and actually comprehend sections of the datasheet during this process. Yes, this'll be the case even for your 3-line program.

    Possibly in conjunction with that, you can get one of the aforementioned USB modules, or get a MAX232 from Radio Shack or wherever (this only works if you have a serial port on your computer--these are slowly being phased out).
     
  4. Oct 6, 2008 #3
    before complicating with too much explaination,
    please let us know why/how do you plan to implement USB into your system.
    what kind of robot are we speaking about??
    have any idea about computing requirements?
     
  5. Oct 6, 2008 #4

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    You could control it directly form the computer.
    Under dos/linux you can set individual bits on the parralel port or you can buy a USB I/O card and use that to control motors etc.

    But this means that every detail of the robots control and response must be handled in real-time from the computer. The reason for using a micro controller (apart from being more portable than the PC) is that you can handle the detail of stepper motors and switches in it and just have a simple command from the PC like "forward 100" .
     
  6. Oct 6, 2008 #5

    dlgoff

    User Avatar
    Science Advisor
    Gold Member

    I've compiled BASIC code to control computer ports. You can write subroutines to do the DOS interrupt calls. Back when I got into it, I was amazed with all the built in DOS functions. Do intel processors still support these function calls and interrupts?
     
  7. Oct 6, 2008 #6

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    Yes under DOS. BUT it has to be DOS not a dos box inside windows ( at least> win95).

    Under windows you are prevented from low level access to the computer - only device drivers are allowed to talk to the port. There are examples device drivers that will send commands to the port or you can use dos!

    eg. http://electrosofts.com/parallel/parallelwin.html
     
  8. Oct 6, 2008 #7

    dlgoff

    User Avatar
    Science Advisor
    Gold Member

    So on these new machines I would have to boot up in DOS to run my executable?
     
  9. Oct 6, 2008 #8

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    If you want to use raw _inp() and _outp() to talk to the ports, yes.
     
  10. Oct 6, 2008 #9

    dlgoff

    User Avatar
    Science Advisor
    Gold Member

    Thanks. I didn't mean to hijack TheCoolBrian thread.
     
  11. Oct 8, 2008 #10
  12. Oct 8, 2008 #11

    MATLABdude

    User Avatar
    Science Advisor

    Can you still get parallel ports these days? I suppose there's always USB to parallel converters.
     
  13. Oct 8, 2008 #12

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    The USB-Parallel adaptors don't necessarily support all the I/O pins to use the port fully, you might be better off getting a USB-PIO card designed specifically for robotics.
     
  14. Oct 8, 2008 #13
    Thanks Guys you all helped alot got any idea of what I should buy first to get started in electrical enginering should I buy a kit or just a bunch of stuff and make stuff from schematics I find online I,am tryin to keep it under about 100 dollars
     
  15. Oct 9, 2008 #14

    dlgoff

    User Avatar
    Science Advisor
    Gold Member

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?