Jump to content

Help with generating a pulse train with LabView


panithan

Recommended Posts

Hi,

I am a student currently working on my senior capstone project. As a novice at LabView, I would like to create a LabView program to drive a stepper motor. However, I am having trouble generating a pulse train in order to drive the motor.

As a reference, I am using the Geckodrive G210 motor drive, which requires a pulse train (square waves) or TTL signal to drive the stepper. More specifically, I need to output a digital pulse train at a specified frequency. Is there a simple way to do this?

Thank you in advance, any help would be greatly appreciated.

Panithan

Link to comment

QUOTE (panithan @ Apr 23 2008, 02:23 PM)

Hi,

I am a student currently working on my senior capstone project. As a novice at LabView, I would like to create a LabView program to drive a stepper motor. However, I am having trouble generating a pulse train in order to drive the motor.

As a reference, I am using the Geckodrive G10 motor drive, which requires a pulse train (square waves) or TTL signal to drive the stepper. More specifically, I need to output a digital pulse train at a specified frequency. Is there a simple way to do this?

Thank you in advance, any help would be greatly appreciated.

Panithan

Sounds like fun.

It is good of you to own up to being a student right away and that you are going to earn credit for the work YOU do on this. It won't be much of a capstone, if we do it for you.

LabVIEW makes you dependent on looking up information in the help section, also we live off of the VI example files - which is where I usually start. You may as well start learning your way around the various resources that ship with the software, and that are available at ni.com.

If you start poking around looking for "stepper motor drive," "pulse train" and so on you will certainly start finding things. It is inportant to know what sort of hardware you have installed and what version of LAbVIEW you are programming with. Communicate that to us when you return.

Some of us here have an aversion to giving away the farm to people who are supposed to be learning for themselves.

However, you can get a lot of help, and very specific help, once you start having some code of your own to show. If you get something down and show it to us you won't be treated as a "Homework Hustler."

Here are some other hints. Learn to use the Measurement and Acquisition Explorer (MAX). This provides test panels and even lets you preview the entire task if you have more current versions. You can generate a pulse train and put a scope or meter on the output pins of the DAQ equipment and see that all is well.

You will need to look at the spec sheet of the DAQ card to see what the properties of the various in and outputs can be. Find the spec sheet for the stepper, and driver circuitry to see what inputs it needs. It sounds like you only need a TTL output, but it is always worth checking the drive current needs up front. Figure out what if anything needs to be an interface between them. If the DAQ card can't provide the drive current and voltage then you will have to get some interface to amp it up. (See US DIgital for all sorts of economical stuff). Anyway looking up stuff on spec sheets is a way of life and you need to get down to that. I don't want look it up for you becasue you just need to do it.

When you are wiring this thing be sure to attend to grounding and fusing things properly. I worked on a capstone project where the EE in charge of that stuff did not. It was a smokey hell at exactly the wrong moment.

Surely you won't only drive the stepper one direction. What makes it go back the way it came?

Mike

Link to comment

QUOTE

Sounds like fun.

It is good of you to own up to being a student right away and that you are going to earn credit for the work YOU do on this. It won't be much of a capstone, if we do it for you.

LabVIEW makes you dependent on looking up information in the help section, also we live off of the VI example files - which is where I usually start. You may as well start learning your way around the various resources that ship with the software, and that are available at ni.com.

If you start poking around looking for "stepper motor drive," "pulse train" and so on you will certainly start finding things. It is inportant to know what sort of hardware you have installed and what version of LAbVIEW you are programming with. Communicate that to us when you return.

Some of us here have an aversion to giving away the farm to people who are supposed to be learning for themselves.

However, you can get a lot of help, and very specific help, once you start having some code of your own to show. If you get something down and show it to us you won't be treated as a "Homework Hustler."

Here are some other hints. Learn to use the Measurement and Acquisition Explorer (MAX). This provides test panels and even lets you preview the entire task if you have more current versions. You can generate a pulse train and put a scope or meter on the output pins of the DAQ equipment and see that all is well.

You will need to look at the spec sheet of the DAQ card to see what the properties of the various in and outputs can be. Find the spec sheet for the stepper, and driver circuitry to see what inputs it needs. It sounds like you only need a TTL output, but it is always worth checking the drive current needs up front. Figure out what if anything needs to be an interface between them. If the DAQ card can't provide the drive current and voltage then you will have to get some interface to amp it up. (See US DIgital for all sorts of economical stuff). Anyway looking up stuff on spec sheets is a way of life and you need to get down to that. I don't want look it up for you becasue you just need to do it.

When you are wiring this thing be sure to attend to grounding and fusing things properly. I worked on a capstone project where the EE in charge of that stuff did not. It was a smokey hell at exactly the wrong moment.

Surely you won't only drive the stepper one direction. What makes it go back the way it came?

Mike

