PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

PCI-6289 Counter ouptut channel not generating pulse when system is restarted

Hi,
I'm having a PCI-6289 board and using this for generating digital counter output (trigger) and Analogue output . My program is working properly until I restart the whole setup (computer + hardware including board). Once the system is restarted, my program is not generating digital counter output but generates Analogue output. I'm using the same reference clock (ctr0) for both Analogue and digital counter.

However when I use the Test Panel of "Measurement & Automation Explorer" for generating digital counter, it is working properly after restart. After using "Measurement & Automation Explorer" (after restart), if I start my program, it is working properly! What could be the reason that my program stops working immediately after restart? Do I need to initialize the board (or power reset etc) before creating the tasks?

Following is the piece of code I'm using for creating digital counter output.

//Create a new NI Task
moCameraTriggerTask = new Task();

//Create a new virtual channel
moCameraTriggerTask.COChannels.CreatePulseChannelTime(szTriggerCounter,
"PulseOutputChan",
COPulseTimeUnits.Seconds,
COPulseIdleState.Low,
mfCameraInitiailTriggerDelay,
(float)(((float)mfCameraTriggerDelay)/1000),
mfCameraTrigHighTime);

moCameraTriggerTask.Triggers.StartTrigger.Type = StartTriggerType.DigitalEdge;
moCameraTriggerTask.Triggers.StartTrigger.DigitalEdge.Source = mszRefClockName;
moCameraTriggerTask.Triggers.StartTrigger.Retriggerable = true;
moCameraTriggerTask.Timing.SamplesPerChannel = 2;
moCameraTriggerTask.Timing.SampleQuantityMode = SampleQuantityMode.FiniteSamples;

moCameraTriggerTask.ExportSignals.ExportHardwareSignal(ExportSignal.CounterOutputEvent, mszCameraOutTerminal);
moCameraTriggerTask.Control(TaskAction.Verify);
moCameraTriggerTask.Start();

Regards,
Kannan
0 Kudos
Message 1 of 9
(4,654 Views)
 

Hi Kannan,

I need a little more clarification on what you're having to do in Measurement and Automation Explorer (MAX) after each reboot to get your program to work.  Did you receive an error when you ran the program after the restart?  Could you describe your application a little bit more? You shouldn't have any problems creating a task after you reboot your computer assuming your creating the task properly.  From your code, I only see you creating an counter channel task.  Are you creating an analog output task? 

In addition, have you tried using our shipping examples after a reboot to verify if they were able to work? I'm assuming you're using Visual C# .NET, however, please correct me if I'm wrong.  The location of the .NET shipping examples can be found using the following website found here.  Take a look at the images and they should help you find the exact location of your .NET examples.  I would recommend starting from the examples and making sure they work.  Also, there is a great article regarding using DAQmx in text based programming environments found here

I hope this helps,
Paul C.

Message Edited by Paul C. on 09-11-2007 05:41 PM

0 Kudos
Message 2 of 9
(4,639 Views)

Hi Paul,

Thanks for your prompt reply. Here are the details,

I'm not receiving any error/exceptions from NI libraries when I run the program after restart, also there is no trigger signal generated. I'm using this trigger for capturing image from high speed digital camera (in hardware trigger mode). I'm also generating Analogue output which is used as imput for running another device. Both CO channel and Analogue channel uses same reference clock. After restart, when I run the program, I'm getting only Analogue output but not trigger (from CO Channel).

I tested the example programs, they are working fine. The difference I can make out from the example and mine is the pulse width and frequency. In my program, the reference clock frequency is 100 Hz, Trigger pulse low time is 4 milliseconds and pulse high time is 2 microseconds.  It means at every cycle, after the delay of 4 milliseconds, the camera needs to be triggered. Also I tried changing pulse high time to 1 millisecond but no effect!

Other difference is, examples (GenDigPulseTrain_Continuous/ GenDigPulseTrain_DigStart) use "CO.CreatePulseChannelFrequency()" call but in my program I'm using "CO.CreatePulseChannelTime()".

 I have gone through the article you mentioned in the reply and my approach too follows the same approach. Still I'm not able to identify the problem. This occurs only when the system (hardware + computer) is restarted otherwise it is working well.

Regards,

Kannan

 

0 Kudos
Message 3 of 9
(4,628 Views)
Hi Kannan,

