Monday, December 1, 2008

USB Logger using a Vdrive2


I built a simple Data logger using a Vinculum Vdrive2. The logger records two sources of voltages within 0 to 5 volts. An 8 bit entry every second is recorded in a USB stick as a .csv file, suitable for use in Excel.

When I first got my Vdrive2 module, I built an RS232 interface to allow sending commands and viewing the responses with Hyperterm. My schematic of the interface can be found here.

You can update the flash ROM on the module by going to FTDI's website and downloading a FTD file to the memory stick. By changing the name to ftrfb.ftd, the Vdrive2 will detect the file and upgrade itself when powered up. Once this is done, remove the file from the stick before starting again. Otherwise it will try re-flashing the ROM again. When I got the module, it had a pretty old version in it, version 2.08.

Each entry into the USB stick is as follows:

A time stamped number of YYMMDDHHMM,ADC value1,ADC value 2,cr

2 hours worth or 7200 entries are placed in a file with the following date stamp.

YYMMDDHH.csv

How the logger works.

A debug port from the logger allows one to follow the operation in realtime with a PC running Hyperterminal.

The logger uses a DS1307 real time clock for date information. To set the date, a small file is placed on the USB stick. You can use notepad to make this little file. Name it "date.txt"

Using notepad, format the date as follows:

yy:mm:dd:hh:mm

As an example, the time is 2008 on November 24th at 2 pm. 24 hour mode is used. The sequence would be:

08:11:24:14:00

When starting up, the little file is read and the date is set. Then the file is renamed to "ndate.txt" to prevent changing the time again. To reset the time, change the file to a new date and rename back to "date.txt". This makes setting the RTC easy.

To prevent loss of data while a file is open, a backup supply is turned on. An opto coupler is used to detect when to start and stop logging. Power to the opto comes from the main source of power. When the power drops off, the file is first closed and backup power is disconnected when done.

My first prototype was built on perfboard with plans to make PC boards in the future (if enough interest is generated). The pic microcontroller is a 16F688 and programmed using Pic Pro Basic. I used Microcode Studio as an IDE and programmed the Pic using the PICkit 1. To do ICSP, I made a little adaptor to bring out the connections from the PICkit 1 to the project. USB stick used with this project was a Kingston Data Traveler DTI/256.

I'm not the best in writing clean programs, but it works. Any suggestion on improvement is welcomed. One idea for improvement is to start getting it to delete the oldest files when the stick gets full. That would require making the memory into a circular buffer. Just haven't figured the file management scheme yet.

Schematic: Vdrive2 Project

Code (8 bit version):
Program "1_PerSec.bas"

HEX file "1_PERSEC.HEX"

date.txt

Typical file "08120117.csv"

10 bit version

program

hex file

4 comments:

servisni manual said...

Hello!
I have made datalogger using your project. I have some questions. Where is modedefs.bas? My compiler is trying to locate this file. Since your program have been made on picbasic pro, is there any other compiler to handle this program?
Thank you milion times for answers.
greetings from Europe

Ilan said...

hi
a am trying to connect my vdrive2 to the hyper terminal were do i download the firmware from ?

yash said...

WE are using VDRIVE2 with Firmware Ver 03.66VDAPF.We are interfacing it with our USB device which is a fingerprint sensor Morphosmart MSO CBM.Details of the Slave Device (fingerprint sensor):
- Communication Class Device in accordance with USB Device Class Specifications version 2.0
- The Device use full speed transfer rate of 12Mbits/s
- Compatible with USB 1.1 and USB 2.0 hosts and hubs
WE tested our sensor with a GET DESCRIPTOR string using the command mode. We are getting desired response when we send the 'DRD' command. But, on our application we don't want the command interface. We want to send/receive data transparently (i.e. w/o using any commands).
The GET DESCRIPTOR string is a data that we send to the sensor , after which the sensor replies:
SYNCïÿìName: CBM
Mobi5 Serial Number: 0944

This is our GET DESCRIPTOR string (18 Bytes):
$53$59$4E$43$04$00$00$00$FB$FF$FF$FF$05$01$00$2F$45$4E
In the above string $53 is a hex value, so we are sending 18 bytes written above in HEX format. We send these values using a Windows XP PC serial PORT. On the PC we are using Terminal v1.9b software (Bray++) and we send hex data using the transmit macros field in Terminal software.
Now while testing, we used the device in command mode initially. Selected the device SC 1 and then pulled the DATAREQ line (pin 36 of VNC1L) low (0V), after that the DATAACK line also became low. But, now if we send the GET DESCRIPTOR string then we DON'T get the desired response. Rather we don't get any response from the device. Thus, we fail to interface the sensor in data mode.

But the same can be done successfully using command mode only and the following is the device log:
Command mode successful trial log:
Commands:
ipa
qp2
qd 0
qd 1
sc 1
dsd 18
%%%%%%%% Comment: send the GET DESCRIPTOR string (18 Bytes) using the transmit macros field in Terminal software. %%%%%%%%%%%%
drd

Responses:
D:\>
$10 $00
D:\>
$01 $20 $81 $10 $00 $00 $00 $10 $01 $02 $00 $02 $02 $01 $9B $07 $47 $00 $00 $01 $01 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00
D:\>
$01 $20 $83 $40 $02 $40 $03 $00 $01 $02 $01 $0A $00 $00 $9B $07 $47 $00 $00 $01 $01 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00 $00
D:\>
$40
SYNCïÿìName: CBM
Mobi5 Serial Number: 0944D:\>

Our objective is to interface without using any commands after we select the device (i.e. after sc 1). We want to send our data (for eg. the GET DESCRIPTOR string ) directly to the sensor and get the response from the sensor without using any commands.

yash said...

We have also tried the VCDC firmware and failed in a similar manner i.e. we didn't get any reply from the sensor.