What is a Phidget?: Difference between revisions

From Phidgets Support
No edit summary
No edit summary
Line 2: Line 2:


==Introduction==
==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:
[[Image:wiap-image1.jpg|500px|link=|alt=|center]]


<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 phone</font>.


----


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:


[[Image:wiap-image1.jpg|500px|link=|alt=]]
Some Phidgets are a complete, self-contained sensing package. One example is a [{{SERVER}}/products.php?product_id=1042 1042]
, which measures motion:
[[Image:wiap-image2-spatial.jpg|500px|link=|alt=|center]]




Line 16: Line 17:




Some Phidgets are a ''complete, self-contained sensing package''.
Or, a Phidget may be a 'building block' to use other sensors. One example is our [{{SERVER}}/products.php?product_id=1048 1048] which allows use of wire thermocouples:
[[Image:wiap-image2-temp.jpg|700px|link=|alt=|center]]


One example is our '''Spatial''', which measures motion:


[[Image:wiap-image2-spatial.jpg|500px|link=|alt=]]
----




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 [{{SERVER}}/products.php?product_id=1018 1018], with eight ports of each type:
[[Image:wiap-image2-ifkt.jpg|700px|link=|alt=|center]]




Or, a Phidget may be a ''building block to use other sensors''. 
----
One example is our '''Temperature Sensor''', which allows use of wire thermocouples:
 
[[Image:wiap-image2-temp.jpg|700px|link=|alt=]]
 
 
 
 
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:
 
[[Image:wiap-image2-ifkt.jpg|700px|link=|alt=]]




Last but not least, a Phidget may be a [{{SERVER}}/products.php?product_id=HUB0000 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.jpg|700px|link=|alt=|center]]




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.jpg|700px|link=|alt=]]


Other Phidgets and products we sell include:
* Sensors, which plug into an [[Phidgets Connectors|Analog Input or VINT Hub Port]]
* [{{SERVER}}/?tier=1&catid=17&pcid=16 Motors], [{{SERVER}}/?tier=1&catid=63&pcid=56 switches], [{{SERVER}}/?tier=1&catid=60&pcid=53 LEDs], and other components
* [{{SERVER}}/?tier=1&catid=1&pcid=0 Single Board Computer] - a complete embedded computer, plus Phidget I/O.


==Data Flow==
==Data Flow==
Data and control flows up and down the USB connection:
Data and control flows up and down the USB connection:
[[Image:wiap-dataflow.jpg|700px|link=|alt=|center]]




[[Image:wiap-dataflow.jpg|700px|link=|alt=]]




You can use [[Using Multiple Phidgets|more than one Phidget at a time]] in your program. 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.


== Software Channels ==
Every Phidget has one or more channels. There are many channel classes, from the Accelerometer class to the VoltageInput class. Each channel class has its own functions, here is an example of some functions available to the VoltageInput channel class:
[[Image:voltageInput_object.jpg|300px|link=|alt=|center]]


