Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

100 kHz Timer Frequency in Windows XP [closed]

Tags:

windows

winapi

There's a popular hobby level CNC machine tool control that operates in Windows XP and it has a timer that operates at a user-selectable rate ranging from 25 kHz up to 100 kHz.

It just so happens that I also build CNC machine tool controllers but I have been using a Galil Motion Control Inc. DMC1800 series DSP motion controller board which I control with my upper-level program. There are prospective buyers that cannot afford that configuration so I wrote another application which I plan to offer as software-based control package. The application is complete with the exception that I have no timer. (MS Multi-Media Timer is NOT sufficient.)

To avoid any confusion I'm referring to a periodic timer that is capable of operating at a frequency of 100 kHz and not a stopwatch timer.

like image 389
user227239 Avatar asked Dec 08 '09 17:12

user227239


2 Answers

Not possible. The fastest available timer on Windows is 1 ms (1 kHz). You'll need a real-time operating system or a dedicated controller. Even in a real-time OS, usually about 20 kHz is your max.

like image 119
Steve Avatar answered Oct 12 '22 23:10

Steve


What exactly does this timer need to do? If it just needs to output a square wave between 25 kHz up to 100 kHz, then you will need extra hardware, but not outrageously expensive hardware. For example, look at this DT-340 from Data Translation. It can go even faster than you need, and I believe it can even trigger an interrupt. Or this PCI 8255/8254 48 I/O.

If you can afford USD 500 or so in your budget, there should be lots of hardware options. The actual programmable timer chip ought to be much cheaper than that, so if you are willing to roll your own circuit and interface it to the computer, you can probably do a lot better than USD 500.

I once build a circuit around the Intel 8253 Programmable Interval Timer chip, which was used inside the original IBM PC for generating the beeps out of the internal speaker. It was hooked up to a 1.193182 MHz crystal and has a 16 bit divider. This chip has been around for decades. If you need better, I'm sure there have been improvements since then.

When I say that the 8253 (or 8254) chip inside a PC is used for driving the internal speaker, I'm not being complete. There is a lot more about the Intel 8253 in Wikipedia. There it explains that output 0 is used to generate the clock interrupt, output 1 is used for DRAM refresh timing, and output 2 is used to drive the internal speaker.

The first two clock outputs generate interrupts, which is what you want, but the above descriptions of what these outputs currently do ought to give you some pause to reflect that changing their behavior might possibly cause Windows XP to notice. The third output to the speaker, is mostly harmless to mess around with, but you would need to figure out some way to redirect that signal to something that generates and interrupt, if that's what you need.

Probably Mach 3 is using the High Performance Event Timer (HPET), which according to here is part of recent Intel chipsets. Timer 0 and 1 are used for 8254 emulation.

"The ICH HPET Timer 2 interrupt may be routed to any one of the following IRQs: 11, 20, 21, 22, and 23, via the TIM2_CONF register. (Note: this register is called TIM3_CONF in Intel® ICH5.)"

like image 36
user189169 Avatar answered Oct 12 '22 23:10

user189169