From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

save data

Solved!
Go to solution

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.

0 Kudos
Message 1 of 14
(3,404 Views)
Solution
Accepted by topic author ajaba

OK.... so what's your question? You have not indicated in what format you're supposed to store the values. Do you want columns? If so, use the Write to Spreadsheet File VI.

 

Code comments:

  • You have enabled VISA Read termination, but you are not using it. You are specifying a fixed number of characters to read. 
  • You are assuming you will have 4 characters at the serial port buffer when the event is triggered. There is a small chance that you will not have 4 characters there.
  • You should not be enabling the VISA event inside the loop. You only need to enable the event once. Also, why are you enabling it again after the loop? You should have a Discard Event there.
  • You do not need 4 Index Arrays. You only need 1. It's resizable, and you don't even need to wire in an index values if you're going to index out all 4 elements. Please read the Help on Index Array.
0 Kudos
Message 2 of 14
(3,398 Views)

Storing the values can be in any format since there is no restriction about it. Columns is good if i can have.

Since my knowledge is poor about it, and i am still a beginner and reading books. Can you please help me to modify the necessary changes?

 

Thanks in advance.

0 Kudos
Message 3 of 14
(3,395 Views)

I would, but I can't make code change on a picture. Smiley Wink You will need to upload your actual VI.

0 Kudos
Message 4 of 14
(3,386 Views)

Yes sure, Now you can find the attached .vi file over here to do necessary modification.

 

Thanks in advance.

0 Kudos
Message 5 of 14
(3,380 Views)

Attached is a modification of your VI. I put in the modifications I had suggested, as well as fixing up your error handling. Previously you had the case structure inside the loop. Thus, if any errors were encountered prior to the loop, the loop would execute the false case, which did absolutely nothing. Worse, your VI would simply contine looping around and around, consuming 100% of your CPU. I changed it so that the loop doesn't even execute if there's an error during the setup. You probably don't want to stop the VI if there's a read error since this may happen occasionally, and it is not necessarily a "must stop" error condition. Thus, I just set it up to log an error on the front panel. You can make up whatever string you want.

 

See if you understand the changes I made.

0 Kudos
Message 6 of 14
(3,370 Views)

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

 

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 inter like this light=15, voltage= 12 and ....)

DO you have any idea on how i can decimilize 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 acuracy.

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.

0 Kudos
Message 7 of 14
(3,366 Views)

Hi

do you have by accident a localized decimal point and this one is not seen from your controller by LabVIEW.

The USA is so nice to us Europeans that we always have problems with it.

 

If this is the case uncheck localised decimal point in the options.

 

There is another way but that is more work and anyhow I'm used to a decimal point.

greetings from the Netherlands
0 Kudos
Message 8 of 14
(3,360 Views)

Hi,

 

I just unchecked the localised decimal point in the option as you said, and the result remained the same.

 

Regarding this sentence, (The USA is so nice to us Europeans that we always have problems with it.) i shall add that, i am not American. I am Asian and basically in Asian perception, they beleive that they are hurt by both American & European during the history ;). However i still love the land of flowers 😉

Anyways, here is a nice place to share ideas about technical issues. 

Back to my problem, 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;

}

0 Kudos
Message 9 of 14
(3,356 Views)

If supposed to present the multi channel data acquisitio.vi, how do you prefer to present it?

 

Basically, if we divide it into several concepts which are accomodated within this labview program, how do you define this concepts?

 

Since my knowledge about labview is poor, i want to go and study about implemented concepts within this software for my presentation

0 Kudos
Message 10 of 14
(3,342 Views)