CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

RS-232 transmission for 'Labview' like programs

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jojos



Joined: 30 Apr 2007
Posts: 64

View user's profile Send private message

RS-232 transmission for 'Labview' like programs
PostPosted: Mon Feb 25, 2008 2:06 am     Reply with quote

Hello. I would like your opinion about the project i am working on. I have finished the most of it and the only thing left is the transmission of some 16 bit data over RS232. I have to build such code that programs, like Labview, can receive that. So i am thinking sending first the '$' ,next x where x would be the marking of the variable i am sending e.g. $1 would be the litres variable, $12 would be some other variable e.t.c.
So if i am sending first the $ sequence and then with a printf sending the 16 bit data, would be OK or not?

My main concern is that if the program e.g. labview can understand this for example, Oh PIC is sending $1 ,so its the litres variable, so after $1 it follows a 16 bit variable (or 2 8 bit numbers to be more accurate because when i use printf and sending a 16bit number i can see on the oscilloscope that RS232 transmits 2 8bit numbers of course ). Is Labview capable of receiving 2 8 bit numbers and make them one 16 bit number or do i have to split my 16bit variable with the make8 instruction an send separate two 8 bit numbers e.g. $1 for the high part of the 16bit variable and $2 for the low part of the 16bit variable?

Thank you. I hope i haven't confuse you a lot
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: RS-232 transmission for 'Labview' like programs
PostPosted: Mon Feb 25, 2008 4:35 pm     Reply with quote

jojos wrote:
Hello. I would like your opinion about the project i am working on. I have finished the most of it and the only thing left is the transmission of some 16 bit data over RS232. I have to build such code that programs, like Labview, can receive that. So i am thinking sending first the '$' ,next x where x would be the marking of the variable i am sending e.g. $1 would be the litres variable, $12 would be some other variable e.t.c.
So if i am sending first the $ sequence and then with a printf sending the 16 bit data, would be OK or not?

My main concern is that if the program e.g. labview can understand this for example, Oh PIC is sending $1 ,so its the litres variable, so after $1 it follows a 16 bit variable (or 2 8 bit numbers to be more accurate because when i use printf and sending a 16bit number i can see on the oscilloscope that RS232 transmits 2 8bit numbers of course ). Is Labview capable of receiving 2 8 bit numbers and make them one 16 bit number or do i have to split my 16bit variable with the make8 instruction an send separate two 8 bit numbers e.g. $1 for the high part of the 16bit variable and $2 for the low part of the 16bit variable?

Thank you. I hope i haven't confuse you a lot


You could look at this from the other direction. What protocols are already built into the PC software you would like to interface with. Pick one that is simple to implement or one that already has example code readily available.
jojos



Joined: 30 Apr 2007
Posts: 64

View user's profile Send private message

PostPosted: Tue Feb 26, 2008 12:42 am     Reply with quote

This is the thing that i don't know what program will every the customer will use. So that is the reason i want to create such a code that every program like labview will understand. Also i left behind the idea of using printf instruction as it transfers also, besides, the real data, and data contain formatting values.
So i am splitting my 16bit variables and i am loading in the TXREG. Of course before every 8 bit variable i transfer the $x sequence. So i think i will include in the manual of the application information about the variables transfered through RS232 and for the string of recognition that is coming before any variable.

e.g.

$1 high byte of variable "litres", $2 low byte of variable "litres"
Zer0flag
Guest







PostPosted: Tue Feb 26, 2008 5:06 am     Reply with quote

Why don't you just send the numbers in plain text then? This way even a human will understand them. You can separate the numbers using CR or LF. As far as I know Labview should be able to recognize these automatically and extract the numbers without problems. Look for "Serial" and "VISA".

jojos wrote:
This is the thing that i don't know what program will every the customer will use. So that is the reason i want to create such a code that every program like labview will understand.
jojos



Joined: 30 Apr 2007
Posts: 64

View user's profile Send private message

PostPosted: Tue Feb 26, 2008 8:09 am     Reply with quote

Zer0flag can you explain this more if you can? You mean i just have to send the variables through TXREG ,not with printf that adds formatting data, and in the end of each variable to send the 'LF' byte.My $x sequence is it necessary or not in this occasion?Could you give an example?Thank you
Zer0flag
Guest







PostPosted: Tue Feb 26, 2008 3:41 pm     Reply with quote

I think you can use printf, why not? As I am also new to LabView I have just seen some examples and think this is the right way to do it.
Google for: visa serial labview
jojos



Joined: 30 Apr 2007
Posts: 64

View user's profile Send private message

PostPosted: Wed Feb 27, 2008 5:04 am     Reply with quote

Another thing i wanted to ask is this.Lets say variable x=10 and i want to sent this value through Serial. If HyperTerminal recieve this data it will give a Line feed instruction ,cause 10 is the LF 'new line feed'. My question is this if i transmit x variable to Labview do i have to convert it in ASCII code or the labview will 'understand' that i am sending a variable with value of 10 and not a LF instruction?
jma_1



Joined: 08 Feb 2005
Posts: 147
Location: Wisconsin

View user's profile Send private message

PostPosted: Wed Feb 27, 2008 7:49 am     Reply with quote

Greetings jojos,

Labview does a lot behind the scenes, but it is still just a programming language. A normal serial routine would determine the available bytes and then read them one at a time. If you have logic in the software to look for the LF no problem. If you read the LF and add it to a buffer, no problem. The LF is very distinct and can be searched for or removed if necessary.

The examples in Labview are numerous and very good. Most things from serial communication, event structures, state machines, data acquisition, FFT, etc. are covered.

I like Zer0flag's suggestion of sending ASCII text. If you send text, debugging any data sent is simple and intuitive.

Cheers,
JMA
Steve H
Guest







PostPosted: Wed Feb 27, 2008 10:22 pm     Reply with quote

Here is a link to a project I did several years ago - All the code is available for download. It works with any programming language that can support a) serial or b) Microsoft ActiveX controls (which LabView and VEE can).

geocities.com/hagtronics/pic_das/index.html

HTH - Steve Hageman
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group