Phidgets
Phidgets let you avoid soldering and microcontroller programming so you
can put together an installation pretty quickly. Good for prototyping.
Phidgets (physical widgets), www.phidgets.com
- primarily supported in Windows, but also on Mac OS X, Linux
- USB devices, installation and re-configuration is "plug and play"
- support available from a number of programming environments:
- Visual Basic
- Visual Basic for Applications (VBA)
- C/C++ (available in Windows, Linux, MacOS)
- Borland Delphi
- Java (Windows, MacOS, Linux)
- etc
USB
- universal serial bus, i.e. lets you hang devices in any order
- use the phidget monitor to see what's successfully connected
- power issues: some phidgets will need separate power (6-12 V DC) in certain heavier-load conditions, others will simply take their power from USB
- you have to wait a bit more the first time you connect a new type of Phidget (or any other USB device for that matter) in a certain USB connector
- sometimes you will get an error the first time, try disconnecting and reconnecting the device, it may work without errors
8/8/8
"Phidget Interface Kit" (8 digital inputs, 8 digital outputs, 8
analog inputs; there exist boards of other sizes)
- we have 5 boards
- will need external power in some USB connectors
- will surely need external power when other phidgets are connected
to the board. If you want to avoid this, connect the phidget directly
to the computer or use a powered USB hub
- use the interface
kit controller to monitor the Phidget Interface Kit
- 8 digital
inputs (see page 5) , basically reading the state of a switch
- 8 digital
outputs
(see page 5)
- basically turns a switch on and off
- simple and frequent example: LEDs
- a LED is a diode, will let current pass in only one direction
- shorter pin to the ground (cathode), the longer one (anode)
to the digital output
- to avoid short, 300 Ohm resistor included in the phidget
output
- 8 analog inputs (page 4)
- you can connect a number of packaged
sensors
- example:
room monitoring (presence, temperature)
- but any other sensor that can be fed with 5V and produce
voltage between 0 and 5V will work. See details below.
- we have 3 sensors for each of: force, light, mini
joystick, rotation, slider, temperature, touch
- besides these, we can also detect acceleration and presence of
RFID tags (see specific phidgets below)
- we don't have at this time sensors for: current, humidity,
magnetic, motion, multi-turn rotation, pressure, vibration, voltage
- always disconnect the USB to the computer before modifying the
interface kit circuit! (attaching analog inputs, digital inputs or
outputs)
Phidget programming in Java. The old libraries can be found here. The new 2.1 libraries are not used in this lecture.
- package Phidgets
- the main documentation is the source of the classes. Luckily it's
very simple
- each phidget is represented by a class with the name like
Phidget*.java
- important Phidget methods
- info: GetSerialNumber(),
GetLibraryVersion(), GetDeviceVersion()
- useful when software and hardware evolve
- GetSerialNumber()
identifies the device uniquely
- Open()
looks for the physical USB device
- you can specify whether you want to open the device in
exclusive mode
- you can specify the serial number of the device, in case
there are more Phidget interface kits attached
- GetIsAttached()
tells whether the device is still attached
- run()
monitors the sensors continuously and will only end when the device is
disconnected
- this of course makes no sense for outputs/actuators like e.g.
motors
- start()
does run() in another thread
- so the main thread is left for other operations, like e.g.
driving outputs
- the thread seems to be a daemon, i.e. if the program main() gets
to the end, the thread dies!
- so you must have some sort of loop, or simply use run()
- Close()
gives away resources needed by your program to access the device
- device-specific methods depend on the actual device function
- most devices let you register listeners
that will have a method called when a device changes state
The Phidget Interface Kit Java API:
- we look at a Java example
- board size
- GetNumOutputs()
the number of digital outputs (8 for our board)
- GetNumInputs()
the number of digital inputs (8)
- GetNumSensors()
the number of analog inputs (8)
- digital input reading: GetInputState(int
index)
- digital output setting: SetOutputState(int
index, boolean value)
- digital output reading: GetOutputState(int
index)
- analog input reading
- GetSensorValue(int
index) returns GetSensorRawValue(int
index) processed according to:
- a normalization minimum: GetSensorNormalizeMinium(int
index), SetSensorNormalizeMinimum(int
index, int value)
- a normalization maximum: GetSensorNormalizeMaximum(int
index), SetSensorNormalizeMaximum(int
index, int value)
- a change trigger: GetSensorChangeTrigger(int index),
SetSensorChangeTrigger(int
index, int value)
- event subscription:
The Phidget Interface Kit lets us connect a variety of sensors and lets
us drive digital outputs. That is not enough though.
Some inputs and outputs need special circuitry so they come as separate
phidgets that are connected via USB to the computer or using the USB
hub on the Phidget Interface Kit
Phidget actuators (outputs):
Phidget sensors (inputs):
- RFID
board
- we have 3
- detects when a certain tag is within 3 inches of the RFID
receiver
- a simple RFID
test program
- one tag can be present only. If more tags are present, one or
none will be reported
- API: (PhidgetRFID):
- the latest RFID tag seen: String
GetLastTag()
- you can register a callback
method to be called whenever a tag comes around
- the device also has some outputs, e.g. a LED
- GetNumOutputs()
- GetOutputState(int
index)
- SetOutputState(int
index, boolean value)
- Java example
- issues
- some older Phidget RFID receivers do not work with the USB
hub of the newer Phidget Interface Kits
- connect them directly to a computer USB instead
- accelerometer
- temperature
sensor with termocouple (-200, +1200 degrees)
- weight
sensor
more about analog input:
high-power
digital output
high-power
digital input:
- external power supply
- < 3 V = 0
- 4-30V = 1
Phidget
videos
Moving towards higher-fidelity
prototypes.
Microcontrollers
- allow you to skip the PC if needed
- allow programming via a serial connection
- sensors/outputs are connected to microcontroller pins, via
specific circuits
- Basic
stamp programmed in BASIC
- PIC
programmed in C
- multithreading: since you read more sensors at a time, it is
important that your microcontroller allows for multiple programming
(multithreading). Early Basic Stamps didn't do this