# PIC16F877A+UART for LABVIEW

Status
Not open for further replies.

#### noel_t

##### Junior Member level 3
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.

#### Attachments

• PIC16F877A+UART for LABVIEW.pdf
920.8 KB · Views: 32

#### noel_t

##### Junior Member level 3
Questions:
1- can you please explain what is the technique to transmit the 10-bit data from PIC ADC to the 8-bit serial port? something like this:

do {
for (i=0; i <=7; i++) {
}

for (i=0; i <=7; i++) {
}

2- How to identify each channel at the reception side (LABVIEW). For example, 1011011110=Channel 0 (ADC-1=Light) or 1011010110=Channel 1 (ADC-1=temperature) and so on. Something like this can work?

do {
USART_Write(an0);
USART_Write(an1);

USART_Write(an2);

USART_Write(an3);

USART_Write(an4);

### Minh trí

Points: 2

#### engshahrul

##### Banned
4 parameter, what is the maximum number for that value?
Is that 8bit is enough for the value?
ex
Code:
for(i=0;i<=3;i++) value[i]=read_a2d(i);
for(i=0;i<=3;i++) uart_transmit(value[i]);

noel_t

### noel_t

Points: 2

#### noel_t

##### Junior Member level 3
4 parameter, what is the maximum number for that value?
Is that 8bit is enough for the value?
ex
Code:
for(i=0;i<=3;i++) value[i]=read_a2d(i);
for(i=0;i<=3;i++) uart_transmit(value[i]);
This is 10-bit value since it is produced by PIC16F877A with 10-bit resolution.

#### engshahrul

##### Banned
Every parameter need to divide into upperbyte and lowerbyte.
Code:
for(i=0;i<=3;i++) value[i]=read_a2d(i);
for(i=0;i<=3;i++){
uart_transmit((value[i]>>5)&0b00011111);
uart_transmit(value[i]&0b00011111);}

Last edited:
noel_t

### noel_t

Points: 2

#### noel_t

##### Junior Member level 3
Every parameter need to divide into upperbyte and lowerbyte.

i don't get the difference between uart_transmit((value>>5)&0b00011111); and uart_transmit(value&0b00011111);}
what is the meaning of 5 at here?
If you want to have the upper byte should not you &(AND) it with 0b11111000?

#### engshahrul

##### Banned
i don't get the difference between uart_transmit((value>>5)&0b00011111); and uart_transmit(value&0b00011111);}
what is the meaning of 5 at here?
If you want to have the upper byte should not you &(AND) it with 0b11111000?

It shift right 5 bit.

noel_t

### noel_t

Points: 2

#### noel_t

##### Junior Member level 3
It shift right 5 bit.

Now exactly i got your meaning. Thus, it transmit the upper byte first and lower byte second for values of i=0;i<=3. (It means 1=light, 2= temperature 3= voltage, 4= current).
Do you have any idea on how to joint this upper byte and lower byte at the other side (PC with labview)?

Status
Not open for further replies.

Replies
66
Views
7K
Replies
28
Views
11K
Replies
1
Views
4K
Replies
2
Views
2K
Replies
4
Views
3K