Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interfacing PIC16F877A with Labview via rs232

Status
Not open for further replies.

Vlad.

Full Member level 3
Full Member level 3
Joined
Jun 4, 2012
Messages
179
Helped
3
Reputation
6
Reaction score
4
Trophy points
1,298
Location
Bucharest/Romania
Visit site
Activity points
2,568
Hello, i have about same problem like the starter of this topic, i write a code to send 4 values of 4 parameters(temperature,Voltage1Voltage2, Curent). I send via PIC16f877A with rs232. i send this 4 values with \n. I make a simple program in Labview to read this 4 parameters and display it individual, but the Labview program bottle up the parameters, he don`t know what values is temperature and what values is Voltage. I atach a arhive with the code, the vi file, and a print screen to see what i receive from PIC. Maybe somebody can help me.

This is the link where can be download my sources:**broken link removed**
 

The best way is probably to send more information. Invent a protocol to suit yourself.
For each value, you are sending some number of bytes - more depending on the measurement precision required.

You could use an extra byte, for before each reading. You can put numbers in that byte to identify the measurement type (temperature1, voltage1, etc.)
eg. You can use the first 4 bits to code up to 16 indentifiers.
You can use the remaining bits to signal other stuff, like "begin set" and "end set", to help regain order should the data stream be temporarily interrupted. Decide basic things about this telemetry. Some schemes might only send a single addressed reading when signalled to reply, requiring 2-way communication. Others might use "One-Way-Send-It-Regardless", and let the receiving program sort it out.

Any program needs to be able to read more than a stream of readings. For each data, it needs some identifier as to what reading it is, even if it sees a byte signalling a start of a whole bunch.

There are already very good serial data bus standards, many supported directly by PIC hardware, or published code blocks to give a PIC that feature. eg. CANBUS, ProfiBUS, etc. For your need, it may help to put together a block of 4 readings, and 4 identifiers, along with unique start and stop bytes.
 

Since you are writing both the sender and receiver, do as Darktrax mentioned and invent your own protocol. I do it all the time. In my case, the PC does all the processing (Master) and the PIC acts as an equipment interface (Slave). Set both the PC and PIC to the same hardware settings for communication. The PIC just loops waiting for a command from the PC. When the PC wants something, it sends a command to the PIC to get the value. For your case, I would think the commands could be as simple as:

"1?" would send the temperature
"2?" would send voltage 1
"3?" would send voltage 2
"4?" would send current.
"*?" would send all 4 values in a packet that you design.

You write the return format whatever way you want (the raw hex bytes for the measurements or the measurements converted to ASCII output). Since you are writing the PC side as well, you know exactly what's coming and in what format. Start simple and add features/complexity if required.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top