Data logging and Reading

File I/O & Databases
noel_t
beginner
beginner
Сообщения: 12
Зарегистрирован: 13 июл 2011, 09:50
Версия LabVIEW: 2010
Контактная информация:

Data logging and Reading

Сообщение noel_t »

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.
Вложения
Block diagram
Block diagram
Front Panel
Front Panel
Аватара пользователя
Eugen Graf

Activity Professionalism Silver Black
guru
guru
Сообщения: 6502
Зарегистрирован: 13 ноя 2007, 02:20
Награды: 4
Версия LabVIEW: 2009
Откуда: Saarbrücken
Контактная информация:

Re: Data logging and Reading

Сообщение Eugen Graf »

Connect your array to Write To Spreadsheet File
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Data logging and Reading

Сообщение mzu2006 »

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 писал(а):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.
noel_t
beginner
beginner
Сообщения: 12
Зарегистрирован: 13 июл 2011, 09:50
Версия LabVIEW: 2010
Контактная информация:

Re: Data logging and Reading

Сообщение noel_t »

This is my .vi.
Please kindly help me to modify the necessary changes.
Вложения
Multi-channel Data Acquisition.vi
Multi-channel data acquisition system based on PIC
(20.45 КБ) 340 скачиваний
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Data logging and Reading

Сообщение mzu2006 »

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.
Вложения
Clipboard02-m.png
Clipboard02-m.png (8.32 КБ) 20174 просмотра
Multi-channel Data Acquisition.vi
(25.01 КБ) 434 скачивания
noel_t
beginner
beginner
Сообщения: 12
Зарегистрирован: 13 июл 2011, 09:50
Версия LabVIEW: 2010
Контактная информация:

Re: Data logging and Reading

Сообщение noel_t »

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.

Код: Выделить всё

//--------------------------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;
}
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Data logging and Reading

Сообщение mzu2006 »

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
noel_t
beginner
beginner
Сообщения: 12
Зарегистрирован: 13 июл 2011, 09:50
Версия LabVIEW: 2010
Контактная информация:

Re: Data logging and Reading

Сообщение noel_t »

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
Сообщения: 12
Зарегистрирован: 13 июл 2011, 09:50
Версия LabVIEW: 2010
Контактная информация:

Re: Data logging and Reading

Сообщение noel_t »

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.
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Data logging and Reading

Сообщение mzu2006 »

Код: Выделить всё

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

Код: Выделить всё

result=(ADRESH<<8)|ADRESL;
You can transmit as many data as you want through RS-232C. Just do it byte-by-byte. something like:

Код: Выделить всё

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:
noel_t
beginner
beginner
Сообщения: 12
Зарегистрирован: 13 июл 2011, 09:50
Версия LabVIEW: 2010
Контактная информация:

Re: Data logging and Reading

Сообщение noel_t »

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.
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Data logging and Reading

Сообщение mzu2006 »

noel_t писал(а):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.
noel_t
beginner
beginner
Сообщения: 12
Зарегистрирован: 13 июл 2011, 09:50
Версия LabVIEW: 2010
Контактная информация:

Re: Data logging and Reading

Сообщение noel_t »

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.
Вложения
9-20-2011 4-54-25 PM.jpg
9-20-2011 4-54-25 PM.jpg (30.84 КБ) 20012 просмотров
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Data logging and Reading

Сообщение mzu2006 »

The selected "Index Array" function selects 0-th element of the array: light
noel_t
beginner
beginner
Сообщения: 12
Зарегистрирован: 13 июл 2011, 09:50
Версия LabVIEW: 2010
Контактная информация:

Re: Data logging and Reading

Сообщение noel_t »

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?
Ответить
  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Data storage»