What is a Phidget?

From Phidgets Support
Revision as of 21:02, 8 May 2017 by Mparadis (talk | contribs)


Introduction

Phidgets are building-block tools for sensing and control from a computer, tablet, or phone.


In the programming language of your choice, you create applications that use Phidgets to interact with the physical world.

Phidgets connect to a USB port of a computer:




Some Phidgets are a complete, self-contained sensing package.

One example is our Spatial, which measures motion:



Or, a Phidget may be a building block to use other sensors. One example is our Temperature Sensor, which allows use of wire thermocouples:



Or, a Phidget may be a flexible I/O (input/output) board which can record and control analog sensors and digital inputs and outputs. One example is our Interface Kit 8/8/8, with eight ports of each type:



Last but not least, a Phidget may be a VINT Hub, whose versatile ports can be used as inputs or outputs, and can also connect to smart VINT devices.



Other Phidgets and products we sell include:

Data Flow

Data and control flows up and down the USB connection:




You can use more than one Phidget at a time to control motors, measure motion, and much, much more. You can also use multiple sensors, inputs, and outputs on our I/O boards.

Combining these abilities lets you build extensive systems that can sense the environment and react to it.

Programming

Using Phidgets means writing code. Within your code, you can create a software object to access our full Phidget library API to access each type of Phidget and use its functions.

The software object sends and receives data to and from the Phidget:

File:Wiap-image4.png

The software object might be a VoltageInput for the sensors attached to an Interface Kit, or a RFID for an RFID reader, for example.




We provide support for many different languages to program in:

Core Languages Mobile Languages Other Languages
C Sharp C# Objective C Objective C LabVIEW LabVIEW
C/C++ C/C++ Swift Swift Max/MSP Max/MSP
Python Python
Java Java
Visual Basic .NET Visual Basic .NET
JavaScript JavaScript

You can visit the Software Overview page for more information on the supported programming languages.


Writing code for your Phidget can be as simple as creating a handle, opening it, getting a sensor value, and printing it.

A simple, stripped-down program in C# to read the the value of a sensor connected to an Interface Kit might look like this:

#include <stdio.h>
#include <phidget22.h>

int main() {
    // A "VoltageInput" Handle; the name we use to access properties and methods of the channel
   VoltageInput vin;

    // Our Sensor's voltage Reading
    int sensorVoltage;

    // Create a new VoltageInput object
    vin = new VoltageInput();
    
    // Set the channel to the port the sensor is plugged into on the InterfaceKit
    vin.Channel = 0;

    // Open and attach the Phidget, waiting 5 seconds before timeout
    vin.Open(5000);

    // Read Sensor on Port 0
    sensorVoltage = vin.Voltage;

    printf("Hello World!  My channel 0 sensor reads %d volts.\n", sensorVoltage);

    // Close
    vin.Close();
    return 0;
}

The Phidget library includes powerful logging and error checking not shown in this brief program. To see some full-featured example programs, check the downloads section for the language of your choice.




Our software libraries are modular. A VoltageInput software object, for example, has functions you can use to control and read the Voltage Input, such as setting the data interval or reading the voltage:



The API for each Phidget contains multiple of these objects. For example, the 1018 Phidget InterfaceKit uses five distinct objects:



The Phidget Common object contains basic functions like open() and close() and is used by every Phidget. It's the same no matter what Phidget you're using. The other objects will also contain largely the same functions, properties, and events across different Phidgets, although there may be minor differences which are explained in the API manual. For example, the 1024 PhidgetRFID Read/Write has a DigitalOutput object which is just like the one for the 1018 Phidget InterfaceKit:





Not only can you control a Phidget locally, but we also provide a tool called the Phidget Network Server.

The Network Server broadcasts your Phidget's channels over your local network:

NetworkServer PhidgetServer.jpg

This allows other computers on your network to control the Phidget or read data from it. The network server isn't limited to desktop computers- it can also be used with phones or Single Board Computers that are running Phidgets code.


The Network Server also includes the Phidget Dictionary, which is a central place to store your data in key-value pairs.




Your Phidgets program can run under any of the major operating systems. With the Network Server, you can even use operating systems that don't normally have USB ports, such as Android and IOS:

Desktop OSes Mobile/Wireless OSes
OS - WindowsWindows OS - Phidget SBCPhidget SBC
OS - OS XOS X OS - AndroidAndroid
OS - LinuxLinux OS - iOSiOS

With the Network Server, you can even mix and match multiple operating systems to control one Phidget. For example, you could connect your Phidgets to a PhidgetSBC running Linux, and control it over the Network Server using an Android tablet.




The Phidget Library gives the option of using software events, rather than just reading values.

With events, you can let the data come to you as it changes:

This allows clean integration with GUI programs, which are usually already event-driven.


With the combination of events, modular sensors, and network support, your system can range from simple to incredibly complex.

We encourage customers to not only build projects for themselves, but also to design and build real-world products using Phidgets. Our libraries can be distributed with your code to your customers.

And this can all occur with the same devices, and the same flexible software API.

Want to learn more? Check out our:

Questions? Please contact us.