Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

pattern of pulse signals in pci-6602

I post this question again if someone can help me with some examples. I am doing a project which controls a three phase AC motor. To run the motor I need to write a LABVIEW program which generates a pulse signals in a specific order which close and open a switch inside an inverter module so that a sinewave is created at the output. I undersatnd how to generate these signals on "digital generation" by looking some examples and help from the discussion forum. but if the project need to work properly these signals need to be created using "generate digital pulse" because the duty cycle of some bits in a channel need to be different. I was told to look at the example "triggered pulse generation with different initial delay" but I couldnt find on the help menu under DAQmx. I also try to see some of the examples on the help menu but i found it difficult to create these signals. I appreciate if someone can help me by posting some examples . I am using LABVIEW 7.0 and pci-6602.

the signals I want to generate on each channel is
channel 1 = 1 0 0 1 0 1
channel 2 = 1 0 1 0 0 1
channel 3 = 0 1 1 0 0 1
channel 4 = 0 1 1 0 1 0
channel 5 = 0 1 0 1 1 0
channel 6 = 1 0 0 1 1 0

thanks
casu
0 Kudos
Message 1 of 15
(5,565 Views)
casu,

You aren't likely to be able to generate the pattern you show with counters. (This pattern is different than the one you posted in another thread when the idea of counters was first suggested.) Also, since your ultimate aim is to control a 3-phase motor, it's now clear that all aspects of timing are likely to be very important. That is, not only must each channel have precise timing of its own edges but the synchronization between channels will also be very important. So the software-timed DIO example I posted in that thread would probably also not be an acceptable starting point.

You could maybe use an M-series board or high-speed digital board for a hw-timed digital pattern output, but only if you aren't going to need to change the timing as part of the control loop. For full-on motion control, you really need some type of real-time processor. I don't think NI's motion controller cards can be programmed to switch a 3-phase motor, and it doesn't sound like you have or are planning to use LabVIEW RT. Can you use a commercial motor drive or controller that handles the switching for you?

-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.
Message 2 of 15
(5,553 Views)
hi kevin
I am sorry giving you some confusion. you are right the data is wrong. the one I posted in the past was right. anyway as you said this project might work or not with LABVIEW, but it used to work with some other software like DSP and this time they want try it if it works on LABVIEW. I dont know that. the only thing I want is some kind of sine wave at the output whether it runs the motor or not. if we use these sequence numbers using digital generation we will get an output like a SIX-STEP sine wave at the output. I get that one. but to smooth out that and make it like a sine wave the theory says some of the signal duty cycle need to be changed. thats why I need to use pulses instead of digital generation. my question is it possible to create a program using "gen dig pulse" for these sequences . if there is an example somewhere would you post it please.
this is the right data

channel 1 = 1 1 0 0 0 1
channel 2 = 0 0 1 1 1 0
channel 3 = 0 1 1 1 0 0
channel 4 = 1 0 0 0 1 1
channel 5 = 0 0 0 1 1 1
channel 6 = 1 1 1 0 0 0

thanks
casu
0 Kudos
Message 3 of 15
(5,549 Views)
casu,

Hi again. Good news -- I've got an example that's fairly close to doing what I think you need. Unfortunately, my network PC isn't near any LabVIEW pc so I can't tweak it right now, but let me point you to an example I posted in another thread.

You could use the same idea with one master pulsetrain that drives your other 6 derived "divided-down" pulsetrains. In your case, you would use 3 high ticks and 3 low ticks for all the divided counters, but the initial delays would be different to create the offset pattern you need. I'd recommend the values 8,5,4,7,6, and 9 ticks to generate the pattern you posted. (The reason why is in the last paragraph.)

Also, you can see in that example that the master pulsetrain can be stopped and re-started which causes the divided counters to also stop and re-start while staying in sync. You would also be able to change the master frequency without stopping it to provide a smooth change in speed to your 6 switches, i.e., the sinewave driving your motor.

One quick gotcha to watch out for. I worked with NI support a few months ago about some quirks in the initial delay. I think that if you ask for 0,1, or 2 ticks you get 2. If you ask for 3 you get 4. But if you ask for 4 or more you get exactly what you want. Something like that. I think there might have been some additional criteria involving the # of low ticks also. In any event, the lesson I took away from it was that if you're going to specify an initial delay, use 4 or more ticks.

-Kevin P.

