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
have also tried variations on the following
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
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)
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
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
-
547.8 KB Views: 30