Do I need a Microcontroller for Computer Control of Electrical Devices?

In summary, the conversation discusses the use of a microcontroller to control a robot through a computer using a USB or printer plug. The preferred method is to use the onboard communications peripheral of the microcontroller, such as serial or USB serial. It is also mentioned that using a microcontroller is easier and more flexible than controlling the device directly from the computer. Options for controlling the device directly from the computer are discussed, such as using DOS or a USB I/O card. It is recommended to get a microcontroller, a C compiler, and a programming book to get started in electrical engineering. Other options could include buying a kit or building from schematics found online.
  • #1
TheCoolBrian
8
0
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:
Engineering news on Phys.org
  • #2
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).
 
  • #3
before complicating with too much explanation,
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?
 
  • #4
TheCoolBrian said:
Edit: And do I Really need a microcontroller if it is connected to the computer can I controle the device directly from the computer

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" .
 
  • #5
mgb_phys said:
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" .
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?
 
  • #6
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
 
  • #7
So on these new machines I would have to boot up in DOS to run my executable?
 
  • #8
If you want to use raw _inp() and _outp() to talk to the ports, yes.
 
  • #9
Thanks. I didn't mean to hijack TheCoolBrian thread.
 
  • #11
Can you still get parallel ports these days? I suppose there's always USB to parallel converters.
 
  • #12
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.
 
  • #13
Thanks Guys you all helped a lot got any idea of what I should buy first to get started in electrical engineering 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
 
  • #14
Last edited by a moderator:

1. What is the purpose of a computer to electrical device?

The purpose of a computer to electrical device is to convert digital signals from a computer into analog signals that can be used to control and operate various electrical devices. This allows the computer to interact with and control the physical world.

2. How does a computer to electrical device work?

A computer to electrical device typically works through the use of software and hardware components. The software converts digital signals into analog signals, and the hardware then transmits those signals to the electrical device, which interprets them and performs the desired action.

3. What types of electrical devices can be controlled by a computer to electrical device?

A computer to electrical device can control a wide range of electrical devices, such as lights, motors, sensors, actuators, and more. It can also be used to control larger systems, such as home automation systems or industrial machinery.

4. What are the benefits of using a computer to electrical device?

Using a computer to electrical device offers several benefits, including increased efficiency and accuracy, remote control capabilities, and the ability to automate tasks. It also allows for the integration of different systems and devices, making it easier to manage and control them.

5. What are some potential challenges or limitations of a computer to electrical device?

Some potential challenges or limitations of a computer to electrical device include compatibility issues between different systems and devices, the need for constant maintenance and updates, and the risk of system failures or malfunctions. There may also be security concerns, as the device is connected to a computer and can be vulnerable to cyber attacks.

Similar threads

Replies
2
Views
1K
Replies
9
Views
1K
Replies
37
Views
3K
  • Electrical Engineering
Replies
5
Views
2K
  • Electrical Engineering
Replies
27
Views
2K
  • Electrical Engineering
Replies
11
Views
7K
  • Programming and Computer Science
Replies
2
Views
833
  • Electrical Engineering
Replies
4
Views
5K
  • Electrical Engineering
Replies
7
Views
2K
Replies
4
Views
2K
Back
Top