LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Set start and end value of a graph

Solved!
Go to solution

We are rapidly coming to the point where simply commenting a single instruction out of the context is useless: can you post your code, the UIR and possibly a set of data to examine?



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 11 of 14
(1,539 Views)

I am not allowed to send the code.

 

But principle I have a array with a pattern. Then the visualization comes.

Here I only format the time (x) axis. Instead of 10 ms I get 0,01 s.

 

        log = 0;
        SetCtrlAttribute(panel,Panel_GRAPH_End,ATTR_XAXIS_GAIN,1/(double)SampleRate);
        log = (int)log10(SampleRate);
        SetCtrlAttribute(panel,Panel_GRAPH_End,ATTR_XPRECISION,log);

 

With this line I set the y-axis from -22 V to 22 V

       SetAxisRange (panelHandle, Panel_GRAPH_End, VAL_NO_CHANGE, 0.0, 0.0, VAL_MANUAL, -22, 22);

 

The the next thing is the plotting.

       PlotWaveform (panelHandle, Panel_GRAPH_End, Graph_B, SizelastPeriod, VAL_DOUBLE, 1.0, -10, 0.0, 1, VAL_THIN_STEP,
                          VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);

 

Now the only thing I would like to do is, that my x-axis should be from the value X to the value Y. From the example you gave me there would be this a possivle solution (changed the line before the plotting):

      SetAxisRange (panelHandle, Panel_GRAPH_End, VAL_MANUAL, X, Y, VAL_MANUAL, -22, 22);

 

But that didn't work and I don't know why. I tried also this but it didn't work. Every time I get instead of a sinus a straight line. So there must be a failure.

      SetAxisScalingMode (panelHandle, Panel_GRAPH_End, VAL_BOTTOM_XAXIS, VAL_MANUAL, X,Y);

 

There is something I didn't have in my mind but I do not get the solution. Sorry for that many questions.

 

Best Regards
       

0 Kudos
Message 12 of 14
(1,535 Views)

I'm just guessing and I don't have time to create an example based on my idea, but you may be running into a cross-effect derived from the interaction of setting an axis gain and an absolute range.

You can try modifying your code as follows:

 

1. Exclude setting the X-axis gain

2. PlotWaveform (panelHandle, Panel_GRAPH_End, Graph_B, SizelastPeriod, VAL_DOUBLE, 1.0, -10, 0.0, 1.0/SampleRate, VAL_THIN_STEP, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);

3. SetAxisScalingMode

 

Post here the result of this test.



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 13 of 14
(1,529 Views)
Solution
Accepted by topic author Fasching_K

Thank you for the help. I found a solution.

 

// Sets the y-axis (voltage)

1. SetAxisScalingMode (panelHandle, Panel_GRAPH_End, VAL_LEFT_YAXIS, VAL_MANUAL, -22, 22);

// Plot the signal

2. PlotWaveform (panelHandle, Panel_GRAPH_End, Graph_A, SizelastPeriod, VAL_DOUBLE, 1.0, 10, (double)BeginlastPeriod/SampleRate, 1/(double)SampleRate, VAL_THIN_STEP, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);

 

(double)BeginlastPeriod/SampleRate: Sets the beginning

1/(double)SampleRate: Is the gain -> calculates the end value

 

Best Regards

0 Kudos
Message 14 of 14
(1,525 Views)