Hello Guest it is March 29, 2024, 04:08:06 AM

Author Topic: Question about how LPT1 is running  (Read 4251 times)

0 Members and 1 Guest are viewing this topic.

Question about how LPT1 is running
« on: August 06, 2009, 02:15:35 PM »
I am developing a proprietary app in Realbasic to pick and place parts onto an SMT board.  I use Mach3 daily for machining parts for my product.  On the same computer Mach 3 runs the motors very smoothly.  With my app, using a parallel port plugin called Inpout32.dll, the motion from the stepper loop has hickups twice a second.  I had thought that Mach 3 was Visual Basic based, so that maybe it used the same plugin which is popular among VB and RB developers.  I can't use Mach 3 to position the parts as there are a number of values per move that need to be input for the operator, Mach 3 can't manage the structure I want to use, so I need a new app. I would like to get an idea from my Mach3 app as to how it is processing the step and direction output regiuters.  Currently I am doing something like:


A single byte for the output registers (pins 2-9)  bits 0 - 7

example is  byte 0 = direction for X,  byte 1 is step pin for X


//set dir based on where it has to go
//loop this code, include accel and decel functions
00000000    //direction pin = 0
01000000    //turn on step pin for X
00000000   //turn step back off
Pause SpeedRate   //set speed of motor/loop

Mach runs the same motors fine, so I know the port and outputs have the potential.  I need to understand what method is best for looping the motor, if anyone has any suggestions on this I'd appreciate it.  Thanks







vmax549

*
Re: Question about how LPT1 is running
« Reply #1 on: August 06, 2009, 03:04:18 PM »
SURE you can do it with MACH, run it from a Macro instead of straight Gcode and you can have as many USER defined inputs as you can imagine.

Just a thought(;-) TP
Re: Question about how LPT1 is running
« Reply #2 on: August 06, 2009, 05:37:33 PM »
There are two things Mach doing that make it work better than your approach.

The Mach program uses a special driver to allow accurate step motor control, its more tuned for this kind of work than the general purpose Inpout32.dll

I believe Mach buffers step commands at the driver level, meaning that when the Mach application gets blocked for a while by Windows, the driver has a buffer full of commands to work though until the Mach application becomes alive again and fills the buffer back up. This works because the drivers are guaranteed to be serviced at a higher rate than user applications.

Its going to be hard to get accurate step motor control under Windows unless you somehow implement a similar approach. Its doable, but it might be easier for you to use one of the DOS or Linux based real time kernels to implement your program.

If there was a software specification and library available for using the Mach LPT driver it would make the job easier, but I don't think that info is available.

Good luck-

Paul T.

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Question about how LPT1 is running
« Reply #3 on: August 06, 2009, 05:37:55 PM »
 I had thought that Mach 3 was Visual Basic based, so that maybe it used the same plugin which is popular among VB and RB developers. ....................................... I would like to get an idea from my Mach3 app as to how it is processing the step and direction output registers.  

Mach is not VB based. It uses a special driver that basically takes complete control of Windows in order to do what it does.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

vmax549

*
Re: Question about how LPT1 is running
« Reply #4 on: August 06, 2009, 07:26:25 PM »
AND that driver code is the best kept secret on the planet(;-)

(;-) TP
Re: Question about how LPT1 is running
« Reply #5 on: August 06, 2009, 07:31:41 PM »
Ha,  yeah I suppose so.  I am resorting to a microprocessor to drive the steppers from strings from the GUI.  Thanks fore the help guys.  This is too proprietary for Mach.  Fortunately I have the external board set up to accept LPT1 and USB to serial at the same time, so both apps(mach 3 and my new gizmo) can talk to the machine when needed without unplugging.