LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pic 16f877 rs 232

Solved!
Go to solution

hello my friends !!

 

I´m working with pic 16f877A ,and i want to do data aquisition (rs232) in labview !

i want to read adc 0 to 5V and visualise on a grafic!!

i´m using an exemple from mikroC :

 

/*
* Project name:
ADC_USART (Transferring ADC data on Serial port)
* Copyright:
(c) Mikroelektronika, 2005.
* Description:
The code performs AD conversion and sends results (the upper 8 bits) via
USART.
* Test configuration:
MCU: PIC16F877A
Dev.Board: EasyPIC3
Oscillator: HS, 08.0000 MHz
Ext. Modules: -
SW: mikroC v6.0
* NOTES:
None.
*/

unsigned short temp_res;

void main() {
USART_Init(9600); // Initalize USART (9600 baud rate, 1 stop bit, ...

// Select Vref and analog inputs, in order to use ADC_Read
ADCON1 = 0; // All porta pins as analog, VDD as Vref
TRISA = 0xFF; // PORTA is input

do {

// Read ADC results and send the upper byte via USART
temp_res = ADC_Read(2) >> 2;
USART_Write(temp_res);
} while (1); // endless loop
}

i know that in mikroC terminal , i can see data comunication , but i don´t have any exemple on labview to work!!

can any one show me any labview exemple or , and a better pic programme ???

 

thanks very mutch.

0 Kudos
Message 1 of 39
(9,846 Views)

Take a look here in your function palette:
Instrument I/O >> Serial

 

Here is something I hope will get you started:

serial read.PNG

 

The first function (white) is called 'VISA Configure Serial Port'.

This is where you will configure : baud rate, stop bits, parity, flow control .... etc

This only needs to occur once, since it is just an initialization step.

 

The rest of the code should be placed in a While Loop.

The loop has a 'wait' function, which controls the aquisition rate.

The loop is stopped whenever the 'stop' button is pressed.

 

To collect data, you can use the 'serial read' function, and wire the number of bits you would like to read.

You may need to parse out the data, if the instrument includes other non-numerical information as well.

To be able to further help you here, you will need to explain what is being communicated by the instrument.

 

After the data is read, it is converted from a sting to a number, in the case of type DBL.

All of this code has, so far, read in a single point.

Since it is in a while loop, it will continue aquiring single points.

So if you use a 'shift register', you can build an array of each point.

 

Lastly, you will pass the built array to a 'waveform graph'.

Cory K
Message 2 of 39
(9,833 Views)
Solution
Accepted by topic author jimboli

jimboli wrote:

i know that in mikroC terminal , i can see data comunication , but i don´t have any exemple on labview to work!!

can any one show me any labview exemple or , and a better pic programme ???


Have you searched for examples? NI comes with serial port examples. Since you are sending out just one byte of information you have to configure the serial port to disable the termination character and set the VISA Read to read just one byte. For the example that Cory gave this means wiring a False to the "Enable Termination Char" input and wiring a 1 to the VISA Read's "byte count" input. I would also suggest using a waveform chart instead of a graph. This way you don't need th shift register or the Build Array function. 

0 Kudos
Message 3 of 39
(9,822 Views)

hello!

thanks very mutch for your help  Cory K and s mercurio !

it help me to understand many things!all the things you said it was very correct !!

i do want to read 10 bits in a chart.

i have tried to do  Cory K  programe , but it do not work !!

i´m missing some thing !!!!!!!!!

i know this is not faire, but can i download your programme????

i´m new at labview, and this interface pic programme !!

if not thank you any way for you precious hellp.I realy did learn somme things!

 

0 Kudos
Message 4 of 39
(9,772 Views)

jimboli wrote:
i do want to read 10 bits in a chart.

i have tried to do  Cory K  programe , but it do not work !!

i´m missing some thing !!!!!!!!!


This is different. Reading 10 bits is different than reading a byte. Your C code showed (as far as I could tell) only sending one byte. You cannot read bits on a serial port. You can only read bytes. So, if you want to read 10 bits you need to read 2 bytes. Please clarify. Also please clarify what you mean by "it did not work". What didn't work? Did you get an error? Did you get data? Did you get no data? Did the computer blow up?

0 Kudos
Message 5 of 39
(9,756 Views)

Smiley Happy no it didn´t blow up !!

yes a understend about 2 bytes!!

well , the programme do not show any error but i´m not reciving any data!

i know that pic is sending data!

i will spende more time to seee what´s going on!!

here is a stupid question!!!!

is there anyone $ programmes whith specific data ????

0 Kudos
Message 6 of 39
(9,749 Views)

jimboli wrote:

Smiley Happy no it didn´t blow up !!

yes a understend about 2 bytes!!

well , the programme do not show any error but i´m not reciving any data!

i know that pic is sending data!


I am assuming you verified with some other program, such as HyperTerminal, if you're on Windows. Can you upload your code?

 

jimboli wrote:
is there anyone $ programmes whith specific data ????

I don't understand what you're asking here. Are you asking if there are programmers you can hire? If so, you can post the information in the Job board.

0 Kudos
Message 7 of 39
(9,742 Views)

Jimboli,

I can attach the VI I showed you above, but that was meant to be a tutorial.

That is not going to work right out of the box for you.

In order to help you out more, you will need to provide us with a little more detail.

 

What is the format of the data that you are receiving?
Have you recieved anything from the instrument yet (in LabVIEW, hyperterminal ...)?

Cory K
0 Kudos
Message 8 of 39
(9,737 Views)

well ,for now i just want to read from pic 0 to 5V, visualise it on a waveform chart.

 if i see  programme runing very slow, i can understend the processe!

then i can creat my oun programme , whith somme help of course!

i have download one programme that i adapted , but it has meny subrotines and loops ..... it is very confuse!

whith that programme a can visualise the adc signal but it gives the same data to ather channels(of labview´s prog)

i think it has some thing to do whith filtering data and use the correct byts!!

i´m reciving 8 bits, and i want 10. but that´s pic prog probleme.

0 Kudos
Message 9 of 39
(9,721 Views)

I'm not quite sure if there was a question in there...

 

To see code running in slow-mode use Highlight mode (the light bulb in the toolbar).

 

You said you "downloaded code". From where? If it's confusing then you can post it, or provide the link to where you got it, and perhaps someone can explain what it does. It's quite possible it's doing more than you need it to.

0 Kudos
Message 10 of 39
(9,713 Views)