Contenu connexe
Similaire à Lab view manual
Similaire à Lab view manual (20)
Lab view manual
- 2. Labview Manual
© 2011 Phidgets Inc.
All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, or
mechanical, including photocopying, recording, taping, or information storage and retrieval systems - without the
written permission of the publisher.
Products that are referred to in this document may be either trademarks and/or registered trademarks of the
respective owners. The publisher and the author make no claim to these trademarks.
While every precaution has been taken in the preparation of this document, the publisher and the author assume no
responsibility for errors or omissions, or for damages resulting from the use of information contained in this
document or from the use of programs and source code that may accompany it. In no event shall the publisher and
the author be liable for any loss of profit or any other commercial damage caused or alleged to have been caused
directly or indirectly by this document.
Printed: April 2011 in Canada
- 3. Content
Table of Contents
Part 1 Welcome to Phidgets 11
Part 2 Introduction 12
1 Understanding Phidgets
................................................................................................................................... 13
2 Platform Support
................................................................................................................................... 14
Part 3 Programming Concept 15
1 Getting Started
................................................................................................................................... 16
2 Event................................................................................................................................... 19
Handler
3 Multiple Devices
................................................................................................................................... 22
Part 4 Phidgets Common 23
1 ErrorHandler
................................................................................................................................... 24
2 PhidgetClose
................................................................................................................................... 25
3 PhidgetDelete
................................................................................................................................... 26
4 PhidgetEventCloseOnError
................................................................................................................................... 27
5 PhidgetEventCreateOnError
................................................................................................................................... 28
6 PhidgetEventExeOnError
................................................................................................................................... 29
7 PhidgetGetDeviceClass
................................................................................................................................... 30
8 PhidgetGetDeviceID
................................................................................................................................... 31
9 PhidgetGetDeviceLabel
................................................................................................................................... 32
10 PhidgetGetDeviceName
................................................................................................................................... 33
11 PhidgetGetDeviceType
................................................................................................................................... 34
12 PhidgetGetDeviceVersion
................................................................................................................................... 35
13 PhidgetGetServerStatus
................................................................................................................................... 36
14 PhidgetLibraryVersion
................................................................................................................................... 37
15 PhidgetOpen
................................................................................................................................... 38
16 PhidgetOpenRemote
................................................................................................................................... 39
17 PhidgetOpenRemoteIP
................................................................................................................................... 40
18 PhidgetServerAddress
................................................................................................................................... 41
19 PhidgetServiceID
................................................................................................................................... 42
20 PhidgetSetDeviceLabel
................................................................................................................................... 43
21 SubVIs
................................................................................................................................... 44
_AttachCHK .......................................................................................................................................................... 45
_ChkError .......................................................................................................................................................... 46
_Close .......................................................................................................................................................... 47
_Delete .......................................................................................................................................................... 48
_Open .......................................................................................................................................................... 49
_OpenRem ote
.......................................................................................................................................................... 50
© 2011 Phidgets Inc.
- 4. Content
_OpenRem oteIP
.......................................................................................................................................................... 51
_SerialReturn.......................................................................................................................................................... 52
_WaitAttach .......................................................................................................................................................... 53
EventCloseIntDouble
.......................................................................................................................................................... 54
EventCloseIntInt
.......................................................................................................................................................... 55
EventExeIntDouble
.......................................................................................................................................................... 56
EventExeIntInt
.......................................................................................................................................................... 57
Part 5 Specific Modules 58
1 Phidget Accelerometer
................................................................................................................................... 59
AcceAxisCount
.......................................................................................................................................................... 60
AcceCreate .......................................................................................................................................................... 61
AcceEventClose
.......................................................................................................................................................... 62
AcceEventCreate
.......................................................................................................................................................... 63
AcceEventExe.......................................................................................................................................................... 64
AcceGetData .......................................................................................................................................................... 65
AcceGetMax .......................................................................................................................................................... 66
AcceGetMin .......................................................................................................................................................... 67
AcceGetTrigger
.......................................................................................................................................................... 68
AcceOpen .......................................................................................................................................................... 69
AcceSetTrigger
.......................................................................................................................................................... 70
2 Phidget Advanced Servo
................................................................................................................................... 71
AdvServoCount
.......................................................................................................................................................... 73
AdvServoCreate
.......................................................................................................................................................... 74
AdvServoEventClose
.......................................................................................................................................................... 75
AdvServoEventCreateCrtChange
.......................................................................................................................................................... 76
AdvServoEventCreatePosChange
.......................................................................................................................................................... 77
AdvServoEventCreateVelChange
.......................................................................................................................................................... 78
AdvServoEventExe
.......................................................................................................................................................... 79
AdvServoGetAcce
.......................................................................................................................................................... 80
AdvServoGetAcceMax
.......................................................................................................................................................... 81
AdvServoGetAcceMin
.......................................................................................................................................................... 82
AdvServoGetCurrent
.......................................................................................................................................................... 83
AdvServoGetEngaged
.......................................................................................................................................................... 84
AdvServoGetPos
.......................................................................................................................................................... 85
AdvServoGetPosMax
.......................................................................................................................................................... 86
AdvServoGetPosMin
.......................................................................................................................................................... 87
AdvServoGetRam pingState
.......................................................................................................................................................... 88
AdvServoGetServoType
.......................................................................................................................................................... 89
AdvServoGetVel
.......................................................................................................................................................... 90
AdvServoGetVellm t
.......................................................................................................................................................... 91
AdvServoGetVelm ax
.......................................................................................................................................................... 92
AdvServoGetVelm in
.......................................................................................................................................................... 93
AdvServoOpen.......................................................................................................................................................... 94
AdvServoSetAcce
.......................................................................................................................................................... 95
AdvServoSetEngaged
.......................................................................................................................................................... 96
AdvServoSetPos
.......................................................................................................................................................... 97
AdvServoSetPosMax
.......................................................................................................................................................... 98
AdvServoSetPosMin
.......................................................................................................................................................... 99
AdvServoSetRam pingState
.......................................................................................................................................................... 100
AdvServoSetServoParam eters
.......................................................................................................................................................... 101
AdvServoSetServoType
.......................................................................................................................................................... 102
AdvServoSetVellm t
.......................................................................................................................................................... 103
© 2011 Phidgets Inc.
- 5. Content
AdvServoStoppedState
.......................................................................................................................................................... 104
3 Phidget Encoder
................................................................................................................................... 105
EncoderCreate
.......................................................................................................................................................... 106
EncoderEventCloseInput
.......................................................................................................................................................... 107
EncoderEventClosePosition
.......................................................................................................................................................... 108
EncoderEventCreateInput
.......................................................................................................................................................... 109
EncoderEventCreatePosition
.......................................................................................................................................................... 110
EncoderEventExeInput
.......................................................................................................................................................... 111
EncoderEventExePosition
.......................................................................................................................................................... 112
EncoderGetCount
.......................................................................................................................................................... 113
EncoderGetEnabledState
.......................................................................................................................................................... 114
EncoderGetIndexPosition
.......................................................................................................................................................... 115
EncoderGetInputCount
.......................................................................................................................................................... 116
EncoderGetInputState
.......................................................................................................................................................... 117
EncoderGetPosition
.......................................................................................................................................................... 118
EncoderOpen.......................................................................................................................................................... 119
EncoderSetEnabled
.......................................................................................................................................................... 120
EncoderSetPosition
.......................................................................................................................................................... 121
4 Phidget InterfaceKit
................................................................................................................................... 122
IFCreate .......................................................................................................................................................... 123
IFEventClose.......................................................................................................................................................... 124
IFEventCreateInput
.......................................................................................................................................................... 125
IFEventCreateOutput
.......................................................................................................................................................... 126
IFEventCreateSensor
.......................................................................................................................................................... 127
IFEventExe .......................................................................................................................................................... 128
IFGetDataRate
.......................................................................................................................................................... 129
IFGetDataRateMax
.......................................................................................................................................................... 130
IFGetDataRateMin
.......................................................................................................................................................... 131
IFGetInputCount
.......................................................................................................................................................... 132
IFGetInputState
.......................................................................................................................................................... 133
IFGetOutputCount
.......................................................................................................................................................... 134
IFGetOutputState
.......................................................................................................................................................... 135
IFGetRatio .......................................................................................................................................................... 136
IFGetSensorCount
.......................................................................................................................................................... 137
IFGetSensorValue
.......................................................................................................................................................... 138
IFGetSensorValueRaw
.......................................................................................................................................................... 139
IFGetTrig .......................................................................................................................................................... 140
IFOpen .......................................................................................................................................................... 141
IFSetDataRate
.......................................................................................................................................................... 142
IFSetOutputState
.......................................................................................................................................................... 143
IFSetRatio .......................................................................................................................................................... 144
IFSetTrig .......................................................................................................................................................... 145
5 Phidget IR
................................................................................................................................... 146
IRCreate .......................................................................................................................................................... 147
IREventCloseOnCode
.......................................................................................................................................................... 148
IREventCloseOnLearn
.......................................................................................................................................................... 149
IREventCloseOnRaw Data
.......................................................................................................................................................... 150
IREventCreateOnCode
.......................................................................................................................................................... 151
IREventCreateOnLearn
.......................................................................................................................................................... 152
IREventCreateOnRaw Data
.......................................................................................................................................................... 153
IREventExeOnCode
.......................................................................................................................................................... 154
IREventExeOnLearn
.......................................................................................................................................................... 155
IREventExeOnRaw Data
.......................................................................................................................................................... 156
© 2011 Phidgets Inc.
- 6. Content
IRGetLastCode
.......................................................................................................................................................... 157
IRGetLastLearnedCode
.......................................................................................................................................................... 158
IRGetRaw Data
.......................................................................................................................................................... 159
IROpen .......................................................................................................................................................... 160
IRTransm it .......................................................................................................................................................... 161
IRTransm itRaw
.......................................................................................................................................................... 162
IRTransm itRepeat
.......................................................................................................................................................... 163
6 Phidget LED
................................................................................................................................... 164
LEDCount .......................................................................................................................................................... 165
LEDCreate .......................................................................................................................................................... 166
LEDGetBrightness
.......................................................................................................................................................... 167
LEDGetCurrentLim it
.......................................................................................................................................................... 168
LEDGetVoltage
.......................................................................................................................................................... 169
LEDOpen .......................................................................................................................................................... 170
LEDSetBrightness
.......................................................................................................................................................... 171
LEDSetCurrentLim it
.......................................................................................................................................................... 172
LEDSetVoltage
.......................................................................................................................................................... 173
7 Phidget Motor Control
................................................................................................................................... 174
MCCreate .......................................................................................................................................................... 175
MCEventCloseInput
.......................................................................................................................................................... 176
MCEventCloseVelocityCurrent
.......................................................................................................................................................... 177
MCEventCreateCurrent
.......................................................................................................................................................... 178
MCEventCreateInput
.......................................................................................................................................................... 179
MCEventCreateVelocity
.......................................................................................................................................................... 180
MCEventExeInput
.......................................................................................................................................................... 181
MCEventExeVelocityCurrent
.......................................................................................................................................................... 182
MCGetAcceleration
.......................................................................................................................................................... 183
MCGetAccelerationMax
.......................................................................................................................................................... 184
MCGetAccelerationMin
.......................................................................................................................................................... 185
MCGetCurrent
.......................................................................................................................................................... 186
MCGetInputCount
.......................................................................................................................................................... 187
MCGetInputState
.......................................................................................................................................................... 188
MCGetMotorCount
.......................................................................................................................................................... 189
MCGetVelocity
.......................................................................................................................................................... 190
MCOpen .......................................................................................................................................................... 191
MCSetAcceleration
.......................................................................................................................................................... 192
MCSetVelocity
.......................................................................................................................................................... 193
8 Phidget PH Sensor
................................................................................................................................... 194
PHCreate .......................................................................................................................................................... 195
PHEventClose
.......................................................................................................................................................... 196
PHEventCreate
.......................................................................................................................................................... 197
PHEventExe .......................................................................................................................................................... 198
PHGetPH .......................................................................................................................................................... 199
PHGetPHMax.......................................................................................................................................................... 200
PHGetPHMin .......................................................................................................................................................... 201
PHGetPHTrigger
.......................................................................................................................................................... 202
PHGetPotential
.......................................................................................................................................................... 203
PHGetPotentialMax
.......................................................................................................................................................... 204
PHGetPotentialMin
.......................................................................................................................................................... 205
PHOpen .......................................................................................................................................................... 206
PHSetTem perature
.......................................................................................................................................................... 207
PHSetTrig .......................................................................................................................................................... 208
9 Phidget RFID
................................................................................................................................... 209
© 2011 Phidgets Inc.
- 7. Content
RFIDCreate .......................................................................................................................................................... 210
RFIDEventClose
.......................................................................................................................................................... 211
RFIDEventCloseOutput
.......................................................................................................................................................... 212
RFIDEventCreateOutput
.......................................................................................................................................................... 213
RFIDEventCreateTag
.......................................................................................................................................................... 214
RFIDEventCreateTagLost
.......................................................................................................................................................... 215
RFIDEventExe.......................................................................................................................................................... 216
RFIDEventExeOutput
.......................................................................................................................................................... 217
RFIDGetAntennaState
.......................................................................................................................................................... 218
RFIDGetLastTag
.......................................................................................................................................................... 219
RFIDGetLEDState
.......................................................................................................................................................... 220
RFIDGetOutputCount
.......................................................................................................................................................... 221
RFIDGetOutputState
.......................................................................................................................................................... 222
RFIDGetTagState
.......................................................................................................................................................... 223
RFIDOpen .......................................................................................................................................................... 224
RFIDSetAntennaState
.......................................................................................................................................................... 225
RFIDSetLEDState
.......................................................................................................................................................... 226
RFIDSetOutputState
.......................................................................................................................................................... 227
10 Phidget Servo
................................................................................................................................... 228
ServoCount .......................................................................................................................................................... 229
ServoCreate.......................................................................................................................................................... 230
ServoEventClose
.......................................................................................................................................................... 231
ServoEventCreate
.......................................................................................................................................................... 232
ServoEventExe
.......................................................................................................................................................... 233
ServoGetEngaged
.......................................................................................................................................................... 234
ServoGetPos.......................................................................................................................................................... 235
ServoGetPosMax
.......................................................................................................................................................... 236
ServoGetPosMin
.......................................................................................................................................................... 237
ServoGetServoType
.......................................................................................................................................................... 238
ServoOpen .......................................................................................................................................................... 239
ServoSetEngaged
.......................................................................................................................................................... 240
ServoSetPos.......................................................................................................................................................... 241
ServoSetServoParam eters
.......................................................................................................................................................... 242
ServoSetServoType
.......................................................................................................................................................... 243
11 Phidget Spatial
................................................................................................................................... 244
SpatialCreate
.......................................................................................................................................................... 245
SpatialEventClose
.......................................................................................................................................................... 246
SpatialEventCreate
.......................................................................................................................................................... 247
SpatialEventExe
.......................................................................................................................................................... 248
SpatialGetAcce
.......................................................................................................................................................... 249
SpatialGetAcceAxisCount
.......................................................................................................................................................... 250
SpatialGetAcceMax
.......................................................................................................................................................... 251
SpatialGetAcceMin
.......................................................................................................................................................... 252
SpatialGetAngRate
.......................................................................................................................................................... 253
SpatialGetAngRateMax
.......................................................................................................................................................... 254
SpatialGetAngRateMin
.......................................................................................................................................................... 255
SpatialGetCom passAxisCount
.......................................................................................................................................................... 256
SpatialGetDataRate
.......................................................................................................................................................... 257
SpatialGetDataRateMax
.......................................................................................................................................................... 258
SpatialGetDataRateMin
.......................................................................................................................................................... 259
SpatialGetGyroAxisCount
.......................................................................................................................................................... 260
SpatialGetMagField
.......................................................................................................................................................... 261
SpatialGetMagFieldMax
.......................................................................................................................................................... 262
© 2011 Phidgets Inc.
- 8. Content
SpatialGetMagFieldMin
.......................................................................................................................................................... 263
SpatialOpen .......................................................................................................................................................... 264
SpatialResetCom passCorrectionParam eters
.......................................................................................................................................................... 265
SpatialSetCom passCorrectionParam eters
.......................................................................................................................................................... 266
SpatialSetDataRate
.......................................................................................................................................................... 267
SpatialZeroGyro
.......................................................................................................................................................... 268
12 Phidget Stepper
................................................................................................................................... 269
StepperCreate
.......................................................................................................................................................... 271
StepperEventCloseCurrentVelocity
.......................................................................................................................................................... 272
StepperEventCloseInput
.......................................................................................................................................................... 273
StepperEventClosePosition
.......................................................................................................................................................... 274
StepperEventClosePosition71
.......................................................................................................................................................... 275
StepperEventCreateCurrent
.......................................................................................................................................................... 276
StepperEventCreateInput
.......................................................................................................................................................... 277
StepperEventCreatePosition
.......................................................................................................................................................... 278
StepperEventCreatePosition71
.......................................................................................................................................................... 279
StepperEventCreateVelocity
.......................................................................................................................................................... 280
StepperEventExeCurrentVelocity
.......................................................................................................................................................... 281
StepperEventExeInput
.......................................................................................................................................................... 282
StepperEventExePosition
.......................................................................................................................................................... 283
StepperEventExePosition71
.......................................................................................................................................................... 284
StepperGetAcceleration
.......................................................................................................................................................... 285
StepperGetAccelerationMax
.......................................................................................................................................................... 286
StepperGetAccelerationMin
.......................................................................................................................................................... 287
StepperGetCurrent
.......................................................................................................................................................... 288
StepperGetCurrentLim it
.......................................................................................................................................................... 289
StepperGetCurrentMax
.......................................................................................................................................................... 290
StepperGetCurrentMin
.......................................................................................................................................................... 291
StepperGetCurrentPosition
.......................................................................................................................................................... 292
StepperGetCurrentPosition71
.......................................................................................................................................................... 293
StepperGetEngaged
.......................................................................................................................................................... 294
StepperGetPositionMax
.......................................................................................................................................................... 295
StepperGetPositionMax71
.......................................................................................................................................................... 296
StepperGetPositionMin
.......................................................................................................................................................... 297
StepperGetPositionMin71
.......................................................................................................................................................... 298
StepperGetTargetPosition
.......................................................................................................................................................... 299
StepperGetTargetPosition71
.......................................................................................................................................................... 300
StepperGetVelocity
.......................................................................................................................................................... 301
StepperGetVelocityLim it
.......................................................................................................................................................... 302
StepperGetVelocityMax
.......................................................................................................................................................... 303
StepperGetVelocityMin
.......................................................................................................................................................... 304
StepperInputCount
.......................................................................................................................................................... 305
StepperInputState
.......................................................................................................................................................... 306
StepperMotorCount
.......................................................................................................................................................... 307
StepperOpen.......................................................................................................................................................... 308
StepperSetAcceleration
.......................................................................................................................................................... 309
StepperSetCurrentLim it
.......................................................................................................................................................... 310
StepperSetCurrentPosition
.......................................................................................................................................................... 311
StepperSetCurrentPosition71
.......................................................................................................................................................... 312
StepperSetEngaged
.......................................................................................................................................................... 313
StepperSetTargetPosition
.......................................................................................................................................................... 314
StepperSetTargetPosition71
.......................................................................................................................................................... 315
StepperSetVelocityLim it
.......................................................................................................................................................... 316
StepperStoppedState
.......................................................................................................................................................... 317
© 2011 Phidgets Inc.
- 9. Content
13 Phidget Temperature Sensor
................................................................................................................................... 318
Tem pCreate.......................................................................................................................................................... 319
Tem pEventClose
.......................................................................................................................................................... 320
Tem pEventCreate
.......................................................................................................................................................... 321
Tem pEventExe
.......................................................................................................................................................... 322
Tem pGetAm.......................................................................................................................................................... 323
bient
Tem pGetAm.......................................................................................................................................................... 324
bientMax
Tem pGetAm.......................................................................................................................................................... 325
bientMin
Tem pGetPotential
.......................................................................................................................................................... 326
Tem pGetPotentialMax
.......................................................................................................................................................... 327
Tem pGetPotentialMin
.......................................................................................................................................................... 328
Tem pGetTem perature
.......................................................................................................................................................... 329
Tem pGetTem peratureMax
.......................................................................................................................................................... 330
Tem pGetTem peratureMin
.......................................................................................................................................................... 331
Tem pGetTherm ocoupleType
.......................................................................................................................................................... 332
Tem pGetTrigger
.......................................................................................................................................................... 333
Tem pInputCount
.......................................................................................................................................................... 334
Tem pOpen .......................................................................................................................................................... 335
Tem pSetTherm ocoupleType
.......................................................................................................................................................... 336
Tem pSetTrigger
.......................................................................................................................................................... 337
14 Phidget TextLCD
................................................................................................................................... 338
TextCreate .......................................................................................................................................................... 339
TextGetBacklightState
.......................................................................................................................................................... 340
TextGetBrightness
.......................................................................................................................................................... 341
TextGetColum nCount
.......................................................................................................................................................... 342
TextGetContrast
.......................................................................................................................................................... 343
TextGetCursorBlinkState
.......................................................................................................................................................... 344
TextGetCursorState
.......................................................................................................................................................... 345
TextGetRow Count
.......................................................................................................................................................... 346
TextOpen .......................................................................................................................................................... 347
TextSetBacklightState
.......................................................................................................................................................... 348
TextSetBrightness
.......................................................................................................................................................... 349
TextSetCharacter
.......................................................................................................................................................... 350
TextSetContrast
.......................................................................................................................................................... 351
TextSetCursorBlinkState
.......................................................................................................................................................... 352
TextSetCursorState
.......................................................................................................................................................... 353
TextSetDisplayChar
.......................................................................................................................................................... 354
TextSetDisplayString
.......................................................................................................................................................... 355
15 Phidget TextLED
................................................................................................................................... 356
16 Phidget Weight Sensor
................................................................................................................................... 357
Part 6 Phidgets Constants 358
1 ServoType
................................................................................................................................... 359
2 ThermocoupleType
................................................................................................................................... 360
3 CodeInfo
................................................................................................................................... 361
4 IREncoding
................................................................................................................................... 362
5 IRLength
................................................................................................................................... 363
© 2011 Phidgets Inc.
- 11. Welcome to Phidgets 11
1 Welcome to Phidgets
LabVIEW Help
November 2010, Version 0.1-021110
This help system includes information about LabVIEW programming for each Phidget device. It contains
programming concepts, step-by-step instructions, and reference information about VIs, functions and
palettes.
To navigate this help system, use the Contents, Index, and Search tabs to the left of this windows.
Phidgets are an easy to use set of building blocks for low cost sensing and control from your PC. Using
the Universal Serial Bus (USB) as the basis for all Phidgets, the complexity is managed behind this
easy to use and robust Application Program Interface (API) library.
This help system may link to Portable Document Format (PDF) versions of documents. You must have
Adobe Reader installed to view or search the PDF versions of these manuals.
Note: (Mac OS X) Phidgets recommends that you use Safari 1.3.2 or later or Firefox 1.0.2
or later to view the Help. (Linux) Phidgets recommends that you use Mozilla 1.2 or later or
Firefox 1.0.2 or later to view the Help.
For more information about this help, refer to the following topics:
Introduction
Programming Concept
Phidgets Common
Specific Modules
Phidgets Constant
© 2011 Phidgets Inc.
- 12. 12 Introduction
2 Introduction
Phidgets are an easy to use set of building blocks for low cost sensing and control from your PC. Using
the Universal Serial Bus (USB) as the basis for all Phidgets, the complexity is managed behind this
easy to use and robust Application Program Interface (API) library.
This manual documents the Phidgets software programming model in National Instruments Labview
language. The Programming Concept should be the first section to be read for someone beginning to
use Phidgets. After the concepts described are understood, users can read Phidgets Common and
Specific Modules for function reference and device documentation in general. Note that these sections
are light on function documentation - generally only containing specific reference information and basic
function information.
For a more detailed introduction, please refer to Understanding Phidgets and Platform Support.
© 2011 Phidgets Inc.
- 13. Introduction 13
2.1 Understanding Phidgets
Hardware Model
All Phidgets are connected to the computer using USB. Most computers support up to 127 USB devices
(or more), so it is easy to connect as many Phidgets as are required for almost any project. Phidgets
can be connected either directly to a computer or through Hubs, but there are some limitations.
The maximum cable length for USB is 15 feet. This is a maximum distance between device and
computer, even if there are one or more Hubs in between. There are cable extenders available on the
market, but these can be unreliable and are not endorsed by Phidgets Inc. Users should never try to run
USB over anything other then a certified USB cable, and should never try to run it longer than the spec.
Phidgets run as USB 1.1 low speed or full speed devices, and are supported by both USB 1.1 and USB
2.0 hosts.
Software Model
The Phidgets Labview library is written under the C library - phidget21, which implements the low-level
protocols necessary to communicate with the Phidgets, and exports a unified interface to the software
programmer. This also makes the Phidgets Labview library cross-platform.
The Phidget Labview library contains only glue logic for interfacing with the C library, thus making
maintenance much easier. It should be noted the library employs threading and events extensively. (See
Programming Concept for more information.)
© 2011 Phidgets Inc.
- 14. 14 Introduction
2.2 Platform Support
Operating System Support
Windows
Microsoft Windows 2000 and later are supported, including 64-bit editions. The Windows libraries are
installed using an MSI installer that can be found on the Phidgets web site. This installs the C library,
the .NET library, the COM library, the Java library, the Phidget Web Service and the Phidget Control
Panel.
The Phidget Control Panel is represented by a “Ph” icon that runs in the system tray (usually on the
right end of the Windows task bar). This program can be used to list and control any Phidgets attached
to the system, and to control the Web Service.
Mac OS X
Mac OS X 10.3.9 and newer on Intel and PPC are supported. The Mac libraries are distributed in a .dmg
and are installed using a standard Mac package installer. This installs the C library, the Kernel driver,
the Java library, the Phidget Web Service and the Phidget Preference Pane.
The Phidget Preference Pane is a preference pane which resides in System Preferences. This program
can be used to list and control any Phidgets attached to the system, and to control the Web Service.
Linux
Linux version 2.4 is supported, including 64-bit editions, but 2.6.7 or newer is recommended. The Linux
libraries are distributed as source. The source for the C library, with optional JNI (Java support)
extensions and the source for the Phidget Web Service are available as a .tar.gz. The included Makefile
makes it easy to build and install the libraries on most Linux distribution.
Other
Other Operating System support is not currently available.
Labview Version Support
The Phidgets Labview library supports 32-bit Labview version 7.1.1 or higher. It also supports 64-bit
Labview version 2009 or higher.
Note: If you use Labview 64-bit, you need to install the Phidgets Labview 64-bit library.
© 2011 Phidgets Inc.
- 15. Programming Concept 15
3 Programming Concept
This manual is designed such that both novice and expert users can quickly reference the various
Phidget LabVIEW functions.
The manual is subdivided into 6 sections: Getting Started, Event Handler, Multiple Devices,
Phidgets Common, Specific Modules and Phidgets Constants.
Each section is defined as follow:
Getting Started: tells users how to communicate with phidgets and perform some basic functions. Use
the Getting Started manual as a tutorial to familiarize yourself with Phidget LabVIEW functions and
basic features you use to build data acquisition and instrument control applications.
Event Handler: needs only be used in applications that need to receive events. Use the Event Handler
manual as a tutorial to learn how to construct the event and use the handler.
Multiple Devices: needs only be used in applications that involve multiple phidgets. Use the Multiple
Devices manual as a tutorial to configure and control many phidgets in one VI.
Phidgets Common: contains the common functions for all phidgets.
Specific Modules: contains all the functions for specific phidgets.
Phidgets Constants: explains all Phidgets pre-defined constants.
Note: It is important for user to upgrade the Phidgets21 library to the most recent version.
Click here to check and download the latest version library.
© 2011 Phidgets Inc.
- 16. 16 Programming Concept
3.1 Getting Started
Phidgets are an easy to use set of building blocks for low cost sensing and control from your PC. Using
the Universal Serial Bus (USB) as the basis for all Phidgets, the complexity is managed behind this
easy to use and robust Application Program Interface (API) library.
As such, the Phidgets Labview VI features a very simple and easy-to-use set of VIs. At the simplest
level, all you have to do to control a Phidget is explained in this section.
For illustration purposes, Phidget Accelerometer will be used.
Note: For a more specific illustration on different phidgets, users can refer to different
examples accordingly.
© 2011 Phidgets Inc.
- 17. Programming Concept 17
Open the diagram of the "Single control example.vi" under the "Accelerometer" folder.
Phidgets can be programmed into 3 steps:
<Step1> Initialize the Phidget. This includes opening a Phidget hardware, creating a Phidget handler or
setting up parameters of a Phidget.
Users can also acquire other information in this step. For more details, please refer to the example
called "Remote Example.vi" under "TemperatureSensor" folder.
© 2011 Phidgets Inc.
- 18. 18 Programming Concept
If users want to open Phidgets over the network, a PhidgetOpenRemote and AcceCreate functions will
be called instead of AcceOpen.
<Step2> Perform any execution related with the Phidget. This includes data acquisition, device control,
event execution etc.
<Step3> Close the Phidget. This may include closing the device, releasing all the resources or freeing a
Phidget handle and an error handler.
© 2011 Phidgets Inc.
- 19. Programming Concept 19
3.2 Event Handler
This demonstrates how to call a Phidgets event and how to use them.
For illustration purposes, Phidget Spatial will be used.
Note: For a more specific illustration on different phidgets, users can refer to different
examples accordingly.
© 2011 Phidgets Inc.
- 20. 20 Programming Concept
Open the diagram of the "Spatial event example.vi" under the "Spatial" folder.
Phidgets Event can be programmed into 3 steps:
<Step1> Create an event handler.
<Step2> Perform any event execution related with the Phidget.
© 2011 Phidgets Inc.
- 21. Programming Concept 21
<Step3> Close the related event.
Note: When execute an event, please make sure "create", "execute" and "close" the same
event. For example, user wants to run an Event called A. He has to place "CreateEventA.vi",
"ExeEventA.vi" and "CloseEventA.vi" on the block diagram. He cannot place "CloseEventB.vi"
instead of "CloseEventA.vi". However, for some Phidgets event, they share same VIs. (For
more details, please refer to specific Phidgets.)
Phidget Error Event:
Another useful example will be "Temp On Error.vi" under "TemperatureSensor" folder.
In this example, the error event is actually located in "Common Functions" folder. It will detect
asynchronous errors from Phidgets.
Note: Phidgets can also support multiple events. For an example, please refer to "Event
handler example.vi" under the "InterfaceKit" folder.
© 2011 Phidgets Inc.
- 22. 22 Programming Concept
3.3 Multiple Devices
Phidgets Labview can control multiple phidgets. As long as the handlers are different, different phidgets
can run in parallel.
For a more detailed illustration, please refer to the example of "Multiple control example (Parallel).vi" and
"Multiple control example (Advanced).vi" under the "Accelerometer" folder.
Note: Another example will be "TemperatureDisplay.vi" under "TextLCD" folder. This example
shows how to combined use different phidgets.
© 2011 Phidgets Inc.
- 23. Phidgets Common 23
4 Phidgets Common
This section describes the VI functions used by all Phidgets. The SubVI folder contains advanced
LabVIEW VIs
ErrorHandler
PhidgetClose
PhidgetDelete
PhidgetEventCloseOnError
PhidgetEventCreateOnError
PhidgetEventExeOnError
PhidgetGetDeviceClass
PhidgetGetDeviceID
PhidgetGetDeviceLabel
PhidgetGetDeviceName
PhidgetGetDeviceType
PhidgetGetDeviceVersion
PhidgetGetServerStatus
PhidgetLibraryVersion
PhidgetOpen
PhidgetOpenRemote
PhidgetOpenRemoteIP
PhidgetServerAddress
PhidgetServiceID
PhidgetSetDeviceLabel
SubVIs (Folder)
© 2011 Phidgets Inc.
- 24. 24 Phidgets Common
4.1 ErrorHandler
Description:
Create a Phidget Error handle.
Connector Pane:
Controls and Indicators:
Input
Describes error conditions that occur before this node runs.
Output
ON if error occurs.
Contains error information.
© 2011 Phidgets Inc.
- 25. Phidgets Common 25
4.2 PhidgetClose
Description:
Close a Phidget handle.
Connector Pane:
Controls and Indicators:
Input
Device # identification.
Describes error conditions that occur before this node runs.
Output
Contains error information.
© 2011 Phidgets Inc.
- 26. 26 Phidgets Common
4.3 PhidgetDelete
Description:
Delete a Phidget handle.
Connector Pane:
Controls and Indicators:
Input
Device # identification.
Describes error conditions that occur before this node runs.
Output
Contains error information.
© 2011 Phidgets Inc.
- 27. Phidgets Common 27
4.4 PhidgetEventCloseOnError
Description:
Close the the error handle.
Connector Pane:
Controls and Indicators:
Input
Device # identification.
Event # identification.
Describes error conditions that occur before this node runs.
Output
Same as the Device In.
Contains error information.
© 2011 Phidgets Inc.
- 28. 28 Phidgets Common
4.5 PhidgetEventCreateOnError
Description:
Set up an error event handle.
Connector Pane:
Controls and Indicators:
Input
Device # identification.
Describes error conditions that occur before this node runs.
Output
Same as the Device In.
Event # identification.
Contains error information.
© 2011 Phidgets Inc.
- 29. Phidgets Common 29
4.6 PhidgetEventExeOnError
Description:
This is called when an asynchronous error occurs.
Connector Pane:
Controls and Indicators:
Input
Device # identification.
Event # identification.
Describes error conditions that occur before this node runs.
Output
Same as the Device In.
Same as the Event Registration Refnum In.
Returns the event status. (Executed is T; Not executed is F)
The error code to get the description of.
Contain the error description string.
Contains error information.
© 2011 Phidgets Inc.
- 30. 30 Phidgets Common
4.7 PhidgetGetDeviceClass
Description:
Get the class of a Phidget.
Connector Pane:
Controls and Indicators:
Input
Device # identification. This function will create a new device identification if it's 0 or
invalid.
Describes error conditions that occur before this node runs.
Output
Same as the Device In.
Returns the device class constant.
Contains error information.
© 2011 Phidgets Inc.
- 31. Phidgets Common 31
4.8 PhidgetGetDeviceID
Description:
Get the device ID of a Phidget.
Connector Pane:
Controls and Indicators:
Input
Device # identification. This function will create a new device identification if it's 0 or
invalid.
Describes error conditions that occur before this node runs.
Output
Same as the Device In.
Returns the device ID constant.
Contains error information.
© 2011 Phidgets Inc.
- 32. 32 Phidgets Common
4.9 PhidgetGetDeviceLabel
Description:
Get the label of a Phidget.
Connector Pane:
Controls and Indicators:
Input
Device # identification. This function will create a new device identification if it's 0 or
invalid.
Describes error conditions that occur before this node runs.
Output
Same as the Device In.
Returns the device label.
Contains error information.
© 2011 Phidgets Inc.
- 33. Phidgets Common 33
4.10 PhidgetGetDeviceName
Description:
Get the specific name of a Phidget.
Connector Pane:
Controls and Indicators:
Input
Device # identification. This function will create a new device identification if it's 0 or
invalid.
Describes error conditions that occur before this node runs.
Output
Same as the Device In.
Returns the device name.
Contains error information.
© 2011 Phidgets Inc.
- 34. 34 Phidgets Common
4.11 PhidgetGetDeviceType
Description:
Get the type (class) of a Phidget.
Connector Pane:
Controls and Indicators:
Input
Device # identification. This function will create a new device identification if it's 0 or
invalid.
Describes error conditions that occur before this node runs.
Output
Same as the Device In.
Returns the device type.
Contains error information.
© 2011 Phidgets Inc.
- 35. Phidgets Common 35
4.12 PhidgetGetDeviceVersion
Description:
Get the firmware version of a Phidget.
Connector Pane:
Controls and Indicators:
Input
Device # identification. This function will create a new device identification if it's 0 or
invalid.
Describes error conditions that occur before this node runs.
Output
Same as the Device In.
Returns the device version.
Contains error information.
© 2011 Phidgets Inc.