09-04-2021 01:45 AM
Hi, I have a problem receiving information, which I explained in the file below.
09-04-2021 05:24 AM
How do you know that you start reading at the beginning of a 10 byte piece.
Maybe you start reading somewhere half way and I don't see something that can capture a new start.
Also send the vi instead of (both vi's in fact) and you seem to initialize the port before each read that anyhow causes trouble.
09-04-2021 11:07 AM
What do you think is the solution to my problem?
09-04-2021 11:08 AM - edited 09-04-2021 11:30 AM
Please compose your question directly in the forum editor. You can embed your images here.
As a first step, you should post your code in the LabVIEW forum, because it is highly flawed.
09-05-2021 06:27 AM
Hi there
I'm writing a program for serial communication. The information of FPGA is sent to a computer through a USB using CH340 serial converter. Data is being read through LabVIEW software using the VISA Configure Serial Port VI and VISA Read modules. The submitted information is 8-bit and is sent in a 10-byte package. However, when it is read, the sent bytes are disordered.
In the image below, you can see the part of the FPGA code that is for sending information. This code reads and sends a memory 1024 times.
First two bytes of constant, then two bytes of data and one byte of constant, then two bytes of data and another byte of constant and two bytes of data are sent.
In the image below, you can also see the part of the code that receives the information in LabView.
After reading the information, 10 bytes are separated and we check the place of the constants by a condition that is correct, and if it is correct, the data will be sent to the next stage for processing.
I really appreciate if you could help me to solve this problem
09-05-2021 06:28 AM
What do you suggest to do? I would appreciate if you could spell it out
I needed to index the array to specify the start and end of the 10 bytes of data sent.
10 byte is consisting of 3 types of data: Time, Temperature and pulse shape
This is the reason behind wire indexing the index array
I did not see any relation. They seem to be random
Could you please explain it?
Please explain more about this.
This is an initial connection that determines that there is a proper connection between application and hardware
09-05-2021 09:41 AM - edited 09-05-2021 09:42 AM
In summary. Do a few basic LabVIEW tutorials first. Attach your code (VIs, not pictures!) and make sure that all controls have typical default values.
09-05-2021 10:19 AM
@altenbach wrote:
if the other end is continuously sending ...012345678901234567890123456789012... there is no guarantee that a 10 element segment is 0123456789, could equally be 4567890123. That's a frame shift.
To elaborate on this a little bit...You need to define a message format to that the receiver knows when the message begins and ends. It looks like this is a binary message that you are currently sending. Therefore, I would do something like have a start byte, typically 0x2 (Start Of Text byte as defined by ASCII), followed by your 10 bytes of data, and finally a checksum of some sort. The checksum could be something as simple as a sum of all the data bytes. So I am basically recommending adding 2 bytes to your message. This is also with the assumption that all of the messages are 10 bytes of data. If that changes, then you will need something to tell the receiver how many bytes of data are in the message.
So with this setup, you will first need to make sure the Termination Character is turned OFF. It is an input on the top of the VISA Configure Serial Port (defaults to TRUE). Then I would read a single byte until 0x2 is read. Once that byte is read, read 11 bytes (10 data bytes plus the checksum), perform the checksum operation and verify it is correct. If correct, you know you have a good message and can do whatever with it. If the checksum fails, throw away the data. Regardless, go back to reading 1 byte at a time until 0x2 is read.
If you want even more details, go watch this: VIWeek 2020/Proper way to communicate over serial
Around half way, I get into the binary protocols.
09-06-2021 01:11 AM
Thanks for your help, but I need to constantly get information from the FPGA and process it, and I can not delay doing so. Do you have other suggestions? I will give you my program to make it clearer.
In the case of "x + y", this is a fixed number that is read at the beginning of the program in order to remove (bias voltage) the ambient noise received by the primary data from the rest of the data. The problem I am facing is not in this part. I put an array after Read visa and there I see that my data is received cluttered.
09-06-2021 01:11 AM
To start the message, I send two values in binary, the decimal is 65 and 122, and then two bytes of data related to my analog data. A fixed value of 112 is sent to separate the previous data value and two bytes of data for temperature, then another fixed value of 90 and two bytes of data are sent for time.
I need fast processing and I can not use the set of checks. I tried this way before and it slowed down data receiving a lot and there was a problem in processing my information.