Dynamic Graphing

Thread Starter

twentyfour

Joined Feb 21, 2012
7
Hi,
I was wondering if anyone here could help me implement a real time line graph into a motor control project that I am working on.

The project is controlling the speed of a DC motor, I would like to graph the Set point vs time and output vs time on a computer. I currently have a live feed of said information to a VB form that can hold it in a text box or write it to a file on a computer. My data scheme follows

$,SSSS,OOOO,\n, which then repeats its self.

The first char is the header the commas are used as delimiters SSSS refers to a 10 bit number of the set point and OOOO is the same but for the output. For example if the a/d conversion of the set point was 1001 in decimal and the output was 988
$,1001,0998,\n,

The line feed is so that I can bring it into excel and graph the information. My issue there is that its time consuming. They do have this data update feature but the fastest refresh rate I can find is once/min.

I was wondering if there is anyone who has used Octave or some other program to rip through a text file and graph its contents. I have tried VB and got it to work but I'm not very efficient at coding in VB so what I came up with is too slow to be of any use to me.

All the information is ASCII so that excel picks it up; I have to convert it all back to decimal to manipulate it so it seems. I can modify how the information is sent also, its just dependent on my PIC.

I can also attach my vb code if someone is willing to take a look at how I convert this and try to graph it.

Oh and one last important thing I just thought of... the PID function operates every 4 milliseconds which how frequently the above msg shows up to the computer.

Cheers!
 

tshuck

Joined Oct 18, 2012
3,534
I can't attest for other programs to do your dirty work;), but I can suggest what you could do on your PC side scripts...

Personally, I use C#, but the .NET Framework works for either and makes this all a little easier...

You could have a thread waiting on input data from the PIC(i.e. serialPort1.OnReceive) which will populate an array(shouldn't need to be too big if, indeed, you end up needing an array...) Another thread works on parsing the data and storing it into another array which another thread will access and plot the data from.

You can design this system to simply drop frames if you don't have time to draw it(4ms).

If you find that your PC code is not able to process the information in a short enough time frame, remember, look-up tables are your friends.:)
 
Top