LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Architecture for multiple sensors through USB input

Background:

 

  • I have a system that transmits temperature and humidity data from different sections of a lab to an Arduino which, in turn, passes the data to my computer via Serial/USB.
  • Each sensor has a specific ID number and powers on and off during operation via a local control (eg. a light switch)
  • Each sensor has properties stored locally that need to be sent based on user command

I would like to make a project that handles passing the data from the serial port to a display vi as efficiently as possible.I have this idea for a general architecture but would appreciate a sanity check from the community.
 

ChamberStream.PNGCurrent Design Idea


Each Vi would have the following responsibilities:

Send/Recieve.vi (Master/Slave):
Similar to this master/slave loop where the master loop triggers the read slave if data is at the serial port and triggers the write slave loops based on a dynamic event from Control.vi



Parse Data.vi (Action Engine): 

  • Inputs:
    • init/set enum (required) 
    • data received by Send/Recieve.vi (optional)
    • ID for Queue used in Display.vi (optional)
  • If enum == init 
  • if enum ==set
  • Parse string from Send/Recieve.vi to get sensor ID and info
    • If sensor ID is new,
      • create a new instance of the Sensor [#] FGV.vi
      • link the vi ref to the ID in a 2D
    • else
      • pull the vi ref from the 2D array
    • write data to the instance of Sensor [#] FGV.vi via  Asynchronous Call
    • write vi ref to Queue used in Display.vi

Sensor [#] FGV.vi (FGV):

  • write to encapsulated sensor class and output a Class indicator when called

Front Panel.vi

  • Holds SubPanels for Display.viLog.vi, and Control.vi

Display.vi (Queued State Machine):

  • Displays indicators from Sensor [#] FGV.vi(s) as an array of class indicators.

Control.vi (Event-driven Producer Consumer loop)

  • Handles user input commands to Send/Recieve.vi and Display.vi.

 


Log.vi (Action Engine):

  • Inputs:
    • Description String
    • Log data
  • Adds Log data to 4D array of [Sensor ID, Sensor Data Type, Sensor Data, Log time]
  • Saves Description String to text file for debug history.
0 Kudos
Message 1 of 5
(832 Views)

@ATE-EGNE wrote:

Background:

 

  • I have a system that transmits temperature and humidity data from different sections of a lab to an Arduino which, in turn, passes the data to my computer via Serial/USB.
  • Each sensor has a specific ID number and powers on and off during operation via a local control (eg. a light switch)
  • Each sensor has properties stored locally that need to be sent based on user command

I would like to make a project that handles passing the data from the serial port to a display vi as efficiently as possible.I have this idea for a general architecture but would appreciate a sanity check from the community.
 

ChamberStream.PNGCurrent Design Idea


Each Vi would have the following responsibilities:

Send/Recieve.vi (Master/Slave):
Similar to this master/slave loop where the master loop triggers the read slave if data is at the serial port and triggers the write slave loops based on a dynamic event from Control.vi



Parse Data.vi (Action Engine): 

  • Inputs:
    • init/set enum (required) 
    • data received by Send/Recieve.vi (optional)
    • ID for Queue used in Display.vi (optional)
  • If enum == init 
  • if enum ==set
  • Parse string from Send/Recieve.vi to get sensor ID and info
    • If sensor ID is new,
      • create a new instance of the Sensor [#] FGV.vi
      • link the vi ref to the ID in a 2D
    • else
      • pull the vi ref from the 2D array
    • write data to the instance of Sensor [#] FGV.vi via  Asynchronous Call
    • write vi ref to Queue used in Display.vi

Sensor [#] FGV.vi (FGV):

  • write to encapsulated sensor class and output a Class indicator when called

Front Panel.vi

  • Holds SubPanels for Display.viLog.vi, and Control.vi

Display.vi (Queued State Machine):

  • Displays indicators from Sensor [#] FGV.vi(s) as an array of class indicators.

Control.vi (Event-driven Producer Consumer loop)

  • Handles user input commands to Send/Recieve.vi and Display.vi.

 


Log.vi (Action Engine):

  • Inputs:
    • Description String
    • Log data
  • Adds Log data to 4D array of [Sensor ID, Sensor Data Type, Sensor Data, Log time]
  • Saves Description String to text file for debug history.

I like to follow the KISS principle. I have a similar setup, but using a Raspberry PI not an Arduino, but it would work the same way. I would use the Ethernet interface and not serial/usb, because then you are not limited in distance, etc.

 

Since you just measure temperature and humidity, you do not really need a lossless communication. I simply run an UDP server on my RPi, and broadcast telegrams to an IP (using Python code for UDP and sensors). On the LabVIEW side I just use a simple UDP client. That is all, simple and works...

 

Message 2 of 5
(776 Views)

@Blokk wrote:
I like to follow the KISS principle. I have a similar setup, but using a Raspberry PI not an Arduino, but it would work the same way. I would use the Ethernet interface and not serial/usb, because then you are not limited in distance, etc. 

To confirm, you're saying that the sensors would still communicate wirelessly to the Arduino, but change the Arduino to communicate over ethernet to the computer? 

 

Since you just measure temperature and humidity, you do not really need a lossless communication. I simply run an UDP server on my RPi, and broadcast telegrams to an IP (using Python code for UDP and sensors). On the LabVIEW side I just use a simple UDP client. That is all, simple and works...


Ok, I'm not familiar with running a UDP server. You're suggesting that I recode my Arduino to act as the server, and have it broadcast its signal to an IP address which my LabVIEW .vi is set to read? Do you know of a tutorial anywhere I can follow to get a better understanding of how to do this? Also, am I able to pick an arbitrary IP address or do I need to follow a convention of some sort?

0 Kudos
Message 3 of 5
(748 Views)

Just Google for "Arduino/Raspberry pi UDP Python code". It is like 6 lines in Python...

You can broadcast to a specific IP address, it is your choice. If you use a local network, it should be your PC's IP obviously. There is even an option with UDP when it broadcasts to all available IP addresses in the network. As i remember this is blocked in Raspberry pi due to security reasons.

 

LabVIEW help menu has a very simple UDP client example, just search for UDP in the help menu...

 

edit: of course, you can also use LabVIEW (Linx) for the UDP server too on the Arduino side. 

Message 4 of 5
(744 Views)

This all seems dead simple to me and unless I am missing something here your architecture looks overly complex for simply logging and displaying serial data

 

If your sensors are already wireless what does it matter how the Arduino connect to the computer?

 

Classes? You are just parsing serial data, and I am guessing you programmed the Arduino so instead of making a complicated LabVIEW program to parse a complicated data format coming from the Arduino, SIMPLIFY the data format coming from the Arduino. 

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 5 of 5
(734 Views)