|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.aplu.nxt.Part ch.aplu.nxt.Sensor ch.aplu.nxt.I2CSensor ch.aplu.nxt.SuperProSensor
public class SuperProSensor
Class that represents a SuperPro prototype sensor
(HiTechnic NXT SuperPro Prototype Board).
The following I2C register layout is assumed:
Device address 0x10
0x00-0x07 Version number
0x08-0x0F Manufacturer
0x10-0x17 Sensor type
0x42 Analog input channel 0, pin A0, upper 8bits
0x43 Analog input channel 0, pin A0, lower 2bits
0x44 Analog input channel 1, pin A1, upper 8bits
0x45 Analog input channel 1, pin A1, lower 2bits
0x46 Analog input channel 2, pin A2, upper 8bits
0x47 Analog input channel 2, pin A2, lower 2bits
0x48 Analog input channel 3, pin A3, upper 8bits
0x49 Analog input channel 3, pin A3, lower 2bits
0x4C Digital input channels, bits 0..7
0x4D Digitag output channels, bits 0..7
0x4E Digital control, bits 0..7, low: input (default), high: output
0x50 Strobe output, bits 0..3
0x51 LED control, bits 0..3
0x52 Analog output channel 0 mode
0x53 Analog output channel 0 frequency, upper 5bits
0x54 Analog output channel 0 frequency, lower 8bits
0x55 Analog output channel 0 voltage, upper 8bits (exotic!)
0x56 Analog output channel 0 voltage, lower 2bits (exotic!)
0x57 Analog output channel 1 mode
0x58 Analog output channel 1 frequency, upper 5bits
0x59 Analog output channel 1 frequency, lower 8bits
0x5A Analog output channel 1 voltage, upper 8bits (exotic!)
0x5B Analog output channel 1 voltage, lower 2bits (exotic!)
Analog inputs in range 0..3.3V, 10 bit (0..1023)
Digital inputs/outputs 0/3.3V, pin B0..B7, max. 12mA per output (high or low)
Strobe outputs 0..3 general purpose digital output
Strobe output WR: rectangle pulse of approx. 0.5 us length (3V approx.) at every
write action to digital out (B0..B7 ports)
Strobe output RD: rectangle pulse of approx. 0.5 us length (3V approx.) at every
read action of digital in (B0..B7 ports)
Analog output frequency 1..8191 Hz, analog output voltage 0..3.3V (0..1023)
Analog output modes:
0: DC
1: sine wave
2: square wave
3: positive sawtooth
4: negative sawtooth
5: triangle wave
6: pulse width modulation
Nested Class Summary | |
---|---|
static class |
SuperProSensor.LED
Enumeration for the on board LEDs. |
Field Summary | |
---|---|
static SuperProSensor.LED |
blueLED
Constant for the blue onboard LED. |
static SuperProSensor.LED |
redLED
Constant for the red onboard LED. |
Constructor Summary | |
---|---|
SuperProSensor()
Creates a sensor instance connected to port S1. |
|
SuperProSensor(SensorPort port)
Creates a sensor instance connected to the given port. |
Method Summary | |
---|---|
void |
addPrototypeListener(PrototypeListener prototypeListener)
Registers the given prototype listener. |
void |
ledOff()
Turn off both onboard LEDs (red and blue). |
void |
ledOff(SuperProSensor.LED led)
Turn the given onboard LED off. |
void |
ledOn()
Turn on both onboard LEDs (red and blue). |
void |
ledOn(SuperProSensor.LED led)
Turn the given onboard LED on. |
void |
read(int[] ain,
int[] din)
Reads the sensor. |
void |
readAnalog(int[] ain)
Reads the analog input of the sensor. |
void |
readDigital(int[] din)
Reads the sensor. |
void |
setAnalogOut(int port,
int mode,
int frequency,
int voltage)
Enables the digital output. |
void |
setDIO(int[] ioControl)
Sets the direction of the 8 digital input/output channels. |
void |
write(int value)
Writes the lower byte of the given value to the digital output channels. |
void |
write(int[] dout)
Writes the given bit state (low/high) to the digital output channels. |
void |
writeStrobe(int value)
Writes the lower half byte (lower 4 bits) of the given value to the strobe output channels. |
void |
writeStrobe(int[] sout)
Writes the given bit state (low/high) to the strobe output channels. |
Methods inherited from class ch.aplu.nxt.I2CSensor |
---|
getData, getLejosI2CSensor, getLejosPort, getProductID, getVersion, sendData, sendData |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final SuperProSensor.LED redLED
public static final SuperProSensor.LED blueLED
Constructor Detail |
---|
public SuperProSensor(SensorPort port)
port
- the port where the sensor is plugged-inpublic SuperProSensor()
Method Detail |
---|
public void setDIO(int[] ioControl)
ioControl
- the direction of each channel. 0: input, 1: output
(default: all digital channels as input)public void readAnalog(int[] ain)
ain
- an integer array of length 4 where to get the analog valuespublic void readDigital(int[] din)
din
- an integer array of length 8 where to get the valuespublic void read(int[] ain, int[] din)
ain
- an integer array of length 4 where to get the analog valuesdin
- an integer array of length 8 where to get the digital valuespublic void write(int value)
value
- the lower 8 bits are written to the digital output channel.public void write(int[] dout)
dout
- an integer array of length 8 that holds the bit state: 0->low, 1->highpublic void writeStrobe(int value)
value
- the lower 4 bits are written to the strobe output channel.public void writeStrobe(int[] sout)
sout
- an integer array of length 4 that holds the bit state: 0->low, 1->highpublic void ledOn()
public void ledOn(SuperProSensor.LED led)
led
- a value of enumeration LEDpublic void ledOff()
public void ledOff(SuperProSensor.LED led)
led
- a value of enumeration LEDpublic void setAnalogOut(int port, int mode, int frequency, int voltage)
port
- 0: for digital output O0, 1: for digital output O1mode
- the mode (1..5)frequency
- the frequency in Hertz (1..8191)voltage
- the peak-to-peak voltage (0..1021 corresponding to 0..3.3V)public void addPrototypeListener(PrototypeListener prototypeListener)
prototypeListener
- the SuperProListener to become registered.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |