Jump to content

Generate my own input signal for a device


Recommended Posts

Hello,

for an experiment I need to send to a device a low frequency square signal.

I want to generate my own input signal for this device.

In fact I would like to be able to set the high level delay and low level delay.

I don't think the "simulate signal express" can fit to my needs.

I believe that I should use a sequence inside an infinite loop while.

The first sequence

set output to 0 (a numeric float constant)

The second sequence

wait x seconds

The third sequence

set output to 100 (a numeric float constant)

and so one

But I don't know if it's a good way to do like this...

Any idea ?

I also encountered a problem when I try to send the 2 constants (0 and 100) to a display.

I don't know what I should do. Maybe I should use a global variable but I never use it with Labview

I hope you can help me

Best regards

PS: I also would like to generate my own low frequency sawtooth signal (rising phase delay is about 60s)

Link to comment

Thanks for your reply.

I can't use this. Because I want to set my own high delay / low delay

For example

t=0 to 10s out=100

t=10s to 15s out=10

t=15s to 20 aout=90

and so one...

I have make this using a sequence with several step in which I modify a local variable.

Some steps also contains a timer object

All this is inside a loop while loop

Link to comment

QUOTE (scls19fr @ Apr 7 2008, 07:10 AM)

I have make this using a sequence with several step in which I modify a local variable.

Some steps also contains a timer object

All this is inside a loop while loop

I'm confused. It seems that your design (while loops, local variable, sequences) cannot be changed, somehow...? :unsure: I don't see why you would want to go through the hassle of creating your own timing functions when LabVIEW has all sorts of internal waveform generation VIs ready to go.

Can you tell us to what purpose you are trying to build this code? This may shed some more light on the subject.

Link to comment

See more informations in this post

http://forums.lavag.org/Break-abort-a-long...nce-t10544.html

I wonder if I shouldn't use something like this VI

Express / Input / Simulate arbitrary signal

(not sure of the translation because in french it's

Express / Entrée / Simuler un signal arbitraire)

Have a look at the same VI Express inside a loop while with a 100ms delay for displaying.

I wonder was X unit is (ms ? s ? iteration ?).

I want a signal

0 to 1s : 0

1s to 1.5s : 20

1.5s to 2s : 100

2s to 3s : 20

After this delay (3s) I would like to be able to modify mysef the value... using a slider... but that's not the problem for now !

Link to comment

QUOTE (scls19fr @ Apr 8 2008, 02:25 AM)

Yes, that translation was correct (Simulate Arbitrary Signal). I've modified your example so perhaps you can see a little more clearly what is happening.

http://lavag.org/old_files/post-3266-1207691811.vi'>Download File:post-3266-1207691811.vi

In the express VI, there are options of either 1) outputting one point per iteration or 2) the entire signal on each iteration. If you are planning on using this in a loop, select the "one point per iteration" selection. You had the "entire signal on each iteration" selected, so it was just outputting the whole sequence of points on each loop to the graph.

Think of this express VI as a "Y value generator", in that it produces a bunch of Y values based on the data points you define inside the express VI.

In the VI you posted, you had selected points that were 1000 "X values" apart for each second in time based on your desired test criteria (1k,1.5k,2k,3k). This is fine, however selecting 30m (or 30 milli-units) as your dX created (1000/0.03) = 33,333.333_ Y values for every second of data. That is why you had 100,000 points coming out of this express VI. To cycle through them in real time, you would have had to have a loop running at a period of (3 second/100,000 points) = 30us per loop, or 33.3kHz. A bit overkill for 4 state changes ;)

In the above, I've changed the express VI to use the "one point per iteration" mode, and selected data points that were 1 unit away from each other for each second of test data. Then using a dX of 10m gave a total output points of (1/0.01) = 100 points (or 300 points in the 3 second total). Matching the dX by putting a 10ms wait in the For Loop hopefully produced the effect you were after.

I also showed how you can use the "Data Valid" output from the express VI to signal when it is done cycling through the points.

Hope this helps!

Link to comment

Thanks for modifying my VI.

But I don't like something...

10ms need to be set in to part of the vi (inside the loop Wait until Next 10ms multiple)

and in the VI Express / Input / Simulate arbitrary signal

