LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Read different bytes to read

Solved!
Go to solution

Hi, i'm working on a project with dc voltage measure, so i'm using a esp-32 wifi to connect to tcp in labview, but when i trying to read voltage above 10V the indicator have a error, he doesnt display a exact voltage, when i use 4 bytes every voltage under 10V is showing up exact what i want but above then 10V, the indicator show up many number that i dont know what numbers are.

I know that under 10V is 4 bytes but above 10V is more then 4 bytes, so i want know how to fix it.

0 Kudos
Message 1 of 11
(444 Views)

What is the protocol definition for communicating with the device. No one here can tell you how to fix your code because no one knows the protocol used to communicate with your device. TCP/IP are simply transport protocols and do not provide any detail on the device protocol used to actually have a meaningful conversation with your device. This protocol could be ASCII or binary. However you need to determine exactly what that is first. When you provide those details then we can provide advice on how to communicate with your device and properly read the voltages.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 11
(418 Views)

hi, sorry about that, i'm new at labview so i dont know many things, what i can do is tell what the project to help something.

I'm using a 12V supply conected to a dc voltage sensor that go to a potenciometer and go to esp-32 using the Analog Read at Arduino IDE(first image), so i use the IP of WiFi and put at labview to run the voltage reader.
So every time that run the labview program , it get in real time the voltage that provided by the 12V supply and i can change the voltage using the potenciometer, but >10V i have a error that i dont know what is it.
I dont know if is ASCII or binary sorry.

I can make a video of the process if you want

Download All
0 Kudos
Message 3 of 11
(403 Views)

A video will do no good either. You are effectively asking us to translate speech without telling us the language that is being spoken. How is the arduino formatting the data that it is sending? Based on the pictures you posted it looks like it is sending the data back in ASCII form. However, how exactly is the data being formatted? Is it using a termination character after each response/data element? In order to assist you we need this information. By the way, this information has nothing to do with LabVIEW. This is entirely defined by the code on your arduino and any programming language reading the data would need to know how it is formatted in order to read and interpret it correctly.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 11
(384 Views)

Are you sure your Analog inputs can actually convert voltages higher than 10V? That would be pretty unusual for microcontroller boards since they do NOT contain lots of signal conditioning (usually almost zero) to adapt signal input ranges to the analog ranges that the ADC can handle. 10V is already pretty high for most ADCs, many only go to a maximum of 5V or even less. And the cheap ones won't be happy with a negative input at all.

Your ESP-32 chip has normally up to 18 ADCs which can have an analog input range of 100 - 950mV, 100 - 1250mV, 150 - 1750mV or 150 - 2450mV by selecting an according attenuation for the onboard VRef source. Anything above that needs to be reduced by some external voltage attenuation circuitry which in the worst case can be a simple resistor voltage divider and in a more luxury version it is a real Op-Amp based amplificator with an amplification factor of less than 1!

 

Your formula in the second last images seems to indicate that you use a voltage divider resistor network. But you forgot to mention what your resistor values are nor did you explain why you use 3.3V in the first calculation for the range of the 12-bit ADC (4096 division factor). And you also do not explain how you make your ADC bipolar as seen in the first measurement graphs while it is clearly unipolar in input range according to the datasheet for the ESP-32.

 

Other than that: I refuse to debug images! It is as simple as that!

Rolf Kalbermatter
Averna BV
0 Kudos
Message 5 of 11
(358 Views)

Ok, i will try to explain, i'm using a 12V supply connected to a dc voltage sensor that have a voltage divisor, have a 30k and 7.5k resistors, so if i do the math the result is out = in/5, "

If you don’t have one of these you can use a couple of resistors. The divider I used has two resistors:

  • A 30k resistor on the “high-side”, the connection between the output and the input voltage.
  • A 7.5k resistor between the output and ground.

This will reduce the voltage input by about a factor of 5."

Thats why i can use this 12V because at in esp-32 will receive about 2.4V

I'm using the 3.3V because its connected to a potenciometer, then i have to put the max voltage 3.3* potenciometer range and divide by 4095.

 

I'm using a second program that use the IP as well, here its working:

image.png

At this program I can see the bytes:

under 10V  its 4 bytes:

image.png

And above 10V its 5 bytes:

image.png

 

But when i put 4 bytes at TCP Read above 10V have an issue, its start to show random numbers and when i put 5 bytes i have a error 56.

 

At arduino IDE i dont have the issue:

PedroSantana_2-1643120659554.png

 

0 Kudos
Message 6 of 11
(316 Views)

Since your device is sending different length responses and it doesn't look like it is using a termination character, try reading 10 bytes and change the mode to Immediate. Since you are always reading 4 bytes you are not in sync with the data stream and end up misinterpreting the data.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 11
(298 Views)

when i put more then 4 bytes i get error 56(Error 56 – LabVIEW: The network operation exceeded the user-specified or system time limit.), it can be my internet, dns, ports something like this?? or just a error at labview?

0 Kudos
Message 8 of 11
(277 Views)
Solution
Accepted by topic author PedroSantana

Did you change the read mode to Immediate as I suggested? If you leave the mode set to Standard as you have done you will get a timeout if you specify more bytes than the data has. When the mode is set to immediate it will return any amount of data that it receives immediately up to the number of bytes you specified. Since your device sends either 4 or 5 bytes as the response, you need to be able to handle this. Here is a simple example of what I am suggesting.

 

TCP With Immediate Read.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 11
(263 Views)

@Mark_Yedinak wrote:

Since your device is sending different length responses and it doesn't look like it is using a termination character, try reading 10 bytes and change the mode to Immediate. Since you are always reading 4 bytes you are not in sync with the data stream and end up misinterpreting the data.


Actually he could also use the client.println() command to send the final data point and then there would be a Carriage Return and Line Feed after the value and he could explicitly use the according termination mode on TCP Read with a larger number of bytes to read as you suggest.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 10 of 11
(240 Views)