Vdrive3 so many "E"

johnlong

Senior Member
Hello All
Have being playing rather unsucessfully with the vdrive3
have had a look at the various codes on the forum and in the manual
can not get it to go passed inti: send "E". I have tried baud rates from 2400 to 9600 at 4,8,16,32
%00,%01,%10 and %11. All to no avail
In the serial terminal it shows it passing from inti: to the gosub get_response looping the LED on the
vdrive just flashes green showing disk connected but no write is recieved on the usb stick (have tried 2 sticks result the same for both) nothing on the sticks
Circuit creater in the manual shows txd (vdrive) to txd picaxe same for rxd, all other codes show txd to rxd and rxd to txd?
have tried both ways
Code:
#picaxe 28x2

' Converted by X2 Conversion Wizard Version 2.0.5 (2010r4.1)
'writen by BCJKiwi

        ; Interfacing a VDrive2 module to PICAXE-28X1
        ; Hardware Setup
        ; VDrive2        -  PICAXE-28X1
        ; 1 Black GND    -  0V               Leg 8,19
        ; 2 Brown RTS    -  CTS input4 C4    Leg 15 (not used)
        ; 3 Red V+       -  V+               Leg 20
        ; 4 Orange RXD   -  HTXD input6 C6   Leg 17
        ; 5 Yellow TXD   -  HRXD input7 C7   Leg 18
        ; 6 Green CTS    -  RTS output0 B0   Leg 21 (not essential, can tie to 0V)
        ; 7
        ; 8 Blue RI      -  not connected
        ; Note RXD on VDrive2 connects to TXD on PICAXE etc.

        ; Tested with an Imation nano 1GB USB stick.
        symbol first_byte = b0
        symbol point = b1
        symbol temp = b2
        symbol loopcounter = b3

        ; set picaxe type

        setfreq m8

        ; set COM port used for download
        ;#com 1
        ; open terminal after download
        ; This is to view the 'sertxd' debugging comments


        setup:
        ; setup serial hardware
        ; at 9600 with background receive
        hsersetup b9600_8,%10   '%01 original
        low B.0 ; ensure CTS is low
        ptr=8
        main1:
	sertxd ("obtaining data")
	        'dummy ADC1 
        	inc b5  	  
  
  	  
           
     	@ptr =b5
  	ptr =ptr+ 1
  	if ptr= 32 then: goto init:endif
 	if b5 > 254then:b5=1:endif
  	goto main1 


        init:
        ; Send Es until the unit responds correctly 
        sertxd ("<Sent> E",CR,LF)
        hserout 0,("E",CR)
        gosub get_response
        if first_byte <> "E" then init

        main:
        ; check to see if a drive is actually inserted
        ; response will start D for yes and N for no
        sertxd ("<Sent> Check Drive",CR,LF)
        hserout 0,(CR)
        gosub get_response
        if first_byte <> "D" then main

        ;now interact with disk
        Disk:
        'Get firmware version
        sertxd ("<Sent> FWV",CR,LF)
        hserout 0,("FWV",CR)
        gosub get_fileresponse

        'Get Directory information
        sertxd ("<Sent> DIR",CR,LF)
        hserout 0,("DIR",CR)
        gosub get_fileresponse

        'Get log file stamps
        sertxd ("<Sent> DIRT Log.txt",CR,LF)
        hserout 0,("DIRT Log.txt",CR) 
        gosub get_fileresponse

        'Get Directory listing
        sertxd ("<Sent> FSE <freespace>",CR,LF)
        hserout 0,("FSE",CR)
        gosub get_fileresponse
        pause 1000

        ; create a log file called 'log.txt'
        ; if you send 11 chars as the file name the last three will become the extension
        ; the '.' is inserted automatically
        ; Filename cannot include spaces
        sertxd ("<Sent> Open file",CR,LF)
        hserout 0,("opw Log.csv",CR)
        gosub get_response
        sertxd ("<Sent> write to file",CR,LF)
        bintoascii loopcounter,b5,b6,b7 ; convert loopcounter byte to 3 ascii digits
              ; and write 8 bytes loop_xyz

        hserout 0,("wrf ",$00,$00,$00,$08,CR,"loop_",b5,b6,b7,CR)
        gosub get_response
        sertxd ("<Sent> Close file",CR,LF)
        hserout 0,("clf Log.csv",CR)
        gosub get_response
        inc loopcounter ; increment counter
        goto Disk

        ; Sub procedure to receive background bytes
        get_response:
           pause 1000 ; wait a while
           sertxd ("<Response 1> ")
           point = 0 ; reset local pointer
           get point,first_byte ; Save the first reply byte
           point =8
        do
           get point,temp ; get returned byte
           sertxd (temp) ; transmit it
           inc point ; increment pointer
          loop while temp <> CR ; if not CR loop
           sertxd (LF) ; Add a LF to the received CR
           sertxd (CR,LF) ; Do another blank line
           hserptr = 0 ; reset the background receive pointer
        return

        get_fileresponse:
           pause 1000 ; wait a while
           sertxd ("<Response 2> ")
           point = 0 ; reset local pointer
           get point,first_byte ; Save the first reply byte
        do
           get point,temp ; get returned byte
           sertxd (temp) ; transmit it
           inc point ; increment pointer
        loop while temp <> ">" ; if not CR loop
           sertxd (LF) ; Add a LF to the received CR
           sertxd (CR,LF) ; Do another blank line
           hserptr = 0 ; reset the background receive pointer
           pause 1000
        return

        ; Other Useful Commands
        ; Pause hserout 0,("e") ; note no CR here
        ; Resume (after pause) hserout 0,(CR)
        ; Suspend disk hserout 0,("sud",CR)
        ; Wakeup disk hserout 0,("wkd",CR)
        ; Get firmware version hserout 0,("fwv",CR)
have also tried variations on the following
Code:
#picaxe 28x2
#no_data
#no_table

symbol loopcounter = b1
symbol point       = b2
symbol first_byte  = b3
symbol temp        = b4
symbol start_byte =b8
symbol last_byte =b5
start_byte="E"

setfreq m8
sertxd ("hello wait")
put 40, start_byte
ptr=8
main1:
	sertxd ("obtaining data")
	        'dummy ADC1 
        	inc b5  	  
  
  	  
           
     	@ptr =b5
  	ptr =ptr+ 1
  	if ptr= 32 then: goto init:endif
 	if b5 > 254then:b5=1:endif
  	goto main1 




init:	pause 500		; allow 500ms to wake-up
	hsersetup B9600_16, %10
	

	
init_vdrive3:				'send Es until Vdrive2 responds correctly
	hserout 40,(start_byte,CR)
	pause 50
	sertxd ("E requested")
	gosub get_response
	
	if start_byte <> "E" then init_vdrive3
	sertxd ("byte returned")
	pause 1000
	
