Discussion:
Drive Stepper Using Digital output with Pulse sequence
(too old to reply)
scuzzy
2008-04-04 13:40:10 UTC
Permalink
Basically I need to drive a stepper motor through a darlington transistor array. And the movement is based on pulses and sequence as below (See attached):
 

B asic information I can provide is:
- This is driven with a PCI-6509 card
- Stepper Motor model is: a generic "24BYJ48" 12Vdc PM stepper motor
- The pulses are generated with Digital Output (not enough counters as I'm driving up to 12 stepper motors, adn each stepper require 4 DO lines)
- Darlington Transistor Array is: Texas Instrument ULN2803A
- The attached sequence is for 1 rotation clockwise
- The reverse sequence would move the motor counter clockwise
 
Questions:
1. How do I generate those signal patterns in Labview? I've tried creating an array but it doesn't seem to work.
2. How do I combine each line sequence into a "group" and just call it and loop it for continous movement? e.g (Port 0:line 0 to line 3 for 1st stepper motor, Port 0:line 4 to 7 for 2nd Stepper motor )
 
I've also attached a very basic Labview code to generate digital out pulses, what changes should I make for it to "record" the pattern?
 
Thanks very much for any assistance...


Stepper Sequence.JPG:
http://forums.ni.com/attachments/ni/70/8583/1/Stepper Sequence.JPG


Pulse Output.vi:
http://forums.ni.com/attachments/ni/70/8583/2/Pulse Output.vi
Matt A
2008-04-07 15:40:10 UTC
Permalink
Hello scuzzy,Based on the information you provided I took a look at your example and made some minor changes that should get you what you're looking for. The example is written to operate 2 motors on channels 0 through 3 and 4 through 7, but you should be able to add more motors pretty easily by duplicating the outlined code. There are notes in the Block Diagram which describe the functionality of each step and I have posted an image of the Block Diagram for easier viewing. Let me know if you have any questions about the example.<img src="Loading Image..."> Message Edited by Matt A on 04-07-2008 10:12 AM


Pulse Output Modified.vi:
http://forums.ni.com/attachments/ni/70/8599/1/Pulse Output Modified.vi


Pulse Output Modified.jpg:
http://forums.ni.com/attachments/ni/70/8599/2/Pulse Output Modified.jpg
scuzzy
2008-04-09 11:10:05 UTC
Permalink
Hi matt,
Thanks for the code. I've tried it but doesn't seem to work. Just some questions:
1. On the "port for Motors" array, clicking on it would generate a list which would read "DIO/port0/line0" and so on. Wouldn't this generate an output on the particular line, instead of generating the output on 4 lines simultanously&nbsp;as it should?
2. Regarding the frequency, the pulse width should be 5ms for each pulse, can it be controlled that way through this loop?
Thanks for any input.
scuzzy
2008-04-09 11:40:06 UTC
Permalink
Juz an addition... I'm trying out and experimenting with this VI, maybe it would give a clearer picture of what I have in mind, although it still does not work the way I want it to:
&nbsp;
But for additional info:
&nbsp;
Port 0 / line 0 -3 has to run simultanously. The other lines of the port (4-7) would be connected to another stepper motor with totally independant movement. So basically
&nbsp;
line 0 would produce: 1 0 0 1
line 1 would produce:&nbsp;1 1 0 0
line 2 would produce: 0 1 1 0
line 3 would produce: 0 0 1 1
&nbsp;
All these four lines would run simultanously, and be repeated. each pulse width would be 5ms - 10ms.
&nbsp;
Thanks!


Write Dig Port Modified_KY.vi:
http://forums.ni.com/attachments/ni/70/8622/1/Write Dig Port Modified_KY.vi
scuzzy
2008-04-09 15:10:08 UTC
Permalink
Another addition...
&nbsp;
Rewrote some codes and tested it out... the VI below seems to work well for me, can anybody let me know is there a better way to seperate lines 0-3 and lines 4-7 as a seperate port. One method I did was to set the arrays to false for the lines that are not involved for that particular motor's movement. But I dun think this is the best method.
&nbsp;
Would appreciate any advise.
&nbsp;
Warm regards...


Generate Pulse Train Dig Out DO.vi:
http://forums.ni.com/attachments/ni/70/8626/1/Generate Pulse Train Dig Out DO.vi
Matt A
2008-04-10 22:10:07 UTC
Permalink
Hello scuzzy,

I apologize if I was a little unclear in my first post, I probably
should have posted the front panel as well. I have attached the image
below so you can see the controls I am using. There you will see that
the "Ports for Motors" control is actually an array of Physical
Channels where each element in the array represents the lines required
for one motor. In my example, I have selected port0/line0:3 for the
first element in the array (motor 1) and port0/line4:7 for the second
element in the array (motor 2). I selected the array option to allow
for scalability and because the ability to index this array allows me
to associate a particular grouping of lines with an array element,
which I can later use to index my motors (allowing me to say motor 1,
motor 2, etc).

<img src="Loading Image...">

I would point out some additional features in the VI I posted as well:

1. I would note that (as shown in the image in my first post) both of the DAQmx Write VIs are in the same loop, so the Rate (Hz)
control will apply to both of them. That is to say, that both motors
will be updated at the same time, so they will both be running at the
same rate. However, they do have separate direction controls because
the booleans can be independently configured to move clockwise or
counter-clockwise. If you wanted to control the motors independently,
you would need to put each of the sections of highlighted code into a
separate while loop, similar to the image below.

<img src="Loading Image...">

2. The PCI-6509 provides software timed digital operations, which means
that the ability to control the timing of the updates depends on how
fast your operating system can run the LabVIEW code. In most Windows
based environments, the best resolution you can attain is on the order
of milliseconds up to tens of milliseconds. That means that if you tell
LabVIEW to wait one millisecond between iterations of the while loop
(1/1 msec=100 kHz update rate) that Windows could execute that code in
intervals of anywhere between 1 millisecond and 10 milliseconds.
Unfortunately, this is a limitation of the way that Windows handles
different programs and distributes control. For example, opening an
internet browser while your program was running would force Windows to
allocate resources to that program, which would take resources away
from LabVIEW and slow the execution. If you need to be able to control
the update rate with better precision than this, you would like need to
move to a Real-Time deployment environment or consider a device with
hardware timed digital operations (like our M Series devices).

3. To address your question about "separating" lines, I would point out
that you can simply create different digital tasks which contain the
different lines you want to use. I have done this above in my example
which uses line0:3 and line4:7 of port0 separately. One potential
problem with this option is that you can have multiple tasks running at
the same time which are attempting to access the same hardware. For
example, when you use the DAQmx Start Task to run a task, that will
block any other task from accessing that port either as an input or an
output. However, since you are performing software timed updates and
only access the hardware with a single set of a data at a time, you
don't actually need to have the task running. As you can see in my
example, I simply use the DAQmx Write to update the data. I never
explicitly start and stop my task because the DAQmx Write will
implicitly start and stop the task to write the data.

I hope this information helps to address your questions. Feel free to post back if you have anything else.Message Edited by Matt A on 04-10-2008 04:41 PM


Pulse Output Modified Front Panel.jpg:
scuzzy
2008-04-11 12:10:07 UTC
Permalink
Hi Matt,
It worked well. Sorry for the miscommunication. Thanks!

Continue reading on narkive:
Search results for 'Drive Stepper Using Digital output with Pulse sequence' (Questions and Answers)
4
replies
How stepper motor works?
started 2006-12-20 00:52:42 UTC
consumer electronics
Loading...