I will try now to modify it in order to be able of manually modify output using a slider when the autostart sequence is over

Best regards

Sebastien

Link to comment

I modified the VI as said it before.

See

Download File:post-11213-1207748140.vi

Download File:post-11213-1207748151.vi

Download File:post-11213-1207748202.vi

When I click on Autostart I get the good signal and I can stop it before

the startup sequence is finished !

So it's much better than my solution with sequence (as I can't break a sequence !)

But I have some problems.

If I click on Autostart and I wait for the end of the startup sequence.

The state return of manual (that's good !) I can modify manualy the throttle using

the slider (that's good too !) BUT

If I click on Stop and click on Autostart, the startup sequence doesn't restart ;-(

I guess the problem is about initializing the VI Express / Input / Simulate arbitrary signal

But I can't initialize it because I such a case there is a loop problem and I can't compile.

An other (same) problem is with predefined sequences such as PROG Step/Square

I can only run it once.

A third problem I about generating a "loop" signal (infinite) when the button loop is pressed.

Hopping you can help me.

Best regard

Sebastien

Link to comment

QUOTE (scls19fr @ Apr 9 2008, 03:48 AM)

Thanks for modifying my VI.

But I don't like something...

10ms need to be set in to part of the vi (inside the loop Wait until Next 10ms multiple)

and in the VI Express / Input / Simulate arbitrary signal

I didn't like the disconnect between the wait/dX either (I would have thought that the dX input would be available on the outside of the Express VI as a terminal so you could synchronize the two easily).

The neat thing about Express VI's though is that you can right-click them and select "Open Front Panel". By accepting the conversion, you now have a subVI that you can dive into and see how it works (even pull code out of to create a template for another VI). Doing this, I'm sure that you could figure out how to wire in the dX instead of having it set inside a "magic blue box". :D

Good Luck!

Link to comment

QUOTE (scls19fr @ Apr 9 2008, 07:48 AM)

Actually, to have this express VI start over when you run out of points, simply change the settings in your express VIs to:

http://lavag.org/old_files/monthly_04_2008/post-3266-1207760436.png' target="_blank">post-3266-1207760436.png?width=400

As far as the rest of the code goes, I have some standard suggestions:

- use globals/local variables sparingly to avoid race conditions in the future

- become familiar with how event structures work, since this application is very "user intensive" and relies on events happening on the front panel

- avoid "stretching" the code. If you can't see everything with minimal (or ideally no) scrolling, then it's time to rethink the design. For instance, this app to me is divided into three major parts: front panel events, triggers, and handlers. For this reason...

- Research the design pattern templates and examples that NI has installed for you, especially (for this case) the producer/consumer loop with events. This design pattern fits into a great number of application designs and has become the weapon of choice for me when re-using code that provides a user interface.

Link to comment

Thanks for the "restart"... I was trying using a different way (using pin in Reinitialisation)

You said me to CITATION

use globals/local variables sparingly

I agree with you I know it's not a clean way but throttle is only read in the other loop...

So I don't think it's so bad ;-)

You also said me to become familiar with how event structures work,

CITATION

avoid "stretching" the code. If you can't see everything with minimal (or ideally no) scrolling, then it's time to rethink the design. For instance, this app to me is divided into three major parts: front panel events, triggers, and handlers. For this reason...

Sorry but I don't understand what you mean (don't forget... I'm french ;-) )

CITATION

- Research the design pattern templates and examples that NI has installed for you, especially (for this case) the producer/consumer loop with events. This design pattern fits into a great number of application designs and has become the weapon of choice for me when re-using code that provides a user interface.

I would like to find a sample... because the NI sample are nearly empty.... so it doesn't help me very much !

I still have a problem with restart !

If I click on Autostart and on Stop before the end of the startup sequence. It works fine.

But when I click again on Autostart the Autostart sequence doesn't start from the beginning

Download File:post-11213-1207769988.vi

Link to comment

QUOTE (scls19fr @ Apr 9 2008, 12:38 PM)

it's not so bad...yet. ;)

QUOTE (scls19fr @ Apr 9 2008, 12:38 PM)

Sorry but I don't understand what you mean (don't forget... I'm french ;-) )

Sorry ;) Okay, I was trying to say, "your code is too big". A well designed application should be able to be seen on one monitor screen, without the need to scroll. Solutions include using state machines in place of sequences, using event structures for button change detection, and sometimes just shortening up the wires.

