LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating waveforms from C code

I've written some c code to control  X,Y scanning mirrors (generating output identical to this, but with triangle waves), but I don't know how to go about integrating it into labview or with the DAQ.  This will end up being it's own SubVI, but I dont know if/how you can incrementally run a for loop and spit out single variables per iteration.

 

Can I run the c code within labview to produce an (X,Y) voltage pair to control the mirrors?  

Do I need to save the output to a file and read from the file?  

 

Any tips or links are appreciated.

 

-jm

0 Kudos
Message 1 of 7
(3,283 Views)

You can compile your C code into a DLL and then you can call it from LabVIEW using Call Library Function Node. There's a section in the LabVIEW Help on calling code from text-based languages. There are also examples that ship with LabVIEW. The "Call DLL" example (search for "dll" in the Example Finder) is a convenient shell that allows you to open each example.

 

Are you sure you can't do the same thing your C code does in LabVIEW?

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

I am sure that I can (and in fact this is what I am trying to emulate - except adding a "Triangle wave" in Y to control two stepping mirrors). 

 

For me, this behavior is a lot easier to achieve as a handful of for-loops in C.  For some reason, I have a difficult time making the jump to writing the same functionality in labview.  Even with the above VI in hand, I'm having a hard time seeing where to revise it to acheive my goals.

 

If some kind soul would like to help, it would be greatly appreciated!

0 Kudos
Message 3 of 7
(3,258 Views)
Here's an incremental update, I'm still trying to work out the kink in the middle.
0 Kudos
Message 4 of 7
(3,249 Views)
I removed some of the "reverse row" calls in Y (I wasn't sure what they were doing and it doesn't appear to affect performance), but the 10x offset in the center is still staring me in the face.  It should be simple when I see it.
0 Kudos
Message 5 of 7
(3,247 Views)
I'm not sure if I completely understood, but is the top supposed to be flat? If so, you just need an Increment operator in the second for-loop.
0 Kudos
Message 6 of 7
(3,237 Views)
I believe I've got it now.  There may be more elegant solutions, but the simplest method (which only just now occured to me) was to copy the ascending ramp,reverse it, and concatonate it with the original.
0 Kudos
Message 7 of 7
(3,224 Views)