Showing posts with label LabView. Show all posts
Showing posts with label LabView. Show all posts

Wednesday, August 22, 2012

LabVIEW Documentation Resources


LabVIEW modules and toolkits also provide additional documentation specific to those products. In the LabVIEW Help, documentation for modules you have installed appears after the Controlling Instruments book in the Contents tab. Documentation for toolkits you have installed appears under the Toolkits book.LabVIEW includes extensive documentation for new and experienced LabVIEW users.

How to choose the right sensor for your measurement system

Design World Editorial Director Paul J. Heney discusses all things sensors with Jim Schwartz, CompactDAQ Product Marketing Engineer for National Instruments. Schwartz explains the types of sensors available, what they do, common measurements that they take and what kind of signals are created for each. In addition, he talks about some of the issues that engineers sometimes have in selecting the right sensor, as well as exploring some of the resources available.



How to Choose the Right Bus for Your Measurement System

You have hundreds of different data acquisition (DAQ) devices to choose from, each with a variety of compatible buses. It can be difficult to select the right bus for your application needs. Each bus has different advantages and is optimized for throughput, latency, portability, or distance from a host. This podcast examines the most common PC bus options and outlines the technical considerations to keep in mind when choosing the right bus for your measurement application.

Tips on Connecting LabVIEW to Industrial Networks


Most new industrial machines or retrofits require some form of connectivity to an existing communications infrastructure. From industrial fieldbuses to 3G cellular networks to web interfaces, even though each design has its own unique requirements, you can use LabVIEW to make the connection.

LabVIEW is a visual programming platform and development environment that can be used to support the connection of laptops and Programmable Automation Controllers (PACs), including CompactRIO, PXI/cPCI systems, and Industrial PCs (IPCs) to a variety of industrial networks and web technologies.

