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
  1. #1
    Join Date
    Aug 2010
    Posts
    4

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

    Hi every one

    I'm trying to copy a data from PIC memory to PC main memory for further analysis.... But I couldn't find how ,,, I'm using MicroCode Studio pluse , PICBASIC PRO COMPILER 2.60 full version, PIC (16f877a or PIC18f4620) ,LABX1.

    The verible define and ADC in the program can shwon as following :

    X var word[40] ' Create to store results
    Y var word [40] ' Create to store results

    MAINLOOP:

    for n = 0 to 39
    ADCIN 4 , X [n] ' read channel A5 and put result in X [ array]

    ADCin 2 , Y [n] ' ' read channel A2 and put result in Y[ array]


    pause 1
    next n

    My Question is, how can I export the data [ X[n],Y[n] ] from the PIC memory to PC main memory and save it as a file such as txt or Excel?

    Thank you in advance

    Yousif M.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by yousifm View Post

    My Question is, how can I export the data [ X[n],Y[n] ] from the PIC memory to PC main memory and save it as a file such as txt or Excel?

    Thank you in advance

    Yousif M.
    Hi, Yousif

    Considering the processors you use, serial comms looks obvious ...

    have a look to SEROUT , HSEROUT and DEBUG commands that are used to send data through an RS232 connection to your PC.

    After that ... you have to use VisualBasic or such programs to place your Data into a convenient .txt file.
    Same VisualBasic commands style to load them to an Excel Sheet ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default

    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  4. #4
    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?

  5. #5
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    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

  6. #6
    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.

  7. #7
    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

  8. #8
    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

  9. #9
    Join Date
    Aug 2010
    Posts
    4


    Did you find this post helpful? Yes | No

    Default


    Hi Robert thank you very much for your replay

    i download the Plx-DAQ.xls , do i need a Parallax microcontrollers to work with or any microcontroller.

    Best regards;

    yousif
    Last edited by ScaleRobotics; - 10th August 2010 at 05:19. Reason: edit link

  10. #10
    Join Date
    Aug 2010
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    have a look to SEROUT , HSEROUT and DEBUG commands that are used to send data through an RS232 connection to your PC.



    Alain[/QUOTE]

    Thank you very much Alain ,, im still looking in those commonds ,, when i use these commends ...what type of files the arrays varaible send and saved in the PC and where ??

    Best regards
    yousif

  11. #11
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by yousifm View Post
    do i need a Parallax microcontrollers to work with or any microcontroller.

    Best regards;

    yousif
    No, you don't need a Parallax. It works with a PIC also.

    Robert
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  12. #12
    Join Date
    Aug 2010
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Hi every one

    Thank you all for helping me ,,, I managed to export the data from PIC to PC using the HyperTerminal and the process as following ,,, maybe it will help another one have the same question
    Code:
    X var word[400] ' Create to store results
    Y var word [400] ' Create to store results
    
    MAINLOOP:
    
    for n = 0 to 399
    
    ADCIN 4 , X [n] ' read channel A5 and put result in X [ array]
    
    ADCin 2 , Y [n] ' ' read channel A2 and put result in Y[ array]
    
    pause 1
    
    next n 
    
    [[[X [n] and Y [n] are the veribles array]]]
    
    'to export the data to HyperTerminal 
    
    for n= 0 to 399
     
     SerOut2 PORTC.6, 396, [10,13,10,13]
     
    SerOut2 PORTC.6, 396, [DEC X [n]]
    
    next n
    
    
    'then the same way for Y[n]
    BUT IN THIS MOTHODS, i coudnt transfer all array elements becouse the data will delet the old one ,,, so maybe its good way to export array for nearly 200 elements

    i tried to use PLX_DAQ but i had a proplem in Data Transmitted ... the PLX conected to pic and resived the data but its can not be transmitted ,,, any one have an idea why thats happened??

    Best regards;

    yousif
    Last edited by ScaleRobotics; - 23rd January 2011 at 20:44. Reason: added code tags

Members who have read this thread : 1

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