Welcome, Guest. Please login or register.
Did you miss your activation email?
June 18, 2018, 12:50:22 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  Controlling a stepper motor from VB
Pages: 1   Go Down
Author Topic: Controlling a stepper motor from VB  (Read 10273 times)
0 Members and 1 Guest are viewing this topic.

Offline Offline

Posts: 2

View Profile
« on: October 06, 2009, 05:52:17 PM »

Hi all,
I am new to this forum and am looking for a bit of help in running a stepper motor from my parallel port.

Currently i have a parallel port breakout board, then the stepper motor drive (and a power supply), connected to the motor.

I have written a simple loop in VB saying set pin 3 on then off, this works ok (the stepper drive requires a pulse to turn the motor around one step), BUT VB is taking its time in sending the pulses out of the parallel port.

This is why i am trying here as you guys know what you are talking about with steppers and programming them.

Dose anyone have any ideas, i have searched the net for hours but to no luck.

Cheers for your help in advance.


Ron Ginger
V4 Screen Contributor

Offline Offline

Posts: 920

View Profile WWW
« Reply #1 on: October 06, 2009, 06:21:13 PM »

Sorry, but you cannot drive a stepper directly from VB. As you have found there are all manner of unpredicatable time delays involved in VB and Windows.

What we speak of on this forum is not really VB- it is a scripting language based on VB, but it is hooked in to the Mach3 software. Mach3 can drive the steppers, this VB like language can issue commands to Mach to move the motors. So you can accomplish many things with this system that involve steppers, but its a bit more complicated that just hooking a stepper to a parallel port and running some VB.

Maybe tell us more of what you want to accomplish and we can offer some ideas.

Offline Offline

Posts: 2

View Profile
« Reply #2 on: October 08, 2009, 02:01:48 PM »

Hi thanks for the responses.

I am currently controlling a stepper using vb express 2008.

All i do is send a pulse from a parallel port pin to a stepper drive unit. Each pulse moves the motor one step.

mach 3 im guessing sends the pulses out the parallel port pins to a breakout board which in turn sends it to the stepper drive.

I want to put a input box to say the number of steps for the motor to take. Im using a DLL called "inpout32.dll"  the code is:-

    Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Short) As Short

    Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Short, ByVal Value As Short)

Private Sub Motor_Move()

        Dim T As Integer
        Dim Motor_Steps as Integer

        Motor_Steps = InputBox ("Motor_Steps")

        T = 0.55

        For i = 0 To Motor_Steps

            Out(port, &H6)
            System.Threading.Thread.Sleep(T) ' 1second
            Out(port, &H2)

        Next i

        Out(port, &H0)

    End Sub

I am guessing that mach 3 has direct access to the parallel port which is the bit im interested in finding out how to do this so that i can send out quicker pulses.

Cheers for your help so far.


« Last Edit: October 08, 2009, 02:03:36 PM by andy692003 » Logged
Global Moderator
Offline Offline

Posts: 2,188


View Profile WWW
« Reply #3 on: October 14, 2009, 04:37:36 AM »

Hi Andy

What you've achieved with inpout32.dll is about as good as it gets with VB (or any other language for that matter) with windoze after 95/98. It's not primarilly that VB doesn't have the speed, its that any ".exe" runs under the control of windoze and can not get privilaged control of the hardware. Your VB program will send out your pulses "OK" i.e. up to a reasonable speed, but the timing of when they actually get to the parallel port is down to the OS. Windoze (like any other non-real-time OS) is constantly wandering off doing "more important" things just when you needed a pulse.

Of course - what you want to do can be done. After all Mach3 does it. Start by reading about writing a windoze kernel driver. (good luck!)



Offline Offline

Posts: 1

View Profile
« Reply #4 on: February 20, 2012, 10:30:03 AM »

Start by reading about writing a windoze kernel driver. (good luck!)

Hi, I know it's an old topic, but i'm thinking about the same.
I saw there is a SDK but I was wondering if it is maybe possible to make a vb plugin/application for mach3 / or an application that uses the library's of mach 3 to control the parallel port
with just 6 buttons

Is this possible?

Offline Offline

Posts: 1

View Profile
« Reply #5 on: March 29, 2012, 02:42:59 PM »

I have same question... I had difficulty to supply the fast pulse to the Mach3 using a program, thus I would like to know what other method can I try to replicate the output of Mach3 to the parallel port?

Is there a library that we can tap into to control +x, -x, +y, -y and run smoothly like it's from Mach3?
Pages: 1   Go Up
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!