Vmusic2 - wrf to text file

adumas

Member
Hi... I have a working program that will write data to a text file.

I want to write out to the text file every second.

Everything works until........ I try to write more than 12 times. Then only a few bits of data are written to the file. See loopcounter < 12 in the code section.

I have rewritten the program several times thinking that I'm hitting some kind of limit.

Is there a limit as to how much can be written to the file? or number of writes to the same file?

The program uses a ds1309 - but you can just as well take out all the associated code and just do static writes (of the same string, e.g., 12313232323) to the module. You will see the same think happen - at some point the data no longer writes correctly to the disk.

I have included a read back at the end of the process so you don't have to eject the drive to see what has been written.

I would really appreciate the help....


Here is the output:

********************************************
<Response> Bad Command

<Sent> Check Drive
<Response> E

<Delete> Delete file
<Response> D:\>

<Sent> Open file
<Response> D:\>

<Send> write to file
<Sent> Close file
<Response> D:\>

<Read> Read file
<Response> 03:14:37
03:14:39
03:14:41
03:14:43
03:14:45
03:14:47
03:14:49
03:14:51
03:14:53
03:14:55
03:14:57
03:14:58
D:\>

<Status> All Done
 

Attachments

BCJKiwi

Senior Member
Doubt that it has anything to do with the problem but perhaps there should not be an LF in this line;

hserout 0,("rd log2.txt",CR,LF)
 

adumas

Member
No, sadly it does not... Hopefully you are someone else can just paste this into their program and run it...


When I change the loopcounter value from 12 to 13, nothing gets written. As I increase the counter I get various results - none of them > 12 lines... Here are the results if I make it 40...

The fact that I am not getting more than 12 lines written puzzles me... Is this some kind of threshold possibly?


<Response> Bad Command

<Sent> Check Drive
<Response> E

<Delete> Delete file
<Response> D:\>

<Sent> Open file
<Response> D:\>

<Send> write to file
<Sent> Close file
<Response> >

<Read> Read file
<Response> 5:51
03:15:53
D:\>

<Status> All Done
 

Technical

Technical Support
Staff member
Have you tried wrf in ascii mode instead e.g.

"WRF 10",CR
instead of
"wrf ",$00,$00,$00,$0A,CR
 

adumas

Member
Hopfully I typed in the code correctly...


'Write out initial part of line
hserout 0,("wrf ",$00,$00,$00,$0A,CR)
'hserout 0,("wrf 10",CR)
pause 200

hserout 0,("wrf 10",CR) strangely produces no output at all. I commented it out above just to verify I was getting output with the hex value.

