Cameras Fieldbus navigation bar

Table of Contents > QUARC > User's Guide > Using Devices

Devices on the Host PC

Another one of QUARC's powerful real-time capabilities is that it allows the devices connected to a host PC to be used to control a remote target. More specifically, QUARC has introduced a set of blocks found in the Simulink Library Browser under the QUARC Targets/Devices/Host library, that allow using devices that are connected to a QUARC host PC to control the real-time code that could be running on a local or remote target. As an example, this powerful capability allows you to use a game controller connected to your PC to tune the parameters of a PID controller running on a mobile robot on the fly! This can be achieved by using the Host Game Controller block found under the same library as mentioned above. This block reads the state of a game controller from the host. The block outputs the game controller co-ordinates and button information. These outputs can be used to control other parameters of the model. For more information about this block please refer to the Host Game Controller block section in QUARC documentation.

Hint QUARC now supports the use of host devices even without MATLAB and Simulink running. See the documentation on the Host Peripheral Client application for details.

All Host blocks now require the presence of a Host Initialize block in the model to configure host-target communications and features.

There are additional blocks for using host devices that can be found under the QUARC Targets/Devices/Host library. Currently provided blocks are listed below.

You can click on each of the above block names to see the corresponding documentation. Although a variety of blocks are offered, the underlying principle of the blocks remains the same. They all allow devices connected to the host PC to be used to control the target. The fact that different devices are supported makes it easier to choose the device that best suits your needs depending on your application. For example the Host Game Controller block is capable of reading button states. The block's buttons output port supports up to 32 button states to be read. However if your application requires more than 32 button states to be read, you can use the Host Keyboard block which can read the state of any key you specify on the keyboard. The block simply outputs a Boolean vector to indicate whether the specified keys have been pressed or not at the current sampling instant.

The Nintendo Wii Remote or "Wiimote" is a device originally designed for gaming purposes but is quickly finding increasing application in other areas. The Host Wiimote block allows real-time code designed in Simulink to interface directly with a Wiimote device connected to the host PC making its 3-DOF accelerometers, four infrared position sensors and 11 buttons accessible to real-time applications.

The state of the wiimote buttons is available at the buttons output as an 11-element vector Boolean values, corresponding to each of the 11 buttons of the wiimote. An element is true if the button is pressed, and false otherwise. To access the state of an individual button, use the Selector block in the Simulink/Signal Routing library. To access the state of every button as a separate signal, use the Demux block in the same library.

The Wiimote block also outputs a 3-vector containing the X, Y and Z axis accelerations, measured in g's, at its xyz_accel output. Again, the Selector or Demux blocks may be used to extract individual accelerations. The Z-axis acceleration will read a positive acceleration due to gravity when the wiimote is held motionless. While it is tempting to double integrate the accelerometer measurements in order to get position, it is important to note that this technique will experience significant drift because any offset in the accelerometer reading, however small, will be integrated. A better method of deriving position would be to use an estimator that combines the accelerometers and IR position sensing to determine absolute position.

The Wiimote is capable of using optical infrared sensing to detect the position of four infrared LEDs (usually mounted on a sensor bar that comes with the Nintendo Wii). Each position is an (x,y) coordinate pair representing the coordinates within a 1024 x 768 grid. The four IR position measurements are available at the IR_x and IR_y outputs, which are 4-vectors with one element for each position sensed. Again, the Selector or Demux blocks may be used to extract individual positions.

Unfortunately, the Wiimote is not always able to detect the positions of all the infrared LEDs because they must be in the line of sight of the device. Hence, the coordinates are not always valid. The IR_valid output is a 4-vector of Boolean values indicating which (x,y) coordinates are valid for the current sampling instant. This output may be used to drive the enable input of a set of Enabled Subsystem blocks to process the sensed positions only when they are valid.

 

navigation bar