VDIP1 USB Host Controller
March 27, 2010
I got my VDIP1 USB Host controller from Saelig today and was able to get it hooked up and reading a Flash drive in a couple hours. Because the Arduino only has one TX / RX serial pin if you connect it using them you cannot communicate with the computer over the built in USB UART on the Arduino. To get around this limitation there are a number of libraries that allow serial communication over non-serial pins.
I chose the NewSoftSerial library to give access to the VDIP1. The first attempt was to use the AFSoftLibrary and it just did not work properly causing some strange looping of the Setup() method. After switching to the NewSoftSerial library everything started working and I had no trouble doing a DIR and creating a new file on the flash drive. I am posting an early version of the sketch just so i can get a good example and a picture / schematic out so expect updates later. Keep reading for the schema, pic and sketch.
Update: I changed the sketch and schematic / pic to include the RTS / CTS flow control.
Click here to see the picture and sketch.
Picture of the wiring I used with the sketch.
I did a little cleaning of the wiring and put it on a proto-shield.
Protoshield new wiring
The sketch allows sending of any command via the Serial monitor for doing testing. Some common commands would be “~DIR~ ~CD DIRNAME~ ~CD ..~” See the VDIP1 command list for the full file operations.
// RX TX
#include
NewSoftSerial usb(2, 3);
int RTSPin = 5;
int CTSPin = 4;
void setup() {
pinMode(RTSPin, INPUT);
pinMode(CTSPin, OUTPUT);
usb.begin(9600);
//usb.begin(57600); // You can modify the default speed of the VDIP1 with firmware updates to be up to 57600 through newSoftSerial.
digitalWrite(CTSPin, LOW); // Set the CTS to low and keep it there.
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
Serial.print("Starting");
usb.print("IPA"); // Set to ascii mode.
usb.print(13, BYTE);
}
char usbRx;
byte charIn;
void SendToUsb(char val) {
while (digitalRead(RTSPin) == HIGH) { }
usb.print(val);
digitalWrite(CTSPin, LOW);
}
void SendToUsbTermCmd() {
while (digitalRead(RTSPin) == HIGH) { }
usb.print(13, BYTE);
digitalWrite(CTSPin, LOW);
}
void loop() {
// Disable the sending on the USB device if you have filled more than 50% of your buffer (64 bytes by default)
if (usb.available() > 32) {
digitalWrite(CTSPin, HIGH);
} else {
digitalWrite(CTSPin, LOW);
}
if (usb.available() > 0) { // read the incoming byte
usbRx = usb.read();
if (usbRx == 0x0D) {
Serial.println();
} else {
Serial.print(usbRx);
}
}
if (Serial.available() > 0) { // read the incoming byte
if (Serial.read() == (byte)'~') {
charIn = 0;
while (charIn != (byte)'~') { // wait for header byte again
if (Serial.available() > 0) {
charIn = Serial.read();
Serial.print(charIn, HEX);
if (charIn == (byte)'~') {
Serial.println("breaking");
break;
}
SendToUsb(charIn);
}
}
SendToUsbTermCmd();
}
}
}
Thanks a lot for this post. I have worked 3full days to setup communication, sync, and behavior for my VDIP1. This post helps complete my program.
Hi,
Can you please teach me on how to use this on a RFID reader with usb connection? I would like to interface it with Arduino.
Thanks in advance.
Regards,
Lee
You would need to know how your RFID reader communicates and likely set it in direct mode. There is likely a protocol they use when reading the RFIDs. Do you have the datasheet for it?
http://www.ananiahelectronics.com/RF9315R-u.htm
The above website is all i can get. Not really a datasheet, but they never provide anymore information.
I just wan to read the RSSI value from this device. Can the VDIP1 do that?
This appears to be a simple serial -> usb device. For this you would start the VDIP in data mode and it should just start feeding you data as it gets it in. Loop back the serial to your microcontroller and display the results of what it receives in the VDIP and you may get your results.
Hi,
I would like to ask the “VDIP1 command list” , where can I find the full list of it?
Thanks in advance!
Regards,
Lee
The full command list is available in the Vinculum Firmware document at: http://www.ftdichip.com/Firmware/Precompiled/UM_VinculumFirmware_V205.pdf
/***************************************************************************/
#define DSR 5
#define DTR 4
void setup() {
// initialize both serial ports:
pinMode(DTR, OUTPUT);
pinMode(DSR, INPUT);
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
digitalWrite(DSR, LOW);
// read from port 1, send to port 0:
if (Serial1.available()) {
int inByte = Serial1.read();
Serial.println(inByte, BYTE);
}
}
/***************************************************************************/
Above is my arduino code for reading the receiver, according to the data sheet, I just need to assert DSR pin(pin 12) to low to enter DATA mode.
I’ve asserted DSR to LOW. But it returns me nothing.
Is there anything else i should do to enter DATA mode? Btw, I’m using the same USB host model as you recommended.
Thank you for the help these days!
Regards,
Lee
Is it because the driver of the usb converter restrict me from accessing data unless installed? (Like what happened to a computer, driver installed only the port is detected)
If so, any solution to it?
Regards,
Lee