What is a Phidget?: Difference between revisions

From Phidgets Support
No edit summary
No edit summary
Line 67: Line 67:
Combining these abilities lets you build extensive systems that can sense the environment and react to it.
Combining these abilities lets you build extensive systems that can sense the environment and react to it.


== Software Objects ==
== Software Channels ==


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:
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:




Line 75: Line 75:




The API for each Phidget contains multiple of these objects. For example, the [{{SERVER}}/products.php?product_id=1018 1018 Phidget InterfaceKit] uses five distinct objects:
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:




Line 81: Line 81:




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 [{{SERVER}}/products.php?product_id=1024 1024 PhidgetRFID Read/Write] has a {{Code|DigitalOutput}} object which is just like the one for the [{{SERVER}}/products.php?product_id=1018 1018 Phidget InterfaceKit]:
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]:




Line 130: Line 130:
You can visit the [[Software Overview]] page for more information on the supported programming languages and operating systems.
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 object that connects to a channel on the Phidget and use our API to control and read data from that channel. 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.
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 object sends and receives data to and from the Phidget:
The software channel sends and receives data to and from the Phidget:




Line 144: Line 144:




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 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:
A simple, stripped-down program in C# to read the the value of a sensor connected to an Interface Kit might look like this:
Line 159: Line 159:
     int sensorVoltage;
     int sensorVoltage;


     // Create a new VoltageInput object
     // Create a new VoltageInput channel
     vin = new VoltageInput();
     vin = new VoltageInput();
      
      
Line 165: Line 165:
     vin.Channel = 0;
     vin.Channel = 0;


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


Line 171: Line 171:
     sensorVoltage = vin.Voltage;
     sensorVoltage = vin.Voltage;


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


     // Close
     // Close
     vin.Close();
     vin.Close();
     return 0;
     return (0);
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 185: Line 185:
Not only can you control a Phidget locally, but we also provide a tool called the [[Phidget Network Server]].   
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:
The Network Server exports your Phidget's channels over your local network:


[[Image:NetworkServer_PhidgetServer.jpg|link=|800px]]
[[Image:NetworkServer_PhidgetServer.jpg|link=|800px]]

Revision as of 19:52, 27 June 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 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.

Software Channels

Our software libraries are modular. A 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 API for each Phidget contains one or more of these channel classes. For example, the 1018 Phidget InterfaceKit uses five distinct channels:



The Phidget Common class 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 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 1024 PhidgetRFID Read/Write has a DigitalOutput class which is just like the one for the 1018 Phidget InterfaceKit:


Programming

Using Phidgets means writing code. 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

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

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

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 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 VoltageInput for the sensors attached to an Interface Kit, or a RFID for an RFID reader, for example.

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



You can open a channel on the device and then poll it for data or set up an 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:

#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 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
    sensorVoltage = vin.Voltage;

    System.console.WriteLine("My channel 0 sensor reads " + 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.

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.