CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

VDrive2 via UART

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mxkid



Joined: 08 Apr 2008
Posts: 16

View user's profile Send private message

VDrive2 via UART
PostPosted: Wed Sep 01, 2010 12:28 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 01, 2010 7:31 pm     Reply with quote

Quote:
Do I need to use an RS232 chip or can it be connected directly?

Look on page 7 of the Vdrive2 Data Sheet (link given below).
They show a direct connection between a 16F688 and the Vdrive2, using
the Tx and Rx pins of the PIC's UART, and two more PIC pins for the CTS
and RTS handshaking signals.

Data sheet:
http://www.vinculum.com/documents/datasheets/DS_VDRIVE2.pdf
Firmware spec:
http://www.vinculum.com/documents/fwspecs/UM_VinculumFirmware_V205.pdf
mxkid



Joined: 08 Apr 2008
Posts: 16

View user's profile Send private message

PostPosted: Thu Sep 02, 2010 3:52 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 02, 2010 4:28 pm     Reply with quote

Read this thread on RTS/CTS handshaking:
http://www.ccsinfo.com/forum/viewtopic.php?t=24612
mxkid



Joined: 08 Apr 2008
Posts: 16

View user's profile Send private message

PostPosted: Fri Sep 03, 2010 6:57 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 22, 2010 10:35 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 20, 2012 4:09 am     Reply with quote

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: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Feb 20, 2012 7:11 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group