A CompactRIO programmable automation controller connected with the NI 9144 modular EtherCAT slave chassis over standard CAT5 cabling.
When coupled with PACs, this platform offers a superset of traditional PLC functions, making it easy to retrofit or upgrade an existing installation. PACs outperform PLCs in the areas of high-speed analog measurements and intensive processing algorithms needed for applications like machine condition monitoring (MCM) or machine vision. Because LabVIEW can interface to most industrial networks, PACs are commonly used to augment the PLCs in an existing machine or automation process to increase efficiency or predict maintenance of mechanical gearboxes and motors.
Integration to existing systems
The simplest way to integrate LabVIEW into an existing system is to use the basic analog and digital I/O capabilities of PACs and PLCs to exchange signals. LabVIEW will provide simple updates to a PLC system such as pass/fail status.
For example, a customer used CompactRIO and LabVIEW to acquire a high-speed voltage reading from a gamma-based thickness sensor, and perform the complex inline signal processing required on that data to calculate an extremely accurate thickness measurement for the steel they were rolling. Then they output a simple analog voltage in the 0-10 V range that corresponded to the thickness of the steel over a cable connected to the existing PLCs controlling the rolling mill. The thickness measurement that the PLCs now use is more accurate than before and the customer can produce better quality and more consistent steel. In the end, they maintained their existing PLC control scheme but augmented it to build a better product.
That is just one example of how LabVIEW can be used with communication schemes. Here’s a quick overview of how to connect it to each of the popular industrial networks.
OPC
A widely used method to integrate multiple vendors’ automation controllers is OPC (OLE for process control). OPC is a Windows based standard for accessing industrial devices. Through the OPC client/server architecture, LabVIEW can integrate with a range of PLCs and PACs from a laptop or IPC. The OPC server manages the various industrial communications and provides a common bus for controllers, sensors, and actuators without physically wiring them together. You can use communication gateways as needed to extend to more specialized protocols.
Modbus TCP and Modbus Serial
Modbus TCP and Modbus Serial are two of the more commonly used industrial protocols. Through multiple levels of functionality, LabVIEW supports Modbus TCP and Modbus Serial on any Ethernet or serial port on PCs or PACs. Through its graphical configuration assistant, you can create a Modbus TCP or Modbus Serial I/O server. LabVIEW can act as a Modbus master or slave and specify the different registers to read and write. In addition to the I/O server functions, there is a direct API to the Serial or TCP/IP versions of Modbus for flexibility and performance. That API can query or write to registers, coils, and discrete I/O. It can also check for exceptions.
PROFIBUS
PROFIBUS is an industrial field bus originally developed in Europe. With more than 30 million installed nodes, it is the communication standard for Siemens Automation PLCs, smart sensors, actuators, and I/O. NI supports the more commonly used version of PROFIBUS, DP (Distributed Peripherals).
Our PROFIBUS PCI, PXI, and CompactRIO one-port interfaces function as masters or slaves, connecting to PC-based controllers. The interfaces include a stand-alone configurator and a LabVIEW driver for human machine interface (HMI) and SCADA applications. You can perform PROFIBUS device control or automated test using these interfaces.
EtherCAT
Published as part of the IEC 61158 specification, Ethernet for Control Automation Technology (EtherCAT) implements a master-and-slave architecture over standard Ethernet cabling, typically in a line topology. As a control bus, it focuses on deterministic, high-speed I/O for single-point applications such as machine control and motion.
Both master and slave devices are available for use with EtherCAT. For the master controller, real-time PACs with dual Ethernet ports on the CompactRIO, PXI, and industrial controller platforms are available. There is also an EtherCAT slave with field-programmable gate array (FPGA) intelligence, the 8-slot NI 9144 chassis for C Series I/O modules.
EtherNet/IP
EtherNet/IP is also a real-time Ethernet protocol, managed by the Open DeviceNet Vendors Association (ODVA) and commonly found in Rockwell Automation (Allen-Bradley) PLCs. It communicates over standard Ethernet using TCP/IP and UDP/IP using a master (scanner) and slave (adapter) network architecture.
The EtherNet/IP Drive for Industrial Communication handles explicit messaging and adapter communication on this network. LabVIEW can use explicit messaging to read from and write to tags on a PLC supported by RSLogix 5000 and RSLogix 500. The adapter communication lets LabVIEW function as a slave (adapter), providing implicit I/O data to a remote PLC.
PCMCIA-FOUNDATION-fieldbus-interfaces
NIVarious USB, PCI, and PCMCIA FOUNDATION Fieldbus interfaces can control Fieldbus networks from LabVIEW.
DeviceNet
DeviceNet is another industrial protocol managed by ODVA and commonly found in Rockwell Automation (Allen-Bradley) PLCs. Unlike Ethernet/IP, which is based on the Ethernet physical layer, DeviceNet is based on the CAN physical layer and increases strength and interconnectivity by specifying various parameters, such as the required cable length, connectors, and baud rates.
The DeviceNet for Control PCI and PXI master (scanner) interfaces manage and control a network of DeviceNet slaves. Included with these interfaces is the NI-Industrial Communications for DeviceNet software, which offers a high-level API that supports drag-and-drop I/O variables and explicit messaging function blocks. DeviceNet for Test interfaces for PCI, PXI, and PCMCIA have master (scanner) and slave (adapter) support, best used for testing DeviceNet products. The included test software consists of a configurator, analyzer, and the NI-DNET driver, which provides low-level functions.
CANopen
CANopen is a higher-level protocol based on the CAN physical layer and was developed as a standard embedded network with highly flexible configuration capabilities. Originally designed for motion control applications, it is common in many industry segments including medical equipment, off-road vehicles, public transportation, and building automation.
For CANopen master function, the CANopen LabVIEW Library has high-level, easy-to-use functions to create CANopen master applications. These functions cover the spectrum of CANopen master applications, including transmitting and receiving service data objects (SDOs) and process data objects (PDOs), network management, heartbeat and node guarding, emergencies, and synchronization objects. Because the CANopen functions work on top of NI-CAN driver software, all PCI, PXI, and PCMCIA high-speed NI Series 2 CAN devices can operate as fully functional CANopen master interfaces.
industrial-networks
DeviceNet, Modbus, Profibus, DNP3, and EtherNet/IP are some of the industrial networks supported in LabVIEW.
DNP3
DNP3 (Distributed Network Protocol) was developed by GE Harris to create a standard protocol specification for vendors of power grid SCADA (Supervisory Control and Data Acquisition) components. Since 1993, this open and public protocol has been managed by the DNP3 Users Group. DNP3 is commonly used in North American electric and water utilities for communication between SCADA masters and outstations like Remote Terminal Units (RTUs).
The Industrial Communications for DNP3 software driver programs LabVIEW targets DNP3 outstation devices with such functions as power quality monitoring, phasor measurements, and other smart grid-related analysis. Because DNP3 is built on standard Ethernet, the NI implementation of DNP3 is portable across multiple LabVIEW supported platforms, including Industrial PCs, PXI, and CompactRIO. The DNP3 software driver supports Ethernet communication, file transfer, and time synchronization between master and outstation. Also, multiple communication channels per outstation and multiple sessions (logical devices) per channel may be used.
PCI,-PXI-and-CompactRIO-PROFIBUS-DP-interfaces
PCI, PXI and CompactRIO PROFIBUS DP interfaces can be set for master and slave support.
FOUNDATION Fieldbus
FOUNDATION Fieldbus is a bi-directional serial communication protocol commonly used in process automation. It uses a system of distributed control with intelligent devices, where the control schedule can be downloaded onto the devices instead of a central control system. Of its two versions, NI interfaces support H1.
The USB-8486, PCI-FBUS, and PCMCIA-FBUS series interfaces connect these fieldbus’s devices to standard desktop, industrial, and notebook PCs. With the PCI-FBUS, an IPC can act as the host within this protocol system. Use the USB-8486 and PCMCIA-FBUS for portable data logging and in-the-field configuration and maintenance of devices and networks.
Web and Enterprise connectivity
Enterprise connectivity is also playing a larger role in deployed systems so that off-site users can view the real-time data and change system parameters on the fly. LabVIEW graphical tools provide functions for Web-published software interfaces, Web services, common gateway interface programming, short message service (SMS), and e-mail messaging. In combination with HTTP and FTP servers on CompactRIO, these functions can be used for remote monitoring and control, phone or e-mail alerts, and file transfers of logged data. Leveraging NI third-party partners, you can share data via global cellular networks or synchronize global processes via GPS in LabVIEW.

