What is a Phidget?: Difference between revisions

From Phidgets Support
No edit summary
No edit summary
Line 1: Line 1:
[[Category:Overview]]
[[Category:Overview]]
<h3>Phidgets are building-block tools for sensing and control from a computer, tablet, or smartphone</h3>.
<font size="+1"><b>Phidgets</b></font> are <font size="+1" color="#336633">building-block tools</font> for <font size="+1" color="#772222">sensing and control</font> from a <font size="+1" color="#222299">computer, tablet, or smartphone</font>.


<div style="background-color: #f9f9f9; border-color: #1c9edb; border-width:1px; border-style: dashed; padding:15px;">
<div style="background-color: #f9f9f9; border-color: #1c9edb; border-width:1px; border-style: dashed; padding:15px;">
Line 8: Line 8:
Phidgets connect to a USB port of a computer:
Phidgets connect to a USB port of a computer:


[[File:wiap-image1.png|border|500px|link=|alt=]]
[[Image:wiap-image1.png|border|500px|link=|alt=]]


</div>
</div>
Line 32: Line 32:


[[Image:wiap-image2-ifkt.png|border|500px|link=|alt=]]
[[Image:wiap-image2-ifkt.png|border|500px|link=|alt=]]
Last but not least, a Phidget may be a [[What_is_VINT?|VINT Hub]], whose versatile ports can be used as inputs or outputs, and can also connect to smart [[What_is_VINT?|VINT]] devices.
[[Image:wiap-vint.png|border|500px|link=|alt=]]


Other Phidgets are our:
Other Phidgets are our:
* [{{SERVER}}/products.php?category=1 Analog sensors], which plug into our I/O boards,  
* [{{SERVER}}/products.php?category=1 Analog sensors], which plug into our I/O boards,  
* VINT Devices
* Motors, switches, LEDs, and other components,  
* Motors, switches, LEDs, and other components,  
* [{{SERVER}}/products.php?category=21 Single Board Computer] - a complete embedded computer, plus Phidget I/O.
* [{{SERVER}}/products.php?category=21 Single Board Computer] - a complete embedded computer, plus Phidget I/O.
Line 45: Line 50:
Data and control flows up and down the USB connection:
Data and control flows up and down the USB connection:


[[Image:wiap-image3.png|border|600px|link=|alt=]]
[[Image:wiap-image3.png|border|600px|link=|alt=]][[Image:wiap-vintFlow.png|border|600px|link=|alt=]]


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.   
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.   
Line 62: Line 67:
[[Image:wiap-image4.png|border|500px|link=|alt=]]
[[Image:wiap-image4.png|border|500px|link=|alt=]]


The software object might be an {{Code|InterfaceKit()}} for an Interface Kit, or a {{Code|PhidgetRFID()}} for an RFID reader, etc.
The software object might be a {{Code|VoltageInput()}} for the sensors attached to an Interface Kit, or a {{Code|RFID()}} for an RFID reader, for example.


</div>
</div>
Line 71: Line 76:
We provide support for many different languages to program in:
We provide support for many different languages to program in:


