LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

newbie question about clocked DIO and timing with labview

I bought a new PCI-6221 board and installed Labview 8.5.  I got everything running and have been playing with it a bit.

 

I'm trying to do two things: read optical encoders and control stepper motor drivers.

 

My stepper motor drivers take only a pulse input and a direction bit.

 

My optical encoders are quadrature input with A and B channels.

 

I was able to to do both tasks quite easily with the DAQ Assistant.

 

Unfortunately, using the DAQ Assistant, I'm only able to do Counter Inputs or Counter Outputs on CTR0 or CTR1 lines - these two lines do not provide enough to control the numbers of steppers/encoders I want without buying another board.

 

I'd like to do all the processing in software.

 

I am familiar with embedded programming of microcontrollers and wanted some help transfering these ideas and putting them into Labview and would greatly appreciate any help.

 

In an embedded controller, I would do the following:

1) setup TimerA with the length of time I want

2) create an interrupt every time TimerA expires

3) interrupt program execution and run the interrupt service routine

4) resume program execution

 

In Labview, I would like to do the following:

1) setup Timer0 to trigger every 1e-6 seconds (1MHz)

2) upon trigger a) increment the Labview variable "U64 time_in_us"

                        b) run a subroutine that (reads in DIO bits, do some processing, outputs some DIO bits)

 

How do I achieve this Labview?

 

I found out that I can create a pulse clock using the DAQ Assistant, do I then need to physically wire the output of the pulse clock to the input trigger of the DAQ device or can I do this in software (drag a wire from a timing source input to the subroutine trigger)? 

 

Any help would be greatly appreciated for this newbie.

 

Also, if I put a while loop that reads in DIO, will I be able to read in/process DIO at the 1MHz rate with a Quad Core 3Ghz Core2 processor?

 

Thanks in advance.

0 Kudos
Message 1 of 4
(2,622 Views)

This is an interesting task.

 

First things first, you can't read every usec the digital input, you should do this in bursts. Every msec 1000 samples.

 

To get a clock on the first port (8 lines) look at the timed DIO example in the examples:

 Hardware IO\Daqmx\multiple function\clocked IO (or something similar)

 

Basically this happens, you create a clock with the analog output and use that clock for the DIO.

 

I'm not sure if you will gain a lot from this method, maybe you should go for a more advanced card.

 

Ton

 

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 4
(2,619 Views)

Thanks for the response.  Is 1khz (1ms updates) the fastest I can read the digital inputs?  The specs say 1MHz clocked DIO.  Is my computer bus not fast enough?  1MHz doesn't seem that fast a sampling rate for a 33mhz pci bus and a 3ghz quad cpu machine.

 

Also, I assume the 6221 has an 80MHz clock base as it says in the specs.

 

I just need to "trigger" the subroutine everytime the clock expires.

0 Kudos
Message 3 of 4
(2,594 Views)

henry99 wrote:

Thanks for the response.  Is 1khz (1ms updates) the fastest I can read the digital inputs?  The specs say 1MHz clocked DIO.  Is my computer bus not fast enough?  1MHz doesn't seem that fast a sampling rate for a 33mhz pci bus and a 3ghz quad cpu machine.

 

Also, I assume the 6221 has an 80MHz clock base as it says in the specs.

 

I just need to "trigger" the subroutine everytime the clock expires.


This is all correct, but you don't trigger every usec the DIO port from software. Let the DAQmx driver do such things, it can give you every msec 1000 samples back. So you have the data you need.

 

Just remember that only the first port (8 lines/connections) can be timed.

How many counters do you need?

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 4
(2,575 Views)