LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie question NON-FATAL RUN-TIME ERROR IN TUTORIAL (PlotY)

I'm a first time user, following the tutorial and when when I click on Acquire I get the following error "NON-FATAL RUN-TIME ERROR:   "sample1.c", line 85, col 13, thread id 0x00000D54:   Library function error (return value == -10 [0xfffffff6]). The control is not the type expected by the function"

 

Code is as follows (line 85 is PlotY......:

 

    case EVENT_COMMIT:                                                                                                       
        srand (time(NULL));                                                                                                  
        amp = rand ()/32767.0;                                                                                               
        SinePattern (100, amp, 180.0, 2.0, sine);                                                                            
        PlotY (panelHandle, PANEL_Waveform, sine, 100, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);  
        break;    

 

 

                                                                                                       

Its not obvious why it crashes on this line, any help would be appreciated.

 

Thanks

 

Jeff

0 Kudos
Message 1 of 5
(5,007 Views)

This kind of error usually is caused by an incorrect panel handle: the program is complaining that you are trying to plot a waveform on a control that is not a graph. A control is identified by the handle of the panel it is located and by the control ID (in verbose fashion, the function is "plot a wavefom on control  number X on panel number Y", where X is the control ID and Y is the panel handle).

 

What you may try to do is to place a breakpoint when you load the panel and see the panel handle, next place a breakpoint on PlotY line and verify that it is the same.

Also, that 'PANEL_Waveform' puzzles me: the standard for CVI is to generate control names in uppercase font: have you created it on your own? Are you sure it is the correct type of control?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 5
(5,003 Views)

Hmmm...

 

The tutorial contradicts itself:

 

Here it indicates "Waveform"

 

To customize the graph attributes, double-click GRAPH in the User Interface Browser and then enter the following values in the Attribute Browser:
a. Use the Find text box to locate the Constant Name attribute. If you prefer, use the Filter text box accessible by toggling the Find label.
Enter Waveform as the Constant Name.

 

But later it states to select "PANEL_WAVEFORM"

 

4. For the Control ID control, you must specify the constant name assigned to the graph
control. While the cursor is in Control ID, press <Enter> to open a dialog box with a
complete list of the constant names in the.uir files in the workspace. In the User
Interface Resource files section, select \sample1.uir. Select PANEL_WAVEFORM
from the list of constants and click OK.

 

So I changed Waveform to WAVEFORM and no change

 

I added a breakpoint when the panel is created and it has a value of 1 for both panel and panelHandle, later when the acquire button is pressed in the AcquireData function the value is still 1 for both panel and panelHandle

0 Kudos
Message 3 of 5
(4,988 Views)

I figured it out..... I had selected a strip chart instead of a graph.

 

Thanks

0 Kudos
Message 4 of 5
(4,979 Views)

Happy to hear that you have solved your problem. Smiley Happy

 

Just to be clear, there is no problem in using lowercase letters for control ID, but since the usual CVI behaviour is to use uppercase letters I was wondering if you created the control by yourself and if it could be a wrong one.

 

CVI does not really address controls by name: if you see in the include file associated to the UIR you'll see that PANEL_CONTROL is really a macro with an associated value, which is the one the program really uses (see my first post to understand how PlotY operates; the same happens for all functions that operate on control like Get/SetCtrlVal or GetSetCtrlAttribute for example).

Neither CVI operates any cross check between the panel handle and the control you are addressing: that's why I pointed you to the panel handle value, to be sure that you are not operating on a control using the handle of a different panel, a situation that may happen if you are using more than one panel at a time.

 

These are the reasons that may rise an 'incorrect control type' error.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 5
(4,974 Views)