graphing a data comming from PIC microcontroller


raggwi

Recommended Posts

I am Ahmed Ragab (Ph.D student) and working for Faculty of Electronic Engineering as assistant lecturer. I employ DaqFactory software package in my research. But I have a problem. I connected the PIC16F877A microcontroller to the DaqFcatory 5.73. Such microcontroller send data to the Daqfactory with the following communication parameters :< 4800, 8, N, 1>. The data are sent as two columns. The first column is the x axis that represents the iteration number while the second column is the y axis that represents the value of temperature. Please send me the procedures that enable me to trace these two columns using 2-D graph and how to accommodate the temperature in a channel in the Daqfactory. I will be appreciated.

Link to comment
Share on other sites

First, you will need to setup a serial device as described in the Serial/Ethernet guide. Basically, go to Quick-Device configuration -> New serial/ethernet device. Create a serial port with your parameters, select the NULL protocol, and give it a name.

Then you can create a sequence to parse the incoming data. I presume that your device sends data continuously without polling? Once you get the device created, open up the Comm monitor to the view the data, then please copy and paste a sample here so I can tell you how to parse the data.

Link to comment
Share on other sites

  • 2 weeks later...

Thank you for your interest,

The data recieved in DaqFactory from the microcontroller are listed below. The microcontroller send the iteration number then the ASCII for space three times then the value of temperature then the ASCII code (013) for carriage return (Enter button). The following are 50 pairs of data (for example) as shown in the monitor.

Rx: 0 29.81413

Rx: 1 29.81413

Rx: 2 28.83613

Rx: 3 29.32513

Rx: 4 28.34713

Rx: 5 28.83613

Rx: 6 28.34713

Rx: 7 29.32513

Rx: 8 29.81413

Rx: 9 29.32513

Rx: 10 29.32513

Rx: 11 29.81413

Rx: 12 29.32513

Rx: 13 29.32513

Rx: 14 28.34713

Rx: 15 29.32513

Rx: 16 28.34713

Rx: 17 28.34713

Rx: 18 27.85913

Rx: 19 29.32513

Rx: 20 28.83613

Rx: 21 29.32513

Rx: 22 29.32513

Rx: 23 28.34713

Rx: 24 29.32513

Rx: 25 28.34713

Rx: 26 29.32513

Rx: 27 28.34713

Rx: 28 29.32513

Rx: 29 29.32513

Rx: 30 28.34713

Rx: 31 28.83613

Rx: 32 29.32513

Rx: 33 28.34713

Rx: 34 28.34713

Rx: 35 29.32513

Rx: 36 28.34713

Rx: 37 29.32513

Rx: 38 29.32513

Rx: 39 29.32513

Rx: 40 28.83613

Rx: 41 29.32513

Rx: 42 29.32513

Rx: 43 28.34713

Rx: 44 29.32513

Rx: 45 29.32513

Rx: 46 28.34713

Rx: 47 28.83613

Rx: 48 29.32513

Rx: 49 28.83613

The data of interest here are the iteration number and the temperature only. Please help me to graph the temperature values(y axis) versus iterations(x axis). I will be appreciated.

Link to comment
Share on other sites

I don't see a carriage return at the end, but maybe it just didn't paste right. Here's the script to get those values:

device.mydevice.purge()
private string datain
while(1)
   try	
	  datain = device.mydevice.readuntil(13)
	  private data = parse(datain,-1," ")
	  data.time = systime()
	  iteration.addvalue(strtodouble(data[0]))
	  temperature.addvalue(strtodouble(data[3]))
	  endif
   catch()
	  delay(0.2)
   endcatch
endwhile

Iteration and temperature need to be Test channels with Timing = 0. Note that I may have miscalced the temperature, it might be [2] or [4]. Once its in the channels correctly you can then graph one vs the other.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.