QUOTE (scls19fr @ Apr 9 2008, 12:38 PM)

I do not know the translated menus, but in english there are a bunch of design templates at: File->New..., then it's listed under VI/From Template/Frameworks

QUOTE (scls19fr @ Apr 9 2008, 12:38 PM)

I still have a problem with restart !

Using another shift register to hold a boolean value for resetting the signals should do the trick.

Download File:post-3266-1207777098.vi

Link to comment

Thanks I will try the idea of shift register with boolean.

I must admit that the use of shift register is not yet very intuitive to me!

About the size of code : I agree with you : it need a good cleanup !

I will use event stucture for managing keys (input keys (START STOP PROG STOP/PROG)

http://svn.berlios.de/viewcvs/openphysic/l...es/trunk/input/

test_input.vi

I will also do it in the other vi

http://svn.berlios.de/viewcvs/openphysic/l...turbines/trunk/

main.vi

for managing keys DATA UP / DATA DOWN / MENU UP / MENU DOWN

these keys sends string to the ECU using serial COM. So I will probably need something

like a queue if I click to many times on a button.

What is your opinion about it ?

Best regards

Sébastien

Link to comment

QUOTE (scls19fr @ Apr 10 2008, 12:31 AM)

What is your opinion about it ?

It sounds like you are heading in the right direction. Take a real close look at the Producer/Consumer with events template I mentioned. It will fit nicely with what you are describing.

Link to comment

I change the vi to use the event structure

It's now much cleaner !!!

Download File:post-11213-1207848111.vi

I still have a problem with initializing the Express VI / Input / Simulate arbitrary signal

The problem happens when I click on Autostart and click on Stop before the end of the Autostart sequence

A similar problem happens with "programmed" signals

The VI Express need to be initialize when

-I click on STOP TURBO

-I click on STOP PROG / MANUAL

About the producer / consummer

I found very informative applications notes on NI site

http://zone.ni.com/devzone/cda/tut/p/id/3023

http://www.ni.com/labview/f/power.htm

I also found a video (in french !) about it

https://lumen.ni.com/nicif/f/webcastlvprogm...7/content.xhtml

Link to comment

QUOTE (scls19fr @ Apr 10 2008, 10:29 AM)

Yes, better!

QUOTE (scls19fr @ Apr 10 2008, 10:29 AM)

I still have a problem with initializing the Express VI / Input / Simulate arbitrary signal

The problem happens when I click on Autostart and click on Stop before the end of the Autostart sequence

A similar problem happens with "programmed" signals

The VI Express need to be initialize when

-I click on STOP TURBO

-I click on STOP PROG / MANUAL

You just need to wire a TRUE boolean to the "Reset" input of the express VIs when you want them to be initialized. Now that you are using events, this should be as easy as wiring a TRUE boolean out of the "start prog" and "autostart" events (I would initialize them on START, not STOP).

Link to comment

CITATION(orko @ Apr 10 2008, 07:43 PM)

Yes, better!

You just need to wire a TRUE boolean to the "Reset" input of the express VIs when you want them to be initialized. Now that you are using events, this should be as easy as wiring a TRUE boolean out of the "start prog" and "autostart" events (I would initialize them on START, not STOP).

All right it works fine now !

I don't know why I didn't make this myself ;-)

Thanks again

I will probably make an other post about the use of events (for the other part of my VI where I send string to the

ECU using serial COM when I click on keys DATA UP / DATA DOWN / MENU UP / MENU DOWN)

because I know that the code inside the event structure must be very short... so I guess that I shouldn't put READ VISA

inside !

Best regards

Sebastien

Link to comment

QUOTE (scls19fr @ Apr 10 2008, 11:44 AM)

I know that the code inside the event structure must be very short... so I guess that I shouldn't put READ VISA

inside !

That is when queues are useful. Enqueuing an item in an event strucure is very fast, and another loop can dequeue the item and take all the time it needs to complete the task (producer/consumer).

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.