Formatting Picaxe Data Output into XML

slimplynth

Senior Member
Someone might find this useful...

Because (tbh) i'm no good with VB.net yet.

I've been outputting sertxd data, collected from my RF data logger as XML to use with HTML or Excel.

Code:
init:
symbol ok_led = 0
pause 10000 	

sertxd(60,"xml_dl",62,13,10)

main:

for w0=1 to 365
	for b2=0 to 23
		for b3 = 0 to 59
			for b4 = 0 to 5
			high ok_led
			b5=b4*10
			w4=w4+1
			
			pause 9120   'wait ten seconds
	        	serin 2,N2400,("data"),b6
	        	low ok_led 
	        	let b6=b6-3   
	        	
                                      sertxd(60,"num",62,#w4,13,10)
			sertxd(60,"time",62,#b2,":",#b3,":",#b5,60,47,"time",62,13,10)
			sertxd(60,"day",62,#w0,60,47,"day",62,13,10)
			sertxd(60,"temp",62,#b6,60,47,"temp",62,13,10)
			sertxd(60,47,"num",62)
			sertxd(13,10,13,10)
			
			next b4
		next b3
	next b2
next w0

goto main
suppose there could be a push switch command to terminate the program with an </xml_dl> tag. (NB im well aware how shoddy my clock is, it's ignored later as i only use it really to slow down the program... i plan to replace this with the digital IC clock when i get my birthday order with rev-ed completed... like many others i want the 20X2 though :()

I open the picaxe terminal screen and copy the input buffer and paste into a txt file, goto the end and insert the </xml_dl> tag. Then save the txt file as overnight_data.xml.. as thats what it's called in the HTML below.

Code:
<xml_dl>

example data output from terminal

<num>1
<time>0:18:20</time>
<day>1</day>
<temp>20</temp>
</num>

<num>2
<time>0:18:30</time>
<day>1</day>
<temp>20</temp>
</num>
Code:
<html>
<head>

</head>


<body>

<script type="text/javascript">
var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null) 
{
xmlDoc.async=false;
xmlDoc.load("overnight_data.xml");
var x=xmlDoc.getElementsByTagName("num");

document.write("<table border='1'>");
document.write("<thead>");
document.write("<tr><th>Reading</th><th>temp</th></tr>");
document.write("</thead>");

for (var i=0;i<x.length;i++)
     
{ 
var w=i+1
document.write("<tr>");
document.write("<td>");
document.write([w]);
document.write("</td>");

document.write("<td>");
document.write(x[i].getElementsByTagName("temp")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");

}

document.write("</table>");
}
</script>

</body>
</html>
clickin on the saved html file above should give a nice table of results, if the xml data file is too long then explorer will moan about how long it's going to take.:rolleyes:

either that or just use excel to open the xml file directly.
 

westaust55

Moderator
Like you, I am rather green *newbie status) in terms of getting data from a PICAXE into say an Excel file.
Something I will need to read up on soon.
In the meantime your information could prove useful.
 

slimplynth

Senior Member
Not sure what the maximum size of the PE terminal input buffer is but for lots of data over longer periods of time I use the Eltima RS232 data logger, which saves to a text file automatically.
 

MFB

Senior Member
Try SelmaDAQ

I have found SelmaDAQ very good for exporting logged data into Excel, over an RS-232 link. This VB macro can be download free from www.selmaware.com.

There is a good PICAXE example by Mike Bessant in the January issue of Nuts & Volts magazine, but you have to pay to download that.
 

slimplynth

Senior Member
I had SelmaDaq on my old tower but i've not used it in ages, how many columns does it let you have for different variables?

I also wanted the data to be displayed in a webpage.
 

MFB

Senior Member
Its probably best to read the latest SelmaDAQ documentation to find that information but I can't remember it being a practicle limitation.
 
Top