Data logging and Reading

File I/O & Databases

Data logging and Reading

Postby noel_t on 02 Sep 2011, 11:52

Hi,

I need to log/store the data of measurements acquired from my micro-controller for further readings by the operator.
So far my readings for Four (4) parameters are working perfectly, therefore i need to modify my Vi design to store these four parameters as well. Please help me.
Attachments
Storage 1.jpg
Block diagram
Storage 2.jpg
Front Panel
noel_t
beginner
beginner
 
Posts: 12
Joined: 13 Jul 2011, 09:50
LabVIEW Version: 2010
Karma: 0

Re: Data logging and Reading

Postby Eugen Graf on 02 Sep 2011, 12:08

Connect your array to Write To Spreadsheet File
User avatar
Eugen Graf
guru
guru
 
Posts: 6502
Joined: 13 Nov 2007, 02:20
Location: Saarbrücken
Medals: 4
Activity (1) Professionalism (1) Silver (1) Black (1)
LabVIEW Version: 2009
Karma: 303
CLAD I/O VIP bloggers internet

Re: Data logging and Reading

Postby mzu2006 on 02 Sep 2011, 23:22

noel_t,
it would be helpful, if you post your :vi: as well. For saving at the end, just add auto-indexing output tunnel on the left end of the while loop and
Eugen Graf wrote:Connect your array to Write To Spreadsheet File

For logging (saving at intermediate points) just assemble your data into an array (using "Build Array") and connect resulting array to the input of the"Write to spreadsheet file".
Set "Append to file" input as true.
User avatar
mzu2006
doctor
doctor
 
Posts: 2456
Joined: 16 Aug 2008, 02:12
Location: St-Petersburg (RU), Phila, Boston, Washington DC
Medals: 3
Professionalism (1) Tutorials (1) Black (1)
LabVIEW Version: 7.1 10 11 12
Karma: 279
CLAD CLD I/O PDA VIP vision bloggers teachers

Re: Data logging and Reading

Postby noel_t on 03 Sep 2011, 20:42

This is my .vi.
Please kindly help me to modify the necessary changes.
Attachments
Multi-channel Data Acquisition.vi
Multi-channel data acquisition system based on PIC
(20.45 KiB) Downloaded 194 times
noel_t
beginner
beginner
 
Posts: 12
Joined: 13 Jul 2011, 09:50
LabVIEW Version: 2010
Karma: 0

Re: Data logging and Reading

Postby mzu2006 on 04 Sep 2011, 04:55

This is what I meant. Leave red part if you want to log as you go, or green part if you want to save final data.
Attachments
Clipboard02-m.png
Clipboard02-m.png (8.32 KiB) Viewed 12110 times
Multi-channel Data Acquisition.vi
(25.01 KiB) Downloaded 275 times
User avatar
mzu2006
doctor
doctor
 
Posts: 2456
Joined: 16 Aug 2008, 02:12
Location: St-Petersburg (RU), Phila, Boston, Washington DC
Medals: 3
Professionalism (1) Tutorials (1) Black (1)
LabVIEW Version: 7.1 10 11 12
Karma: 279
CLAD CLD I/O PDA VIP vision bloggers teachers

Re: Data logging and Reading

Postby noel_t on 04 Sep 2011, 19:51

It's working perfectly and as the requirement of the project. Thanks a lot.

Now the only thing which lefts is to maximize the accuracy of this multi-channel data acquisition. By the way, the values which are shown in my LCD is like this (light=15.4 , Temp=30C, Voltage=12.4V, current= 2.3A). but in LABVIEW it only shows the the integer like this (light=15, voltage= 12 and ....)

Do you have any idea on how i can decimalize it. Since i am using PIC16F877A and it converts by 10-bit. But when i sent to through UART it becomes 8-bit only and affect the accuracy.

Basically what do you advise to do to maximize the accuracy? Any changes at the PIC code part?I can send you my pic code which is written in .c (Hi-tech compiler). Let me know if it helps.

***I just unchecked the localised decimal point in the option, and the result remained the same.(in LabView 2010)

i share some part of the PIC16F877A code (C Language, Hitech Compiler) which i think is related to ADC configurations and accuracy of the readings.

