LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using multiple channels with DAQmx reference trigger (analogue edge)

The scenario is as follows:

 

I have 4 channels (global virtual channels) each monitoring a varying differential voltage input. I need to trigger a fixed pattern digital port output when the level of one of these analogue channels crosses a pre-determined threshold value and I need to record all 4 of the analogue channels whilst this is happening.

 

Now I have a vi that works and performs this function the way that I want it to - but it only works with a single analogue input channel. As soon as I try to wire in multiple input channels (even though I attempt to select only one of them as the source for the reference trigger function) the vi throws up errors and the DAQmx reference trigger (analogue edge) function fails to trigger.

 

The detailed help for this function in LabVIEW gives the following information:

 

DAQmx reference trigger (analogue edge)

 

Configures the task to stop the acquisition when the device acquires all pretrigger samples; an analog signal reaches the level you specify; and the device acquires all post-trigger samples. When you use a Reference Trigger, the default for the read RelativeTo property is First Pretrigger Sample with a read Offset of 0.

 

task/channels in is the name of the task or a list of virtual channels to which the operation applies. If you provide a list of virtual channels, NI-DAQmx creates a task automatically.

 

source is the name of a virtual channel or terminal where there is an analog signal to use as the source of the trigger. For E Series devices, if you use a virtual channel, it must be the only channel in the task. The only terminal you can use for E Series devices is PFI0.

So this function does what I want when I have a single virtual channel connected to the 'task/channels in' and have the same channel name as the 'source'. As soon as I put all 4 of my channels into the 'task/channels in' and name any one of them as the 'source' it's a no-go.

 

It appears as though the comment about the 'source' in the LabVIEW help file which it states applies to E Series devices 'For E Series devices, if you use a virtual channel, it must be the only channel in the task. The only terminal you can use for E Series devices is PFI0' is true for my system - even though I'm using an M Series device.

 

Any ideas as to how I can get the vi to function the way I want?

 

My hardware is as follows:

PXI-1050

PXI-8360 MXI-Express in slot 1

PXI-6533 Digital I/O in slot 4

PXI-6251 M Series Multifunction DAQ in slot 8

 

LabVIEW 2011 SP1

 

I've attached a copy of the vi in its working state with a single global channel selected and a much simpler digital port output array than I would normally intend to be using.

 

Many thanks

 

 

 

 

0 Kudos
Message 1 of 14
(4,497 Views)

Hi Schwuck,

 

I would like to help you with your problem and I believe I understand what you are trying to do but it would be great if you could clear a couple of things up for me.

 

You say "... I need to trigger a fixed pattern digital port output when the level of one of these analogue channels crosses a pre-determined threshold value and I need to record all 4 of the analogue channels whilst this is happening." What do you mean by 'while this is happening'? Do you mean that you need to view the analogue inputs at all times but only trigger the digital output once a threshold is met or do you mean you only need to monitor the analogue signal and output the digital pattern once an analogue threshold is met?

 

Once I know this I believe I can make some suggestions which may help.

 

Best Regards,

 

Chris

National Instruments - Tech Support
0 Kudos
Message 2 of 14
(4,453 Views)

Hello Chris and thanks for the offer of some help. 

 

Thought that it may help if I gave you some details of the test specification that I am attempting to meet.

 

The system that I'm working on is a pneumatic electronic braking system. I have 4 analogue input channels, each is a separate voltage input from a pressure transducer connected to a different part of the braking system. I have each of these inputs scaled and set up as global virtual channels.

The digital port output is connected to a hardware driver for a system of 4 solenoids. These 4 solenoids control the target pressure for the system.

 

Test spec is as follows:

 

Part 1

'Apply a 7.0 bar supply to the master control port of the system in such a manner as to ensure that the pressure rises from 1.50 bar to 4.50 bar in 100ms.'  

 

Part 2

