Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Drive Stepper Using Digital output with Pulse sequence

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):
 
Basic 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...
Download All
0 Kudos
Message 1 of 10
(12,608 Views)
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.




Message Edited by Matt A on 04-07-2008 10:12 AM

Matt Anderson

Hardware Services Marketing Manager
National Instruments
Download All
0 Kudos
Message 2 of 10
(12,575 Views)

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

0 Kudos
Message 3 of 10
(12,557 Views)
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:
 
But for additional info:
 
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
 
line 0 would produce: 1 0 0 1
line 1 would produce: 1 1 0 0
line 2 would produce: 0 1 1 0
line 3 would produce: 0 0 1 1
 
All these four lines would run simultanously, and be repeated. each pulse width would be 5ms - 10ms.
 
Thanks!
0 Kudos
Message 4 of 10
(12,554 Views)
Another addition...
 
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.
 
Would appreciate any advise.
 
Warm regards...
0 Kudos
Message 5 of 10
(12,543 Views)
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).



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.



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

Matt Anderson

Hardware Services Marketing Manager
National Instruments
Message 6 of 10
(12,514 Views)

Hi Matt,

It worked well. Sorry for the miscommunication. Thanks!

0 Kudos
Message 7 of 10
(12,503 Views)

I am trying to drive 4 stepper motors concurrently (ideally in parallel) and synchronise them using a USB device with only digital I/O and no counter timer.

 

I would like to make the stepper run at different speeds so that when the rotational motion is transformed into longitudinal motion the motors make the 'sliders' follow arbitrary waveforms at about 5Hz frequency.

 

Should I generate a digital waveform for each bit then combine them together before sending to the device?

 

The problem that we are facing is that the motors loose synchronisation and the loop speed changes.

 

Olivier

 

 

0 Kudos
Message 8 of 10
(11,278 Views)

Olivier,

 

3 key questions to determine feasibility:

 

1.  What data acq hw do you have?

2.  What range of frequencies do you need to support?

3.  Is the waveform known ahead of time, or do you want/need to make decisions on the fly about the motion profile?

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 9 of 10
(11,239 Views)

Hi

 

I am a beginner at labview and need a VI which can drive a vibration motor by NI-DAQ in time-constant periods.(e.g permanently every 20 minutes drives it for couple of seconds and then turn it of like a digital pulse every 20 minutes with a duration of say 5 seconds).I used the digital output line for this purpose but i don't know how to make a VI which can perform this task for me automatically. It would be so kind of you if you send me a simple VI with to deal with this.

 

Thanks

 

Farid

0 Kudos
Message 10 of 10
(10,156 Views)