I'm still a little confused on what you are doing withing Measurement and Automation Explorer (MAX) that makes your program work after a reboot.  If you could clarify this, it would be very helpful.  I also wanted to mention that that the GenDigPulseTrainContinuous_DigStart C# .Net example waits for a digital start trigger on a specified source before it starts gettinging the pulse train.  Are you sure that the you're sending this trigger to start the pulse train?  If you just want the counter to start generating the pulses immediately without a start trigger, I would recommend using the GenDigPulseTrain_Continuous C# example and modifying the following lines of code.

Replace this:
myTask.COChannels.CreatePulseChannelFrequency(counterComboBox.Text,
                   "ContinuousPulseTrain", COPulseFrequencyUnits.Hertz, idleState, 0.0,
                   Convert.ToDouble(frequencyTextBox.Text),
                   Convert.ToDouble(dutyCycleTextBox.Text));

With this (include the timing parameters you want.  I just used .02 Low Time and .04 High time):
myTask.COChannels.CreatePulseChannelTime(counterComboBox.Text, "ContinuousPulseTrain", COPulseTimeUnits.Seconds, COPulseIdleState.Low, 0, .02, .04);

This should work fine.  I think what is happening is that your never receiving the digital start trigger.

I hope this helps,
Paul C.
0 Kudos
Message 4 of 9
(4,603 Views)

Hi Paul,

I'm not doing anything really with MAX, just I use it for verifying the board is working or not! When the trigger is not getting generated through program, I used to verify through MAX.  

As you said, I have tried modifying the GenDigPulseTrain_Continuous  sample (please refer attachment) but it is not working (after restart) and there is no error! I'm creating reference clock  on /ctr0 and this reference clock is the source for my trigger channel /ctr1. Please refer the attachment.

Regards,

Kannan

 

0 Kudos
Message 5 of 9
(4,590 Views)
Hi Kannan,

Thank you for posting your code.  I was able to take a look and find out the reason the code isn't working.  The reason is because our M-series require the use of both counters for finite pulse train generation.  In your code, the first task you set up takes the use of counter 0.  When you set up the second task to do a finite pulse generation, it can't because the second counter it requires is already used by the first task (moRefClockTask).  If you would like, you can generate a continuous pulse train (which only requires one counter) and you're code should work fine.  If you would like more explanation for why you require two counters for finite pulse train generation it can be found here.

I hope this helps,
Paul C.
0 Kudos
Message 6 of 9
(4,532 Views)

Hi Paul,

Thanks for locating the problem. But this raises another design question. How can I synchronize both Camera trigger task and Analogue output channel (recall my previous mails)? In the current code, I'm using the reference clock (moRefClockTask) for synchronizing both of them. I need to send analogue output voltage and trigger pulse at the same time.

 

Regards,

Kannan  

0 Kudos
Message 7 of 9
(4,517 Views)
Hi Kannan,

Hopefully, I am understanding the application you're trying to accomplish.  Please tell me if I state something that is incorrect.  You're trying to generate analog output at the same time you send a digital trigger to start your camera.  You're also using your one of your counters to create a reference clock for synchronization.  You could just use the internal timebase to divide down to 100Hz and use that as your sample clock.  Regardless, I have few ideas that might work for you.

My first suggestion, the simplest to implement, would be to use one analog output task that exports a digital start trigger for your camera.   This can all be accomplished with just one analog output task.  You do this by using the DAQmx export signal function (DAQmxExportSignalStartTrigger)to export a digital start trigger to one of your PFI lines.  This trigger will be sent at the same time your analog output task starts.  From your code, I can see that you had a small high pulse of 200 microseconds long.  The digital start trigger will be a little longer, but if your just triggering off the rising edge, this should still work.

My second suggestion would be to still use both counters to generate the finite pulse train as a digital trigger for the camera.  I would use the internal timebase as the sample clock for both the counter and the analog output task to keep them synchronized.  Additionally, you will need to start both of the tasks at the same time.  This can be achieved by exporting the same digital start trigger (as I mentioned above with the DAQmx export signal function) to a PFI line to be used as the arm start trigger of the counter.

Please let me know if I'm not understanding your application or these solutions won't work for you.

Thanks,
Paul C.
0 Kudos
Message 8 of 9
(4,487 Views)

Hi Paul,

Your understood my objective well. I have chosen your first suggestion and verified with a scope. It is working fine (in test environment).  It may take about week to deploy in the target environment. It could have turned out to be tough if I did not get your suggestion in time, thanks a lot.

Regards,

Kannan

0 Kudos
Message 9 of 9
(4,450 Views)