Thursday, August 16, 2012

LabView with Android


android
download the labview library download the labview library
android technical specifications will familiarize you with the concepts of bluetooth communication.
hacking with labview how to hack with labview instructions

download the labview library
install jki's vi package manager -> jki's vi package manager
download the android package -> labviewhacker_lib_android_bluetooth_library-1.0.0.9.vip or the 2010 edition labviewhacker_lib_android_2010-1.0.0.3.vip
install the package using jki's package manager

other downloads:
sendsensor.apk

technical specifications
the sensors available on an android platform -> http://developer.android.com/reference/android/hardware/sensor.html

int type_accelerometer a constant describing an accelerometer sensor type.

int type_all a constant describing all sensor types.

int type_gravity a constant describing a gravity sensor type.

int type_gyroscope a constant describing a gyroscope sensor type

int type_light a constant describing an light sensor type.

int type_linear_acceleration a constant describing a linear acceleration sensor type.

int type_magnetic_field a constant describing a magnetic field sensor type.

int type_orientation this constant is deprecated. use sensormanager.getorientation() instead.

int type_pressure a constant describing a pressure sensor type

int type_proximity a constant describing an proximity sensor type.

int type_rotation_vector a constant describing a rotation vector sensor type.

int type_temperature a constant describing a temperature sensor type