main:	; create a log file called 'log' (for some reason 'log.txt' didn't work)
	let ptr =8
	
	sertxd ("<Sent> Open file",CR,LF)
	
	if loopcounter = 0 then	
	hserout 0,("opw log.csv",CR)     ' creates a new file PTR 39 DUMMY BYTE      
	else hserout 0, ("MKD"," ","log",#loopcounter,".csv",CR)  ' creates sub directory in above fie	
	endif
 	 
 	pause 50
	gosub get_response1 
 
	sertxd ("<Sent> write to file",CR,LF)          
	pause 50 
	 		; convert loopcounter byte to 3 ascii digits
						; and write 8 bytes loop_xyz
	hserout 0,("wrf ",$00,$00,$00,$08,CR,lf)
	hserout 8,(@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc,CR,LF) 
	hserout 16,(@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc,CR,LF)
	
	hserout 24,(@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc,CR,LF)
	hserout 32,(@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc,CR,LF)
	hserout 0,(CR)
	pause 50
	gosub get_response1
	
	sertxd ("<Sent> Close file",CR,LF)   	
	hserout 0,("clf log",CR)
	pause 5000
	gosub get_response1
	ptr=0
	inc loopcounter 
	'debug					; increment counter
	goto main1					; repeat
		
	; Sub procedure to receive background bytes 
get_response1:
	pause 100 					; wait a while	
	sertxd ("data write ")
	
	
 

					; reset local pointer
	point =8
	get point,first_byte 
 	  			; Save the first reply byte
	
         	do
         	   get point,temp				; get returned byte
   	   sertxd (#temp)
     	   'debug				; transmit it
   	   inc point					; increment pointer
      	loop while temp <> last_byte	 			; if not CR loop
	
	sertxd (LF)					; Add a LF to the received CR
	sertxd (CR,LF)					; Do another blank line
	
	hserptr = 0					; reset the background receive pointer 
	return


get_response:

	pause 100
	
	get 40,start_byte
	'debug
	return
this will go forward as i have preloaded the scratchpad with the value for E
So here is the biggy what am I missing (I am assuming the firmwear is the latest version as advertised at purchase of the vdrive)
regards
john
 

Attachments

jsmanson

Member
Didn't review your code, but one thing I had to do is use an older 1 gig or smaller usb stick, Vdrive2 at least doesn't 'like' the larger more recent USB sticks... if that helps...
 

johnlong

Senior Member
here is some interesting reading on this device, if it helps, it'a a year old....

http://www.drdobbs.com/embedded-systems/hosting-usb/240169402
Thanks for that if he's struggling thats me knackered then, but must not give in
Did think about the size of the stick the big ones only 8meg but might be some thing going on inside it doesnt like
So will have a search for and old small belt an braces type there is a comment in ftdi doc on the vd3 on compatable sticks, and i read some were on the form that some have rom drive in them or such device which wont work.
Thats one avenue the other and more likely is I am not interperating what i am reading correctly.
regards
john
 

hippy

Technical Support
Staff member
Code:
hsersetup b9600_8,%10   '%01 original
With background receive disabled the "getresponse" routine will likely not return the correct result, and polarity has been partially inverted which will cause its own problems.

The code also appears to be converted from some other PICAXE. It may be that there are some other subtle issues which could arise from that. It would probably be better to create simpler test code which simply interrogates the VDrive3 and reports responses before trying to do something more complex with it. That would also make it easier for people to analyse the code and assess its behaviour if not familiar with the VDrive.
 

johnlong

Senior Member
Hi Hippy
Tried all the variations of %10,%01,%11,%00 with the same result
so this was leading me to think that the error was else where in the code that I could not determine
Have tried a shorter code just to get passed the E issue but never get the return byte
Editor seems to only like the %10 in the set up command as all others are rejected but have downloded the others
All the codes out there that I have seen seem to be a variation on profmason even the one in circuit creater of the manual
for the device (wiring diffrent txd,rxd). Just added a small routine to act like and adc
But will certainly relook at the hsersetup with a shorter code again to get the return byte back
Was just wondering If there was any blindingly obvious code errrors to more astute members and as you have indicated %10 is one
So a relook at my T and N's. I do know the code is a bit sloppy but thourght dont walk to far down the road before I have to turn back. Or is it a device to device mismatch error. Will look closer at both aspects
Is there away in editor to debug and view the terminal at the same time so as to see more clearly whats happening
regards
john
 

jsmanson

Member
Hi John, I am enclosing some bits of code from my program that sucessfully writes to the Vdrive2. It won't run on it's own as I haven't included all of the symbol statements, but I wanted to include the main statements that write data out to the usb file. What I learned (after many nights getting this thing to work): The write command MUST send multiples of 4 bytes of data, if you send 3 bytes or 5 bytes, it will NOT write to the file. If necessary, send bank (space) characters to get even multiples of 4 bytes. The command also require <CR> (cairrage return) statements in there as well, follow my example...

One of the RTS or CTS lines must be either held high or low or the thing will not work.

Hope this helps... John
 

Attachments

johnlong

Senior Member
Hi jsmanson
Thank you for that have being playing around with it all day still no forward movement thou
just can not get the return byte back
have tried CTS to gnd also RTS to gnd
have tried all the combo of %1, %0, %11, %00, %10, %01, %00
The LED on the vdrive is just a constant green indicating disk ready so can I assume from that
the vdrive has reconigesed the disk attached or is that an indication that the vdrive knows its powered up and ready
tried the following small code just to see if the first byte is captured
Code:
#picaxe28x2
setfreq m8


symbol first_byte=b2
symbol start_byte = b3

hsersetup b9600_8,%1

init_vdrive2:				'send Es until Vdrive3 responds correctly
	hserout 0,("E",CR)
	'debug
	gosub get_response
	sertxd ("no byte ")
	if first_byte <> "E" then init_vdrive2
	
	gosub disp
	
get_response:
	pause 250

 	get 0,first_byte 		'save the first byte received
 	

	let hserptr = 0		'reset the background receive pointer 

return



disp:
sertxd ("drive has returned byte")

pause 5000
return
Also without sucess
the maxell is an old 8 meg stick, I have reformatted it to FAT 32 to see if that helps (that will be a no then) the scandisk cruzer blade 8gb this far to large I take it
thinking I may have issues else where maybe power but got a steady 4.5v at the vdrive when I drop it down
to 3.3v the unit fails to turn the usb
regards
john
 

Jeremy Harris

Senior Member
I got it to work, after a long struggle, but did give up on it in favour of the much easier to drive SD logger.

One major problem with the V Drive is that it responds quickly to serial commands, often before the Picaxe has had time to get ready for a serial input from it. It also works at "proper" baud rates, and gets twitchy with the big errors in some of the Picaxe software baud rates. I found that upping the Picaxe clock speed had two benefits. It made the Picaxe baud rates more accurate and it reduced the processing time from sending a serial command or data to the VDrive and receiving the acknowledgement.

I have one here detained to go in a new logger, just waiting for my reserve of patience to build to a level where I'm prepared to go and do battle with it again. If it's any consolation I did have a breadboard set up and working with it quite well a few years ago, so I know it can be made to work, it's just a matter of me getting the time to dig out the old files and polish them up to a presentable level. I stopped all work on the VDrive when I discovered the SD logger, and have been using those continuously to write data files from a Picaxe that I can load directly to Excel for analysis for several years now, in a few project, like this one: http://www.picaxeforum.co.uk/showthread.php?20563-Data-logging-to-a-microSD-card , this one: www.picaxeforum.co.uk/showthread.php?20562-DIY-humidity-and-temperature-sensor this one: www.picaxeforum.co.uk/showthread.php?20551-Environmental-uSD-card-data-logger and more recently this one: http://www.picaxeforum.co.uk/showthread.php?23893-Air-quality-monitor-and-logger

You may get some pointers from those thread that may help. I'm just sorry that I didn't persevere with the VDrive as I'm sure that with a little more work it would do the job more easily than using SD cars or µSD cards.
 

johnlong

Senior Member
Thank you Jeremy
Have read your previous post from start to finish and decided after reading them that the SD route is the one
for me. However by time I had played around with the other elements and got around to buying one from the picaxe store
they stopped selling them. So hench the vdrive, not my first choice, as after reading your work on the uSD and looking at the command structure for the SD they are writen in a better format for the not so savvy hobbyists out there, who struggle with picaxe basic and thats writen in english and hides alot of the underlining maths for us.
Taking note of your comments going to attach a resonator (4,8,16Mhz) and cranker her up to see if that helps.
I intend it not so much as a data logger more a mass storage device. As I am using the scratchpad of the 40x2 for the data storage and manipulation with a once a day write to the vdrive (figure that way less power used a day)
The intention is to read it and store the data in Excel daily, weekly or monthly
Abit disconcerted about the limitations on what type of stick that can be used with it, as the gentleman in jsmanson post #3 states
Finding it hard to find sticks 4G seems the lowest in most places, even asking around the family to dig in draws

thanks for dropping in Hippy you comments are always welcome.

regards
john
 

johnlong

Senior Member
Hi All
Some forward movement with the vdrive3, after looking at other codes and the examples posted here, without any forward
motion the only answer that remained was that it not working on the bread board, (I know before posting as Hippy has frequently
said bread boards ha)
scandisk.jpg
So bit the bullet and knocked a board up to eliminate that from the equation and see whats left.
It worked the following code is opening and creating an excel file, this is being sent to an 8GB scandisk Cruzu Blade
This is due I think to the 8mhz resonator I added
?? However
Code:
#picaxe 28x2
#no_data
#no_table

symbol loopcounter = b1
symbol point       = b2
symbol first_byte  = b3
symbol temp        = b4
symbol start_byte =b8
symbol last_byte =b5


setfreq em32
sertxd ("hello wait")

ptr=48
main1:
	sertxd ("obtaining data  ")  
	        'dummy ADC1 
        	inc b5  	  
  
  	  
           
     	@ptr =b5
  	ptr =ptr+ 1
  	sertxd (#ptr,",")
  	bintoascii b5,b10,b11,b12
  	pause 500
  	if ptr= 80 then: goto init:endif
 	'debug
  	goto main1 




init:			; allow 500ms to wake-up
	hsersetup B9600_32, %1
	pause 500

	
init_vdrive3:
				'send Es until Vdrive3 responds correctly
	hserout 0,("E",CR)
	pause 50
	sertxd ("E requested ")
	gosub get_response
	
	if start_byte <> "E" then init_vdrive3 
	sertxd ("byte returned")
	
	
main:	
	
	
	sertxd ("<Sent> Open file",CR,LF)
	pause 200
	
	if loopcounter = 0 then	
	hserout 0,("OPW gol.csv",CR)           
	else hserout 0, ("MKD"," ","gol",#loopcounter,".csv",CR)  ' creates sub directory in above fie
	pause 200	
	endif
 	 
 	pause 50
	gosub get_response1 
 
	sertxd ("<Sent> write to file",CR,LF)          
	pause 50 
	ptr=48
	hserptr = 0	
	hserout 0,("wrf ",$00,$00,$00,$08,CR,#@ptrinc,#@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc,CR)
	hserptr = 0
	pause 30
	hserout 0,("wrf ",$00,$00,$00,$08,CR,#@ptrinc,#@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc,CR)
	hserptr = 0
	pause 30
	hserout 0,("wrf ",$00,$00,$00,$08,CR,#@ptrinc,#@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc,CR)
	hserptr = 0
	pause 30
	hserout 0,("wrf ",$00,$00,$00,$08,CR,#@ptrinc,#@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc,CR) 
	 	
	pause 30
	
	
	gosub get_response1
	
	sertxd ("<Sent> Close file",CR,LF)    	
	hserout 0,("clf gol.csv",CR)
	pause 50
	gosub get_response1
	ptr=0
	inc loopcounter	
	high C.7  'ALLOWS removal of the stick without it being corrupted
	'debug
	sertxd ("safe to remove")			
	end					
		
	; Sub procedure to receive background bytes 
get_response1:
	 					;	
	sertxd ("data write ")
						; reset local pointer
	point =48
	 
 	  			; Save the first reply byte
	
         	do
         	   get point,temp				; get returned byte
   	   sertxd (#temp)
     	   'debug				; transmit it
   	   inc point					; increment pointer
      	loop while temp <> last_byte	 			
	
	sertxd (LF)					; Add a LF to the received CR
	sertxd (CR,LF)					; Do another blank line
	
	hserptr = 0					; reset the background receive pointer 
	return


get_response:
	
	
	
	get 0,start_byte
	pause 20
	
	sertxd ("in responce", "ptr=",#@ptr, "SB=",#start_byte)
	sertxd (LF)					; Add a LF to the received CR
	sertxd (CR,LF)
	'debug
	hserptr=0
	return
The file when opened in excel all I get is
  • In the formular bar is 1.23456789101112E+31
tried to upload the excel file it wont let me
It says the file is 32 bytes big in the file folder
So things are still not correct, As there is no data?
But we have it opening and making a file so small steps forward
Shows the hardware is functioning
Is it due to some thing I need to do in excel
Or more likely me not fully understanding the command structure properly

Have kept the hserout at 8 bytes long I think as previously mentioned by jsmason
I feel its not fully crasping the hsersetup command B9600_32,%1 (with em32) am I telling the chip 32 bytes
or am I sending 9600,8,n,1 8 bytes a time.
Have tried sending 32 block same results

regards
john
 

grim_reaper

Senior Member
John,

You're writing a .CSV file, not a native Excel file. Try opening the CSV file Notepad.
It should have the 32 bytes of data that you wrote to it in main:.

Grim
 

Jeremy Harris

Senior Member
Excel will normally open .csv files, but I have a feeling that there are some quirks, and possible a setting in Excel that lets it just open a .csv file. I know that I can import .csv files into both Excel and LibreOffice Calc just fine, as I do it all the time with the .csv datafiles from my data loggers (but they all use either the OpenLog or the SDLogger
 

johnlong

Senior Member
John,

You're writing a .CSV file, not a native Excel file. Try opening the CSV file Notepad.
It should have the 32 bytes of data that you wrote to it in main:.

Grim
Hello Grim

After removeing the LF and CR from the responce gosubs I am getting a 32 byte excel file
Opening said excel file the formular bar is know empty but the cells (A2,A3,A4,A5) have charictor strings in them
Did =len(A2) responce was a value of 2 for (A3) value of 18 (A4) value of 9
I take it that relates to the length of the strings within the cell
getting such charitors in the cells such as ¬¦ ¬~ and so forth
which will have the numeric value encoded, got the same result in notepad never used notepad before
when I put =CODE(A2) I get a value of 1 the first in the string (A3) 14
how do I open up the cell to extract and convert all the bytes within it
Down to my last tuft of hair haha
I know there is value in them as when I tried to paste them into this post got little greyed out boxes with hex values
in them but not showing on the post
regards
john
 
Last edited:

grim_reaper

Senior Member
Is this the bit of code that you want to write to the CSV file? (I'm at work, can't play with 'AXE editor!)

Code:
sertxd ("<Sent> write to file",CR,LF)          
ptr=48
hserptr = 0	
hserout 0,("wrf ",$00,$00,$00,$08,CR,#@ptrinc,#@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc, #@ptrinc,CR)
(repeats 3 more times, with pauses)

If I'm interpreting this correctly, the output should be (in decimal) 0, 0, 0, 8, 13, 48, 49, 50, 51, 52, 53, 54, 55, 13.
Now, I'm guessing the pre-amble bit is for the Vdrive3 - the 3x zeros, the 8 and the CR? What's the command syntax for "wrf"??
As I'm sure you know, the 48 to 55 should be ASCII for numbers 0 to 7, plus another CR.
So first of all, am I right in thinking you're dumping 0, 1, 2, 3, 4, 5, 6, 7 to the CSV as a test? And that's what you're expecting to see in the spreadsheet?

There are many places where this data can be misinterpreted. The major one will be the byte encoding used by Windows. Unless your PC is "ancient", it will be using Unicode by default, and this requires TWO bytes per character. That would explain the symbols being produced by Excel when you open the CSV. However, I'm still not entirely sure what data you're trying to produce!

What you need is a Hex / Byte editor that shows the raw data in the file. I seem to have lost mine(!) but it was a freeware thing called 'Hex Editor' that I used for years. Maybe others can recommended a smarter/newer application.

Can you please clarify what you are attempting to write (data wise - e.g. a few numbers for testing, some characters, etc.), what version of Windows and Excel you have, and what format you want the data in?
I can help you with this a bit more when I get home this evening - about 8pm.

Grim
 

grim_reaper

Senior Member
Just re-read my last post and sorry if it's a bit over-the-top!

I've tried to recreate your data and the output in Excel - see attached picture. The top part is the raw data entered into HxD Hex Editor (just downloaded it, seems quite good) - the data is in hexadecimal, not decimal as per my last post. The middle is the file opened in Excel and then Notepad at the bottom.

It's kind of the same result you described - how similar is it?!

Bytes in CSV.png
 

hippy

Technical Support
Staff member
One thing you might try is to create the data you want to see in Excel, save that and then look at what the file contains. What's in the file is what your PICAXE program has to create.
 

johnlong

Senior Member
Hi All
This is what I am recieving in excel you did better than me Grim you got numbers.

excelusb.jpg

Have altered the code in 2 areas to get this far
Code:
get_response1:
	 					;	
	sertxd ("data write ")
						; reset local pointer
	point =48
	 b15=99
	 pause 1000
 	  debug			; Save the first reply byte
	
         	do
         	   get point,temp				; get returned byte
   	   sertxd (#temp)
     	   debug				; transmit it
   	   inc point					; increment pointer
      	loop while temp <> CR	 			
	
	'sertxd (LF)					; Add a LF to the received CR
	'sertxd (CR,LF)					; Do another blank line
	
	hserptr = 0					; reset the background receive pointer 
	return
By commenting out the LF and CR,LF
Rearranged the data being sent via hserout to the following
it stopped it from filling the excels formular bar giving the 32 bytes
Running windows vista (with a blue screen) with non commercial excel in microsoft office also have open office on it
Code:
	hserout 0,("wrf ",$00,$00,$00,$20,CR)
	hserout 0,(LF,@ptrinc,@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc)	
	
	hserout 0,(@ptrinc,@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc)	
	
	hserout 0,(@ptrinc,@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc)	
	
	hserout 0,(@ptrinc,@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc) 
	 	
	pause 30
I feel the 2 are comunicating as 1 the file is created and 2 seeing the "E" return byte in the debug screen.
The program is at the moment just a dummy ADC run to create the values to understand more the workings the unit
values of 1 to 32 are generated before the write so this is what I expect to see in excel
Obviously time stamping will be added later
Once this hurddle is over come
But not sure its a programing error on mybehalf or the excel side of things.
regards
john
 

jsmanson

Member
Not sure if this helps, but here is some code snippets that I use to write to a csv file using a vrdive2 which excel reads no problem:

First step is to build the data for the file writing operation....

**********************************************************

prep_file_data:
'send out ascii data to file, stores the data into loc 100-175
'first send date info
'"20yy-mm-dd,xxxxx," where x is the jul_date, 16 ascii digits
put 200,"2"
put 201,"0"
bintoascii year,temp3,temp1,temp2
put 202,temp1
put 203,temp2
put 204,"-"
bintoascii month,temp3,temp1,temp2
put 205,temp1
put 206,temp2
put 207,"-"
bintoascii date,temp3,temp1,temp2
put 208,temp1
put 209,temp2
put 210,","
bintoascii jul_date,temp1,temp2,temp3,temp4,temp
put 211,temp1
put 212,temp2
put 213,temp3
put 214,temp4
put 215,temp
put 216,","
'next part, store the adc data
'"xxx," where x is the byte adc data, 5 of them 20 ascii digits
bintoascii adc_sal1,temp1,temp2,temp3
put 217,temp1
put 218,temp2
put 219,temp3
put 220,","
bintoascii adc_sal2,temp1,temp2,temp3
put 221,temp1
put 222,temp2
put 223,temp3
put 224,","
bintoascii adc_dom,temp1,temp2,temp3
put 225,temp1
put 226,temp2
put 227,temp3
put 228,","
bintoascii adc_irr,temp1,temp2,temp3
put 229,temp1
put 230,temp2
put 231,temp3
put 232,","
bintoascii adc_well,temp1,temp2,temp3
put 233,temp1
put 234,temp2
put 235,temp3
put 236,","
'last part, store the flow data
'"xxxxx," where x is the word flow data, 6 of them 36 ascii digits
bintoascii f_toilet,temp,temp1,temp2,temp3,temp4
put 237,temp
put 238,temp1
put 239,temp2
put 240,temp3
put 241,temp4
put 242,","
bintoascii f_ro_in,temp,temp1,temp2,temp3,temp4
put 243,temp
put 244,temp1
put 245,temp2
put 246,temp3
put 247,temp4
put 248,","
bintoascii f_house,temp,temp1,temp2,temp3,temp4
put 249,temp
put 250,temp1
put 251,temp2
put 252,temp3
put 253,temp4
put 254,","
bintoascii f_irr,temp,temp1,temp2,temp3,temp4
put 255,temp
put 256,temp1
put 257,temp2
put 258,temp3
put 259,temp4
put 260,","
bintoascii f_rain,temp,temp1,temp2,temp3,temp4
put 261,temp
put 262,temp1
put 263,temp2
put 264,temp3
put 265,temp4
put 266,","

**********************************************************************

So my actual write routine for all of the items for ones day's of data looks like this:

**************************************
write_data:
usb_online = 1
'this routine writes the flow data to usb drive (appends log.txt file if present)
if usb_online = 1 then
call prep_file_data 'this routine takes the current data and writes it to scratchpad, starting at loc 100

'now open the file for writing
call check_file 'openes the log.txt file for writing
'usb_online = 1
if usb_online = 1 then
'strobe out the data in scratchpad, starting at loc = 100
temp = 1
again:

'PART 1 - Regular Flow Data &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

ptr = 200
hserout 0,("wrf ",$00,$00,$00,$08,CR,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc)
'sertxd("Group1 write",cr,lf)
hserptr = 0 ; reset the background receive pointer
hi2cout [i2c_lcd],(".")
pause 300
hserout 0,("wrf ",$00,$00,$00,$08,CR,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc)
'sertxd("Group2 write",cr,lf)
hserptr = 0 ; reset the background receive pointer
hi2cout [i2c_lcd],(".")
pause 300
hserout 0,("wrf ",$00,$00,$00,$08,CR,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc)
'sertxd("Group3 write",cr,lf)
hi2cout [i2c_lcd],(".")
hserptr = 0 ; reset the background receive pointer
pause 300
hserout 0,("wrf ",$00,$00,$00,$08,CR,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc)
'sertxd("Group4 write",cr,lf)
hi2cout [i2c_lcd],(".")
hserptr = 0 ; reset the background receive pointer
pause 300
hserout 0,("wrf ",$00,$00,$00,$08,CR,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc)
'sertxd("Group5 write",cr,lf)

.......................NOTE, code snippet, I didn't include this whole section....

***************************************************************************

Note that I manually put in the necessary commas between values etc. The above code writes out the data including the last comma to the scratchpad memory, which is used in the code above to do the actual write. Other code adds an "OK" or an "ERROR" note to the end of the line, here is the line that adds the error note as an example:

hserout 0,("wrf ",$00,$00,$00,$08,CR,"ERROR ",$0D,$0A,CR)

This is used to warn me if there was a data irregularity on that's day's data, otherwise it just says "OK".

Lets break down what this line above is doing. The "("wrf ",$00,$00,$00,$08,CR," portion is telling vdrive to write to the presently opened file. NOTE that the last character sent is "CR", this signals to the vdrive that you have just sent it a command, and to now process that command, in this case, wrf is the command to write to the file that is currently open. The commend wrf is part of a two part command, the second part is the data to be sent (some commends are only one part, not two). So, with this coommand, you are also telling vdrive that the next $08 - 8 characters sent is the data to be written to the file. If you instead put in $04, it would send the next 4 characters to the file, and so on. Only use multiples of 4 chars, if you use something else it will not write, period. I have messed with this many times.

Now the next part ","ERROR ",$0D,$0A,CR). OK count up the chars - we have a total of 6 chars taken up by the word "Error" with a space after it, that leaves 2 chars left. The carriage return ($OD) and line feed ($OA) are 2 more making a total of 8 chars. the CR at the end ONLY SERVES TO SIGNAL TO THE VDRIVE THAT THE COMMAND YOU SENT IS DONE. That CR is NOT sent to the file. The code to append with an "OK" is identical, except substitite "OK ", which is "OK" plus 4 spaces, making it a total of 6 spaces, plus the cr and line feed chars.

Vdrive will then send those 8 chars out to the file, the last two characters finish the line of data in the file, so the next data send will go on the next line of the text file. Again, the "wrf" is interpreted by the vdrive to write to the currently active file, it needs to be there. the three $00's are, I don't know what they are, but leave them in there. The $08 is the length of data to be sent., which data follows the CR following the $08.

Note, the binntoascii command converts bytes and words to specific (fixed numbers of) characters, the word variable value of "400" will get written as "00400" as I write 5 chars for any word value. Excel can deal with the leading zero's no problem. Or if you want to get fancy, you can code around leading zeros and convert them to a space characters instead, your choice.



Write to a file named "xxx.csv", where xxx is your file name, I use "log.csv". When written, open it up in notepad, not excel. You should see (in my case) (example data only....):

2016-03-12,00112,034,235,000,023,034,03422,00000,00234,00456,ERROR
2016-03-13,00113,034,235,000,023,034,03822,00078,05234,00456,OK

Note each day should show up on each line, not all on one line. If it's all on one line, you are not sending out the carriage retrun and line feed chars properly.

If you are getting the notepad opened csv files to display like above, excel will open them fine and stick them in each column and row correctly.

This make sense?

John
 

jsmanson

Member
so, using the example in the previous post, the code does not line up with the data correctly.

Assuming you are wanting to send EXACTLY 20 characters to the file every time you write to the file, plus a carriage return and line feed, (which take up 2 chars), and you need to send a multiple of 4 chars, means you send 24 chars in total. So you need to pad the data with 2 space characters.

hserout 0,("wrf ",$00,$00,$00,$20,CR) .................OK first command, vdrive will send out the exact next 20 chars to the file................
hserout 0,(@ptrinc,@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc) .... 8 chars, take out the line feed.......

hserout 0,(@ptrinc,@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc) ..... now up to 16 chars..............

hserout 0,(@ptrinc,@ptrinc, @ptrinc, @ptrinc) ...... OK you are now up to 20 chars worth of data, so far so good..... but you are not done.........

hserout 0,(" ",$0D,$0A,CR) ..... OK, you added the last two spaces, adding up to 22 chars, then the cr and lf chars to write those to the file (NOW we are at 24, perfect!!), then that last important CR to signal to vdrive that the command is DONE. [PLEASE NOTE: The Picaxe forum editor does not put in the correct spaces, put two spaces between the quotes, or just send the ascii char for a space which is 32] Alternate version: hserout 0,(32,32,10,15,CR)

AND DON'T FORGET TO ADD COMMAS BETWEEN YOUR DATA VALUES OR EXCEL WONT BE ABLE TO EASILY CONVERT TO COLUMNS PROPERLY. Your code example did not add commas between values when it 'built' the example data in memory.


pause 30
 
Last edited:

grim_reaper

Senior Member
I'm going to have to agree with Hippy (as per usual!) - it's much easier to attack this in reverse order.

Below is a screen shot of a simple CSV file containing 1 and 2 in cells on the first row, and 3 and 4 in cells on the second row. The file content is all in hexadecimal.

Test CSV.png

It's not as complicated as I alluded to previously - but you will have to change a few things to get valid data! The numbers themselves can be written as you have been doing (e.g. $31 displays a 1), and if you want items in the same row, you need a $2C to represent the comma. Fairly straight-forward.
The main difference to what you have at the moment is the carriage returns - I've just realised jsmanson has posted while I was writing this(!) - and it's as he says; you need a CR, LF for Excel (the default new line sequence for Windows).

I think between us we've thrown enough information at you for one night, and I need to go to bed, so let us know how you get on with all of it!!

Grim
 
Last edited:

jsmanson

Member
Hello again, I am home now and can send you a log file from my program. The program is quite long, so I have only been sending you code snippets, but here is what the log file output looks like, I named the file log.txt, not log.csv, it doesn't really matter excel opens them fine. My program writes todays date, a integer value for todays date, 5 - 3 digit byte values, 5 - 5 digit flow values, and 10 - 4 digit flow values, then a marker at the end indicating status of the communications between the main program and a remote picaxe (the remote picaxe has to reset flow values back to '0' each day), all values are separated by commas, and the cr,lf at the end of course. Hope this helps.

John

P.S. note the dates are a bit goofy, I have a routine in the program that allows me to manually 'test' the end of day file write, so I can simulate the data transfer any time during the day for testing, normally the thing only runs at midnight.
 

Attachments

johnlong

Senior Member
Hi All, jsmanson
In your post #21 your say $20 is 20(dec) bytes I took this from the ascii table in editor and thourght
that it was 32 in dec hence the 4 lines of 8 bytes
I think I grasp what you mean to write 32 bytes I need to send 36 to accomadate th CR,LF's 2 byte
If you have the time can you explain the comma's abit further

Code:
	hserout 0,("wrf ",$00,$00,$00,$20,CR)
	hserout 0,(@ptrinc,@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc)
Are you refering to the commas in the above or as in your example resetting the hserptr to 0 after each punctuating
the byte sequance being the bit editor does not do with close parathesse new line.

Feeling that there light and a chance for new hair growth
ps does the forum have a spell checker In it

greatly appreciate it
regards
ohn
 

jsmanson

Member
Commas everywhere lol!!

You have to insert commas between the data fields or data points that you are sending to the file. The code snippet below is populating the scratchpad mamory with the data to be written to the file:

bintoascii jul_date,temp1,temp2,temp3,temp4,temp
put 211,temp1
put 212,temp2
put 213,temp3
put 214,temp4
put 215,temp
put 216,","

You can see I am putting the ascii value for a comma in location 216, immediately after I store the field (in this case the value for "jul_date", which is a word variable)

When you eventually do the actual write, namely:

hserout 0,(@ptrinc,@ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc, @ptrinc) etc...

one of those @ptrinc values will be that comma.


About the $20 value - Yikes I completly forgot about the bcd thing, so you're probably fine writing the 32 bytes with $20, my mistake. But remember you have to allow the last two chararcters for the LF and CR at the end of the line, so using $20 will allow you write exactly 30 characters of useful data, including those.... commas lol!
 
Last edited:

johnlong

Senior Member
Hi jsmanson
Just a quick one about the scratchpad mamory (take it there is no spell checker lol)
As I understand it with setting hersetup to %1 I am recieving data back from the usb in to
the scratchpad memory of the picaxe starting at location 0 (the manual states at loc0) so if I send 36 bytes out I
get 36 back in effect at locations 0 to 35.
If this is correct 2 thngs 1 the scratchpad stores this data and it remains there until it is over writen
If I am right in this assumption it can then be used to check if the data was writen to the usb correctly?
by comparing 0 to (say) 100, 1 to 101 ect if not equal too rewrite data
Thank you so much for taking the time out with this the "," would have alluded me, I never would have picked that one up
Some times well most of the time I could do with a comic version of the commands
Thats the good thing about this forum it enables so many people at so many diffrent levels
to achive there goals

regards
john
 

jsmanson

Member
I tested and ended up using the scratchpad memory when I was writing my program to prepare outgoing data, it works fine ( I am using a 40x2 which has 1024 bytes of scratchpad space available).

OK, the vdrive sends serial data back to the user when the user issues commands, sometime's the data is something you requested, such as the name of a directory or file listing, but often it's just something short like "D:/", which is just the vdrive saying it execuded your command and all is good. (See the vdrive documentation for what responses can be expected from each command). So this thing is really meant to be used similar to a modem, where you issue (type) commands to it and you can see what it says back. However, we are using it in a programming environment, where we are building code (decision trees or branches) based on what "comes" back. Most code for this thing looks to trap an error (first character back is an "E", if it's a "D", everything is OK, that's really all you can do if you are automating this thing. If you set the hser pointer back to 0 after each hserout 0,(xxx...) then you are letting the next command received back from the vdrive (which fills the scratchpad starting at loc0) start again at position 0 in the scratchpad. In this way, you won't fill up the scratchpad with all of the verbage coming back from vdrive. In my case, I set aside loc0-99 for vdrive "babble", and then used loc100 on up for temporarily storing the day end data, to make it easy to 'strobe' that data out to the vdrive using the power of the @ptrinc incrmenting pointer variable in basic. You don't have to use the scratchpad for sending data to the vdrive, you could code it direct, use eeprom, another storage location, whatever you'd like. But if using the scratchpad, don't use the lower area of the scratchpad, or your outgoing data might get overwritten by the verbage coming back from the vdrive. I found out that 'reserving' the first 100 bytes of scratchpad worked fine for my use, I think some command responses got up to around 60 or 70 bytes, particuarly when you first start thie thing up, it spits back the firmware version etc etc.

If you are asking for listing of directories etc that may be long, maybe reserve some additional space.

In theory you could I guess store your outgoing data sarting at loc0, send it, read the response starting at 0, reset the hser pointer, and do it again etc, but I would be worried that the vdrive might be in the middle of communication with the picaxe at the same time you start storing that data, in effect mixing up the two data streatms.

Also, for testing purposes, I wrote a routine in my program that 'dumps' both the scratchpad and eeprom memories to a txt file on the vdrive usb, at any time during program operation, so I read it in excel, I can see what the last commend response that came back from the vdrive starting at loc0, and exactly what the outgong data looks like starting at loc100, it's useful for debugging.

Hope this helps! John
 
Last edited:

hippy

Technical Support
Staff member
As I understand it with setting hersetup to %1 I am recieving data back from the usb in to the scratchpad memory of the picaxe starting at location 0 (the manual states at loc0)
Background receive will write to wherever 'heserptr' points to in the scratchpad and increment that on every byte received. 'hserptr' will point to location zero initially but you will have to ensure you reset it to zero if you want later received data in locations from zero upwards.

so if I send 36 bytes out I get 36 back in effect at locations 0 to 35.
I can't comment on exactly what you get back if you send 36 bytes out, but that's the gist of it if the module is echoing what it receives and you had 'hserptr' pointing to zero.
 

johnlong

Senior Member
Thank you Gents
Its getting alot clearer, begining to understand the function of the usb
and it relationship with the picaxe Nice good clear instructions
yer you can get the data back but thats not relay what its good for write it forget it check it
on the laptop
By both agreeing that yes you will get something back and like you say Js its verbage (like that)
to sit there and try to fathom out whats what would be beyound me at the moment with it
As the man in the Chinese restaurant said "its good to fork" ","
Let just get it interfaceded (done solder removes errors) correctly, 8Mhz res atleast at the moment
creates a file on and 8G stick, so that removed the problem of finding
a smaller stick (struggling to find any under 4G)
with you the good advice I have recieved from you all to get it readable in excel
Some times the manuals can generate not enough or too much I end up chasing snakes
Looking forward to this

regards
john
 

johnlong

Senior Member
8meg.jpgHi All
After a long weekend of tinkering WE HAVE DATA in excel
I have had to use a long winded approach to get it in there
using the commented out loop produced charictors not number values in excel
used the clipboard in excel
Code:
symbol nd=b6
symbol s_t=b7
symbol temp = b8
setfreq em32
b5= ","

ptr = 104
put 104,"1":put 105,b5:put 106,"2":put 107,b5:put 108,"3":put 109,b5:put 110,"4":put 111,b5
put 112,"5":put 113,b5:put 114,"6":put 115,b5:put 116,"7":put 117,b5:put 118,"8":put 119,b5
put 120,"9":put 121,b5:put 122,"1": put 123,b5:put 124,"2":put 125,b5:put 126,"3":put 127,b5:
put 128,"4":put 129,b5:put 130,"5":put 131,b5:put 132,"6":put 133,b5:put 134,"7":put 135,b5


'b1=1
'for b1=0 to 36
'inc b1
'gosub conv
'ptr=b1
'ptr=ptr+1
'ptr = b5
'ptr=ptr+1
'if ptr = 136 then:goto init:endif
'next

'conv:
'bintoascii b1,b10,b11,b12
'return


init:			
	hsersetup B9600_32, %1
	pause 3000
	

init_vdrive3:
				'send Es until Vdrive3 responds correctly
 	hserout 0,("E",CR)
 	pause 50
	sertxd ("E requested ")
 	gosub get_response
		
 	if s_t <> "E" then init_vdrive3 
	hserout 0,(CR)
	 
	sertxd ("bytes returned",#s_t,    #nd)   
	pause 5000
	
main: 
	
	sertxd ("<Sent> Open file",CR,LF)   
	pause 200
	
		
	hserout 0,("OPW POS.CSV",CR) 	
	pause 200 	
	gosub get_response1	 
	
	sertxd ("<Sent> write to file",CR,LF) 
	pause 30

	hserout 0, ("wrf ",$00,$00,$00,$24,CR)
	hserout 0,(@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc)	
	
	hserout 0,(@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc)	
	
	hserout 0,(@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc)	
		
	hserout 0,(@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc)
	
	
	hserout 0,($20,$20,$0D,$0A,CR)
	
	gosub get_response1
	pause 300
	gosub fin
	sertxd ("value",  #hserptr)
	high C.7
	sertxd ("safe")
	
 	end
get_response:
	
	
	
 	get 0,s_t
 	pause 20	
	hserptr=0
	return
	
get_response1:
	 					;	
	sertxd ("data write ")
	ptr = 103
	do
	get ptr,temp
	inc ptr
	loop until temp <>CR
	
	hserptr=0
	
	return 
	
						; reset local pointer
	fin:  			
	hserout 0,("CLF POS.CSV",CR)
	pause 50
	gosub get_response1
	hserptr =0
	return
Can not for the life of me fathom out why the bintoascii is not giving ascii values
is it because when it gets to double figures it requires 2 bytes of th scratchpad
here is the excel files the first is stored on a 8meg stick the second is stored on an 8GB stick
8meg.jpg

8meg.jpg

Still along ways off but atleast I now know its writing to the sticks even the 8GB one
it wrote the whole code to the stick at one point
regards
john
 

hippy

Technical Support
Staff member
Can not for the life of me fathom out why the bintoascii is not giving ascii values is it because when it gets to double figures it requires 2 bytes of th scratchpad
Could be. It is hard to tell what you had from that commented out code as there doesn't seem to be any code putting anything to scratchpad.
 

johnlong

Senior Member
Hi Hippy
Sorry for that being having a play this morning
freash day freash brain sorted the original bintoascii problem by rearranging as follows
this is the original that was causing problems
Code:
b5=","


for b1=0 to 36
inc b1
gosub conv
ptr=b1
ptr=ptr+1
ptr = b5
ptr=ptr+1
if ptr = 136 then:goto init:endif
next

conv:
bintoascii b1,b10,b11,b12
return
I rearranged it and got it to work with the following

Code:
main:
ptr =200
do
 inc b1
bintoascii b1,b2,b3,b4 ; convert b1 to ascii
  @ptr=b1
ptr=ptr+1
@ptr=b5
ptr=ptr+1
if ptr=392 then:exit:endif
 loop
it was incing b1 by 2 so getting for b1:- 1,3,5,7,9 ect
The following is working and getting whole numbers in excel but only upto b1's value of 67 so far

Code:
#picaxe 28x2
#no_data
#no_table

symbol temp =b6
symbol S_B = b7









b5 = ","




setfreq em32
main:
ptr =200
do
 inc b1
bintoascii b1,b2,b3,b4 ; convert b1 to ascii
  @ptr=b1
ptr=ptr+1
@ptr=b5
ptr=ptr+1
if ptr=392 then:exit:endif
 loop

inti:
	'hsersetup B9600_32, %10  
	hsersetup B9600_32, %1
	pause 3000
	
	
	init_vdrive3:
				'send Es until Vdrive3 responds correctly
 	hserout 0,("E",CR)
 	pause 50
	sertxd ("E requested ")
 	gosub sis
		
 	if s_b <> "E" then init_vdrive3 
	
	sertxd ("bytes returned",#s_b)   
	pause 5000

daat:
	hserout 0,("OPW POS.CSV",CR) 	 
	pause 200 	
	gosub sis

	ptr = 200
	
	hserout 0,("wrf ",0,0,0,192,CR)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc)
	
	 hserout 0,($20,$20,$0D,$0A,CR)
	 
	 gosub response
	 pause 500
	 hserout 0,("CLF POS.CSV",CR)
	 
	pause 50
	gosub sis
	hserptr=0
	high C.7
	sertxd ("safe")
	end
	 
	  
	 
SIS:
	get 0,s_b
 	pause 20	
	hserptr=0
	return
	 
	 
	 response:
	 ptr =200
	do
	get ptr,temp	
 	inc ptr	
	loop until temp <> CR
	sertxd (#temp," ,",#hserptr," ,",#@ptr)
	hserptr = 0
	 return
putting the #@ptrinc in for the data points has insured whole numbers in excel
I need to look more at the addressing for the hserout commands not sure that ive got them totally
right
regards
john
 

johnlong

Senior Member
Hi All
Have made some inroads with the vdrive
I have it creating 4 collums of valid data

2datawrite.jpg

significant improvement on what I had yesterday
obtained it by rewriting the code to the following
Code:
#picaxe 28x2
#no_data
#no_table

symbol temp =b6
symbol S_B = b7
symbol F_B =b8
symbol L_B=b9
symbol WD=b12






b5 = ","




setfreq em32
begin:
ptr =200
ABC:


 inc b1
bintoascii b1,b2,b3,b4 ; convert b1 to ascii
  @ptr=b1
ptr=ptr+1
@ptr=b5
ptr=ptr+1
if ptr=344 then:goto inti:endif
 goto abc
 


inti:
	hsersetup B9600_32, %10  
	hsersetup B9600_32, %1
	pause 3000
	
	
	init_vdrive3:
				'send Es until Vdrive3 responds correctly
 	hserout 0,("E",CR)
 	pause 50
	sertxd ("E requested ")
 	ptr =0
 	gosub sis
		
 	if S_B <> "E" then init_vdrive3 
	
	sertxd ("bytes returned",#s_b)   
	pause 5000

daat:
	hserout 0,("OPW POS.CSV",CR)
	 	 
	pause 200
	
	pause 250
	gosub response

	ptr = 200
	hserout 0,("wrf ",$00,$00,$00,$14,CR)
	hserout 0,("Col1,Col2,Col3,Col4",CR)
	hserout 0,("wrf ",0,0,0,228,CR)
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'1
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'2
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'3
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'4
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'5
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'6
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'7
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'8
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'9
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'10
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'11
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'12
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'13
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'14
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'15
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'16
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'17
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'18
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'19
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'20		
		
	hserout 0,($0D,$0A,CR)
	 
	 gosub response
	 pause 500
	 hserout 0,("CLF POS.CSV",CR) 
	 
	pause 50
	inc wd
	gosub clr
	if wd =2 then:high C.7:sertxd ("safe"):end
	elseif wd<2 then:goto begin
	 endif

	
	

	  
	 
SIS:
	get 0,s_b
	
	
 	pause 20	
	hserptr=0
	return
	 
	 
	 response:
	 
	 ptr = 200
	 
	 
	do
	get ptr,temp	
 	inc ptr	
	loop until temp <> CR
	sertxd ("temp  ",#temp,   "hserptr",#hserptr,   "@ptr", #@ptr)
	hserptr = 0
	 return
Clr:
 	ptr =200
	
      do
	@ptr=0
	ptr=ptr+1
      loop until ptr=344 
	ptr=200
	b1=2
	return
there is still 3 zeros kicking about that I am having a job to get rid of
you can see 2 in the first collum on the second write and 1 at the end of
the first block of data if any one has a sugestion most welcome
its getting nearer when the data issue is sorted
it will be time to add the RTC to get a time and date stamp
regards
john
 

johnlong

Senior Member
Hi All
The following if run as if in simulator shows how the data is being transferd to excel
Have manipulated the PTR pointer so that 1 data write area can be use to write
several scratchpad blocks for variable data storage assuming all blocks are equal
Simulates Nice and Clear
Code:
#picaxe 28x2
#no_data
#no_table

symbol temp =b6
symbol S_B = b7

symbol WD=b12




b5 = "," 

wd=0
b1=0

setfreq em32 

ptr=200

ABC:
	
 	 inc b1
 	bintoascii b1,b2,b3,b4 ; convert b1 to ascii  
  	  @ptr=b1   'dummy adc scratchpad block 200 - 344
	ptr=ptr+1
	@ptr=b5     'puts "," comma to seperate the data for excel to read
	ptr=ptr+1
 	if ptr = 344 then:b10=10:ptr=360:goto BCA:endif
	goto abc
	
	 
BCA:
	 
	 inc b10
	bintoascii b10,b2,b3,b4 ; convert b10 to ascii
	 @ptr=b10   ' dummy adc scratchpad block 360 - 504
  	ptr=ptr+1
	@ptr=b5
	ptr=ptr+1	
 	if ptr= 504 then:wd=0:goto main:endif 'Trigger for data write
	goto bca
	
main:
	
	if wd =0 then:ptr = 200:goto daat:endif ' Trigger PTR pointer manipulation 1st block 
	if wd =1 then: gosub Clr1:endif     'Triggers data dump to avoid overwriting errors
	if wd =2 then:ptr= 360: goto daat:endif  ' trigger for 2nd scratchpad block
 	if wd =3 then: gosub Clr2:endif  'reset 2nd block 
  	if wd =4 then:end:endif


daat:
	hsersetup B9600_32, %10  'This is wrong but editor will not accept correct command below 
	'hsersetup B9600_32, %1 ' commented out for simulation purposes
	pause 3000
	
	
init_vdrive3:
				'send Es until Vdrive3 responds correctly
 	hserout 0,("E",CR)
 	pause 50
	sertxd ("E requested ")
 	
 	gosub response
		
 	if S_B <> "E" then init_vdrive3   
	  
	sertxd ("bytes returned",#s_b)   
	pause 300

 	
	hserout 0,("OPW POS.CSV",CR)	 	 
	pause 300
	gosub response

	
	hserout 0,("wrf ",$00,$00,$00,$14,CR)
	hserout 0,("Col1,Col2,Col3,Col4",CR)
	hserout 0,("wrf ",0,0,0,228,CR)
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'1
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'2
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'3
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'4
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'5
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'6
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'7
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'8
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'9
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'10
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'11
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'12
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'13
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'14
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'15
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'16
	
 	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'17
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'18
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'19
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'20		
		
	hserout 0,($0D,$0A,CR)
	 
	 gosub response 
	 pause 500
	 hserout 0,("CLF POS.CSV",CR) 
	 sertxd ("File Closed")
	pause 300
	inc wd  ' used for triggering data dump
	
	goto main	 
 response:   ' Data transfer to USB
	 
	 get 0, s_b
	s_b="E" 'In for simulation perposes allows the data write to be seen in terminal window
	        'when simulating
	do
	get ptr,temp	
 	inc ptr	
	loop until temp <> CR
	
	hserptr = 0	
	 return 	
 	
Clr1:     'Reset 1st scratchpad data block
 	
 	ptr = 200 		
         do
	@ptr=0
	ptr=ptr+1
	if ptr =344 then:exit:endif
         loop 
         inc wd
         return
         
Clr2:     'Reset 2nd block   
	ptr = 360
	 do
	@ptr=0
	ptr=ptr+1
	if ptr =504 then:exit:endif
         loop 
         inc wd
         sertxd("safe to remove")
         return
The small area after the close file the bytes there can not get rid of them?

regards
john
 
Last edited:

grim_reaper

Senior Member
Code:
...
	hserout 0,("wrf ",$00,$00,$00,$14,CR)
	hserout 0,("Col1,Col2,Col3,Col4",CR)
	hserout 0,("wrf ",0,0,0,228,CR)
...		
	hserout 0,($0D,$0A,CR)
...
The small area after the close file the bytes there can not get rid of them?
John,

Can't tell you exactly what the problem is, but the lines in your code extracted above seem like a good place to start.

Cr is a 'shortcut keyword' for $0D. Lf is a 'shortcut keyword' for $0A. So what you have on that last line above is actually "Cr, Lf, Cr" !
Windows uses the combination CrLf to produce a new line, so you should (ideally) be writing "Cr, Lf" at the end of every CSV line.
(Personally, I'd scrap using $0D in favour of the CR - sometimes confusing to use both).

I think you'll have to do a bit of experimenting to get it to show what you want it to. But if you change ...$14,CR) to ...$14,CR,LF) on that first line, it'll give you a quick idea of whether I'm on the right track or not!

Grim
 

hippy

Technical Support
Staff member
There seems to be some confusion over VDRIVE command terminators and end of lines which need to be put in the CSV file being generated.

Commands to the VDRIVE should end with a single CR.

End of lines in a CSV or text file for Windows would normally end with CR, LF.

This is what is in a CSV file I saved from Excel -

Col1,Col2,Col3,Col4<CR><LF>
1,2,3,4<CR><LF>
5,6,7,8<CR><LF>

Dumped as 39 ($27) hex bytes ...

Code:
000000 : 43 6F 6C 31 2C 43 6F 6C 32 2C 43 6F 6C 33 2C 43   Col1,Col2,Col3,C
000010 : 6F 6C 34 0D 0A 31 2C 32 2C 33 2C 34 0D 0A 35 2C   ol4..1,2,3,4..5,
000020 : 36 2C 37 2C 38 0D 0A                              6,7,8..
I would suggest just starting with trying to generate that -

Code:
hserout 0, ( "OPW POS.CSV", CR )	 	 
pause 300
gosub response
hserout 0, ( "wrf ", $00,$00,$00,$27, CR )
pause 100
hserout 0, ( "Col1,Col2,Col3,Col4", CR, LF )
hserout 0, ( "1,2,3,4", CR, LF )
hserout 0, ( "5,6,7,8", CR, LF )
gosub response 
pause 500
hserout 0, ( "CLF POS.CSV", CR )
Get that working before going on to anything more complicated.
 

johnlong

Senior Member
Hi Hippy, Grim_reaper
Have sorted out the data overlapping and getting the following in excel
vdrive.jpg

The 2 data blocks from the dummy adc are know separated nicely
Did this by reducing the number of hserout lines and altering the bytes out command to 236
the only problem is that the first and last data points for each block is missing
This is due I have convinced myself is due to init vdrive SEND "E" this is incing the PTR pointer
by one so on return PTR will be 201 and 361 respectivly have tried using ptr=199 and ptr= 359
but get in excel the commas as numbers the data as charictors
also noticed that if I introduce ptr's not at 0,8,16 ie 7,15,23 when simulated ptr is not recognised
and it just carries on fill up the scratchpad.
Latest version that is producng the above excel results
Code:
#picaxe 28x2
#no_data
#no_table

symbol temp =b6
symbol S_B = b7
symbol p = b8
symbol WD=b12




b5 = "," 

wd=0
b1=0

setfreq em32 

ptr=200
b1=0
ABC:
	ptr=200
	b1=0 
	do
 	 inc b1
  	bintoascii b1,b2,b3,b4 ; convert b1 to ascii  
  	  @ptr=b1   'dummy adc scratchpad block 200 - 344
 	ptr=ptr+1
  	@ptr=b5     'puts "," comma to seperate the data for excel to read
	ptr=ptr+1
 	if ptr = 344 then:goto BCA:endif
	'goto abc
	
	 loop
BCA:
	ptr =360
	b10=10
	 do
	 inc b10
	bintoascii b10,b2,b3,b4 ; convert b10 to ascii
	 @ptr=b10   ' dummy adc scratchpad block 360 - 504
  	ptr=ptr+1
	@ptr=b5
	ptr=ptr+1	
 	if ptr= 504 then:wd=0:goto main:endif 'Trigger for data write
	'goto bca
	loop

main:
	
	if wd =0 then:ptr =200:goto daat:endif ' Trigger PTR pointer manipulation 1st block 
	if wd =1 then: gosub Clr1:endif     'Triggers data dump to avoid overwriting errors
	if wd =2 then:ptr= 360: goto daat:endif  ' trigger for 2nd scratchpad block
 	if wd =3 then: gosub Clr2:endif  'reset 2nd block 
   	if wd =4 then:end:endif


daat:
	'hsersetup B9600_32, %10  'This is wrong but editor will not accept correct command below 
	hsersetup B9600_32, %1 ' commented out for simulation purposes
	pause 3000
	
	

init_vdrive3:				'send Es until Vdrive3 responds correctly
  	hserout 0,("E",CR) 
 	pause 300
	sertxd ("E requested ")
 	
 	gosub response
		  
 	if S_B <> "E" then init_vdrive3     
	   
	sertxd ("bytes returned",#s_b)   
	pause 300
	
 

 	
	hserout 0,("OPW DAT.CSV",CR)	 	 
	pause 300
	gosub response

	
	hserout 0,("wrf ",$00,$00,$00,$14,CR)
	hserout 0,("Col1,Col2,Col3,Col4",CR)
	pause 300
	hserout 0,("wrf ",0,0,0,236,CR)
	pause 300
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'1
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'2
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'3
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'4
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'5
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'6
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'7
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'8
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'9
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'10
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'11
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'12
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'13
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'14
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'15
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'16
	
 	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'17
	
	hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'18
	
	hserout 0,($00,$00,$00,$00,$00,$00,$0a,$0d,cr)'19 Added this to form a break between data
	
	'hserout 0,(#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,#@ptrinc,@ptrinc,cr)'20		
		
	hserout 0,($00,$00,$0D,$0A,CR)' To tell drive data write ended
	 
	 gosub response 
	 pause 500
	 hserout 0,("CLF DAT.CSV",CR) 
	 sertxd ("File Closed")
	pause 300
	inc wd  ' used for triggering data dump 
	
	goto main
	
	 
 response:   ' Data transfer to USB
	 
	get 0, s_b
	do
	get ptr,temp	
 	inc ptr	
	loop until temp <> CR	
	hserptr = 0
	
	 return 	
 	
Clr1:     'Reset 1st scratchpad data block
 	
 	ptr = 200 		
         do
	@ptr=0
	ptr=ptr+1
	if ptr =345 then:exit:endif
         loop 
         inc wd
         return
         
Clr2:     'Reset 2nd block   
	ptr = 360
	 do
	@ptr=0
	ptr=ptr+1
	if ptr =505 then:exit:endif
         loop 
         inc wd
         sertxd("safe to remove")
         return
just the first and last byte problem to get around

regards
john
 

hippy

Technical Support
Staff member
After you issue your "OPW DAT.CSV" you call "response" which alters 'ptr'. It won't therefore be pointing to where it should be pointing when you come to output your fist "hserout 0,(#@ptrinc, ..."
 

johnlong

Senior Member
Hi Hippy
It came to me in the bath if ptr after the gosub response to obtain the "E" is inc'ed by1
subtract it so added ptr=ptr-1 in the gosub and got the following
vdrive3.jpg

As you can see data point 1 =1 as should be data point 1 (block2) = 11 the last points 72 and (block2) 82
put in the LF's as sugested at the end of each line for the data write it stopped it from writing the data
only got the collum headings
Code:
 response:   ' Data transfer to USB
	 
	get 0, s_b
	do
	get ptr,temp	
 	inc ptr	
	loop until temp <> CR	
	hserptr = 0
	ptr=ptr-1
	 return
Have noticed that in the excel clipboard part of the picaxes code is writen at one point
all the code was there a command to stop it from doing this or is it the nature of the beast
next step is the time stamp
kind
regards
john
 

hippy

Technical Support
Staff member
Code:
	do
	get ptr,temp	
 	inc ptr	
	loop until temp <> CR	
	hserptr = 0
	ptr=ptr-1
	 return
There can be multiple inc ptr while waiting for a CR, but only one ptr=ptr-1

Also, this is reading data that background receive has written into scratchpad, which along with -

if wd =0 then:ptr = 200:goto daat:endif

before calling 'response' suggests that is actually reading the data you put there rather than data received from the VDRIVE.

There seems to be multiple issues but the code is too complicated to analyse exactly what is happening without having to put a lot effort in to do that.
 
Top