02-06-2012 04:13 PM - edited 02-06-2012 04:15 PM
Hello,
I wanna send this message format (attached jpg) by using serial port. So i made the attached vi, but I faced those problems
how to send the FCS?
how to make it send the message format every 1 second?
And I need to know is this work on right track or not?.
thanks.
Solved! Go to Solution.
02-06-2012 05:36 PM
marvel...,
Several things need to be considered.
First, since you are transmitting binary data and the format specifies how to determine the length of a message, you need to disable termination characters in the intialization VI.
To send the data once per second enclose the VISA Writes in a while loop with a 1000 ms Wait. As long as your messages do not approach 1000 characters you should be OK on timing.
I would concatentate all the characters of the message, except the SOP, to do the FCS. Then prepend the SOP and append the FCS byte. Use one Write to send the whole string.
Lynn
02-07-2012 04:48 PM
really, thanks very much.
but can you explain what are you meant by
"First, since you are transmitting binary data and the format specifies how to determine the length of a message, you need to disable termination characters in the intialization
VI."
and
"I would concatentate all the characters of the message, except the SOP, to do the FCS. Then prepend the SOP and append the FCS byte. Use one Write to send the whole string."
then, is my work on right track?
thanks.
02-07-2012 05:28 PM
Here is a quick modification to your VI showing how to concatenate the strings and use the while loopand Wait functions to repeat once per second.
Some of these things are very basic to LabVIEW. If you have not done so, take a little time to work through the on-line tutorials.
Lynn
02-07-2012 05:44 PM
really, very thanks to you. I'll do my best to learn from your modifications.
and if you can provide me by good on-line tutorials, it'll be nice.
thanks very much for you.
02-07-2012 06:52 PM
sorry, I have a questions on the modifications.
what are you meant by the following:
"set loop to run once per second. "
"Replace with subVI to calculate FCS"
"Disable Termination char >>>"
sorry for disturbing you.
thanks.
02-07-2012 09:01 PM
Look at the on-line tutorials here.
Turn on the context help while programming. The little box will tell you a lot about the functions and VIs in your program or the palettes.
The function above the "set loop to run once per second" note is Wait (ms). It does not end until the number of milliseconds wired to its input have elapsed.
"Replace with subVI ... FCS." In your data format document it tells you how to calculate the FCS. It requires a string containing the CMD, LEN, and data bytes. Its output is the FCS byte. You can write that. Then remove the sequence structure and wire your subVI in it place.
"Disable Termination char." The >>> just point to the False boolean constant I wired to the input on the VISA Configure Serial Port.vi. The Context help does not show that input except as a little stub of a boolean wire, but the detailed help describes it.
These things will be more clear after you have worked through the tutorials.
Lynn
02-07-2012 09:13 PM
thanks very much.
sorry, i don't get what are you meant by
Replace with subVI ... FCS." In your data format document it tells you how to calculate the FCS. It requires a string containing the CMD, LEN, and data bytes. Its output is the FCS byte. You can write that. Then remove the sequence structure and wire your subVI in it place
In my data format document, he told me that it's
"This field is computed as an XOR of all the bytes in the
message starting with CMD and through the last byte of data. The receiver
XORs all the received data bytes as indicated above and then XORs the received
FCS field. If the sum is not equal to zero, the received packet is in error"
thanks.
02-08-2012 10:40 AM
If you do not understand the specifications for your communications protocol, how do you expect to develop a program to implement that protocol?
People who volunteer our time on the Forum do so to help people learn how to use LabVIEW. We have other jobs and do not have the time to do your work for you. If you cannot do it yourself and wish to hire someone, post your job on the Job Openings Board.
I showed you how to get "all the bytes in the
message starting with CMD and through the last byte of data."
XOR is a basic logical operation for which LabVIEW has a primitive function in the Boolean palette.
Lynn
02-09-2012 03:31 AM
sorry for disturbing you and i appreciate your time but the problem was about somthing wrong in the modification but i have solved it.
now, you can see it and told me your opinion if you don't mind.