labview running on a pc communicates with the android platform using bluetooth. the relationship between two bluetooth devices is known as a client and server or master and slave. in a piconet (a collection of these devices), there can be one server and 7 clients communicating with it at one time. for our purposes the computer running labview is the server and the android phone is the client.



before transmission of data can happen the following three events must occur.
1. discovering
  • the server makes a discovery request.
  • clients within bluetooth range (<30ft) that are set to the discoverable mode will respond to this request with a set of information about themselves such as device name, class, and unique mac address. [note: the discovery request can also be initiated by a client. in this case the server and all other devices within range will respond to this request].
  • when the server chooses a client to pair with, a request for pairing is automatically sent to that specific client.
2. pairing
  • the server and the client share a link-key which is used for authentication between the two.
  • once the two devices are paired the server and client share more security sensitive information required for an encrypted connection.
3. connecting
  • the server opens a bluetooth server socket and broadcasts a set of services identified by their channel numbers, names, descriptions and most importantly unique universally unique identifiers (uuid). [note: the uuid is a user defined string and can be anything as long as it stays within its standardized 128-bit format.]
  • the server waits and listens for incoming connection requests.
  • the client performs a service discovery protocol (sdp) lookup during which it searches the services provided by the server to find the one it wants to communicate with. the client does this by going through the uuids the server is providing and tries to match one of them with the uuid it has.
  • upon finding a match, the client requests to communicate on that specific channel.
  • the server hears this request and replies with a confirmation or a rejection. if the request is confirmed, the server shares the requested rfcomm channel with the client.
  • the two devices can now be considered connected and are ready for data transmission. data transmission happens until connection is lost or the server or client terminates the connection.


hacking with labview
here, you will get to set up your android phone and computer to transmit sensor data from the phone to labview.

hardware you will need:
  1. a computer with labview.
  2. a bluetooth adapter. (this is required if you computer does not have a built-in bluetooth card. my laptop does not, so i use the iogear bluetooth 2.1 usb micro adapter.)
  3. an android phone with bluetooth capability (e.g. samsung galaxy, htc, droid, etc.)
  4. usb cable to connect phone to computer.

software you will need: (download the following onto your computer)
  1. labview 2010 or above
  2. drivers for your bluetooth adapter
  3. download the android package
  4. android example.vi (the package in step 3 will install here, c:\program files\national instruments\labview 20xx\vi.lib\labviewhacker\android and run android example.vi)
  5. sendsensor.apk

bluetooth communication between computer and your phone
  • confirm your computer has bluetooth connection. (this hack was tested using the iogear bluetooth 2.1 usb micro adapter)
  • adding your android phone as a device to which your computer can connect to: (these instruction are for windows vista, but similar step should be taken for any other versions of windows)
  • go to control panel > hardware and sound > bluetooth device, and under optionstab you will see a section titled "discovery." check the box that says "allow bluetooth device to find this computer".
  • before clicking okay
  • at the same place, in another tab called devices you will see an "add..." button. click. "add bluetooth device wizard" will begin.
  • before proceeding the phone needs to be discoverable.
  • on your android phone turn on bluetooth. then go to settings > wireless & networks > bluetooth settings, and check the box next to "discoverable." your phone will be discoverable for 2 minutes, during which you can complete the pairing process from your computer.
  • back on the computer
  • click next in the bt wizard.
  • select your specific phone and click next.
  • when it asks you "do you need a pass key to add this device?" choose "let me choose my own pass key" and enter a code (e.g. 0101) and click next.
  • on your android phone you will see a pop up window titled "bluetooth pairing request," input the same code you created on your computer and press okay.
  • back on your computer, a window will pop up saying something like "windows needs to install driver software for your bluetooth peripheral device." choose "locate and install drivers." (if windows is unable to find driver software for "bluetooth peripheral devices," do not worry. proceed by clicking "finish" in the bt wizard.)
  • you should now be able to see your phone as a device under the devices tab incontrol panel > hardware and sound > bluetooth device. (your phone should now be paired with your computer. this does not mean your phone is connected to your computer yet.)