P.S. While you *can* change the motor speed on-the-fly, you aren't going to get high-speed real-time motion control this way. I don't know what the DSP *actually* did, but it easily could have been doing far better motion control than you can hope to achieve under Windows. Not to be a downer, but just to forewarn you that there is a point where the problem stops being your code and starts being the Windows OS.
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 4 of 15
(5,532 Views)
thanks kevin it is a big help. I try to run the program changing some of the numbers and get a pulse train signal,but the two adjecent counters ( eg. ctr0 and ctr1) their output is not completely out of phase. some part of one counter pulse get inphase with the other counter pulse. maybe that could be resolved by the initial delay. I tried that by creating an array for those values you listed and connected to the initial delay on the "co pulse" function . I dont know if I am right or not,but still I dont see any change on the two outputs . as you remeber the two counter output need to be always opposite (ctr0 and ctr1 ,ctr2 and ctr3, ctr4 and ctr5). also Do I need to change the value in " division factor", "master info" and "divided info" boxes?. if i need what would be the value entered in each box?. as I mentioned you last time I just need to create a sine wave at the output of the inverter module.

thanks for the continious help.
casu
0 Kudos
Message 5 of 15
(5,518 Views)
casu,

For your app, every element of the "division factor" array should be 6 -- this specifies that all your pulsetrains will have the same frequency. In addition, you should create an array of initial delays that you send into the DAQmx Create Channel vi. I believe the set of values I gave you before should give you the pattern you need -- 8,5,4,7,6,9. You can see that the counter pairs have a phase that varies by 3 ticks worth of initial delay out of a total period of 6, the division factor. This should make sure the pairs produce outputs that are the inverse of each other.

The other boxes, "master info" and "divided info" are indicators that are updated by the program. You don't need to put anything in there. Right now they just show each of the counters doing their countdowns to 0 as they generate their pulsetrains.

-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 6 of 15
(5,509 Views)
hi kevin thanks a lot the program works. as you said the motor speed stay same while I changed the frequency. it's ok. I just need to run the motor. I have one task left which is to write LabVIEW program which reads and display motor speed .

thanks again
casu
0 Kudos
Message 7 of 15
(5,499 Views)
hi kevin
I am back again. since you right the program I need your help again please. this time reading the RPM of the motor . I try to built a vi which reads the RPM following examples from the help menu but I get error saying " time is expired before ..." despite entering different numbers for "time out". I dont know why . is there a certain number I have to enter or something else. also
you use "event structure" on the program which I never use before. the vi which reads the RPM should be inside that structure or it can be outside.
thanks for your help
casu
0 Kudos
Message 8 of 15
(5,488 Views)
Casu,

It sounds like a timeout error. Since you tried different timeout values w/o success, are you sure you've got a good signal coming in? Try checking it out from MAX using edge counting to be sure you're getting TTL pulses. Another debug step would be to use MAX to generate a constant pulse train and configure your RPM measurement counter to measure its frequency.

To get started, I would suggest configuring and starting the task before the main loop, then inside the "timeout" case of the event structure you would Read, Stop, and re- Start the task. This will help you make sure things basically work but it isn't the best architecture in the long run. Your read rate would vary as a user interacts with the front panel and your whole loop'll get stuck during the time it takes to perform a read and re-start.

In the longer run I'd recommend that you configure your RPM measurement for continuous sampling. If your measurement is solely for the sake of updating the front panel and not for closing a speed control loop, I'd further recommend that you read several values at a time. There are DAQmx Read property node settings that will let you read the most recent data already taken.

Finally, I'd read an odd number of values >= 5 and take the median of them. I've had some situations doing period readings in electrically noisy environments. Occasionally, there'd be noise that would produce a "phantom" pulse somewhere within a real one, creating 2 consecutive period values that would be invalid. A median value of those 2 plus 3 or more neighbors will effectively ignore them. Using odd #'s of samples makes sure that the median will be one of the values actually sampled.

Of course, with the 6602 you can set up digital filtering on your input line. I didn't used to do this because it seemed to limit the effective measurement resolution of the intervals. I think that's been fixed, but am not 100% certain.

If you have trouble with it, post back with the code and describe errors or other weird data.

-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 15
(5,487 Views)
Hi Kevin
I have tried to add some vi functions on the main program which reads RPM of the motor following the hint you posted . I tried both ways but didn't work for me.
The first one not a lot change from what you knew(I posted the program). There is error when the program runs. The reading on this one even if it works as you said it will not show me the current speed of the motor while it is running.
On the second one I changed the DAQmx read vi with "DAQmx read property node" and leave the rest as it is . There is no error on this one when the program runs . I don't know if I am doing right or wrong ,but there is no connection for data on this one.
I prefer the second way which can show me up to date frequency of the motor.

The other thing you mention last time about the program "changing the motor speed on the fly " is not possible . Yes I checked it. The motor speed stay constant despite the frequency change. I want to know if there is any reason why the program didn't respond for a change in frequency.

Thanks a lot for the continuous help
casu
0 Kudos
Message 10 of 15
(5,453 Views)