LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial read from ESP32

Good morning all,

 

Apologies if this has been placed in the wrong area, but I think it is ok. 

1. I am currently using several ESP32 microcontrollers to read micro pore pressure sensors. These are plugged in to com ports on a PC running labview 2018 with NI VISA and associated drivers. 
2. I have successfully interfaced those sensors with labview using the VISA tool kit and can successful read the digital output in a simple labview VI which finds the VISA resource reads and outputs serial. 
3. I am also however using a compactRIO 9045 which is assigned to a project with the same vi. 

4. When I initiate the same piece of labview VI (which works fine in a standlone vi on my pc) I can no longer see the com ports of the pc in my VISA resource drop down list and only the two ASLR:: of the CompactRIO, regardless of refreshing, changing filtering settings and so on I cannot see the com ports of the pc. 
5. I can at all times see the PC com ports in NI MAX and query/read them in the NI VISA panel on NI MAX so I know that the sensor + esp are working fine. 

6. It to me is a strange one and I have tried to allow both systems to have access to one another through the VISA remote/server settings but I am not sure whether this is correct. I have also ensured i am not trying to read the sensor in more than one location. 

Any ideas, or is it simply not possible to read com ports from another device in this case? 

0 Kudos
Message 1 of 8
(913 Views)

You've gone from a "General PC running Windows, communicating over several Serial ports to other devices that send data back to the PC's LabVIEW's program" to a "LabVIEW Real-Time Project, involving a Host Computer (PC) running Windows that has a TCP/IP connection to a "Target" computer (compactRIO) running a Real-Time OS (probably NI Real-Time Linux), into which (I'm assuming, here, not 100% certain I'm right about this) you have connected the microcontrollers.  You now have to write two LabVIEW programs -- a Host routine that starts up the compactRIO and starts it running its program, and the code you write for the compactRIO that does whatever you want it to do with the ESP32.  Note that if the compactRIO reads data from the ESP32, you'll want/need to get these data from the RIO up to the PC, where you can view them (Charts and Graphs) and save them (File I/O).

 

Is this what you are expecting to do?

 

Bob Schor

0 Kudos
Message 2 of 8
(850 Views)

Hi Bob,

 

Thanks for taking the time to reply. My first question wasn’t very clear. Basically I use the PC to interface the Labview program which is running on the compact RIO (I.e the dashboard is controlled from my computer). 

The RIO is connected via usb to the PC, and I deploy the modules/upload labview program to run from the PC. 

What I’m trying to work out is why  in that labview program (which is inside a project configured with the remote system - CompactRIO 9045) do I only see the two com ports on the compact RIO in the drop down for VISA resources in the labview program? 

 

I have tried loads of different things (refreshing, filtering, visa class, security on visa, remote systems, access allowance for the machine in labview, re installing VISA and associates drivers etc), but still, I can only see the com ports of the PC when I am in NIMAX or if I set the same bit of the labview code to run on the PC and not the RIO.

I wonder if in what you say you’ve kind of given me the answer already, maybe running a stand-alone  VI + global variable on PC and reading that global variable in the CompactRIO VI may work? 

It just baffles me as I can query and read them in NIMAX and a labview code on the PC, as well as them being on the list of aliases in NIMAX.  

Thanks,

 

Thomas

 

0 Kudos
Message 3 of 8
(837 Views)

@Tam_95 wrote:

What I’m trying to work out is why  in that labview program (which is inside a project configured with the remote system - CompactRIO 9045) do I only see the two com ports on the compact RIO in the drop down for VISA resources in the labview program?


That is because the VI you are running is in the context of the cRIO.  It makes zero sense for a cRIO to be able to access a COM port on your PC.  If you move your VI to the "My Computer" context, it will see the COM ports on your PC.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 8
(819 Views)

@crossrulz wrote:

@Tam_95 wrote:

What I’m trying to work out is why  in that labview program (which is inside a project configured with the remote system - CompactRIO 9045) do I only see the two com ports on the compact RIO in the drop down for VISA resources in the labview program?


