/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
Interface for a step motor
Fra : Alex Nagelmann


Dato : 13-10-01 19:03

Hi there!

I want to program a program for a stepper motor controlled by an ULN 2003 IC
via the parallel port.
Can anyone say how i can talk to the parallel port?
Does this work under Visual Basic?

Thank you for your answers!

Alex



 
 
Villy Jensen (14-10-2001)
Kommentar
Fra : Villy Jensen


Dato : 14-10-01 08:01

Hi Alex

It is possible to interface a stepper motor to LPT using a ULN 2003,
and it is possible to comunicate to LPT under VB - I have collected
lots of links specially for your purpose at:
http://hjem.get2net.dk/villy/vje_vbio.htm




BUT BEWARE:
WINDOW$ ecxecutes all running applications (including the OS) in
'time-slices'!
This phenomena will cause the pulses for the stepper motor to be CUT TO
PIECES AND SEND IN 'BURSTS' causing unpredictable, unusable and noisy
rotor movement (if any) when trying to stepping more than 1 Hz


Yoy might overcome the 'time-slice-problem' by temporaryly applying the
very TOP SYSTEM PRIORITY to your stepper motor application:

From Allapi, http://www.allapi.net/api/SetThreadPriority.php

Const THREAD_BASE_PRIORITY_IDLE = -15
Const THREAD_BASE_PRIORITY_LOWRT = 15
Const THREAD_BASE_PRIORITY_MIN = -2
Const THREAD_BASE_PRIORITY_MAX = 2
Const THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN
Const THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX
Const THREAD_PRIORITY_BELOW_NORMAL = (THREAD_PRIORITY_LOWEST + 1)
Const THREAD_PRIORITY_ABOVE_NORMAL = (THREAD_PRIORITY_HIGHEST - 1)
Const THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE
Const THREAD_PRIORITY_NORMAL = 0
Const THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
Const HIGH_PRIORITY_CLASS = &H80
Const IDLE_PRIORITY_CLASS = &H40
Const NORMAL_PRIORITY_CLASS = &H20
Const REALTIME_PRIORITY_CLASS = &H100
Private Declare Function SetThreadPriority Lib "kernel32" (ByVal hThread As
Long, ByVal nPriority As Long) As Long
Private Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As
Long, ByVal dwPriorityClass As Long) As Long
Private Declare Function GetThreadPriority Lib "kernel32" (ByVal hThread As
Long) As Long
Private Declare Function GetPriorityClass Lib "kernel32" (ByVal hProcess As
Long) As Long
Private Declare Function GetCurrentThread Lib "kernel32" () As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim hThread As Long, hProcess As Long
'retrieve the current thread and process
hThread = GetCurrentThread
hProcess = GetCurrentProcess
'set the new thread priority to "lowest"
SetThreadPriority hThread, THREAD_PRIORITY_LOWEST
'set the new priority class to "idle"
SetPriorityClass hProcess, IDLE_PRIORITY_CLASS
'print some results
Me.AutoRedraw = True
Me.Print "Current Thread Priority:" + Str$(GetThreadPriority(hThread))
Me.Print "Current Priority Class:" + Str$(GetPriorityClass(hProcess))
End Sub

I have never tesed the above 'priority code snippet' - I prefer using DOS
mode (NO WINDOW$!!!!), as QBasic executes at a reasonable speed
with minimal and undisturbing timeslice problems!



For Your application I recomend using DOS and of one of the following
programming languages:
1) QBasic
2) GW BASIC
3) PowerBasic (=PB)
4) Visual Basic for DOS (VBDOS)
5) QuickBasic (=QB) version 4.0 eller 4.5
6) QuickBasic PDS (=QBPDS)
(QBasic is the slowest and QBPDS is the fastest excecuting programs)


Having programmed several stepper motor applications (using either
controllers or ULN 2003) I am able to program LPT O/P at rates up to
30 KHz using QB, VBDOS or PowerBasic on any 33MHz 486DX PC.


Happy stepping
Villy
http://hjem.get2net.dk/villy




> Hi there!
>
> I want to program a program for a stepper motor controlled by an ULN 2003
IC
> via the parallel port.
> Can anyone say how i can talk to the parallel port?
> Does this work under Visual Basic?
>
> Thank you for your answers!
>
> Alex
>
>









Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408928
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste