USB Disk/SD Card R/W Controller with RS232 User s Guide 2004-2010 Sure Electronics Inc. DB-DP11118& DB-DP11119_Ver1.1
Table of Contents USB DISK/SD CARD R/W CONTROLLER WITH RS232 USER S GUIDE Chapter 1. Overview...1 1.1 Overview... 1 1.2 Features... 2 1.3 Applications... 2 Chapter 2. Hardware Detail...3 2.1 USB Disk - RS232... 3 2.2 SD Card - RS232... 4 Chapter 3. Communication Protocols...6 Chapter 4. Function Code...7 4.1 Function Code... 7 4.2 System Status Inquiry... 7 4.3 Time Inquiry and Setting... 8 4.4 Date Inquiry and Setting... 8 4.5 UART Baud Rate Inquiry and Setting... 8 4.6 Directory Creation... 8 4.7 Current Directory Inquiry and Modification... 9 4.8 View Directory... 9 4.9 Delete Directory... 9 4.10 Open File... 9 4.11 Close File... 10 4.12 Write to File... 10 4.13 Read File...11 4.14 Move File Pointer...11 4.15 Delete File... 12 4.16 Timely Log Data... 12 4.17 View and Set The Flag of Stopping Writing to File... 13 4.18 How to Use Command... 13 4.19 Notes... 13 Chapter 5. Mechanical Drawing...14 Chapter 6. Contact Us...16 2004-2010 Sure Electronics Inc. DB-DP11118& DB-DP11119_Ver1.1_Page i
USB Disk/SD Card R/W Controller with RS232 NOTES: Product Version : Ver 1.0 Document Version : Ver 1.1 DB-DP11118& DB-DP11119_Ver1.1_Page ii 2004-2010 Sure Electronics Inc
Chapter 1. Overview USB DISK/SD CARD R/W CONTROLLER WITH RS232 USER S GUIDE 1.1 Overview Thanks for using USB Disk or SD card R/W controllers by Sure Electronics. This item is a portable, compact and high performance USB Flash Disk or SD card W/R controller with aluminium alloy housing. With RS232 port provided, you can easily do operations to USB flash disks or SD card, such as view USB flash disk s or SD card s information, write to or read files, delete folders, modify the directory, etc., by writing commands on PC via UART communication software. Set by corresponding commands, this controller can also be used as a data logger for logging data at a specified period in many applications, such as weather station recording, soil moisture level recording and so on. It needs to be powered by supply from 9V to 12V through a 6.20mm dia power port. In addition, a CR2032 lithium cell provided in the accessory needs to be installed on the PCB to ensure the system clock s normal working after power down. TABLE 1-1 R/W CONTROLLER SERIES Product No. Product Name DB-DP11118 USB Flash Disk W/R Controller with RS232 DB-Dp11119 SD Card R/W Controller with RS232 FIGURE 1-1 OVERVIEW OF DB-DP11118 2004-2010 Sure Electronics Inc. DB-DP11118& DB-DP11119_Ver1.1_Page 1
USB Disk/SD Card R/W Controller with RS232 FIGURE 1-2 OVERVIEW OF DB-DP11119 FIGURE 1-3 ACCESSORIES 1.2 Features Support mass storage protocols and all non-encrypted USB disk and SD card Support Bulk-Only transfer protocol Support FAT12, FAT16 and FAT32 file management system Provide RS232 level interface and internal TTL level interface The range of standard baud rate: 4800bps to 115200bps; default baud rate after power on: 9600bps All interfaces are ESD-safe ensuring stable performance Sample code for PIC24 Storage Demo Board (DB-DP11122) is provided 1.3 Applications Weather station recording Soil moisture level recording Log GPS information DB-DP11118& DB-DP11119_Ver1.1_Page 2 2004-2010 Sure Electronics Inc
Chapter 2. Hardware Detail USB DISK/SD CARD R/W CONTROLLER WITH RS232 USER S GUIDE 2.1 USB Disk - RS232 1. Power supply Input voltage range DC: 9V to 12V Polarity: positive (internal) and negative (external) 2. USB port: USB-A port (as shown in figure 2-2) 3. RS232 port: DB-9 female port FIGURE 2-1 PORTS TABLE 2-1 PINS OF DB-9 FEMALE PORT Pin Name Pin Name 1 NC 6 NC 2 TXD 7 NC 3 RXD 8 NC 4 NC 9 NC 5 GND - - 4. LED indicators: FIGURE 2-2 LED INDICATORS 2004-2010 Sure Electronics Inc. DB-DP11118& DB-DP11119_Ver1.1_Page 3
USB Disk/SD Card R/W Controller with RS232 TABLE 2-2 LED INDICATORS LED Mark Color Status Description Power Green ON Normal power supply OFF No power Active Yellow ON USB disk inserted OFF USB disk not inserted Status Red ON Files are opened and USB disk can t be pulled out OFF Files are closed and USB disk can be pulled out 2.2 SD Card - RS232 1. Power Supply: Input voltage range DC: 9 to 12V Polarity: positive (internal) and negative (external) 2. SD card interface: Standard SD card socket 3. RS232 port: DB-9 female port FIGURE 2-3 PORTS TABLE 2-3 PINS OF DB-9 FEMALE PORT Pin Name Pin Name 1 NC 6 NC 2 TXD 7 NC 3 RXD 8 NC 4 NC 9 NC 5 GND - - 4. LED indicators: DB-DP11118& DB-DP11119_Ver1.1_Page 4 2004-2010 Sure Electronics Inc
Hardware Detail FIGURE 2-4 LED INDICATORS TABLE 2-4 LED INDICATORS LED Mark Color Status Description Power Green ON Normal power supply OFF No power Active Yellow ON SD card inserted OFF SD card not inserted Status Red ON Files are opened and SD card can t be pulled out OFF Files are closed and SD card can be pulled out 2004-2010 Sure Electronics Inc. DB-DP11118& DB-DP11119_Ver1.1_Page 5
USB DISK/SD CARD R/W CONTROLLER WITH RS232 USER S GUIDE Chapter 3. Communication Protocols MCU communicates with the controller via RS232 port. A simple transfer protocol as follows is developed to make sure the reliable data transmission. MCU here is used as the master device and the controller as the slave device. Data transmission between the master device and the slave device is in a way of command string. The master device sends request command strings and the slave device returns response strings. TABLE 3-1 SERIAL PORT PARAMETERS Baud Rate Data Bit Stop Bit Parity Flow Control 4800 8 1 No No 9600 8 1 No No 14400 8 1 No No 19200 8 1 No No 38400 8 1 No No 56000 8 1 No No 57600 8 1 No No 115200. 8 1 No No DB-DP11118& DB-DP11119_Ver1.1_Page 6 2004-2010 Sure Electronics Inc.
Chapter 4. Function Code USB DISK/SD CARD R/W CONTROLLER WITH RS232 USER S GUIDE 4.1 Function Code TABLE 4-1 FUNCTION CODE Operation Name Command Description Get the relative system information, such as System Status UART baud rate, date, time, status of USB disk STATUS Inquiry or SD card, the number of files opened, the version of firmware and so on Time Inquiry and View the current system time; modify the current TIME Setting system time and save it into EEPROM Date Inquiry and View the current system date; set the current DATE Setting system date and save it into EEPROM UART Baud Rate View UART baud rate; set UART baud rate and BAUDRATE Inquiry and Setting save it into EEPROM Directory Creation MD Create new directory in USB disk or SD card Current Directory View or modify the current directory in USB disk Inquiry and CD or SD card Modification Directory Inquiry DIR View folders and files under the specified directory in USB disk or SD card Delete Directory RD Delete specified folders in USB disk or SD card Open File FOPEN Open the specified file in USB disk or SD card Close File FCLOSE Close the opened file in USB disk or SD card Write to File FWRITE Write to the opened file in USB disk or SD card Read File FREAD Read the opened file in USB disk or SD card Move File Pointer FSEEK Read or move the position of file pointer in the opened file Delete File FDEL Delete the specified files in USB disk or SD card Timely Data Logging LOGFILE Automatically log data from UART port at specified time View and Set the If there s STOPFLAG, stop FWRITE or LOGFILE Flag of Stopping STOPFLAG and view, set STOPFLAG Writing to File How to Use Command HELP Basic instructions for using each command 4.2 System Status Inquiry Command: STATUS Current baudrate: 4800/9600/14400/19200/38400/56000/57600/115200 2004-2010 Sure Electronics Inc. DB-DP11118& DB-DP11119_Ver1.1_Page 7
USB Disk/SD Card R/W Controller with RS232 Current date and time: year/month/day/hour/minute/second (Ex:2009-7-13 12:05:39) USB disk or SD card exists or not If USB disk or SD card exists named Sure Electronics, it will return Media name: Sure Electronics. If USB disk or SD card doesn t exist, it will return No media present. File opened number: 0/1 Version: 1.0 4.3 Time Inquiry and Setting 1. Inquiry Command: TIME Current time: hh:mm:ss (Ex: 22:15:59) 2. Setting Command: TIME [hh:mm:ss] If command is correct, it will return Success: Set time successfully. If command isn t correct, it will return Invalid time specified. Legal time is from 00:00:00 to 23:59:59. 4.4 Date Inquiry and Setting 1. Inquiry Command: DATE Current date: yyyy-mm-dd (Ex: 2009-7-13) 2. Setting Command: DATE [yyyy-mm-dd] If command is correct, it will return Success: Set date successfully. If command isn t correct, it will return Error: Invalid date specified. Legal date is from 2000-01-01 to 2099-12-31. 4.5 UART Baud Rate Inquiry and Setting 1. Inquiry Command: BAUDRATE If command is correct, it will return Current baudrate: 4800/9600/14400/19200/38400/56000/57600/115200 (one of the values). If command isn t correct, it will return Warning: BAUDRATE is illegal. 2. Setting Command: BAUDRATE [4800/9600/14400/19200/38400/56000/57600/115200] (one of the values). If command is correct, it will return Success: Set baudrate successfully. If command isn t correct, it will return Error: Invalid baudrate specified. Legal baudrate is 4800, 9600, 14400, 19200, 38400, 56000, 57600, 115200. 4.6 Directory Creation Command: MD [\path\name] If command is correct, it will return Success: Make directory successfully. DB-DP11118& DB-DP11119_Ver1.1_Page 8 2004-2010 Sure Electronics Inc
Function Code If USB disk or SD card doesn t exist or command isn t correct, it may return one of the following results: Warning: No media present. Warning: Parameter required. Warning: The same directory has existed. Warning: The file with the same name has existed. Warning: Illegal path or directory name. Error: Make directory unsuccessfully. 4.7 Current Directory Inquiry and Modification 1. Inquiry Command: CD If command is correct, it will return the current directory. 2. Modification Command: CD [\path\name] If command is correct, it will turn to the directory [\path\name]. It may return Error: The system cannot find the path specified. 4.8 View Directory Command: DIR [\path\name] If command is correct, it will return the information of folders and files under [\path\name]. If the directory is abnormal, it will return Error: DIR fails. If there re no folders or files, it will return Warning: No files or directories. 4.9 Delete Directory Command: RD [\path\name] If command is correct, it will return Success: Remove directory successfully. If command doesn t include parameters, it will return Warning: Parameter required. If the directory to be deleted is abnormal, it will return Error: Remove directory unsuccessfully. 4.10 Open File Command: FOPEN [\path\name] If command is correct, it will return Success: Open File Successfully. If USB disk or SD card doesn t exist or command isn t correct, it may return one of the following results: Warning: No media present. 2004-2010 Sure Electronics Inc. DB-DP11118& DB-DP11119_Ver1.1_Page 9
USB Disk/SD Card R/W Controller with RS232 Warning: Parameter required. Warning: You only cannot open more than one file. Warning: The directory with the same name has existed. Error: Open file unsuccessfully. 4.11 Close File Command: FCLOSE If command is correct, it will return Success: Close file successfully. If there re no files, it will return Warning: No file has been opened. If files can t be closed, it will return Error: Close file unsuccessfully. 4.12 Write to File 1. Command written at the beginning of the file: FWRITE SET If command is correct, it will return nothing. If no file is opened, it will return Warning: No file has been opened. Can not use FWRITE command. If there re parameters included in command, it will return Error: No parameter required. If there re illegal parameters included in command, it will return Warning: Only support FWRITE from SET, CUR or END(default). If it fails to write to files, it will return Error: Write file unsuccessfully. 2. Command written at the current position: FWRITE CUR If command is correct, it will return nothing. If no file is opened, it will return Warning: No file has been opened. Can not use FWRITE command. If there re parameters included in command, it will return Error: No parameter required. If there re illegal parameters included in command, it will return Warning: Only support FWRITE from SET, CUR or END(default). If it fails write to files, it will return Error: Write file unsuccessfully. 3. Command written at the end of a file: FWRITE END (default). If command is correct, it will return nothing. If no file is opened, it will return Warning: No file has been opened. Can not use FWRITE command. If there re parameters included in command, it will return Error: No parameter required. If there re illegal parameters included in command, it will return Warning: Only support FWRITE from SET, CUR or END(default). DB-DP11118& DB-DP11119_Ver1.1_Page 10 2004-2010 Sure Electronics Inc
Function Code If it fails write to files, it will return Error: Write file unsuccessfully. 4.13 Read File Command: FREAD [place] [length] If command is correct, it will return data in a required length. If no file is opened, it will return Warning: No file has been opened. Can not use FREAD command. If command doesn t include parameters, it will return Warning: Parameter required. If the position from which the content is read is wrong, it will return Warning: Only support FREAD from SET or CUR(default). If the length is not between 0x00000001 and 0xFFFFFFFF, it will return Error: FREAD length must be between 0x00000001 ~ 0xFFFFFFFF. If the file can t be read from the beginning, it will return Error: There is something wrong with the file. Can not do FREAD from SET. If the file can t be read from the ending, it will return Warning: The file has reached the end. If the length to be read exceeds the file s size, it will return Warning: FREAD length is past the file's size. We will just read to the file's end. If the file can t be read, it will return Error: Read file unsuccessfully. 4.14 Move File Pointer 1. Inquiry Command: FSEEK If command is correct, it will return Success: Your current position in the file is 0xXX. If no file is opened, it will return Warning: No file has been opened. Can not use FSEEK command. 2. Move Pointer Command: FSEEK [place] [length] If command is correct, it will return Success: Seek file successfully. Your current position in the file is 0xXX. If no file is opened, it will return Warning: No file has been opened. Can not use FREAD command. If the place chosen is wrong, it will return Error: You only can choose the seeking place from SET, CUR or END. If the command doesn t include parameter Length, it will return Error: Length required. If the length of fseek isn t between 0x00000001 and 0xFFFFFFFF, it will return Error: Offset must be between 0x00000000 ~ 0xFFFFFFFF. If fseek is wrong, it will return Error: Seek file unsuccessfully. 2004-2010 Sure Electronics Inc. DB-DP11118& DB-DP11119_Ver1.1_Page 11
USB Disk/SD Card R/W Controller with RS232 4.15 Delete File Command: FDEL [\path\name] If command is correct, it will return Success: Remove file successfully. If the command doesn t include parameters, it will return Warning: Parameter required. If the file to be deleted is write-protected, it will return Warning: Write Protected! Can not remove this file. If the file to be deleted can t be found, it will return Error: Can not find the file. If the name of the file to be deleted, it will return Error: Invalid filename. If the file to be deleted is opened, it will return Error: This file has been opened, please close it firstly. If what to be deleted is a folder, it will return Error: This is a directory. Please use RD command to remove it. If the file can t be deleted, it will return Error: Remove file fails. 4.16 Timely Log Data 1. Command for timely logging data at a specified period: LOGFILE [TS:hh:mm] [TE:hh:mm] [\path\name] If command is correct, it will return Success: LOGFILE command has been set successfully. If the command doesn t include parameters, it will return Warning: Parameter required. If the starting time is incorrect, it will return Warning: Logfile's start time is required, which should be between TS:00:00 to TS:23:59. If the ending time is incorrect, it will return Warning: Logfile's end Time is required, which should be between TE:00:00 to TE:23:59. If the starting time is later than the ending time or the starting time and the ending time are not in the same day, it will return Warning: Logfile's Start Time and End Time must be in the same day. And the End Time must be after the Start Time. If the place where the file is saved is not specified, it will return Warning: The file name stored data is required. If the file path or the file name is incorrect, it will return Warning: Illegal log file path or file name. 2. Command for logging data all the day: LOGFILE [\path\name] If command is correct, it will return Success: LOGFILE command has been set successfully. If the command doesn t include parameters, it will return Warning: Parameter required. If the place where the file is saved is not specified, it will return Warning: The file name stored data is required. If the file path or the file name is incorrect, it will return Warning: Illegal log file path or file name. DB-DP11118& DB-DP11119_Ver1.1_Page 12 2004-2010 Sure Electronics Inc
4.17 View and Set The Flag of Stopping Writing to File 1. Inquiry Command: STOPFLAG If command is correct, it will return Current STOPFLAG:. If command is incorrect, it will return Warning: STOPFLAG is illegal. 2. Set Command: STOPFLAG [sign] Function Code If command is correct, it will return Success: Set STOPFLAG successfully. If the length of the parameter exceeds 15 characters, it will return Warning: The maximal length of STOPFLAG is 15 characters. If the setting fails, it will return Error: Set STOPFLAG unsuccessfully. 4.18 How to Use Command Command: HELP or? It will return the basic instructions for using each command. 4.19 Notes SET: the beginning of a file CUR: the current position in a file END: the ending of a file Note: Only uppercase letters are supported. 2004-2010 Sure Electronics Inc. DB-DP11118& DB-DP11119_Ver1.1_Page 13
USB DISK/SD CARD R/W CONTROLLER WITH RS232 USER S GUIDE Chapter 5. Mechanical Drawing FIGURE 6-1 DIMENSION OF THE FRONT PANEL (DB-DP11118) FIGURE 6-2 DIMENSION OF THE FRONT PANEL (DB-DP11119) DB-DP11118& DB-DP11119_Ver1.1_Page 14 2004-2010 Sure Electronics Inc.
USB Disk/SD Card R/W Controller with RS232 FIGURE 6-3 DIMENSION OF THE BACK PANEL FIGURE 6-4 DIMENSION OF THE SIDE PANEL (DB-DP11119) 2004-2010 Sure Electronics Inc. DB-DP11118& DB-DP11119_Ver1.1_Page 15
Chapter 6. Contact Us USB DISK/SD CARD R/W CONTROLLER WITH RS232 USER S GUIDE Sure Electronics Co., Ltd. East zone, 3F, Building 6 Jingang Technology Innovation Center No.108 Ganjiabian Rd (ZIP: 210000) Qixia District Nanjing P.R.China Tel: +86-25-68154800-860 Fax: +86-25-68154891-832 Website: www.sure-electronics.com Email: customerservice@sure-electronics.com DB-DP11118& DB-DP11119_Ver1.1_Page 16 2004-2010 Sure Electronics Inc.