01-22-2009 08:22 AM
Hello,
I'm fairly sure this is impossible to do in Labview but thought I would ask the question just in case:
On a digital falling edge I need to set one digital line on a PCI-6224 high and one low, then read sixteen lines as a port. Next the high and low output lines should change status and then the sixteen lines should be read again.
The process repeats on successive falling edges. The time between edges may be as short as 11 microseconds (90kHz).
We currently have a program written in C++ to do this job but I'd like to create something a bit more user friendly and have virtually no C++ experience myself.
Thanks.
Solved! Go to Solution.
01-23-2009 03:36 AM
Hi Simon,
I believe this is possible although not simple! I take it that the read has to follow the write so we can delay this task. Is there a certain amount of time that needs to pass? I am slightly concerned about the short time but if this has been done with this hardware using C++ then it should be possible with LabVIEW. How wide are the pulses? Would the timing be acceptable if we were able to write to the channels on the rising edge and then read on the falling edge? And I take it these pulses are from an external source. With this we should be able to determine a way to do this.
Regards,
01-27-2009 05:09 AM
Hi James,
Thanks for your reply, yes you are right the read needs to follow the right with a delay of at least 140ns. The old program which currently does this job is running in DOS on a computer which is at least 10 years old with an Amplicon digital i/o card in it.
The problem is that there is one clock signal and two channels have to be read during each cycle. I'll try and explain more clearly:
There are two binary counters in the external circuit which feed into a series of D type flip flops. There are 32 outputs from the flip flops, 16 for one channel, 16 for the other. The flip flop outputs are all wired to 16 pins on a connector and each flip flop has an output enable. On a latch pulse the data on the flip flop inputs is stored but only sent to the outputs when the output enable is active. The latch pulses are 0.5 microseconds long and occur on each clock rising edge. The current program probably waits for a clock rising edge, delays for 0.5 microseconds, sends one of the output enable lines high, waits 140ns, reads data (channel 1), sets the first output enable low and the other high, reads data (channel 2), waits for the next rising clock edge.
I think one solution to this would be to rebuild one of the PCBs in the device so that all 32 outputs from the flip flops have their own output pin and the output enables are always active then just read both channels on a clock falling edge. I just wondered if it would be possible to do it without changing the hardware as the old program does.
Thanks,
Simon.
01-28-2009 05:59 AM
Hi Simon,
I have an idea of how to do this using the DAQmx card. This hasn't been tested but I believe this should work with just a few tricks with DAQmx. There are three tasks that will be required:
Counter Output
==============
This should be a retriggerable counter task. Take a look at the example in the LabVIEW example finder under Hardware Input/Ouput>>DAQmx>>Generating Digital Pulses>>Gen Dig Pulse Train-Finite-Retriggerable.
1. This should generate two pulses every time the external trigger is recieved so your 11us pulses are the trigger for this task.
2. These pulses are for each read of the digital lines so:
Rising edge - Changed the enable lines
Falling edge - Read the data.
By making these pulses wide enough (>140ns) this will take care of the settling time of the DO lines.
3. The gap between the pulses should be long enough for any delay require between reads.
Digital Output
==============
This should be a regenerative continuous output - see example Hardware Input and Output>>DAQmx>>Digital Generation>>Cont Write Dig Port-Ext Clock.vi.
1. The clock source should be set by right clicking on the source control. Select I/O Name Filtering and then enable the advanced terminals tick box. Then you can select the appropriates counters internal output.
2. You will need to set the clock edge to be the rising edge.
3. Prime the buffer with the two outputs we require e.g. 10 and 01 then sending a pulse to the clock will effectively switch between the two.
Digital Input
=============
This should be a standard continuous input task such as the example Hardware Input and Output>>DAQmx>>Digital Measurements>>Cont Read Dig Channel-Ext Clk.vi
1.Set up the timing VI almost identically to the output task. Same source but this time clock on the falling edge.
2.Do with your data what you will!
Overall Program
===============
The main consideration is that you should start the counter output last as once this is running the others can start clocking data.
I hope this helps and is clear enough. Let me know if it makes sense or if you need more information or even any help building this program.
Regards,
01-30-2009 10:46 AM
Hi James,
Thanks very much for the suggestion, I'm impressed! I think it will do the job if the card runs all the processes ok. I should have time to test it properly next week and will let you know how it goes.
Regards,
Simon.
02-04-2009 04:42 AM
Hi James,
I've been trying out the program you suggested and the first two secions work really well even when the triggers are coming in at 90kHz.
However adding in the digital read section brings up an error stating 'selected lines do not support buffered operations'. Do you know what is going on there? I've attached the program which is just a combination of the three examples you mentioned. I am using port 0 of my card (with 32 lines) to read from and using lines on ports 1 and 2 for the trigger input and enable outputs.
Thanks,
Simon.
02-04-2009 10:55 AM
Hi James,
Don't worry about my previous message, I worked out what I'd done wrong. I can only use the output lines on port 0 for the looped continuous operations. I'd appreciate any suggestions on how to more elegantly structure my program though. Can I put all the loops together in one?
Thanks,
Simon.
02-04-2009 11:36 AM
Hi Simon,
Glad to hear you found that! You can remove the loops, the loops for the outputs are doing nothing inside them so you can just have the loop for the input. As well as this you will need to enforce program flow by merging the error clusters before the loop to ensure that everything before that has executed, this will also allow you to ensure that the counter task is started last. This is because once the counter task is running your other tasks can start operating so we need to ensure they both start at the same time.
Finally I would remove the outer structures and just have the program start when you press run so you dont need the go button, outer while or case structure. I have attached the code with these changes which you can use if you like or you may have some other requirements that I don't realise.
Regards,
02-09-2009 06:05 AM
Hi James,
Thanks for editing the program, unfortunately I've got Labview 8.2 and can't open it. Could you attach it again in the older format or just a picture of the block diagram if that's easier? There was one strange thing I came across in assigning digital lines as virtual channels. I had expected that the lines once assigned to a channel would be interpreted as a virtual port, however they still seem to retain their original port status. For example if I assign lines 7 and 8 to a virtual channel and read them when 8 is high I get a value of 256 instead of 2. Is there any way to create a virtual port or should I just work around this?
Thanks,
Simon.