I am in the process of writing a CNC controller in visual basic. I am doing this mainly to learn more about programming in
VB and because I am a glutton for punishment. I plan to run this on a Windows 98 machine which will avoid the problems associated with direct access of the printer port.
My question concerns timing for the step pulses to the printer port. The Timer control in
VB is obviously not up to the task. I had a couple of thoughts on this as follows:
1. First, I wrote some code that just uses a loop to put a pause in before issuing the next step pulse. It seems to work OK, but I was wondering if there was a better way.
2. My next thought was to use the timeGetTime function to read the system clock. I would first read the system time and then enter a loop. Inside the loop a comparison would be made of the start time, interval, and current time to see if the loop should be exited. (ie: if start_time + interval >= current_time....)
Here are the problems I have with these two options.
Option 1 will be machine specific requiring some kind of constant to adjust timing between different machines. This option can also be affected by other programs running in windows or windows processes themselves running.
Option 2 is only accurate to 1 millisecond and therefore would limit maximum feedrate based on the number of steps per revolution. Take my first project for example. A mill with 1000 steps/inch would yield a maximum feedrate of 60 inches per minute. Probably OK for my small mill, but not for a router, and not if I use micro-stepping on the motors. Both of which I would like to do someday.
Does anyone have any ideas for other options or ways to make these options better??
Thanks,
John Brannen