[[Image:wiap-image5.png|border|500px|link=|alt=]]
{| style="border:1px solid darkgray;" cellpadding="5px;"
|-style="background: #f0f0f0" align=center
|-
 
|'''Core Languages''' || |'''Mobile Languages''' || |'''Other Languages'''
|-
|[[Image:Icon-CSharp.png|alt=C Sharp|24x24px|link=Language - C Sharp 22]] [[Language - C Sharp 22|C#]] || [[Image:Icon-Android.png|alt=Android Java|24x24px|link=Language - Android Java 22]] [[Language - Android Java 22|Android Java]] || [[Image:Icon-LabVIEW.png|alt=LabVIEW|24x24px|link=Language - LabVIEW 22]] [[Language - LabVIEW 22|LabVIEW]]
|-
|[[Image:Icon-C++.png|alt=C/C++|24x24px|link=Language - C/C++ 22]] [[Language - C/C++ 22|C/C++]] || |[[Image:Icon-iOS.png|alt=iOS|24x24px|link=Language - iOS 22]] [[Language - iOS 22|iOS]] || |[[Image:Icon-MaxMSP.png|24x24px|alt=Max/MSP|link=Language - Max/MSP 22]] [[Language - Max/MSP 22|Max/MSP]]
|-
|[[Image:Icon-Python.png|alt=Python|24x24px|link=Language - Python 22]] [[Language - Python 22|Python]]
|-
|[[Image:Icon-Java.png|alt=Java|24x24px|link=Language - Java 22]] [[Language - Java 22|Java]]
|-
|[[Image:Icon-Visual Basic Net.png|alt=Visual Basic .NET|24x24px|link=Language - Visual Basic .NET 22]] [[Language - Visual Basic .NET 22|Visual Basic .NET]]
|-
|[[Image:Icon-Cocoa.png|alt=Cocoa|24x24px|link=Language - Cocoa 22]] [[Language - Cocoa 22|Cocoa]]
|-
|}


We offer support for even more languages than shown here; please refer to the [[Software Overview]] page for a complete comparison.
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.
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 for an Interface Kit might be:
A simple, stripped-down program in C to read the the value of a sensor connected to an Interface Kit might look like this:


<div class="source">
<div class="source">
<syntaxhighlight lang=cpp>
<syntaxhighlight lang=cpp>
#include <stdio.h>
#include <stdio.h>
#include <phidget21.h>
#include <phidget22.h>


int main(int argc, char* argv[]) {
int main(int argc, char* argv[]) {
     // An "Interface Kit" Phidget Handle
     // A "VoltageInput" Phidget Handle; the name we use to access properties and methods of the Phidget
     CPhidgetInterfaceKitHandle device = 0;
     PhidgetVoltageInputHandle voltageInput;


     // Our Sensor Reading
     // Our Sensor Reading
     int sensorValue;
     int sensorValue;


     // Create, open, and attach
     // Create a new VoltageInput object
     CPhidgetInterfaceKit_create(&device);
     PhidgetVoltageInput_create(&voltageInput);
     CPhidget_open((CPhidgetHandle) device, -1);
      
     CPhidget_waitForAttachment((CPhidgetHandle) device, 10000);
    // Set the channel to the port the sensor is plugged into on the InterfaceKit
    Phidget_setChannel((PhidgetHandle)voltageInput, 0);
 
    // Open and attach the Phidget
     Phidget_openWaitForAttachment((PhidgetHandle)voltageInput, 5000);


     // Read Sensor on Port 0
     // Read Sensor on Port 0
     CPhidgetInterfaceKit_getSensorValue(device, 0, &sensorValue);
     PhidgetVoltageInput_getvoltage(voltageInput, &sensorValue);


     printf("Hello World!  My Port 0 sensor reads %d.\n", sensorValue);
     printf("Hello World!  My Port 0 sensor reads %d.\n", sensorValue);


     // Close and clean up
     // Close and clean up
     CPhidget_close((CPhidgetHandle) device);
     Phidget_close((PhidgetHandle)voltageInput);
     CPhidget_delete((CPhidgetHandle) device);
     PhidgetVoltageInput_delete(&voltageInput);
     return 0;
     return 0;
}
}
Line 110: Line 137:
</div>
</div>


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


</div>
</div>
Line 117: Line 145:
<div style="background-color: #f9f9f9; border-color: #1c9edb; border-width:1px; border-style: dashed; padding:15px;">
<div style="background-color: #f9f9f9; border-color: #1c9edb; border-width:1px; border-style: dashed; padding:15px;">


Our libraries are modular.  An Interface Kit software object, for example, has functions you can use to control the Interface Kit specifically, such as setting the output or reading a sensor:
Our software libraries are modular.  A {{Code|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:
 
 
[[Image:voltageInput_object.jpg|border|300px|link=|alt=]]
 
 
The API for each Phidget contains multiple of these objects. For example, the [http://www.phidgets.com/products.php?product_id=1018 1018 Phidget InterfaceKit] uses five distinct objects:
 


[[Image:Manag-singleobject.png|border|300px|link=|alt=]]
[[Image:1018_objects.jpg|border|600px|link=|alt=]]


The object also has a set of common functions that are the same for all Phidgets, such as the way to open, close, and delete:


[[Image:Manag-inheritedobject.png|border|300px|link=|alt=]]
The {{Code|Phidget Common}} object contains basic functions like {{Code|open()}} and {{Code|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 [http://www.phidgets.com/products.php?product_id=1024 1024 PhidgetRFID Read/Write] has a {{Code|DigitalOutput}} object which is just like the one for the [http://www.phidgets.com/products.php?product_id=1018 1018 Phidget InterfaceKit]:


This common set of Phidget function stays the same across all Phidgets.  The device functions change based on what you can do with each board, such as here for RFID:


[[Image:Manag-inheritedobjectII.png|border|300px|link=|alt=]]
[[Image:1024_objects.jpg|border|400px|link=|alt=]]
 


</div>
</div>
Line 151: Line 185:
<div style="background-color: #f9f9f9; border-color: #1c9edb; border-width:1px; border-style: dashed; padding:15px;">
<div style="background-color: #f9f9f9; border-color: #1c9edb; border-width:1px; border-style: dashed; padding:15px;">


The WebService allows use of operating systems without USB ports.  So, we also provide support for many different operating systems:
Your Phidgets program can run under any of the major operating systems. With the WebService, you can even use operating systems that don't normally have USB ports, such as Android and IOS:
 
{| style="border:1px solid darkgray;" cellpadding="7px;"
|-style="background: #f0f0f0" align=center
|-


[[Image:wiap-image6.png|border|400px|link=|alt=]]
|'''Desktop OSes''' || |'''Mobile/Wireless OSes'''
|-
|[[Image:Icon-Windows.png|alt=OS - Windows 22|24x24px|link=OS - Windows 22]][[OS - Windows 22|Windows]] || |[[Image:Icon-Linux.png|alt=OS - Phidget SBC 22|24x24px|link=OS - Phidget SBC 22]][[OS - Phidget SBC 22|Phidget SBC]]
|-
|[[Image:Icon-Mac-OS.png|alt=OS - OS X 22|24x24px|link=OS - OS X 22]][[OS - OS X 22|OS X]] || [[Image:Icon-Android.png|alt=OS - Android 22|link=OS - Android 22|24x24px|link=OS - Android 22]][[OS - Android 22|Android]]
|-
|[[Image:Icon-Linux.png|alt=OS - Linux 22|24x24px|link=OS - Linux 22]][[OS - Linux 22|Linux]] || [[Image:Icon-iOS.png|alt=OS - iOS 22|link=OS - iOS 22|24x24px|link=OS - iOS 22]][[OS - iOS 22|iOS]] 
|-
|}


With the WebService, you can even mix and match multiple operating systems to control one Phidget.
With the WebService, 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 WebService using an Android tablet.


</div>
</div>
Line 162: Line 208:
<div style="background-color: #f9f9f9; border-color: #1c9edb; border-width:1px; border-style: dashed; padding:15px;">
<div style="background-color: #f9f9f9; border-color: #1c9edb; border-width:1px; border-style: dashed; padding:15px;">


The Phidget Library give the option of using software events, rather than just reading values.
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:
With events, you can let the data come to you as it changes:

Revision as of 21:20, 19 January 2017

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

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:

File:Wiap-image1.png


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

One example is our Spatial, which measures motion:

File:Wiap-image2-spatial.png

Or, a Phidget may be a building block to use other sensors.

One example is our Temperature Sensor, which allows use of wire thermocouples:

File:Wiap-image2-temp.png

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.

File:Wiap-vint.png

Other Phidgets are our:

  • Analog sensors, which plug into our I/O boards,
  • VINT Devices
  • Motors, switches, LEDs, and other components,
  • Single Board Computer - a complete embedded computer, plus Phidget I/O.


Data and control flows up and down the USB connection:

File:Wiap-image3.pngFile:Wiap-vintFlow.png

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.


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# Android Java Android Java LabVIEW LabVIEW
C/C++ C/C++ iOS iOS Max/MSP Max/MSP
Python Python
Java Java
Visual Basic .NET Visual Basic .NET
File:Icon-Cocoa.png Cocoa

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(int argc, char* argv[]) {
    // A "VoltageInput" Phidget Handle; the name we use to access properties and methods of the Phidget
    PhidgetVoltageInputHandle voltageInput;

    // Our Sensor Reading
    int sensorValue;

    // Create a new VoltageInput object
    PhidgetVoltageInput_create(&voltageInput);
    
    // Set the channel to the port the sensor is plugged into on the InterfaceKit
    Phidget_setChannel((PhidgetHandle)voltageInput, 0);

    // Open and attach the Phidget
    Phidget_openWaitForAttachment((PhidgetHandle)voltageInput, 5000);

    // Read Sensor on Port 0
    PhidgetVoltageInput_getvoltage(voltageInput, &sensorValue);

    printf("Hello World!  My Port 0 sensor reads %d.\n", sensorValue);

    // Close and clean up
    Phidget_close((PhidgetHandle)voltageInput);
    PhidgetVoltageInput_delete(&voltageInput);
    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 WebService.

The WebService allows you to control a Phidget over your local network:

This allows your to use more than one computer, or even a smartphone:

File:Webservice general pctoandroid.png

The WebService also includes the Phidget Dictionary, which is a central place to store your data in a distributed application.


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

Desktop OSes Mobile/Wireless OSes
OS - Windows 22Windows OS - Phidget SBC 22Phidget SBC
OS - OS X 22OS X OS - Android 22Android
OS - Linux 22Linux OS - iOS 22iOS

With the WebService, 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 WebService 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.


The library also includes support for using (and distinguishing between) more than one Phidget in your code - even the same type of Phidget.

This is usually done by reference to the unique serial number of each Phidget, as here in a Python code example:

There are other ways to do this, such as setting your own labels, or using our Phidget Manager to detect attached Phidgets.


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.