Code: Select all
//--------------------------Light Sensor LDR

        //sensor A //LDR
        ADCON0=CHANNEL0;         
        lcd_goto(8);
        read_adc();                            ////This function generates the average reading value of ADC
        light=read_temp();                 ////This function stores the generated value by ADC into the variable "temp"
         
        dis_num(light/10);             
        send_char('.');               
        dis_num(light%10);             

        putch(light/10);

//--------------------------Temperature Sensor LM35

        //sensor B //LM35
        ADCON0=CHANNEL1;                           
        lcd_goto(28);                   
        read_adc();
        temperature=read_temp();
        temperature = (temperature*0.48876);
       
        putch(temperature);

        dis_num(temperature);

//==================subroutine ADC=========================
void read_adc(void)                                                                 ////This function generates the average reading value of ADC
{
    unsigned short i;
    unsigned long result_temp=0;
    for(i=2000;i>0;i-=1)                                                            //looping 2000 times for getting average value
   
{

        ADGO = 1;                          //ADGO is the bit 2 of the ADCON0 register
        while(ADGO==1);                    //ADC start, ADGO=0 after finish ADC progress
        result=ADRESH;
        result=result<<8;                //shift to left for 8 bit
        result=256*result|ADRESL;            //10 bit result from ADC
        result_temp+=result;

        }

    result = result_temp/2000;            //getting average value
}

unsigned short read_temp(void)                                                        ////This function stores the generated value by ADC into the variable "temp"
{
    unsigned short temp;
    temp=result;
    return temp;
}
noel_t
beginner
beginner
 
Posts: 12
Joined: 13 Jul 2011, 09:50
LabVIEW Version: 2010
Karma: 0

Re: Data logging and Reading

Postby mzu2006 on 05 Sep 2011, 00:27

localized decimal point has nothing to do with it. You transmit 8 bits only. Transmit more. Your code is hard to read (a lot of auxiliary stuff), but it appears to me that putch(temperature) - actually outputs 1 byte of temperature, right? So output both bytes now (low byte and 2 other bits in another byte) and change your LV software accordingly
User avatar
mzu2006
doctor
doctor
 
Posts: 2456
Joined: 16 Aug 2008, 02:12
Location: St-Petersburg (RU), Phila, Boston, Washington DC
Medals: 3
Professionalism (1) Tutorials (1) Black (1)
LabVIEW Version: 7.1 10 11 12
Karma: 279
CLAD CLD I/O PDA VIP vision bloggers teachers

Re: Data logging and Reading

Postby noel_t on 07 Sep 2011, 16:00

As you said, PIC16F877A is transmitting only 8-bits most probably because of following reasons:

1- UART is capable of transmitting data only 8-bits, and that's why as you said, people go for dividing the bits into two groups of lower and

higher to join them later not to affect the accuracy.