put android application on your phone

  • connect android phone to computer as "usb mass storage."
  • from your computer, open the android folder and copy sendsensor.apk onto the sd card.
  • disconnect phone so to have the sd card recognized by the phone.
  • on your phone, find "files" in the applications folder. click on "phone files" and find sendsensor.apk.
  • click and install. press done.
  • run labview application on your computer
  • navigate to c:\program files\national instruments\labview 20xx\vi.lib\labviewhacker\android and run android example.vi 
  • on the front panel find 'my bluetooth address' and make a note of the value underneath it (e.g. 00:02:43:7b:8c:2a). 
  • on your android phone, find and press on sendsensor (application with a fuchsia logo and a black compass). 
  • when you are asked for bluetooth device id, type in the "my bluetooth address" value. 

before clicking ok, press and hold the dialog box and select "copy all." this is so you can simply paste the address if you restart the application).
  • now press okay. 
  • press "search bt devices" in the android application.
  • press on the bluetooth device that has your computer bluetooth name and address (this option will also have the fuchsia logo next to it as opposed to a bluetooth logo).
  • in the application the screen will change from the "search" tab to the "control" tab.
  • you should now be transmitting data to your vi.


1. 'bluetooth name and address' identifies the bluetooth adapter used by the computer. 

2.'android initialize' creates a channel with user defined uuid and service name. this new channel is added on to the end of the services provided by the server. thus, the channel number is not user defined and depends on how long that list is. it then hangs the server vi until there is an incoming connection request from a client. when this request is received the vi continues if the uuid matches the one in the client's request. 

3. 'android data' reads in 144 bytes over the connection. the format the android application prepares the sensor values requires this specification. we then parse the incoming string based on how we have packaged it on the android side using the various parsing vi

LabVIEW Functions

In addition to a full lineup of measurement and automation hardware and test and monitoring platforms, National Instruments offers the LabVIEW software platform. LabVIEW, which stands for Laboratory Virtual Instrumentation Engineering Workbench, is designed for science and engineering professionals working in the areas of data acquisition, instrument control and industrial automation. In a broad sense, the functions of this platform strive to increase productivity and reduce time to market for developers.

Basic Functions

As a graphical programming environment, LabVIEW allows scientists and engineers to create, measure, test and control applications. Like the platform itself, these applications are fully scalable. LabVIEW functions via a graphic interface – including optional drag-and-drop graphical programming – comprised of icons and flowchart-like wires. The platform helps reduce testing time by synchronizing multiple measurements and analysis in a unified format. LabVIEW functions on Windows, Linux and Mac operating systems.

Specific Functions
LabVIEW's built-in library of instrument drivers allows it to connect to thousands of different instruments and sensors, as does its integration with plug-and-play USB, PCI, Wi-Fi and Ethernet devices. The platform's native analysis and signal processing functions permit it to analyze engineering instruments via frequency analysis, curve fitting and other measurements. LabVIEW's automatic multi-threading allows the platform to handle large data sets, while its execution-highlighting function optimizes code for parallel execution with integrated debugging and visualization tools.

Features
The LabVIEW platform can reuse existing code as well as code from resource libraries, and it supports customized user interfaces. File sharing and collaboration features support interaction with an online community of more than 110,000 active LabVIEW users. National Instruments offers maintenance and support services, including software upgrades, on-demand training resources and modules, as well as direct access to technical support from software engineers.
VariationsLabVIEW is offered in three different versions as of February 2012. Each performs the same basic function but differs in the details. LabVIEW Basic caters to hardware input-output integration and the development of graphical user interfaces. LabVIEW Full adds more than 850 analysis and math functions, plus event-driven programming, to the platform. LabVIEW Professional allows users to deploy applications via program-distribution and source code controls. All versions of LabVIEW perform the basic functions of reading, writing and sharing data.

