Emulating Touchscreens In Python


Software, especially DOS-based software meant for CNC control lasts forever, but hardware most certainly does not. When faced with aged and decrepit hardware meant for controlling a CNC machine that was slowly dying, [Oliver] needed something that would emulate 3M Microtouch touchscreen. Not wanting to go the hardware route, he decided to emulate a touch screen in Python.

The Python code is fairly simple, taking mouse input and translating it to the serial protocol the 3M Microtouch, and thus the old DOS CNC app, uses. Writing the Python to capture mouse clicks was only half of the problem, though. [Oliver] also needed a way to send these mouse clicks to an old DOS application. Virtualizing an old machine running DOS created a few timing problems, but a solution was eventually found with DOSBox and the Virtual Serial Port Emulator that can connect two applications with serial ports.

[Oliver] was finally able to get everything working, bringing this equipment back to life for at least another 30 years. Let’s just hope all the code is well documented and archived for the next guy.

11 thoughts on “Emulating Touchscreens In Python

    1. If you’ve ever watched a machinist use a ancient control panel he’s really familiar with, you would know. It’s magic. He runs his fingers across the vinyl surface is a strange dance without really looking; maybe holding a conversation with you at the same time. Then he presses a button, and six tons of machinery begin to hum and whir; employing a massive amount of energy. After a few moments, your part drops into a little bin.

      1. Dos and touchscreen, how modern.
        Real men program CNCs with punchtape. ;-)

        And have nervous breakdowns when the Tape punch breaks and have to program in a 80 tooth involute gear by hand, one hole at a time.

        1. Actually we got a new (used) tape punch before I finished punching that in by hand, and bought out the worlds remaining supply of paper and mylar tape to go with it. I had to revise the program as well, going point to point over the involute took up more than a whole roll of tape, which is how the punch broke in the first place, but you could fake the involute curve with only 3 arcs and be within 0.000003″ anyways. Theoretically, if the temperature is right, etc etc…

          Multi megabyte CNC programs do NOT belong on punch tape.

          Probably over 15 years ago now. We sill had a couple of very temperamental MDSI re-branded DataGeneral Novas to program with. Really day to day I used SmartCAM on DOS, also long gone, bought out several times since then. I never ever did get conic sections working with SmartCAM’s code generator, AGIE’s documentation was a little sparse on the topic as well for the DEM612’s and DEM315’s, I think the 315’s documentation consisted of “TBD”

          They upgraded the AGIES to use floppy disks and ethernet since I’ve left. No reason to upgrade to AGIES newest top of the line, because the 1978 top of the line is just about as accurate as the current model, the current one has a better surface finish and is quite a bit faster cutting, from what I’ve read on the specs. Precision and accuracy is the same though. Plus the old machines could cut with 20 micron Molybdenum wire for when you absolutely had to have a 0.0005″ 12micron inside radius on something.

  1. Gotta love companies too cheap to properly fix a CNC. you can completely abandon the DOS machine and use one of the myriads of modern control software suites to modernize the CNC machine. Less than 25% of the cost of a new machine and they cna have that old one running better than it ever has.

    If this is a hackerspace CNC, then retrofitting to one of the open source controls would have been a better route to gain a lot of additional features and abilities.

    1. To soothe your fears – this isn’t actually driving any CNC machine (or even connected to one) – the person who wanted this actually just uses the software for specific calculations.

  2. No no no no no!

    DOSBox was not designed for this. It was designed for running games. If you’ve ever been on their forums before, you know how annoyed the authors get when people pop up and say “Application XYZ doesn’t work or does something strange”. In fact, I think they have a forum rule basically banning that kind of discussion.

    I would never ever trust DOSBox to drive a physical machine like this. I *might* trust VMware to do it, just because they’re in the business of providing accurate virtualization that is rock solid (plus you can pass through serial ports with ease). But I’ve seen DOSBox do some really strange and whacky things with physical MIDI devices, so I simply cannot imagine trusting it to drive a CNC machine.

    1. To soothe your fears – this isn’t actually driving any CNC machine (or even connected to one) – the person who wanted this actually just uses the software for specific calculations.

  3. What I’ve learned-
    it’s not that easy to get away from DOS with a lot of machines. The software just will not work on a newer OS. Proprietary ISA interface cards are also a problem.

    I have about 15 machines running on dosbox under XP, we just keep the OS clean and store all variables to mapped drives. on the rare occasion one has a problem, we just ghost it. We planned on using HORM but never needed it.

    Changing what the operator is used to in a lot of factories really screws up production as the barely skilled operator has to learn which buttons to push.

    Touchscreens are OK, but nothing beats a cheap mouse and keyboard for durability and serviceability.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.