When the master control port pressure reaches 5.0 bar (approximately 16ms after the 4.5 bar measurement required by that last step, assuming a linear pressure ramp rate) energise all 4 control solenoids (energising these solenoids causes the pressure delivered by the system to drop) and simultaneously measure the pressure recorded by all 4 pressure transducers.

 

Part 3

When the pressure delivered by the system drops to 1 bar de-energise 2 of the control solenoids (this causes the pressure delivered by the system to stop falling) and measure the pressure recorded by all 4 pressure transducers.

 

Part 4

Measure the pressure delivered by the system 50ms after de-energising these two solenoids. 50ms after this measurement (so 100ms after those previous 2 solenoids were de-energised) de-energise the remaining two solenoids for 50ms and then re-energise them. Measure the pressure recorded by all 4 pressure transducers 225ms after the last two solenoids were re-energised.

 

So ideally this is what I want the system to do is:

Record data at 1000Hz from all 4 pressure transducers throughout the duration of the test.

Change the state of the solenoids (digital port output) when one of the 4 pressure transducer outputs crosses a 5 bar threshold (rising edge).

Start outputting a pre-determined solenoid firing sequence when a different one of the pressure transducer outputs crosses a 1 bar threshold (falling edge).

Display a graph of the continuous data recorded from all 4 pressure transducers throughout the duration of the test and perform the necessary post-acquisition processing.

 

Now I don't believe that I can actually achieve this 'ideal' target with labview. So I'm willing to compromise and split this sequence into two separate sections as follows:

 

For parts 1 and 2

Use DAQmx reference trigger (analogue edge) with all 4 global virtual channels wired to the task/channels in and a sample rate of 1000Hz. Name the first of these channels as the source and set the trigger point to 5 bar (rising edge). Set the number of pre-trigger samples to be sufficient so that I capture data that covers the pre-trigger pressure rise from 1.5 to 4.5 bar. Upon achieving the trigger pressure change the state of a digital port output to energise all 4 solenoids, measure the pressure from all 4 global virtual channels and set the number of post trigger samples to be as small as possible.

 

Then for parts 3 and 4.

Use DAQmx reference trigger (analogue edge) with all 4 global virtual channels wired to the task/channels and a sample rate of 1000Hz. Name the second of these channels as the source and set the trigger point to 1 bar (falling edge). Set the number of pre-trigger samples to be as small as possible and still include the second channel crossing the trigger threshold. Upon achieving the trigger pressure start writing a pre-determined pattern sequence to the digital port output (also at 1000Hz). Set the number of post trigger data points for the DAQmx reference trigger function to match the number of data points included in the digital port output pattern.

 

After this display the two graphs of recorded analogue data (and keep my fingers crossed that the system was fast enough to start looking for that 1 bar falling edge trigger before the trigger pressure was achieved) and perform the necessary post acquisition analysis.

 

Still with me?

So after all that - in answer to your original question. I want to start recording a set of 4 analogue inputs prior to any one of them achieving a threshold value, start to output a digital pattern immediately when a specified one of those analogue inputs crosses the threshold value (whilst still recording the analogue input channels) and then continue to record the analogue input channels whilst the digital output pattern is being written.

 

There, I don't know why I didn’t just say that in the first place. Record analogue data continuously whilst outputting a digital pattern that is triggered by one of these analogue inputs crossing a threshold value.

0 Kudos
Message 3 of 14
(4,432 Views)

Hi Schwuck,

 

I think I understand the system now. I'll have a think and get back to you shortly.

 

If you haven't already posted this, it would be useful to know what hardware you a using for acquisition.

 

Cheers,

 

Chris

National Instruments - Tech Support
0 Kudos
Message 4 of 14
(4,429 Views)

Just checked and all you hardware is listed so ignore my last comment.

 

Chris

National Instruments - Tech Support
0 Kudos
Message 5 of 14
(4,428 Views)

Hi Schwuck,

 

After some thought, I believe it may be a better option for you to trigger your digital output based on an analogue start trigger. I'm assuming that you will need to initialise the solenoids so you will need to run one task in parallel with the analogue task (which in this case would just be configured as a continuous analogue input task).

 