That is because the VI you are running is in the context of the cRIO.  It makes zero sense for a cRIO to be able to access a COM port on your PC.  If you move your VI to the "My Computer" context, it will see the COM ports on your PC.


There is a way to access VISA resources from another system. But it is not trivial and in many cases not very useful. VISA has a so called VISA server, mentioned in the OP, but that doesn't make VISA resources from other systems magically appear as local resources. You have to address them accordingly by defining the correct VISA resource name

 

For the specific setup you would have to enable VISA Server on your PC and then you can address the PC VISA ports from the cRIO by creating a VISA resource similar to "visa://<hostname>/<VISA resource string>"

 

Here hostname is the network name of your PC with enabled VISA Server and the VISA resource string is the according VISA resource name as you would use it on the PC such as ASRL1 or COM1.

 

NI Max will NOT automatically try to enumerate all possible VISA remote servers, as it is already slow enough to enumerate the local resources only. If it would try to do the same for all potential remote addresses, you could go and do a sleep over until it returns with eventual resources. 😁

Rolf Kalbermatter
My Blog
Message 5 of 8
(812 Views)

One point I'm not super clear on- are the ESP32's connected to your Windows PC, or to the RIO?

 

Programs running on the RIO can only see things connected to the RIO. Programs running on the Windows PC can only see things connected to the Windows PC.

 

(Yes, even if you're running a remote VI on the RIO using the Windows machine).

 

Edit: This does not apply with remote the VISA servers Rolf mentioned, but I doubt that's what you're trying to do, and I wouldn't recommend it even if you were trying to do that, as a direct connection will be better all around).

0 Kudos
Message 6 of 8
(805 Views)

OK, back to Square 1.

 

In your original Post, you said you had successfully used ESP32 microcontrollers with LabVIEW 2018 on a PC, and everything worked.  In point 3, you say you are also using a compactRIO 9045 -- why?, and for what?

 

As we've said (in various ways), most RIOs "don't do VISA".  I'm surprised that none of us (yeah, Bob, you too!) asked you to "please attach (all of) your LabVIEW code", because a key question is why are you trying to do serial reads with VISA on a compactRIO that doesn't have a serial interface?

 

It seems to me that you have several choices here, one of which you've already "solved":

  1. Do everything on the PC.  You've already solved reading from the ESP32s in this situation.
  2. Do everything on the compactRIO, except for the ESP32s (because VISA doesn't work "well" on these devices).
  3. Run two programs simultaneously on two machines:  whatever you are doing on the compactRIO (which we know nothing about), and runing the ESP32s on a separate PC (which you already know how to do).
  4. Create a LabVIEW Real-Time Project, with the Host code handling the communication with the ESP32s and communicating with a connected compactRIO via TCP/IP which is doing whatever you want the compactRIO to be doing, with the Host (PC) and Target (RIO) communicating and synchronizing their actions via the TCP/IP connection.

We can probably help you with #4, but you have to tell us a lot more about what you are doing on both Host and Target, and we'll probably need to see some LabVIEW code (real VIs, not pictures of code).  Note that VIs should probably be for versions of LabVIEW no more recent than LabVIEW 2021.

 

Bob Schor

0 Kudos
Message 7 of 8
(791 Views)

@Bob_Schor wrote:

 

As we've said (in various ways), most RIOs "don't do VISA". 


I don't want to detract too much but could you elaborate on this? I haven't used cRIO's in several years, and when I did I didn't need VISA so I never tried it. I do know some cRIO's run Windows now so I assumed it would work. I've also had no trouble using serial devices on Linux before so I assumed they'd work there as well. I can't really find much info online either way other than finding that VISA does work with non-RT Linux.

 

There is another set of options the OP could use-

 

5. Use raw TCP to communicate with the ESP32's rather than VISA. This would require putting the ESP32's on either your local network's wifi or getting a dedicated (non-internet-connected) wifi router for your lab setup.

 

6. Use the MQTT protocol over wifi to potentially simplify things so you don't need to implement your own TCP protocol. This would require a MQTT broker somewhere in the loop, and I kinda doubt you can (or at least, should) run a broker on your RIO.

0 Kudos
Message 8 of 8
(786 Views)