PC control, where do i begin?

Discussion in 'General Electronics Chat' started by CaliusOptimus, May 6, 2007.

  1. CaliusOptimus

    Thread Starter Well-Known Member

    Aug 14, 2005
    sry, the title was supposed to be 'PC control, where do i begin?'

    ive seen kits for controlling things like stepper motors, light dimmers and other random 'home automation'. which programming language is a good starter for simple hardware i/o kinda stuff? ive played with perl for a long time for simple things, but it definitely has its uses and limitations, im ready to move onto something a little more complex and versitle. maybe start with controlling an led from the parallel port or something as a kind of 'hello world' project. are there any good books or online tutorials about this kinda thing?
  2. mrmeval

    AAC Fanatic!

    Jun 30, 2006
  3. cumesoftware

    Senior Member

    Apr 27, 2007
    Well, begin by the beginning.:D
    What do you want, specifically?
  4. CaliusOptimus

    Thread Starter Well-Known Member

    Aug 14, 2005
    i dunno, ive got so many wonderful ideas :) as i stated, id like like to start off with a simple hello world, ie controlloing an led from a parallel port, but eventually id like to get into some more complex projects like an automated PCB drill using a few stepper motors, w/ a command line interface for starts. say, id enter the absolute location of the first hole, the distance and direction to the next hole etc. then create some sort of graphic interface with a grid, which i would add all of the points (holes to be drilled) to the grid, then a line designating which hole to go to next. kind of like the stitching on an embroidery machine. <- just one of many on my 'to do' list

    im not particularly new to low level programming, but controling pc hardware is uncharted teritory. im working with xp pro, and id rather not bother with with my old 686 p.o.s., as most of the examples in the link MrMeval posted are made for DOS or linux. (the 686 is already designated for Duke Nukem 3D anyway, lol) all that said, i appreciate your input!
  5. gootee

    Senior Member

    Apr 24, 2007
    At the programming level, "PC hardware control" software doesn't involve too much that would be new to you. It basically consists of writing bytes or bits into predefined memory locations, that the hardware uses. And there might be timing issues. I'm most familiar with the C language. But Basic, and most other languages, should also be able to do what you want. A lot of people run their CNC stuff with a DOS machine, because it does what you tell it WHEN you tell it. And it also runs on older machines that are basically free, now.

    If you just want to drill PCBs, and don't want to design and program everything from scratch, there are free software packages out there that will already do what you want, such as DanCad3D, and also free ready-made circuit-and-pcb designs that will work with it, through a PC parallel port. I have the links to both of those on the page at this link:


    On the other hand, if you want to do it all from scratch, it would probably be a great learning experience.

    Just an idea: You could use a "teaching" mode, in order to get a pcb's hole-pattern into the system, such that you would "manually" tell the machine where to move and where to drill, and it would then remember it, like a macro.

    But be aware that there are already "standard" formats for PCB drill control, such as the ubiquitous "Excellon" (a type of PCB drilling machine) format, which "all" PCB-layout packages produce automatically (as a text file, actually). So it "might be nice" to be able to use that format, with your machine. There should be software already available, for converting that format to something closer to what your machine needs to see. But it probably wouldn't be too difficult to write that part. It's been a long time since I researched all of that. But maybe search for "G-codes", and excellon, stepper, cnc, etc. I have a portion of the links I collected, for all of that, at:

    http://www.fullnet.com/~tomg/links.htm ,

    where there are also lots of other neat tech links.

    Bear in mind, also, that there might be a few complexities that you haven't yet considered. For example, you might want your software to be able to automatically correct or adapt the stored drill-hole pattern, if the board is at a slight angle, and/or x-y offset, from where the original pattern was made. The software part of that should be relatively simple. But you'd have to incorporate a method for telling the machine the actual position and orientation of the board, just before the start of drilling. One way to do that might be to manually control the drill (e.g. with the keypad) and move it to two different hole locations, to tell the software where they are, and then also tell it WHICH two holes they are, in its stored pattern.

    You might also want to compensate for "backlash" in software, instead of buying or building anti-backlash nuts for your leadscrews, e.g. just add "x" number of steps whenever an axis changes direction. Alternatively, you could make sure that the drill always approaches every hole from the same direction, for each axis.

    When I was thinking about making a CNC machine, I dreamt-up some easy ways to automatically recalibrate the machine (the software, actually), periodically, to account for things like leadscrew wear, and whatever else might gradually wear down or wear out, since at the time I wanted to be able to use cheap and readily-available parts, and wasn't even sure that each axis would be perfectly linear (directionally OR travel-wise).

    At any rate, once the basic mechanics are in place, you can always modify the software.

    When I saw the title of your message, I initially thought you were talking about a closed-loop automatic feedback control system, using a PC in the feedback loop. That type of system is very generally applicable, to many different types and levels of tasks, and might be something for you to think about, for the future.

    Your current example, moving stepper motors for PCB drilling, would be what is known as an "open loop" control system, since it doesn't employ sensors to feed back the drill's actual position, to the PC. It may not matter too much, for your application, especially if you have limit switches to define a "home" position, and home the drill every once in a while, if necessary, to re-establish its true position.

    It's probably a good place to start, anyway, since you have to have an open loop system as part of every closed-loop system.

    Have fun!

    Tom Gootee


  6. lightingman

    Senior Member

    Apr 19, 2007
    Using the parallel port is quite easy, you will need to install a dll file, and then it is a case of reading and writing to the port. Using Visual basic is the easiest way to do it.I have all of the heating and ventilation system here controled by P.C. from 1 parellel port, and the building power supply is monitered and logged using another P.C. with a bit of interfacing.All is done using VB6...Daniel.