Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Reprogram trigger pulse width during acquisition

I am programming a vision application using 1409 board and a Jai camera in external trigger, pulse width mode. This enables setting the camera exposure time by programming the trigger pulse width. Based on one of the examples I found in the knowledge base I came to the following code:

mImaq.Images.RemoveAll
mImaq.Images.Add NUM_BUFFER

mImaq.Signals.Add.Name = "TRIG_IN"
mImaq.Signals.Add.Name = "TRIG_OUT"
mImaq.Pulses.Add.Name = "CamTrig"

ExposeTime = txtExpTimeMs.Text / 1000#
delay = 1# / txtFPS.Text - ExposeTime
''Debug.Print delay, ExposeTime
mImaq.Pulses("CamTrig").Initialize delay, ExposeTime, cwimaqTrain, cwimaqActiveLow, cwimaqImmediate
mImaq.Signals("TRIG_OUT").I
nitialize cwimaqExternal, cwimaqGeneratePulse, cwimaqActiveLow, 3
Set mImaq.Signals("TRIG_OUT").Pulse = mImaq.Pulses("CamTrig")
mImaq.Signals("TRIG_IN").Initialize cwimaqExternal, cwimaqCaptureEveryImage, cwimaqActiveLow, 1
mImaq.AcquisitionType = cwimaqAcquisitionContinuous
mImaq.Start

This code works fine. I know would like to change the exposure time (i.e. reprogram the pulsewidth) without interrupting the acquisition, so I tried the following:

ExposeTime = txtExpTimeMs.Text / 1000#
delay = 1# / txtFPS.Text - ExposeTime
mImaq.Pulses("CamTrig").delay = delay
mImaq.Pulses("CamTrig").width = ExposeTime
mImaq.Start

Now why does this not work? I do not get any errors, yet the pulsewidth does not change.
0 Kudos
Message 1 of 5
(3,412 Views)
Here's an educated guess:

You are setting up the pulse parameters, but they aren't getting sent to the camera. I am guessing the line "Set mImaq.Signals("TRIG_OUT")..." actually outputs whatever settings you have in Pulses. I would add that line to your code for changing the pulse width.

I'm not sure if you would need to have the line mImaq.Start, because the acquisition is already started. That could confuse the system. I would try it with and without that line.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 5
(3,412 Views)
Thanks for the tip Bruce.
Unfortunately, it does not help. With or without the Imaq.Start line.
0 Kudos
Message 3 of 5
(3,412 Views)
Hi,

The NI-IMAQ driver will not let you change and update the pulse parameters on the fly. It's possible with a counter card, like the 6602, but not with the NI-IMAQ driver. We will try to find a workaround for you. The workaround would not stop the acquisition but stop the pulse generation, reconfigure it, and then restart it relatively quick. I'll get back to you on this as soon as we get it to work.

Regards.

Joris Vanderschrick
Applications Engineer
NI Belgium
0 Kudos
Message 4 of 5
(3,412 Views)
Hi,

The solution is just to stop the pulse generation and retrigger it with another pulsewidth.
NI only writes software for customers in exceptional cases. The States advised us to wait until a next release of the ni-imaq driver that will enable you to change the pulse-width on-the-fly.

Regards.

Joris Vanderschrick
Team Leader Application Engineering
NI Belgium
0 Kudos
Message 5 of 5
(3,412 Views)