Programming to control hardware

GEC: Discuss gaming, computers and electronics and venture into the bizarre world of STGODs.

Moderator: Thanas

Post Reply
User avatar
raptor3x
Padawan Learner
Posts: 167
Joined: 2005-07-04 11:34pm
Location: University Park, PA
Contact:

Programming to control hardware

Post by raptor3x »

So I've come to realize that I don't know even the basics of how to write code to interface a computer with external hardware. I know how to write codes to do FEM, FVM simulations, mesh generation, etc. but how the computer controls the blinking lights on my network card is a complete mystery to me. So, can any computer science (software engineering?) people give me a starting point or list of good books?
The best part of being a mad scientist is never having to ask yourself, "Should I really be doing this?"

"Liberals tend to clump together in places where they can avoid reality and diversity of opinion, like big cities, especially in the east and west coast and college towns." --nettadave2006


"Googles methods are a secret black box and some left leaning folks sit on it's board. I've noticed an imbalance when I search certain other topics related to Obama or other hot button topics, especially in the first page or two of results given.."--nettadave2006
Gerald Tarrant
Jedi Knight
Posts: 752
Joined: 2006-10-06 01:21am
Location: socks with sandals

Re: Programming to control hardware

Post by Gerald Tarrant »

My experience was more from a bottom up type of learning, so this may not be useful to you, in which case: apologies Ignore.

A good place to start might be to get a basic understanding of digital logic, and maybe the ability to read the various data sheets associated with the hardware you're interested in. Those are kind of important to move into the next step, drivers. Drivers do a couple of things, they manage the low level stuff on hardware (command words and such) and they protect shared resources from over use by multiple threads (the technique I'm familiar with used "semaphores"). For instance if one of your threads were using the modem to send out 20k of data somewhere, a semaphore would prevent another thread from doing anything with the modem until the first thread reported that it was finished sending stuff. I don't think you need a deep understanding of any of those things, but if you can get a basic grasp of those things, you'll probably be ready to start tinkering.
The rain it falls on all alike
Upon the just and unjust fella'
But more upon the just one for
The Unjust hath the Just's Umbrella
User avatar
GrandMasterTerwynn
Emperor's Hand
Posts: 6787
Joined: 2002-07-29 06:14pm
Location: Somewhere on Earth.

Re: Programming to control hardware

Post by GrandMasterTerwynn »

raptor3x wrote:So I've come to realize that I don't know even the basics of how to write code to interface a computer with external hardware. I know how to write codes to do FEM, FVM simulations, mesh generation, etc. but how the computer controls the blinking lights on my network card is a complete mystery to me. So, can any computer science (software engineering?) people give me a starting point or list of good books?
It's like writing code to anything else. Depending on the environment, it can be as simple as linking in the right DLL and invoking the appropriate manufacturer-supplied access functions. If you're in a lower-level environment, you're going to have to push data into pointers to registers on a memory map. You will have to supply the right words to the device to make it do what you want it to do. All of this is usually found in the SDK for whichever device you're interested in trying to access.

The question becomes what sort of hardware are you interested in accessing and on what platform?
User avatar
Dooey Jo
Sith Devotee
Posts: 3127
Joined: 2002-08-09 01:09pm
Location: The land beyond the forest; Sweden.
Contact:

Re: Programming to control hardware

Post by Dooey Jo »

raptor3x wrote:So I've come to realize that I don't know even the basics of how to write code to interface a computer with external hardware. I know how to write codes to do FEM, FVM simulations, mesh generation, etc. but how the computer controls the blinking lights on my network card is a complete mystery to me. So, can any computer science (software engineering?) people give me a starting point or list of good books?
You could try, or at least read up on, programming stuff for the GameBoy Advance. There's lots of material out there, and it can be fun. Then you will have to interface "directly" with the hardware by reading and writing directly to certain hardware memory addresses (the memory mapping Terwynn is talking about) in various ways.
Image
"Nippon ichi, bitches! Boing-boing."
Mai smote the demonic fires of heck...

Faker Ninjas invented ninjitsu
User avatar
Sarevok
The Fearless One
Posts: 10681
Joined: 2002-12-24 07:29am
Location: The Covenants last and final line of defense

Re: Programming to control hardware

Post by Sarevok »

I would recommend finding a easy to use micro controller and starting from there. This will help you get a feel of how software can have a tangible effect on the physical world by controlling simple devices like a light switch or motor.
I have to tell you something everything I wrote above is a lie.
User avatar
Korvan
Jedi Master
Posts: 1255
Joined: 2002-11-05 03:12pm
Location: Vancouver, B.C. Canada

Re: Programming to control hardware

Post by Korvan »

You can get micro controllers these days with built in web servers. You simply connect the controller to your computer with an Ethernet cable and send commands via http. Super simple to use. With a webcam mounted on a servo motor connected to the controller and a free colour tracking addon, I was able to get the camera to track objects. It's been a couple of years since I've messed around with it and I can't remember where I ordered it from, but it wasn't too expensive. There are a number of alternatives that a search on "micro controllers with built in web server" turns up as well.
Post Reply