After this initialisation you can run a digital task which is triggered by an analogue rising edge. You said you also wanted to change the digital output once an analogue falling edge is seen. This task would be performed next. I have put some code together but I'm unable to test it without your hardware. Please configure it and see what happens.

 

Best Regards,

 

Chris

National Instruments - Tech Support
0 Kudos
Message 6 of 14
(4,423 Views)

Hi Chris and many thanks for trying to help me out. It is very much appreciated.

The analogue task in your code times out at the 'DAQmx Wait Until Done.vi' and so never progresses as far as its while loop.

After sorting out the wiring to the case selector for the digital task, the DAQmx Start Trigger (Analogue Edge).vi in the 'Wait for rising edge' and 'Wait for falling edge' cases both throw up errors. Both show error code -200452 with the text 'Property Node DAQmx Trigger (arg 2) in DAQmx Start Trigger (Analog Edge).vi:2->Pressure Transducers.vi <append> <B>Property: </B>Start.AnlgEdge.Src

<B>Task Name: </B>Digital Port A'.

I am pretty sure that this is caused by the same problem that I was having initially - the analogue input channels that I'm waiting for trigger levels from (AnIn 1 for the 'rising edge' and AnIn 2 for the 'falling edge') which I select as the 'source' for the DAQmx Start Trigger functions in the digital task are not part of the 'task/channels in' to that function (I have Digital Port A wired in there - that is the correct global virtual channel for my digital port output).

If I try to select both AnIn 1 and Digital Port A together as the task/channels in for the digital tasks I don't get anywhere. The digital task then fails at the DAQmx Timing (sample clock).vi with the resulting error code of -201426 with the text 'Property Node DAQmx Timing (arg 1) in DAQmx Timing (Sample Clock).vi:4->Pressure Transducers.vi <append> <B>Device: </B>Dev1 <B>Device: </B>Dev2 <B>Task Name: </B>AnIn1, Digital Port A'. To be fair though I pretty much knew that wiring an analogue input channel along with a digital output channel into the 'task/channels in' of the DAQmx timing function was only ever going to end in tears.

 

 

0 Kudos
Message 7 of 14
(4,416 Views)

Hi Schwuck,

 

Read into this a little further and I think that the code I wrote may work one day, but not with your hardware! My mistake, the 6153 doesn't support analogue triggering.

 

How fast do you need to get the reaction time of the system? It would be fairly easy to set up some software triggering.

 

Regards,

 

Chris

National Instruments - Tech Support
0 Kudos
Message 8 of 14
(4,402 Views)

Hi Chris,

 

I tried performing this with software triggering (see attached) but it was just too slow. I can get the system to look for target pressure values at fast enough rates but for it to then exit out of that loop where it is looking for a trigger, change the state of the solenoids and then start the loop where it is looking for the next trigger takes on average 30 to 40ms with my hardware.

 

Software triggering like this used to be much faster when I was using an PCI-6251 and a PCI-DIO-32HS in my previous system - taking far less than 5ms to transition between steps - but since making the switch to the PXI system it has become unacceptably slow for this application.

 

It's a real shame that I can't just get the DAQmx reference trigger (analogue edge) to work with me naming one of a set of multiple input channels from its 'task/channels in' terminal as its 'source'. The LabVIEW help file for it says that the it should be able to do that with my M-series card. If only I could do this then my first piece of attached code (although not perfect) would near enough do what I want.

 

It's looking more probable to me that I'm going to have to wire up some sort of voltage comparitor to my presure transducer outputs and wire the output from this into PFI0 of my PXI-6251. Maybe triggering with this as the 'source' will work whilst allowing me to capture data from multiple input channels.

0 Kudos
Message 9 of 14
(4,396 Views)

If you can give me the error code produced by your original code I will look for any work arounds recommended internally.

 

Chris

National Instruments - Tech Support
0 Kudos
Message 10 of 14
(4,393 Views)