Hello Guest it is March 28, 2024, 04:25:00 PM

Author Topic: Controlling a stepper motor from VB  (Read 13390 times)

0 Members and 1 Guest are viewing this topic.

Controlling a stepper motor from VB
« on: October 06, 2009, 06: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.

Andy



Re: Controlling a stepper motor from VB
« Reply #1 on: October 06, 2009, 07: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.
Re: Controlling a stepper motor from VB
« Reply #2 on: October 08, 2009, 03: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

            'Forward
            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.

Andy

« Last Edit: October 08, 2009, 03:03:36 PM by andy692003 »

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Controlling a stepper motor from VB
« Reply #3 on: October 14, 2009, 05: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!)

Ian
Re: Controlling a stepper motor from VB
« Reply #4 on: February 20, 2012, 10:30:03 AM »
Start by reading about writing a windoze kernel driver. (good luck!)
Ian

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
+x,+y,+z
-x,-y,-z

Is this possible?
Thnx
Re: Controlling a stepper motor from VB
« Reply #5 on: March 29, 2012, 03: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?