I tried other permutations as well...
hserout 0,("wrf 10")
hserout 0,(CR
 

100317

New Member
So far i know is there no limitation to write to a file.
I have included my Temperaturelogger Program. It runs since dec. 2007, the records are 32 Byte long , and the file has now over 400KB.

Have fun.
Hans

Code:
; set picaxe type
#picaxe 28x1

; open terminal after download
#terminal 4800

symbol first_byte = b0
symbol point = b1
symbol temp = b2
symbol loopcounter = b3
symbol isnegative = b13
symbol negative = b14
symbol T_schl = b15

setup:
	; setup serial hardware at 9600 with background receive
	hsersetup b9600_4,%01
	low 0
	pause 1000
	Sertxd ("Wetterlogger.bas",CR,LF)
	Sertxd ("25.12.2007",CR,LF)
	toggle 7

init:
	hserout 0,("E",CR)
	gosub	get_response
	if first_byte <> "E" then init

Main:
	
Anfang:
	gosub Check_drive
	gosub Open_file
	gosub	get_response
	sertxd (CR,LF)
	gosub Uhrabfrage
	hserout 0,("wrf ",$00,$00,$00,$0e,CR,b8,b9,".",b10,b11,".",b12,b13,";",b4,b5,":",b3,b2,CR)
	gosub	get_response
	toggle 7	
	gosub Helligkeit
	hserout 0,("wrf ",$00,$00,$00,$06,CR,";",b1,b2,b3,b4,";",CR)
	gosub	get_response
	toggle 7
	T_schl = 0
	gosub temperatur1
	hserout 0,("wrf ",$00,$00,$00,$08,CR,negative,b3,b4,b5,",",b7,b8,";",CR)
	gosub	get_response
	toggle 7
	T_schl = 0
	gosub temperatur2
	hserout 0,("wrf ",$00,$00,$00,$09,CR,negative,b3,b4,b5,",",b7,b8,CR,LF,CR)
	gosub	get_response
	pause 1000
	toggle 7	
	gosub Close_file
	low 7
Wartezeit:
	Sleep 260 			'wait 10 Minutes
	goto anfang
	

get_response:
	t_schl = 0
	pause 1000				
	point = 0			
	get point,first_byte	
	do
	get point,temp		
	sertxd (temp)		
	inc point			
	loop while temp <> CR	
	sertxd (LF)			
	sertxd (CR,LF)		
	hserptr = 0			 
	return
	
Check_drive:
	hserout 0,(CR)
	gosub	get_response
	if first_byte <> "D" then Check_drive
	return

Close_file:
	hserout 0,("clf tempdat.txt",CR)
	pause 300	
	gosub	get_response
	toggle 7	
	return

Open_file:
	hserout 0,("opw tempdat.txt",CR)	
	pause 300
	gosub	get_response
	toggle 7
	return
	
Uhrabfrage:	
	i2cslave %11010000, i2cslow, i2cbyte
	readi2c 0, (b0,b1,b2,b3,b4,b5,b6,b7)
	bcdtoascii b4,b8,b9	'convert b4 in b8 und b9 --> Day
	bcdtoascii b5,b10,b11	'convert b5 in b10 und b11 --> Month
	bcdtoascii b6,b12,b13	'convert b6 in b12 und B13 --> Year
	bcdtoascii b2,b4,b5	'convert b2 in b4 und b5 --> Hour	
	bcdtoascii b1,b3,b2	'convert b1 in b3 und b2 --> Minute	
	bcdtoascii b0,b1,b7	'convert b0 in b1 und b7 --> Second
	toggle 7
	Sertxd ("Date:",b8,b9,".",b10,b11,".",b12,b13," ",b4,b5,":",b3,b2,CR,LF)
	return

Helligkeit:
	readadc10 0,w3				'Analog = Pin 2 Picaxe28X1
	bintoascii w3,b0,b1,b2,b3,b4		'convert w3 in b0 to b7 
	sertxd ("Brightnes: ",b1,b2,b3,b4,CR,LF)
	Toggle 7	
	return

Temperatur1:
	w4 = 0
	readtemp12 0,W4				'Port C 0 = Pin 11
	pause 200
	gosub tempausw
	sertxd ("Temperature     : ",negative,b3,b4,b5,",",b7,b8,CR,LF)
	toggle 7
	return

Temperatur2:
	w4 = 0
	readtemp12 1,W4				'Port C 0 = Pin 12
	pause 200
	gosub tempausw	
	sertxd ("Temperature  1 : ",negative,b3,b4,b5,",",b7,b8,CR,LF)
	toggle 7
	return

Tempausw:
	isNegative = w4 / $8000
	negative = " "
 	If isNegative = 1 Then
 	W4 = -w4
 	negative = "-"
 	End If
	b1 = 0 
	b2 = 0
	w4 = w4*10/16
	b1 = w4/10
	b2 = w4//16
	bintoascii b1,b3,b4,b5
	bintoascii b2,b6,b7,b8
	return
	
[code/]
 
Last edited:

adumas

Member
Thanks - I'll try it out... My goal is to stress test the process - so I know it can write a 1000 times without a problem... Otherwise, I won't know if it is dependable... My circuit - the module, the chip, etc...

I'll run yours for the next hour or so and see the output...

Again, many thanks...

(p.s. - Since I'm sure it will work, the fun will be in figuring out why and comparing it to my setup... Joy of joys...)
 
Top