Phidget InterfaceKit
This element allows you access
to PhidgetInterfaceKit devices, I/O boards with digital inputs,
digital outputs and/or analog outputs., like devices 1010, 1011, 1012,
1018, 1019 and 1203.
The analog inputs are used to measure continuous quantities, such as
temperature, humidity, position, pressure, etc. The digital outputs can
be used to drive LEDs, solid state relays, transistors; in fact,
anything that will accept a CMOS signal. The digital inputs can be used
to convey the state of devices such as push buttons, limit switches,
relays, and logic levels.
With this element, you can access to the module directly (with the
serial number) or through the network, using the WebService of the
phidget's driver in a remote computer with the phidget
Interfacekit
connected (here, you need the IP, port and password too).
Usage
To use any Phidget element,
drag an drop its icon to the list of
model elements of your model. Then, edit the connection parameters and
invoke phidget.connect()
in your code.
All methods returning a
boolean will return true
on
successful completion of the command, false
otherwise. Methods
returning a double value will return Double.NaN
if there is any
error when connecting to the phidget.
Available method for this
group of phidgets include:
- public boolean connect();
// establish the connection. Returns true if successful
- public int getAnalogCount();
//Returns the number of analog inputs on the Interface Kit.
- public int getDigitalInCount();
//Returns the number of digital inputs on the Interface Kit.
- public int getDigitalOutCount();
//Returns the number of digital outputs on the Interface Kit.
- public boolean setDigitalOut(int
ind, boolean value); //Sets the state of a digital output.
Setting this to true will activate the output, False is the default
state.
- public boolean
digitalOutputStatus(int ind); //Returns the state of a digital
output. Depending on the Phidget, this value may be either the value
that you last wrote out to the Phidget, or the value that the Phidget
last returned. This is because some Phidgets return their output state
and others do not. This means that with some devices, reading the
output state of a pin directly after setting it, may not return the
value that you just set.
- public boolean getDigital(int
ind); //Returns the state of a digital input. Digital inputs
read True where they are activated and false when they are in their
default state.
- public int
readAnalogSensorValue(int ind); //Returns the value of a analog
input. The analog inputs are where analog sensors are attached on the
InterfaceKit 8/8/8. The valid range is 0-1000.
- public int readAnalogADValue(int
ind); //Returns the raw value of a analog input. This is a more
accurate version of readAnalogSensorValue. The valid range is 0-4095
(12-bits).
- public boolean setDataRate(int
ind, int value); //Sets the data rate of a sensor, in
milliseconds.
- public int getDataRate(int ind);
//Gets the data rate of a sensor, in milliseconds.
- public int getDataRateMax(int
ind); //Gets the maximum data rate of a sensor, in
milliseconds.
- public int getDataRateMin(int
ind); //Gets the minimum data rate of a sensor, in milliseconds.
Example of use
// Init the module
myInterfaceKit.connect();
// Some values on digital outputs
myInterfaceKit.setDigitalOut(7, true);
myInterfaceKit.setDigitalOut(1, !myInterfaceKit.getDigital(6));
// Reading sensors
Sensor0 = myInterfaceKit.readAnalogSensorValue(0)); // value from 0 to 1000
Sensor1 = myInterfaceKit.readAnalogADValue(0)); // More precision, value from 0 to 4095