LabVIEW Embedded

cancel
Showing results for 
Search instead for 
Did you mean: 

PIC16F877A+UART for Display of Measurements LABVIEW

Solved!
Go to solution

I need to send four measurement parameters to the PC for display and storage purposes. The software for this aim is LABVIEW. I am new to PIC and Interfacing, but by putting so much effort and asking questions from experts, i could have accomplished the acquisition of all the data till today.
I could also transmit a character "HELLO" through RS232 with my UART to USB converter and the result in hyperterminal was observed as well.
I am quite happy that i could have reached up to this stage. but on the other hand, unfortunately my knowledge is absolutely poor about LABVIEW.
I have heard that if i have control over the format of the data from PIC to LABVIEW, it is not that difficult.
Please find the attached pictures of the design for better understanding.

Questions:
1- can you please explain what is exactly meant by format of data?(I also don't know the format of data i sent through USB)
2- After specifiying the format, what would be the next stage?
3- If it is possible, please provide me with some sample codes for Hi-tech C, and LABVIEW as well.

0 Kudos
Message 1 of 4
(8,231 Views)
Solution
Accepted by topic author ajaba

@ajaba wrote:


Questions:
1- can you please explain what is exactly meant by format of data?(I also don't know the format of data i sent through USB)


It refers to the actual characters that are sent over the serial port to a computer. The computer needs to know how to interpret the information so you can convert the string to a number. It also needs to know when it has received the full transmission. This is typically done by appending a specific character to the end of the text. A carriage return character (ASCII code of 13) or a linefeed character (ASCII code of 10) are typical ones that are used. When you want to send a measurement to a computer you'd send the number first (converted to a string), and then send the termination character (you choose whether you want a carriage return or a linefeed).

 


2- After specifiying the format, what would be the next stage?

You need to define a communication protocol. For instance, does the device always send the measurement when it's on? Is it only supposed to send a measurement when it receives a command to do so? If you want it so that it only sends a measurement when it receives a command then you need to define what you want that to be. That means the PC side has to first send that command. For example, in HyperTerminal you'd type out the command. When the microP receives that command, you send the response.

 


3- If it is possible, please provide me with some sample codes for Hi-tech C, and LABVIEW as well.

LabVIEW has a shipping example to do serial port reads. Open the Example Finder (Help -> Find Examples) and search for "serial". Open the Basic Serial Write and Read. This example is set up to allow you to send a command (if necessary), and then to read from the serial port. The reading will whatever bytes are on the port.

0 Kudos
Message 2 of 4
(8,213 Views)

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;

}
==========================================================================================================
//Since only 8 bits at a time can be sent with USART and the ADC value is 10 bits.
//How to recombine the Lo and Hi 8-bit values to get 10-bit value?

do {
for (i=0; i <=7; i++) {
myarray[i]=read_temp();
}

for (i=0; i <=7; i++)  {
putch (Lo(myarray[i]));               //send the lower 8 bits of ADC reading
putch(Hi(myarray[i]));                 // Send upper 8 bits of ADC reading
}
===========================================================================
Please let me know your feedback about this code?Is it sufficient for sending analog measurement values?

do {

    USART_Write(255);
    an0 = ADC_Read(0) >> 2; 

    an0 = (an0 - 1);                                     / 1 is taken away from the value of ADC read, because if Voltage In is 5 volts ADC value

    USART_Write(an0);                                 / will be 255 and labview will mistake the data as the start byte. Data can read from 0 - 254.   
    an1 = (an1 - 1);

    an1 = ADC_Read(1) >> 2; 

    USART_Write(an1);       

    an2 = ADC_Read(2) >> 2; 
    an2 = (an2 - 1);

    USART_Write(an2);       

    an3 = ADC_Read(3) >> 2;
    an3 = (an3 - 1);

    USART_Write(an3);       

    an4 = ADC_Read(4) >> 2; 
    an4 = (an4 - 1);

    USART_Write(an4);       

 

How about this?

0 Kudos
Message 3 of 4
(8,210 Views)

As i have already accompolished receiving all the Four (4) measurements from PIC. Would you please help me on how i can store them as well for at least 7days!

I have heard of DSC module in LABVIEW, how is working with this module. Does it need any special configurations?


0 Kudos
Message 4 of 4
(8,168 Views)