Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16F877A+UART for LABVIEW

Status
Not open for further replies.

noel_t

Member
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: 1,404
Hi,

It's been a while since I used labVIEW, I made a program that send 25 parameters from the laptop to the PIC using an USB to UART convertor. Reading data is also successfully.

I've attached the application that I made, using RS232 functions in labv.View attachment labV.zip

Hope it helps and take al ook at the data formats.

kind regards
 
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++) {
myarray=read_temp();
}

for (i=0; i <=7; i++) {
putch (Lo(myarray)); //send the lower 8 bits of ADC reading
putch(Hi(myarray)); // Send upper 8 bits of ADC reading
}

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 {
an0 = ADC_Read(0) >> 2;
USART_Write(an0);
an1 = ADC_Read(1) >> 2;
USART_Write(an1);

an2 = ADC_Read(2) >> 2;
USART_Write(an2);

an3 = ADC_Read(3) >> 2;
USART_Write(an3);

an4 = ADC_Read(4) >> 2;
USART_Write(an4);

Thanks in advance for your help.
 
Noel_t... Am I still doing a VB interface....I have a basic form done with the four windows, an RS232 input for a stream of data in this format "Txxx.xVxxx.xCxxx.xGxxx.x \r\n"
T temp, V voltage, C current, G light...

Have you got VB2010 installed?
 
Noel_t... Am I still doing a VB interface....I have a basic form done with the four windows, an RS232 input for a stream of data in this format "Txxx.xVxxx.xCxxx.xGxxx.x \r\n"
T temp, V voltage, C current, G light...

Have you got VB2010 installed?
I really appreciate your efforts on this.
I have already bought the original DVD of VB2010 and i will install it by today.
I am waiting for your response.
On the other hand i am struggling to get info on how to do the same thing in LABVIEW as well.

Thanks a lot one more time dear Ian.
 
I dont even know which compiler you use for the PIC. Store the ADCH and ADCL in a char en transmit is using UART. In Labview add them both together.

if you want to identify the ADC channel, just use the upper nibble of ADCH, something like = char ADCHvalue=ADCH+|0xA0. You've just added the ADC channel to your value of the ADC. So transmitting ADCHvalue and ADCL give you the value of the ADC and the channel.

Cheers
 
Noel_t !! I found things a lot easier, transferring relativity small data, using plain text..
Code:
   sprintf( txdbuffer, "T%dV%dC%dG%d\n", temp, volts, current, light);
   while(*txbuffer != 0)
      send(*txbuffer++);

Its easier to grab these values in VB later..

Ian
 
I dont even know which compiler you use for the PIC. Store the ADCH and ADCL in a char en transmit is using UART. In Labview add them both together.

if you want to identify the ADC channel, just use the upper nibble of ADCH, something like = char ADCHvalue=ADCH+|0xA0. You've just added the ADC channel to your value of the ADC. So transmitting ADCHvalue and ADCL give you the value of the ADC and the channel.

Cheers

I am using Hi-Tech Compiler with C language. MPLAB + PROTEUS + PIC16F877A. I have bought a ready made UART to USB converter from : **broken link removed**

By the way, your LABVIEW file for my reference can't be opened since my version is 8.5. I think i need to find a way to solve this problem.
 
Last edited:
Hi noel, serial com in labview is a snap of the fingers. Since reading is all you want to do, here is a stripped of version of the basic serial read write vi shipped with labview as an example. I see from your pdf that you are successfully sending data to the serial software. The attached vi will read the data. If you get a successful read, you can than use it as you wish. If you encounter any problems, let me know.
 

Attachments

  • Basic Serial Read.zip
    14.6 KB · Views: 502
Hi noel, serial com in labview is a snap of the fingers. Since reading is all you want to do, here is a stripped of version of the basic serial read write vi shipped with labview as an example. I see from your pdf that you are successfully sending data to the serial software. The attached vi will read the data. If you get a successful read, you can than use it as you wish. If you encounter any problems, let me know.
Thanks a lot Wond. I will check it and let you know.
 
noel_t.. Have you installed VB2010 yet.. I want to know if you decided on binary transfer or text.....

Yes i have already installed VB2010. I can't get exactly your meaning by binary transfer or text. But any type of transfer which can show the measurements shall be OK. By the Way, ADC transmits ADC readings in 10-bit of data. But UART can only accept 8-bit for transmission, Therefore i am not sure what technique you want to use as the solution for this.
I already know some ways to send data in 4 bits or 8 bits and later join or add them together. Maybe it can help you if you think it is useful i upload the codes.
 
I use "sprintf" extensively .. this way I can print a line to the serial port ( just as you would the lcd screen)... ie.. the receiving PC will receive a text string with all the values contained in the string I have tested the software using the following string... "T564V343C23G22" I achieve this by...
Code:
sprintf(outbuffer,"T%dV5dC%dG%d",temp,volts,current,light);

This gives me an output buffer with the four values embedded within.
The VB app retrieves the data back to a double value for storage / displaying..
 
Wow, it seems you are doing a great job. Since there is no necessity of applying any particular type of transfer in this project, thus i think your method is great to accomplish it. It is fantastic to receive an output buffer with the four values embedded in.

I use "sprintf" extensively .. this way I can print a line to the serial port ( just as you would the lcd screen)... ie.. the receiving PC will receive a text string with all the values contained in the string I have tested the software using the following string... "T564V343C23G22" I achieve this by...
Code:
sprintf(outbuffer,"T%dV5dC%dG%d",temp,volts,current,light);

This gives me an output buffer with the four values embedded within.
The VB app retrieves the data back to a double value for storage / displaying..
 
the only thing standing in my way at the moment is "delegates" i have to retrieve the data in a thread, and i keep getting cross call errors. I'll get there in the end.

good luck ian. Sure you can get it soon. Sorry that i can't assist for that. I look forward to get great news from you :) thanks!
 
hi noel_t, i'm doing exactly the same thing as u and i would like to know whether have u get what u desire? because i wan to show my UART output to a graph in Labview as well. I've tried to connect the VISA RESOURCE OUT to a waveform chart but there is error saying the data format is not correct. My UART output is kind of string.
 
Hi Keat,

In fact, i am waiting for a friend to help me for that, but based on my readings/information till now, if you are sending string in LABVIEW, it should work.
Pls make sure u are sending data in 8-bits.
check ur program with Hyperterminal first and see whether u are getting anything or not.
U may provide more information about your code or compiler and type of ucontroller u are using.

hi noel_t, i'm doing exactly the same thing as u and i would like to know whether have u get what u desire? because i wan to show my UART output to a graph in Labview as well. I've tried to connect the VISA RESOURCE OUT to a waveform chart but there is error saying the data format is not correct. My UART output is kind of string.
 
Hi noel_t,

I used a software named "RealTerm" from this website http://realterm.sourceforge.net/ yes my device is sending out signal to the CPU. However, there is some framming error which i do not know how to solve it. I wrote my assembly code in asm file and the microcontroller that i'm using is pic18f4520. I wan to know how to convert the string input from my device to show a wavegraph in LabView. Any idea?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top