View previous topic :: View next topic |
Author |
Message |
mxkid
Joined: 08 Apr 2008 Posts: 16
|
VDrive2 via UART |
Posted: Wed Sep 01, 2010 12:28 pm |
|
|
Hi all,
I have recently been given a Vdrive2 to connect to my PICDEM 2 board. I already use the temperature sensor on the board and save the data to the I2C chip and download it via RS232. I would like to save the data onto a USB memory stick via the Vdrive2 and would like to connect it to a UART interface. Do I need to use an RS232 chip or can it be connected directly? I’m sure that it must be quite simple – using ‘printf’ for example but I’m not sure if you need to toggle the CTS and RTS pins. Any examples or help would be appreciated – I’m sure once it ‘clicks’ in my head I will have it up and running in no time!
Thanks! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
mxkid
Joined: 08 Apr 2008 Posts: 16
|
|
Posted: Thu Sep 02, 2010 3:52 pm |
|
|
Thanks for the information.
I've had a read and it seems fairly simple with the commands given. However, I am still unable to get it working. Here's my code:
Code: |
#include <16f876a.h>
#fuses hs,nowdt,noprotect,nolvp
#use delay(clock=4000000) // 4mhz clock
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
#include "flex_lcd.c" // used to drive the lcd display
int data = 42;
void main()
{
lcd_init(); // get lcd ready
lcd_gotoxy(1,1);
printf(lcd_putc, "vdrive2 test");
delay_ms(8000);
//putc('E'); // send echo
//putc(0x0d); // carriage return
// create file and open it
printf("OPW test.txt");
//putc(0x0d); // carriage return
// delay_ms(500);
// write to file
printf("WRF ");
putc(0x00); // number of byted of data
putc(0x00);
putc(0x00);
putc(0x02); // two bytes (1) data (2) carriage return
putc(0x0d); // carriage return
printf("%u\t", data); // send data to the text.txt file
putc(0x0d); // carriage return
// close the file
printf("CLF test.txt");
putc(0x0d); // carriage return
lcd_putc("\f"); // clear after the display screen
lcd_gotoxy(1,1);
printf(lcd_putc, "test complete");
}
|
I think it could be down to a hardware problem. I am connecting the CTS# and RTS# lines together as the led flashes from red to green three times and then goes out until I plug a memory stick in. It then goes green so I can assume that it's healthy (the memory stick led comes on as well). I have looked for information regarding these pins but can't find a great deal on them.
Any more help would be great. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
mxkid
Joined: 08 Apr 2008 Posts: 16
|
|
Posted: Fri Sep 03, 2010 6:57 am |
|
|
Hi,
I've had a look on the web and it seems that most people tie the RTS and CTS lines together.
I'm still having no luck creating and writing the file though. To be honest it seems that a lot of people have the same trouble. My code looks ok and I've tried putting delays in between sending the vdrive data but still no luck. I've also tried creating a file on the usb and just saving data to that. No joy.
The led on the front flashs red and green for about 2 seconds and go off until I plug a memory stick in. It then goes green and turns red when it's talking to the usb stick (it just happens at the start sometimes). It then goes off when I take the stick out so I'm sure the device is working correctly.
Anymore ideas I can try? I might get a scope on the tx and rx lines to see whats happening but apart from that I'm out of ideas.
Cheers! |
|
|
mxkid
Joined: 08 Apr 2008 Posts: 16
|
|
Posted: Wed Sep 22, 2010 10:35 am |
|
|
Hi,
Just to complete the thread I've got it working. It was down to handshaking - I downloaded "VncFwMod.exe" from the Vinculum website and created a new ftd file that had the rts and cts lines disabled.
Got to say there's not much out there regarding these devices - I intend to reuse the rts and cts lines in time but it was a good way to prove out the device.
Thanks for your help. |
|
|
paolope
Joined: 29 May 2009 Posts: 7
|
|
Posted: Mon Feb 20, 2012 4:09 am |
|
|
I became crazy with this unit (VNC2), but then I discovered:
1) no puts()! because adds 0x0a and this damn unit accepts the command, interprests a second one and answers Bad command (or uses 0x0a as data)
2) no \r\n in printf(), but only \r
3) always use fixed formats, that is NO %f YES %6.1f otherwise the char count sooner or later will fail
4) others recommend to monitor RTS which could go high if input buffer is getting full
at the moment I do not know if there are some other 'hidden' surprises
paolo |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Mon Feb 20, 2012 7:11 am |
|
|
I use both the V1 and the V2 chips in my dataloggers and yes, there is 'fun' in learning about them!
That being said, I bumped up the baudrate to 115k2 with no handshaking and it's quite happy.The max is 6Mbaud but why push it !
As for storing your data, I found the 'best' solution was to store data in 'CSV' format.Currently I record date,time,temperature reading,status as one 'record' of string data with embedded commas(CSV). This allows Excel or other PC programs to easily read the data. |
|
|
|