how I export data from the PIC memory to PC main memory and save excel or txt file


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rsocor01 View Post
    Robert, this is a great product to capture data from microcontroller data logging to PC excel spreadsheet if your application has a serial interface. I need to do the exact same thing, but my application only has a USB interface. Is there anyway to adapt PLXDAQ to USB or a similar product to PLXDAQ that will work with USB?

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jellis00 View Post
    Is there anyway to adapt PLXDAQ to USB or a similar product to PLXDAQ that will work with USB?
    No, that I know of. But you can write your own application to do that with VBA (Visual Basic Applications).
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Originally Posted by jellis00
    Is there anyway to adapt PLXDAQ to USB or a similar product to PLXDAQ that will work with USB?
    Adapt your MCU??
    http://www.picbasic.co.uk/forum/cont...ns-for-Dummies!
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    The PLXDAQ should work fine with a USB to serial cable setting up a virtual com port, I think.

    Anand

  5. #5
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default USB and PC Files

    Not quite what you want but I used the VDrive2 module from FTDI (cost about $50).

    The program creates a CSV file that the PC opens with XL

    Regards Bill Legge

    The code I wrote to get the VDrive2 working was:
    Code:
    ' -----[ Program Description ]---------------------------------------
    '
    ' Name: WVL Vdrive_03		File write test                                
    ' Program stores two 8-bit readings to USB thumb drive using a Vdrive2
    ' 
    ' Vdrive jumper in UART MODE (UART/SPI pulled up datasheet V.99 is correct)
    ' Pin        Name    Description
    ' 
    ' 1          GND     5V common
    ' 2          RTS     Request to Send
    ' 3          Vdd     Connects to +5V
    ' 4          RXD     Receive Data
    ' 5          TXD     Transmit Data
    ' 6          CTS     Clear to Send (connect to common or make low)
    ' 7          NC      No Connection
    ' 8          RI      Ring Indicator (not used)
    ' 
    ' PIC18F8722 on BIGPIC5
    ' DEBUG used for PC comms and SERIN/SEROUT for VDrive2 comms all at 9600 Baud
    '
    ' -----[ DEFINES ]---------------------------------------------------
    '
    clear
    DEFINE OSC 40						' Compile as HS
    
    DEFINE LCD_DREG	PORTD	    ' Define PIC port used for LCD Data lines
    DEFINE LCD_DBIT	4		    ' Define first pin of data nibble
    DEFINE LCD_RSREG PORTD	    ' Define PIC port used for R/S line
    DEFINE LCD_RSBIT 2		    ' Define Portb pin used for R/S
    DEFINE LCD_EREG	PORTD   	' Define PIC prot used for E line
    DEFINE LCD_EBIT	3		    ' Define PortB pin used for E connection
    DEFINE LCD_BITS	4		    ' Define the 4 bit communication mode
    DEFINE LCD_LINES 4		    ' Define using a 2 line LCD
    DEFINE LCD_COMMANDUS 1500	' Define delay time between sending commands
    DEFINE LCD_DATAUS 45	    ' Define delay time between data sent
    lcdout $fe,$1
    pause 2000
    FLAGS=0
    
    INCLUDE "modedefs.bas"				' Include serial modes
    
    DEFINE DEBUG_REG  PORTC
    DEFINE DEBUG_BIT  6
    DEFINE DEBUG_BAUD 9600				' VDrive2 default speed
    DEFINE DEBUG_MODE 0
    
    DEFINE DEBUGIN_REG  PORTC
    DEFINE DEBUGIN_BIT  7
    DEFINE DEBUGIN_BAUD 9600
    DEFINE DEBUGIN_MODE 0
    
    define	ADC_BITS 8
    '
    ' -----[ VARIABLES ]-----------------------------------------------------------
    '
    X			VAR	byte
    Y           var	byte
    Z			var	byte
    A			var	byte
    B			var	byte
    C			var	byte
    D			var	byte
    E			var	byte
    F			var	byte
    G			var	word
    DataIn		var	byte[50]
    Echo		var	byte
    Rx          VAR PORTC.0		' Data in from VDrive	[Yellow]   
    Tx          VAR PORTC.1 	' Data out to VDrive	[Orange]
    Heartbeat	var	PORTD.0 
    
    Number		VAR	BYTE[10]
    '
    ' -----[ INITIALISE ]----------------------------------------------------------
    '
    ADCON1 	= %00001111			' All digital
    TRISA	= %00000011			' A0 and A1 inputs
    TRISB	= %00000000
    TRISC	= %00000001			' C0 is data in, C1 is data out
    TRISD	= %00000000
    TRISE	= %00000000
    TRISF	= %00000000
    TRISG	= %00000000
    TRISH	= %00000000
    TRISJ	= %00000000
    '
    ' -----[ IDENTIFY ]------------------------------------------------------------
    '
    	lcdout $fe,$80, "WVL Vdrive_03"
    	lcdout $fe,$c0, "PIC18F8722"
    	pause 3000
    	lcdout $fe,1
    
    ' *****************************************************************************
    ' *                                                                           *
    ' *                         ESTABLISH COMMS WITH VDRIVE                       *
    ' *                                                                           *
    ' *****************************************************************************
    
    Begin:
    	Debug "VDrive2 Starting",13   
    	Pause 200
    	Debug "Attempting synchronisation:"
         
    Syncro:
    	Pause 200 
    	toggle Heartbeat
    	X=X+1
    	debug " ",dec3 X
    	SerOut2 TX,84,["E",13]    			' Send sync command folowed by CR               
        SerIn2 RX,84,200,Toolong,[Echo]		' Wait 200mS for reply 'E'
    	if Echo = "E" then Comms_Good
        
    Toolong:       
    	GoTo Syncro
        
    Comms_Good:
    	Debug 13,"Disk synchronised",10,13	   	' Show SUD has been sent
    	pause 500
    
    ' *****************************************************************************
    ' *                                                                           *
    ' *                             M A I N  C O D E                              *
    ' *                                                                           *
    ' *****************************************************************************
    
    	gosub Check_disk
    	gosub Get_version
    	gosub File_list
    	gosub File_name_size						' File size & name before FOR...NEXT loop
    	gosub Free_space
    	gosub File_delete
    	pause 100
    	gosub File_open								' Create the file   "TestFile.csv" (XL type)
    												' When read becomes "TESTFILE.CSV"	
    	for X=1 to 17
    		toggle Heartbeat		
    		debug "Writing to file X: ",dec3 X,13		
    		SerOut2 TX,84,["WRF ",0,0,0,4,13]		' 32 bit number of bytes
    		serout2 Tx,84,[dec3 x,10,13]			' Number of bytes must be exact
    	next X										' Additional CR puts XL numbers into a column
    	
    	gosub File_close
    	
    	gosub File_size								' File size after FOR...NEXT loop	
    
    												' Read the file size and send first byte to LCD			
    	serout2 Tx,84,["IPA",13]					' Switch to ASCII characters for display of HEX digits
    	pause 100									' Essential to wait after o/p switch
    	serout2 Tx,84,["DIR TestFile.csv",13]		' Issue the command
    	serin2  Rx,84,[Wait ("TESTFILE.CSV $"),_
    		hex2 A,skip 2,hex2 B,skip 2,hex2 C,skip 2,hex2 D]
    	lcdout $fe,$80, "$: ",hex2 A," ",HEX2 B," ",HEX2 C," ",HEX2 D
    	pause 100
    			
    	debug "All done",10,13	
    	end
    	
    ' *****************************************************************************
    ' *                                                                           *
    ' *                         S U B R O U T I N E S                             *
    ' *                                                                           *
    ' *****************************************************************************	
    
    Check_disk:
    	for X=0 to 49 : DataIn[X]=0 : NEXT X		' Clear the array
    	serout2 tx,84,[13]							' Issue the command. "D"= Disk Ok, "N"=no disk
    	serin2  Rx,84,[str DataIn\1]				' Read  1 character												
    	If DataIn[0] = "N" then 
    		debug "No disk detected "
    		pause 500
    		goto Check_disk
    		else
    		debug "Disk found OK",10,13
    	endif
    	pause 100									' These pauses are essential
    	return
    
    Get_version:
    	debug "Firmware version:"
    	for X=0 to 49 : DataIn[X]=0 : NEXT X		' Clear the array
    	serout2 tx,84,["FWV",13]					' Issue the command
    	serin2  Rx,84,[str DataIn\50\">"]			' Read characters until ">" is found												
    	debug str DataIn\50							' Send data to the PC
    	pause 100									' These pauses are essential
    	return
    	
    File_list:
    	debug 13,10,10,"List all files:"
    	for X=0 to 49 : DataIn[X]=0 : NEXT X		' Clear the array
    	serout2 Tx,84,["DIR",13]					' Issue the command
    	serin2  Rx,84,[str DataIn\50\">"]			' Read up to max of 50 chrs
    	debug str DataIn\50
    	pause 100
    	return
    	
    File_name_size:
    	debug 13,10,10,"File name & size:"
    	serout2 Tx,84,["IPA",13]					' Switch to ASCII characters for display of HEX digits
    	pause 10									' Essential to wait after o/p switch
    	for X=0 to 49 : DataIn[X]=0 : NEXT X		' Clear the array
    	serout2 Tx,84,["DIR TestFile.csv",13]		' Issue the command
    	serin2  Rx,84,2000,Jump2,[str DataIn\50\">"]' Read up to max of 50 chrs
    Jump2:											' Needed in case there is no file on the drive		
    	debug str DataIn\50	
    	pause 100
    	return
    	
    File_size:
    	debug 13,10,10,"File size:",13
    	serout2 Tx,84,["IPA",13]					' Switch to ASCII characters for display of HEX digits
    	pause 10									' Essential to wait after o/p switch
    	for X=0 to 49 : DataIn[X]=0 : NEXT X		' Clear the array
    	serout2 Tx,84,["DIR TestFile.csv",13]		' Issue the command
    	serin2  Rx,84,2000,Jump3,[Wait ("TESTFILE.CSV "), str DataIn\50\">"]
    												' Read up to max of 50 chrs
    Jump3:											' Needed in case there is no file on the drive		
    	debug str DataIn\50,10,13	
    	serout2 Tx,84,["IPH",13]					' Switch to HEX characters
    	pause 100
    	return	
    	
    		
    Free_space
    	debug 13,10,10,"Free space:",13
    	serout2 Tx,84,["IPA",13]					' Switch to ASCII characters for display of HEX digits
    	pause 10									' Essential to wait after o/p switch
    	for X=0 to 49 : DataIn[X]=0 : NEXT X		' Clear the array
    	serout2 Tx,84,["FS",13]						' Return 4 bytes
    	serin2  Rx,84,[str DataIn\50\">"]			' Read up to max of 50 chrs		
    	debug str DataIn\50	
    	serout2 Tx,84,["IPH",13]					' Switch to HEX characters
    	pause 100
    	return	
    			
    File_open:
    	debug "Opening file",10,13
    	serout2 Tx,84,["OPW TestFile.csv",13]		' Issue the command
    	return
    
    File_close:
    	debug 10,"Closing file",10,13
    	SerOut2 TX,84,["CLF TestFile.csv",13]		' Issue the command
    	return
    	
    File_delete:
    	debug 13,10,10,"Deleting file",10,13	
    	serout2 tx,84,["DLF TestFile.csv",13]		' Issue the command
    	return

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts