Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

CWGraph problem

Solved!
Go to solution

Hi I am trying to use the CWgraph to display Data coming from Serial com port but there is no luck . I was using the mschart1 that comes with VB6 and every thing is working fine , but since they need to acquire 3 hours test , i would prefer to use Measurement studio.

i will attch my code , Hope you can help me guys.

P.S : I am using VB6 with M-studio v 2.1

LV 8.2
0 Kudos
Message 1 of 10
(10,156 Views)

kmous,

 

 What happens when you try and run this code?  I tried running it and just got a flat line, but I don't have anything hooked up to my serial port.  Is that what you see?

Eric B.
National Instruments
0 Kudos
Message 2 of 10
(10,142 Views)

I think I found the trick , but i am going to get back to you ASAP , I am gonna test it at the lab where the hardware is and let you know what;s happening 🙂

Question : is there a way that i can fix the X axes(time) 0 to 60 seconds and then the plot line keeps going from left to right to see the display data for 1 hour at least ? so that i can scroll back to any time i want ? 

LV 8.2
0 Kudos
Message 3 of 10
(10,134 Views)
kmous, To fix the X-Axis and maintain history, you have to change two properties of your CW Graph. First, you can set the axis scale manually in the properties under the Axes tab. Second, you have to change the chart history value to make sure that enough data is being stored. This is on the Graph tab. Change the chart history to Fixed and set a value that is large enough to hold all the data you want to be able to see.
Eric B.
National Instruments
0 Kudos
Message 4 of 10
(10,105 Views)

Hi Eric , Thx for the help 🙂 during my research i found out that i cannot Zoom back out on 2d Graph ? is that right ? I know i can use the Zoomrect xy with undo but is this a good way to do it ?

 

2- it works fine with my hardware , i can get the data i want , but i still get a line at 0 of my array Data once i push Connect it is like it is there by default 😞 , how can i get rid of this ? i dunno why it is diplaying that line !!! my array Data takes the data from .input and calls my Methods !!! so it should display only my data that comes from my hardware , I am sure it is something with the Array Data.

LV 8.2
0 Kudos
Message 5 of 10
(10,099 Views)
Solution
Accepted by topic author kmous

kmous,

 

 Yes, to zoom out on the 2d graph, you want to set the TrackMode to TrackZoomRectXYWithUndo so you can undo the zoom.  That is the best way to essentially zoom out.  For your code, you may want to add a check in your timer code to check for valid data before you plot it so you're not plotting the inital 0s before you get your data.  Maybe set some sort of boolean flag as soon as you receive data that is not 0 (rather than throwing out all 0s so you can still plot 0s later if you get them)

Eric B.
National Instruments
0 Kudos
Message 6 of 10
(10,090 Views)

For the Plotting thing , i made a for loop in the timer to check if  my Data(i) =0 or not , if it is 0 in all array then , i dont display the Data 🙂 works fine.

 

None of the zoom funtions works 😞 , I did enable trackmodeallevents in usercontrol_initialize() whcich is right.

Private Sub UserControl_Initialize()

CWGraph1.Axes(1).SetMinMax 1, 60 ' reset X axis
CWGraph1.Axes(2).SetMinMax -20, 40
 CWGraph1.TrackMode = cwGTrackAllEvents
 Call ShowAvailablePorts

End Sub

 

see attached. 

LV 8.2
0 Kudos
Message 7 of 10
(10,076 Views)
To get the zoom working, I had to set it to cwGTrackZoomRectXY...when I had it set to cwGTrackAllEvents, the zoom did not work.  What happens if you set it to cwGTrackZoomRectXY?
Eric B.
National Instruments
0 Kudos
Message 8 of 10
(10,058 Views)

UMM I had to do that with my programming , it works but it disabled the cursor position one , i ll figure out a way to deal with. (i thought that i could change that on the Graph property page).

 

Is there a way or maybe a mouse event that let me do the following :

I want to include in my excel file where the data is saved a Marker or flag or any thing that can tell me i pressed my mouse at time 40 on my plot.

example , during the test , if i click on a point on my plot , i want my excel file to remenber that i pressed that point at that specific value and time , u know what i mean ?

thank you

 

LV 8.2
0 Kudos
Message 9 of 10
(10,054 Views)
I'm not sure how you would represent that in your file, but you could place some code in your CWGraph1_Click callback to write to the same excel file you are writing to in your timer code.  You have a global reference to that file handle, so you can write to it in that callback as well.
Eric B.
National Instruments
0 Kudos
Message 10 of 10
(10,042 Views)