I was looking around and came up with a way to generate a pulse by constructing a trigger digital waveform, then putting it in an array and feeling each elements into the output. I also used the wait timer to control the speed of the loop counter. However, when I actually connected the output to the driver & motor, it doesn't really work the way I expected. The motor moves, but at a very slow speed. I have tested the motor driver by inputting a signal from an analog function generator, and it seems to work fine. Am I doing anything wrong here?

PS. The direction of the motor is controlled by a constant 1 or 0 input, so that part is pretty easy.

I've attached a screenshot of my program here.

Thank you.

post-11337-1208984028.jpg?width=400

Link to comment

To answer your question about motor speed is hard becasue I don't know anything about the motor. But I can guess...suppose for example that you motor has 100 poles, then each pulse will only move the motor through 100th of a rev, and it would take 100 pulses to move it one rev. Really, this is why they are called steppers. They sort of click their way around from pole to pole rather than a smooth continuous motion. If you crank the motor speed up it will go faster.

The nice thing about a stepper for you is can position the motor more exactly than is easy with a continuous motor. If your wheel has a circumference of 10 inches and the motor has 100 stops per rev, then one pulse gets you exactly 0.1 inches of motion (subtracing out any slippage between wheel and ground). You would know you grounds speed from this also. 100 pulses per second would be 10 inches a second.

You can crab steer a four motor four wheel system by sending unequal numbers of pulses to the wheels. Sounds easy, eh?

Mike

Link to comment

QUOTE (panithan @ Apr 23 2008, 04:55 PM)

I've attached a screenshot of my program here.

One thing that will help is if you make sure to use "good LabVIEW coding practices". This will help you as well as others debug your code and will make the code look "more professional" (which could help you with your capstone). The main points I see is to keep your wires neat (not a lot of bends, wires don't overlap on each other, etc.), to keep the dataflow from left to right and top to bottom, and to put comments in the code.

As mross pointed out, the motor will take 100 pulses to move one rotation, so if you have an output frequency of 100 Hz the motor will actually turn at 1 Hz (1 rotation per second = 100 steps per second). If your motion is not somewhat smooth, you may have an issue in the electronics that are driving the stepper motor are not powerful enough to cause the motor to move from pole to pole in one step. A way to check this independantly of your program would be to hook up a signal generator to the driving circutry. If you don't know how to use an oscilloscope, this would be a good time to learn. Sometimes the issues run into are not in the software or the hardware, but this dubious area inbetween.

Good luck!

Link to comment

Thank you for all the advice.

My question now is how do you control the speed of the loop iterations? My code right now will outputs a pulse every other iteration. However, I can't seem to increase the speed to what I need. I know I can use the "wait till next millisecond multiples" function to slow down the speed, however, I can't seem to increase it to beyone 1kHz.

Link to comment

QUOTE (panithan @ Apr 26 2008, 09:32 PM)

Thank you for all the advice.

My question now is how do you control the speed of the loop iterations? My code right now will outputs a pulse every other iteration. However, I can't seem to increase the speed to what I need. I know I can use the "wait till next millisecond multiples" function to slow down the speed, however, I can't seem to increase it to beyone 1kHz.

I have not used the VIs that you show. I do have a VI that I use to make pulsewidth modulated square wave. I run it from 1 to 10000Hz so there is no doubt with the right method you can increase the speed. You should experiment with some other examples for producing square wave output.

It may be better to generate the pulses on an analog output channel.

When I get to work tomorrow I will look at the PWM VI and see if it could be useful.

I assume that for control of the vehicle you will want to command specific numbers of pulses to be generated at varying speeds, and you may want straight forward and reverse travel with manual control - on, off and change speed. Also you may be programming specific "moves" such as spin 180 degrees in one place. It may not be appropriate for this to have only one method of pulse generation. For this reason you need to learn as much as possible about the different ways this can be done.

Your current method may have the limitation that it can only make pulses at 1KHz.

I am not the best and only source of information on this forum. So you must learn how to interest people in helping you. One good way is to keep showing us your code and a willingness to improve it according the the ideas presented here. For example Tim S suggested you straighten out your wires and organize the code so that the "Flow" can be understood with less trouble. Likewise, I mentioned eliminating the sequence structure. If it is difficult to read your code, you will get less assistance.

All that aside, we can't be as helpful without seeing the code you are using. Attaching the VIs (or if it is multiple VIs perhaps a zip file of them) to the forum messages is a good idea. Often you will get back improved versions of the code as part of a reply.

Mike

Mike

Link to comment

QUOTE (panithan @ Apr 26 2008, 09:32 PM)

Thank you for all the advice.

My question now is how do you control the speed of the loop iterations? My code right now will outputs a pulse every other iteration. However, I can't seem to increase the speed to what I need. I know I can use the "wait till next millisecond multiples" function to slow down the speed, however, I can't seem to increase it to beyone 1kHz.

You are relying on Windows to maintain your timing, and LabVIEW on Windows cannot reliably run loops faster than 1kHz. Also, you may be running into the limits of your I/O board - what is its maximum sample rate? To do this properly you really want to use a counter/timer board, not a digital output board.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.