2- According to my ADC subroutine configurations in the code below, the pic ADC only take readings of 8-bit. I explained the reason in front of the code.
//==================subroutine ADC=========================
void read_adc(void) ////This function generates the average reading value of ADC
{
unsigned short i;
unsigned long result_temp=0;
for(i=2000;i>0;i-=1) //looping 2000 times for getting average value

{

ADGO = 1; //ADGO is the bit 2 of the ADCON0 register
while(ADGO==1); //ADC start, ADGO=0 after finish ADC progress
result=ADRESH;
result=result<<8; //shift to left for 8 bit
result=256*result|ADRESL; //10 bit result from ADC (As i assume over here,when we multiply 256 to the result of ADC (*256) it results to 8-bit reading, however basically, PIC16F877A is having a built-in 10-bit ADC. The reason i put like this, as i was facing difficulty with readings of current sensor,(ACS712-Hall Effect Sensor-not fair result) a friend adviced to use it, and he did not explained the reason, but anyhow the outcome was fair.
Just to add this, i don't think so putch command by itself output 1 byte of data. I think for any data to be sent through UART,it can not exceed than 1 byte.

Please let me know your comment.
noel_t
beginner
beginner
 
Posts: 12
Joined: 13 Jul 2011, 09:50
LabVIEW Version: 2010
Karma: 0

Re: Data logging and Reading

Postby noel_t on 12 Sep 2011, 09:56

Dear Mzu,

I really need your help to explain to me briefly how the program works, i am facing difficulty for preparation of technical report about that.
If it is possible give me some hints or structure that based on that i can collect information. It seems to me one or two paragraph in summary would be enough if i explain briefly and nicely.

Thanks in advance.
noel_t
beginner
beginner
 
Posts: 12
Joined: 13 Jul 2011, 09:50
LabVIEW Version: 2010
Karma: 0

Re: Data logging and Reading

Postby mzu2006 on 13 Sep 2011, 00:09

Code: Select all
result=ADRESH;
result=result<<8; //shift to left for 8 bit
result=256*result|ADRESL;


This piece looks suspicious. I assume you want to have 2 bytes in result, high byte is ADRESH, low byte is ADRESL. In C multiplication takes precedence over bitwise OR, so last line is clearly incorrect.
I would change the above piece of code to something like

Code: Select all
result=(ADRESH<<8)|ADRESL;


You can transmit as many data as you want through RS-232C. Just do it byte-by-byte. something like:
Code: Select all
short int value;  // I assume 16 bit

putch(value>>8);    // HIGH goes first
putch(value&255); // LOW goes second


Now, do not forget to read BOTH of the bytes in :labview:
User avatar
mzu2006
doctor
doctor
 
Posts: 2456
Joined: 16 Aug 2008, 02:12
Location: St-Petersburg (RU), Phila, Boston, Washington DC
Medals: 3
Professionalism (1) Tutorials (1) Black (1)
LabVIEW Version: 7.1 10 11 12
Karma: 279
CLAD CLD I/O PDA VIP vision bloggers teachers

Re: Data logging and Reading

Postby noel_t on 13 Sep 2011, 10:10

I think you got my meaning wrongly. what i meant was explanation about the application program u helped me to make as Multi-channel Data Acquisition.vi
i need to know that how the program works, i am facing difficulty for preparation of technical report about that.
If it is possible give me some hints or structure that based on that i can collect information. It seems to me one or two paragraph in summary would be enough if i explain briefly and nicely about this made LABVIEW program.
noel_t
beginner
beginner
 
Posts: 12
Joined: 13 Jul 2011, 09:50
LabVIEW Version: 2010
Karma: 0

Re: Data logging and Reading

Postby mzu2006 on 15 Sep 2011, 03:01

noel_t wrote:i need to know that how the program works, i am facing difficulty for preparation of technical report about that.

It assembles data to array and saves it to disk ... Post what you've written somebody might be able to pinpoint some obvious mistakes.
User avatar
mzu2006
doctor
doctor
 
Posts: 2456
Joined: 16 Aug 2008, 02:12
Location: St-Petersburg (RU), Phila, Boston, Washington DC
Medals: 3
Professionalism (1) Tutorials (1) Black (1)
LabVIEW Version: 7.1 10 11 12
Karma: 279
CLAD CLD I/O PDA VIP vision bloggers teachers

Re: Data logging and Reading

Postby noel_t on 20 Sep 2011, 12:00

Here is the only part that i don't understand the duty. Even though i went through the context help, but still can not sense the practical usage of this array. What does it do exactly at here.
Attachments
9-20-2011 4-54-25 PM.jpg
9-20-2011 4-54-25 PM.jpg (30.84 KiB) Viewed 11948 times
noel_t
beginner
beginner
 
Posts: 12
Joined: 13 Jul 2011, 09:50
LabVIEW Version: 2010
Karma: 0

Re: Data logging and Reading

Postby mzu2006 on 20 Sep 2011, 19:54

The selected "Index Array" function selects 0-th element of the array: light
User avatar
mzu2006
doctor
doctor
 
Posts: 2456
Joined: 16 Aug 2008, 02:12
Location: St-Petersburg (RU), Phila, Boston, Washington DC
Medals: 3
Professionalism (1) Tutorials (1) Black (1)
LabVIEW Version: 7.1 10 11 12
Karma: 279
CLAD CLD I/O PDA VIP vision bloggers teachers

Re: Data logging and Reading

Postby noel_t on 20 Sep 2011, 22:58

If like this, therefore each array must accommodate 1 byte or 8-bits of data right?

1st array----------> Bit 0 to 7

2nd array..........>Bit 8 to 16

.
.
.
.
.and the same for the others two.

Is it correct what i think?
noel_t
beginner
beginner
 
Posts: 12
Joined: 13 Jul 2011, 09:50
LabVIEW Version: 2010
Karma: 0

Next

Return to Data storage

Who is online

Users browsing this forum: No registered users and 2 guests

cron