From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adjustable phase offset with two counter outputs

Solved!
Go to solution

Hi there,

In this experimental setup, I have a piezoelectric inkjet printhead controlled by a TTL pulse train to deliver uniform droplets onto a surface. I am using the "time" version of the counter output vi (High-time/Low-time) because it allows me to change the characteristics of the droplets very easily. I use a stroboscopic approach for imaging the droplets as they are ejected. Basically, an LED strobe light is pulsed at a frequency that exactly matches that of the inkjet printhead. A CCD camera is used to image the droplets, which look "frozen" on the screen because of the strobing effect. The LED strobe light is triggered by another TTL pulse train (both pulse trains come from counter outputs on my USB-6353 X-series DAQ board).

 

Of course, I could trigger both the inkjet printhead and the strobe light with the same counter output, which would ensure that their frequencies are matched. But it is really nice to have a "strobe delay" that allows for adjustment of the phase offset between strobe and printhead triggers. The hardware that came with the printhead has this strobe delay feature as an external knob. It is useful because one can essentially march through time by turning the knob and visualize the droplet formation as it exits the tip of the nozzle.

 

I have a vi that can trigger both the printhead and the strobe, but I cannot figure out how to adjust a phase offset between the two in while the program is running. It should be possible, but I just can't get it. I would really appreciate any help with this. Attached is the preliminary code, along with a diagram that may help explain what I would like to do

 

Many thanks,

-Matt

Download All
0 Kudos
Message 1 of 7
(2,894 Views)

Thoughts:

 

1... Have you tried the INITIAL DELAY parameter?  That sets the delay for the first pulse, but since both counters are adjusted simultaneously they should stay synched.  If you set the INITIAL DELAY to 0.005, wouldn't one counter lag the other by 5 mSec?

(Not sure of that, haven't looked in detail at the config you're using).

 

2... The IS TASK DONE call is completely useless; since you're generating CONTINUOUS SAMPLES, the task will never be done until you STOP it.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 7
(2,870 Views)

Thanks Steve,

You are correct, the INITIAL DELAY parameter does cause one counter to lag by the other. However, I would like to modify this parameter on-the-fly while the code is running. I attempted to use a CO.Pulse.Freq.InitialDelay property node inside a while loop to adjust the Initial Delay, but I got an error stating that this specified property cannot be set while the task is running.

 

Thanks,

-Matt

0 Kudos
Message 3 of 7
(2,851 Views)

I was afraid that you would need to modify it on the fly, so my idea won't work.

 

Sounds like you'll have to do some bookkeeping on your own.

If you add 5 mSec to ONE cycle of ONE counter, then you will delay it from then on.

If you need to change it to 6 mSec, you add 1 mSec (6 - 5) to ONE cycle of ONE counter.

If you need to change it to 4 mSec, you add -2 msec (4 - 6) to ONE cycle of ONE counter.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 7
(2,847 Views)

I follow you, but it is unclear to me how to implement that. Should I stop the task, clear it, then restart it by creating a new channel with an updated INITIAL DELAY?

 

Thanks for your time and help.

0 Kudos
Message 5 of 7
(2,843 Views)
Solution
Accepted by topic author mes291

No - forget the INITIAL DELAY.  That is only for the INITIAL (first) pulse.

 

You're already adjusting the high-time / low-time already, right?

 

So, have a new control called PHASE OFFSET, starting at zero.

 

Have a variable called CURRENT PHASE OFFSET , starting at zero.

 

When the PHASE OFFSET is changed (by the user), figure the difference between where he wants to be and where you are (Control - CURRENT PHASE OFFSET), and add that much time to the LOW TIME, but only for one cycle.  Basically you're stretching one cycle.  Store the new value in the CURRENT PHASE OFFSET variable for next time.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 6 of 7
(2,838 Views)

You're the man Steve! Attached is an updated version of the vi. It works perfectly for this application. Thank you very much for your help with this.

 

-Matt

0 Kudos
Message 7 of 7
(2,830 Views)