A Simple Home Alarm System with DAQ and Labview


We all like peace of mind knowing that our home is safe when we are away, at work, or for whatever other reasons. The system here is a simple home alarm system with a motion sensor. The Labview virtual instrument (VI) described here can be easily expanded to a full-fledged alarm system with several sensors, and strategies of detection.
Objectives:
Design a simple alarm system using a PIR (Passive InfraRed) motion sensor that will detect movement on digital input of a DAQ device, and then output an alarm sound using the computer speakers,  sending at the same time a message of intrusion.
Background:
A Passive InfraRed sensor (PIR sensor) is an electronic device that measures infrared (IR) light radiating from objects in its field of view. PIR sensors are often used in the construction of PIR-based motion detectors (see below). Apparent motion is detected when an infrared source with one temperature, such as a human, passes in front of an infrared source with another temperature, such as a wall.(source)
Pre-Requirements:
Labview and DAQmx softwares  installed in your PC, and the DAQ device duly working, and recognised by Labview.
Required Equipment:
NI Labview 2010 Student
NI DAQmx 9.0.2
NI USB-6009 DAQ device
PIR movement sensor C-7288 or similar
Wiring leads

Basic Knowledge:
It is required to have basic knowledge in setting up a simple VI, such as the VI in the project Internet Control of a Labview VI.
The PIR Connections:
The Labview VI:
Build a Labview VI such as shown below. It uses an email SubVI that sends an email notification using SMTP service:
The Labview VI and all the components are available here.
Before Running the VI:
You need to have your DAQ Assistant function correctly set for your DAQ device. Check the above mentioned project Internet Control of a Labview VI.
Next, you need to open the Email_alert_subVI.vi contained in the zipped file just downloaded. You need to set up the SMTP details correctly.
Test the subVI running it, and checking whether you receive the email sent by the subVI.Please note that you have to be online to test the subVI.
 In order to make default the set up constants of SMTP, make current value default in the Block Diagram (e.g. for Sender’s Name constant, right click onto it with mouse, choose Data Operations, and next choose Make Current Value Default, and so on for each constant).
After setting up all constants, save the subVI, and open it, and check if the values you have chosen are shown on your subVIs’s Front Panel. Double check, testing again the subVI ensuring email is sent to you by the subVI.
How it works:
When running continuously the VI, the DAQ device detects motion with PIR sensor. The detected signal generates a 400Hz sinal that is sounded in your PC speakers, and the Intrusion LED on Front Panel of Labview VI is switched on.
The detected signal sends an email alert, using the subVI already set up by you with your SMTC account detals.
The alarm latches, and can be only stopped if you reset it by pressing the RESET button on the Front Panel. After resetting the VI will be ready to detect any new motion.
Tips and Tricks:
  • You can modify the VI in order log each intrusion time to file using a ‘Write To Spreadsheet File.vi’ express VI. There are plenty of examples on Internet on how to do it.
  • Expand your application by integrating more logic into the VI.  Possible scenarios might include a wait of a few seconds after clicking run to give you time to exit your home before the alarm starts to detect motion.
  • You can sent text messages to your cell phone using email to text servies (SMS) such asClickatell, and many other such services. Normally these services are not free, but they are reliable. They all allow free credit to test your system.
  • You can add an arming feature with keyboard input such as the Home Alarm at Student Projects page  found here.
  • You can also add webcam as a motion detector and record any intrusion. You can find a tutorial with Yawcam. The system will send you also a text message (SMS) making use of a cheap webcam. Press here to see the tutorial.
Acknowledgments:
A special thanks is due to NI Developper Zone for inspiration. The actual project is based on article Dorm Room Alarm System Using a PIR Motion Detector, and following resources: