LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine Data Type Matching Help

Hello everyone,

 

I am a LabView novice and I am trying to create a program that generates, acquires, and graphs a waveform. The program will use DAQmx blocks corresponding to the compact DAQ AI and AO modules.

 

I decided to use a state machine after running into some data type difficulties using producer/consumer loops and some physical channel difficulties when using a simple series structure.

 

My problem is that I cannot wire the case selector to either the AO or AI voltage blocks in separate cases. This doesn't allow me to actually create my wfm generation and aquisition cases so my program is broken.

 

I keep getting the error: "you are trying to connect two terminals with different data types. the type of the source is an unsigned word and the type of the sink is a user defined refnum tag". My AO and AI type is a voltage that I selected from the drop down menu. I do not know how to change these DAQmx data types to something other than "user defined refnum tags". This is the same error that I got when I tried to connect my producer/consumer queues.

 

I am pretty sure that there is a simple solution to this and I would really appreciate some help :).

 

 

 

 

 

0 Kudos
Message 1 of 9
(3,073 Views)
You are going to have to show what the heck you are trying to wire up. The unsigned word sort of makes sense if you are using a refnum to define the cases but I can't think of any DAQ function where you would possibly wire this to and an DAQmx AI or AO function does not have a voltage pulldown.
0 Kudos
Message 2 of 9
(3,065 Views)

Dennis,

 

Here's a little overview about what I'm trying to do:

 

I originally wrote a program that read a sine wave from SignalExpress with the AI module. I didn't have any trouble with this. My supervisor asked me to rewrite it so that the AI was reading and graphing directly from an AO signal generated within the same program. I tried to simply wire them in series and I kept getting errors regarding the use of multiple physical channels.

 

I decided to run a parrallel loop structure instead so they could generate and acquire simultaneously. Yesterday I tried to create the Producer/Consumer loop and I hit the connecting different data types, "user defined refnum tag" error. Today I decided to try a state machine, and I ran into the same error.  

 

I used the simple state machine template for the structure. Following the initialize default state, I tried to create a state called "Generate Wfm" which shows up in red. I tried to connect the data types by wiring from the "beginning state" typedef block, through the shift register, to the case selector and finally to AO voltage "task in" terminal. I never specified a data type for the typedef block so I think the unsigned word is showing up because I can make it a boolean, enum, etc.

 

To clarify, when I said "AO function" I meant the "DAQmx Create virtual channel, AO voltage" block. 

 

 

There is, of course, the possibility that I am doing this completely wrong....this is my first week using LabView.

 

 

Thanks so much for the help and let me know if you need more clarification.

 

 

0 Kudos
Message 3 of 9
(3,050 Views)

What I wanted was an actual VI or at least an image. Connecting the state to the task in makes absolutely no sense and yes, it is completely wrong. You probably don't need to connect anything into the task input of the DAQmx Create Channel.

 

Attaching a VI is pretty simple. You just click the 'Add Attachements'. Attaching an image has just become easier. Click the 'Upload or Insert an image' button.

0 Kudos
Message 4 of 9
(3,046 Views)

Here's my tentative VI. 

 

 

I'm sure there are plenty of mistakes so I apologize in advance haha

 

 

Thanks!

0 Kudos
Message 5 of 9
(3,041 Views)
The states are defined by the enumerated constant.  edit the constant first - then add the state to the case structure.  While you are editing the state constant, do yourself a favor and create a strict dype def control from the constant.  If you do that and replace the block diagram constants with constans of type <created enum type def> you can simply edit the control and "file-apply changes" to update every instance where its used.

"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 9
(3,039 Views)

Here's the VI as an image to make things a little easier.

 

 

 

Thanks!

0 Kudos
Message 7 of 9
(3,033 Views)

You are also mishandling the tasks. You have a single shift register for a task but you actually have two separate tasks - an analog write and an analog read. You would need two shift registers - one for each. You also do not need the Index Array function in the Generate Waveform state. the output of the Waveform buffer Generation is not an array.

 

I'm also unsure what you are actually trying to do. From each of your states, you go to the stop state and that will stop the while loop. You would then have to change the front panel control Next State and rerun the VI. DO NOT use the run continuous button. You should have an idle state where you can choose what to do next.

0 Kudos
Message 8 of 9
(3,027 Views)

Thanks everyone!

 

I'm sort of figuring it all out now. I got the enumerated constant down in my new program and I am currently learning about why all of my case names disappeared haha...

 

Once I started over from scratch, everything became a little easier to understand. The template was good but starting fresh with all of your tips has helped.

 

Conceptually, the data flow makes sense but LabVIEW seems to be a bit more demanding than a lot of other programs I've used. 

 

Good luck 

0 Kudos
Message 9 of 9
(3,002 Views)