You can use [[Using Multiple Phidgets|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.
You can check your Phidgets' API for information about available channels. For example, the [{{SERVER}}/products.php?product_id=1018 1018] has five channels (with five distinct channel classes):
[[Image:1018_objects.jpg|600px|link=|alt=|center]]


== Software Channels ==


Our software libraries are modular.  A {{Code|VoltageInput}} channel class, 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 Phidget class contains basic functions like {{Code|open()}} and {{Code|close()}} and is used by every Phidget. Other classes will also contain largely the same functions, properties, and events, although there may be minor differences which are explained in the API. For example, the DigitalOutput channel on the [{{SERVER}}/products.php?product_id=1024 1024] has the same functions available as the DigitalOutput channel on the [{{SERVER}}/products.php?product_id=1018 1018] (as shown in the image above):
[[Image:1024_objects.jpg|400px|link=|alt=|center]]




[[Image:voltageInput_object.jpg|300px|link=|alt=]]
To help you understand the concepts above, we have included a simple C# program that could be used with the [{{SERVER}}/products.php?product_id=1018 1018].


<syntaxhighlight lang=csharp>
using Phidget22;


The API for each Phidget contains one or more of these channel classes. For example, the [{{SERVER}}/products.php?product_id=1018 1018 Phidget InterfaceKit] uses five distinct channels:
int main() {
    VoltageInput vin; // define a VoltageInput handle


    vin = new VoltageInput(); //instantiate the class
   
    vin.Channel = 0; //specify which channel


[[Image:1018_objects.jpg|600px|link=|alt=]]
    vin.Open(5000); //open the channel, waiting up to 5 seconds for attach


    System.Console.WriteLine("My channel 0 sensor reads " + vin.Voltage); // Get the voltage value


The {{Code|Phidget Common}} class 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 classes 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 [{{SERVER}}/products.php?product_id=1024 1024 PhidgetRFID Read/Write] has a {{Code|DigitalOutput}} class which is just like the one for the [{{SERVER}}/products.php?product_id=1018 1018 Phidget InterfaceKit]:
    vin.Close(); // close the channel
}
</syntaxhighlight>


[[Image:1024_objects.jpg|400px|link=|alt=]]


==Programming==
==Programming==
 
Using Phidgets means writing code. We provide support for many different programming languages:
Using Phidgets means writing code. We provide support for many different languages to program in:


{| style="border:1px solid darkgray;" cellpadding="5px;"
{| style="border:1px solid darkgray;" cellpadding="5px;"
Line 110: Line 104:
|}
|}


Your Phidgets program can run under any of the major operating systems.


Our software libraries can run on all major operating systems:
{| style="border:1px solid darkgray;" cellpadding="7px;"
{| style="border:1px solid darkgray;" cellpadding="7px;"
|-style="background: #f0f0f0" align=center  
|-style="background: #f0f0f0" align=center  
Line 125: Line 119:
-->
-->
|}
|}
With the [[#Network Server|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 iPad running iOS.
You can visit the [[Software Overview]] page for more information on the supported programming languages and operating systems.
Within your code, you can create a software channel that connects to a channel on the Phidget and use our API to control and read data from that channel. The software channel might be a {{Code|VoltageInput}} for the sensors attached to an Interface Kit, or a {{Code|RFID}} for an RFID reader, for example.
The software channel sends and receives data to and from the Phidget:
[[Image:wiap-methods.jpg|600px|link=|alt=]]
You can [[Phidget Programming Basics|open a channel]] on the device and then [[Polling vs. Events|poll it for data]] or set up an [[Polling vs. Events|event handler]] to process data as it comes in.
----
Writing code for your Phidget can be as simple as creating a channel, 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:
<syntaxhighlight lang=csharp>
using Phidget22;
int main() {
    // A "VoltageInput" Handle; the name we use to access properties and methods of the channel
    VoltageInput vin;
    // Create a new VoltageInput channel
    vin = new VoltageInput();
   
    // Set the channel to the port the sensor is plugged into on the InterfaceKit
    vin.Channel = 0;
    // Open the channel, waiting up to 5 seconds for attach
    vin.Open(5000);
    // Read Sensor on Port 0
    System.Console.WriteLine("My channel 0 sensor reads " + vin.Voltage);
    // Close
    vin.Close();
}
</syntaxhighlight>
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.


== Network Server ==
== Network Server ==
Not only can you control a Phidget locally, but we also provide a tool called the [[Phidget Network Server]]. The Network Server exports your Phidget's channels over your local network:
[[Image:NetworkServer_PhidgetServer.jpg|link=|800px|center]]


Not only can you control a Phidget locally, but we also provide a tool called the [[Phidget Network Server]]. 
The Network Server exports your Phidget's channels over your local network:
[[Image:NetworkServer_PhidgetServer.jpg|link=|800px]]


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 [[OS_-_Phidget_SBC|Single Board Computers]] that are running Phidgets code.  
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 [[OS_-_Phidget_SBC|Single Board Computers]] that are running Phidgets code.  
Line 188: Line 131:


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



Revision as of 22:56, 7 July 2017


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 a 1042 , which measures motion:




Or, a Phidget may be a 'building block' to use other sensors. One example is our 1048 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 1018, 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.



Data Flow

Data and control flows up and down the USB connection:



You can use more than one Phidget at a time in your program. 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.

Software Channels

Every Phidget has one or more channels. There are many channel classes, from the Accelerometer class to the VoltageInput class. Each channel class has its own functions, here is an example of some functions available to the VoltageInput channel class:


You can check your Phidgets' API for information about available channels. For example, the 1018 has five channels (with five distinct channel classes):


The Phidget class contains basic functions like open() and close() and is used by every Phidget. Other classes will also contain largely the same functions, properties, and events, although there may be minor differences which are explained in the API. For example, the DigitalOutput channel on the 1024 has the same functions available as the DigitalOutput channel on the 1018 (as shown in the image above):


To help you understand the concepts above, we have included a simple C# program that could be used with the 1018.

using Phidget22;

int main() {
    VoltageInput vin; // define a VoltageInput handle

    vin = new VoltageInput(); //instantiate the class
    
    vin.Channel = 0; //specify which channel

    vin.Open(5000); //open the channel, waiting up to 5 seconds for attach

    System.Console.WriteLine("My channel 0 sensor reads " + vin.Voltage); // Get the voltage value

    vin.Close(); // close the channel
}


Programming

Using Phidgets means writing code. We provide support for many different programming languages:

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


Our software libraries can run on all major operating systems:

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

Network Server

Not only can you control a Phidget locally, but we also provide a tool called the Phidget Network Server. The Network Server exports 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.

Further Reading

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.