LabVIEW LEGO MINDSTORMS NXT Module Programming Guide Manual

LabVIEW LEGO MINDSTORMS NXT Module Programming Guide Manual
Pages 97
Views 794
Downloads : 2 times
PDF Size : 572.7 KiB

Summary of Contents

LabVIEW LEGO MINDSTORMS NXT Module Programming Guide Manual

  • Page 1

    LabVIEWTMLEGO® MINDSTORMS® NXT Module Programming GuideSeptember 2009372574C-01

  • Page 2

    SupportWorldwide Technical Support and Product Informationni.comNational Instruments Corporate Headquarters11500 North Mopac ExpresswayAustin, Texas 78759-3504USATel: 512 683 0100Worldwide OfficesAustralia 1800 300 800, Austria 43 662 457990-0, Belgium 32 (0) 2 757 0020, Brazil 55 11 3262 3599, C...

  • Page 3

    Important InformationWarrantyThe media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. Na...

  • Page 4

    ConventionsThe following conventions are used in this manual:»The » symbol leads you through nested menu items and dialog box options to a final action. The sequence File»Page Setup»Options directs you to pull down the File menu, select the Page Setup item, and select Options from the last di...

  • Page 5

    © National Instruments CorporationvLabVIEW LEGO MINDSTORMS NXT ModuleContents 8,Chapter 1 8,Introduction 8,Related Documentation 8,..................................................................................................1-1 9,Assumptions.....................................................

  • Page 6

    ContentsLabVIEW NXT Module Programming Guidevini.com 27,InvalidData 27,....................................................................................... 27,2-10 28,NXTColorSensorRead...................................................................... 28,2-11 29,Digital I/O Devices........

  • Page 7

    Contents© National Instruments CorporationviiLabVIEW NXT Module Programming Guide 69,NXT Display Methods 69,....................................................................................2-52 69,NXTDrawText 69,..................................................................................

  • Page 8

    © National Instruments Corporation1-1LabVIEW LEGO MINDSTORMS NXT Module1IntroductionThe LEGO® MINDSTORMS® NXT software uses a graphical programming language called NXT-G that is based on National Instruments LabVIEW 7.1. The high-level programming blocks in NXT-G block diagrams are built out o...

  • Page 9

    Chapter 1IntroductionLabVIEW LEGO MINDSTORMS NXT Module1-2ni.comAssumptionsThis document assumes that you are using the LabVIEW LEGO MINDSTORMS NXT Module with LabVIEW 2009. This document also assumes that you are familiar with the following LabVIEW programming concepts:•Data types: integers, B...

  • Page 10

    Chapter 1Introduction© National Instruments Corporation1-3LabVIEW LEGO MINDSTORMS NXT ModuleNXT Bytecode Instructions and LabVIEW FunctionsThe NXT firmware executes a program file by interpreting its contents as bytecode instructions. You can think of many of the bytecode instructions as loosely...

  • Page 11

    Chapter 1IntroductionLabVIEW LEGO MINDSTORMS NXT Module1-4ni.comLabVIEW BasicsData TypesThe module only supports a limited subset of the data types that LabVIEW supports. Supported Data TypesThe module supports the following data types:•8-bit signed and unsigned integer numerics •16-bit signe...

  • Page 12

    Chapter 1Introduction© National Instruments Corporation1-5LabVIEW LEGO MINDSTORMS NXT ModuleThe same principle is true for custom controls, type definitions, and block diagram constants. As long as the NXT firmware supports the data type of the wire connected to a particular block diagram termin...

  • Page 13

    Chapter 1IntroductionLabVIEW LEGO MINDSTORMS NXT Module1-6ni.comFunctionsThe module does not support all LabVIEW functions, and some supported functions exhibit special behavior or limitations when you use them with the module. In general, any function that relies on one or more unsupported data ...

  • Page 14

    Chapter 1Introduction© National Instruments Corporation1-7LabVIEW LEGO MINDSTORMS NXT ModuleStrings•String Length•Concatenate Strings–String array inputs are not supported.•String Subset•Number to Decimal String–The width input is ignored.•Decimal String to NumberArraysThe module s...

  • Page 15

    Chapter 1IntroductionLabVIEW LEGO MINDSTORMS NXT Module1-8ni.com•Less?•Greater or Equal?•Less or Equal?•Greater than 0?•Less than 0?•Greater or Equal to 0?•Less or Equal to 0?Miscellaneous•Bundle–The module does not support Bundle by Name.•Unbundle–The module does not suppor...

  • Page 16

    Chapter 1Introduction© National Instruments Corporation1-9LabVIEW LEGO MINDSTORMS NXT Module•Max and Min•In Range and Coerce•Generate Random NumberBoolean•Not And•Not Or•Not Exclusive Or•And Array Elements•Or Array ElementsString•Trim White Space•Reverse String•Replace Subs...

  • Page 17

    Chapter 1IntroductionLabVIEW LEGO MINDSTORMS NXT Module1-10ni.comCase Structures•Only one specific value, or Default, is allowed in the case selector label for each subdiagram. You cannot use ranges (the “..” notation) or comma-separated lists of values.•Usage of error cluster wires with ...

  • Page 18

    © National Instruments Corporation2-1LabVIEW LEGO MINDSTORMS NXT Module2Extensions to LabVIEWThe NXT firmware supports various I/O devices for which LabVIEW has no built-in interfaces. Examples include motor outputs, sensor inputs, and the NXT display. To support these devices, the module provid...

  • Page 19

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-2ni.comNoteRefer to th 94,e Using Dynami 94,c System 94, Calls 94, section of this document for more information about using the NXTDynamicSyscall refnum.Each method you use corresponds to a call to an internal system function matc...

  • Page 20

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-3LabVIEW LEGO MINDSTORMS NXT ModuleThe Port property has the following considerations:•Every NXTInput Property Node must include one and only one Port property.•For a given Property Node, the value on the wire connected to Por...

  • Page 21

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-4ni.comPortU8Write-onlyRequiredLegal value range: [0, 3]This property specifies the physical input port to which all other property reads and writes apply. Note that legal values are zero-based, such that the values 0, 1, 2, and 3 ...

  • Page 22

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-5LabVIEW LEGO MINDSTORMS NXT ModuleSensorTypeU8Read-writeOptionalLegal values:This property specifies the sensor type for this port. The sensor type primarily affects scaling factors used to calculate the normalized sensor value, ...

  • Page 23

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-6ni.comSensorModeU8Read-writeOptionalLegal values:This property specifies the sensor mode for this port. The sensor mode affects the scaled value, which the NXT firmware calculates depending on the sensor type and sensor mode.If yo...

  • Page 24

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-7LabVIEW LEGO MINDSTORMS NXT ModuleRawU16Read-onlyOptionalLegal value range: [0, 1023]This property specifies the raw 10-bit value last read from the analog to digital converter on this port. Raw values produced by sensors typical...

  • Page 25

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-8ni.comNormalizedU16Read-onlyOptionalLegal value range: [0, 1023]This property specifies a 10-bit sensor reading, scaled according to the current value of the SensorType property on this port. The NXT firmware automatically applies...

  • Page 26

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-9LabVIEW LEGO MINDSTORMS NXT ModuleScaledU16Read-writeOptionalLegal value range depends on SensorMode, as listed in the following table:This property specifies a sensor reading, scaled according to the current sensor type and mode...

  • Page 27

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-10ni.comInvalidDataBooleanRead-writeOptionalLegal values: TRUE, FALSEThis property signifies that the values of Raw, Normalized, and Scaled might be invalid due to sensor configuration changes that the NXT firmware has not processe...

  • Page 28

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-11LabVIEW LEGO MINDSTORMS NXT ModuleNXTColorSensorReadReturn Value:This system call method returns the value of the color sensor and accommodates the RGB data format.NoteThis system call method is different from others in that it ...

  • Page 29

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-12ni.comDigital I/O DevicesTo program digital I/O devices, you need to use both the NXTInput and NXTSyscall interfaces. You need both interfaces because digital and analog devices share the same physical ports.Digital I/O devices i...

  • Page 30

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-13LabVIEW LEGO MINDSTORMS NXT ModuleA call to NXTCommLSWrite constitutes the start of an asynchronous transaction between the NXT brick and a digital device, such that the program continues to run while the firmware manages sendin...

  • Page 31

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-14ni.comNXTCommLSCheckStatusParameters:This system call method checks the status of the I2C communication on the specified port. If the last operation on this port was a successful NXTCommLSWrite operation that requested response d...

  • Page 32

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-15LabVIEW LEGO MINDSTORMS NXT ModuleNXTCommLSWriteParameters:This system call method copies data from the buffer input to an internal write buffer and instructs the NXT firmware to perform a transaction by sending the write buffer...

  • Page 33

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-16ni.comNXTCommLSReadParameters:This system call method attempts to copy BufferLength bytes from the internal read buffer to your buffer.If the return value is zero, the read operation succeeded and Buffer contains all bytes availa...

  • Page 34

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-17LabVIEW LEGO MINDSTORMS NXT ModuleOutput Devices: Motors and LampsTwo different kinds of output devices are compatible with the NXT brick: interactive motors, NXT motors with integrated position encoders, and non-interactive mot...

  • Page 35

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-18ni.comUse the following tips when working with the Port and PortList properties:•Every NXTOutput or NXTOutputMulti Property Node must include one and only one Port of the PortList property, respectively.•For a given Property ...

  • Page 36

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-19LabVIEW LEGO MINDSTORMS NXT ModulePortU8NXTOutput: write-onlyNXTOutputMulti: unsupportedRequiredLegal value range: [0, 2]This property specifies the physical port to which all other property read/writes apply. Note that legal va...

  • Page 37

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-20ni.comPortListU8 arrayNXTOutput: unsupportedNXTOutputMulti: write-onlyRequiredLegal value range: [0, 2] (arrays of 1, 2, or 3 elements in this range)This property specifies a list of physical ports to which all other property wri...

  • Page 38

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-21LabVIEW LEGO MINDSTORMS NXT ModuleUpdateFlagsU8NXTOutput: read-writeNXTOutputMulti: write-onlyOptionalBitfield including any combination of the following flag bits:This property is an unsigned byte bitfield with zero or more of ...

  • Page 39

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-22ni.comFor UPDATE_RESET_BLOCK_COUNT, block-relative refers to the way this flag is used in the LEGO MINDSTORMS NXT software. By convention, this flag is set every time an NXT-G motor control block starts execution. This convention...

  • Page 40

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-23LabVIEW LEGO MINDSTORMS NXT ModuleModeU8NXTOutput: read-writeNXTOutputMulti: write-onlyOptionalBitfield including any combination of the following flag bits:This property is an unsigned byte bitfield with zero or more mode bits ...

  • Page 41

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-24ni.comRegModeU8NXTOutput: read-writeNXTOutputMulti: write-onlyOptionalInteractive motors onlyLegal Values:This property specifies the regulation mode to use with the specified port(s).This property is ignored if you do not set th...

  • Page 42

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-25LabVIEW LEGO MINDSTORMS NXT ModuleTurnRatioI8NXTOutput: read-writeNXTOutputMulti: write-onlyOptionalInteractive motors onlyLegal value range: [–100, 100]This property specifies the proportional turning ratio for synchronized t...

  • Page 43

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-26ni.comRunStateU8NXTOutput: read-writeNXTOutputMulti: write-onlyOptionalLegal Values:This property specifies an auxiliary state to use with Mode, RegMode, and Power on the specified port(s). Set only one of the legal values at a g...

  • Page 44

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-27LabVIEW LEGO MINDSTORMS NXT ModulePowerI8NXTOutput: read-writeNXTOutputMulti: write-onlyOptionalLegal value range: [–100, 100]This property specifies the power level set-point for the specified port(s).The absolute value of Po...

  • Page 45

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-28ni.comActualSpeedI8NXTOutput: read-onlyNXTOutputMulti: unsupportedOptionalInteractive motors onlyLegal value range: [–100, 100]This read-only property returns the actual percentage of full power that the NXT firmware is applyin...

  • Page 46

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-29LabVIEW LEGO MINDSTORMS NXT ModuleTachoLimitU32NXTOutput: read-writeNXTOutputMulti: write-onlyOptionalInteractive motors onlyLegal value range: [0, 4294967295]This property specifies the rotational distance in degrees that you w...

  • Page 47

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-30ni.comTachoCountI32NXTOutput: read-onlyNXTOutputMulti: unsupportedOptionalInteractive motors onlyLegal value range: [–2147483648, 2147483647]This read-only property reports the internal position counter value for the specified ...

  • Page 48

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-31LabVIEW LEGO MINDSTORMS NXT ModuleBlockTachoCountI32NXTOutput: read-onlyNXTOutputMulti: unsupportedOptionalInteractive motors onlyLegal value range: [–2147483648, 2147483647]This read-only property reports the block-relative p...

  • Page 49

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-32ni.comRotationCountI32NXTOutput: read-onlyNXTOutputMulti: unsupportedOptionalInteractive motors onlyLegal value range: [–2147483648, 2147483647]This read-only property reports the program-relative position counter value for the...

  • Page 50

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-33LabVIEW LEGO MINDSTORMS NXT ModuleOverloadedBooleanNXTOutput: read-onlyNXTOutputMulti: unsupportedOptionalInteractive motors onlyLegal values: TRUE, FALSEThis read-only property returns TRUE if the speed regulation functionality...

  • Page 51

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-34ni.comRegPValueU8NXTOutput: read-writeNXTOutputMulti: write-onlyOptionalInteractive motors onlyLegal value range: [0, 255]This property specifies the proportional term used in the internal PID control algorithm. Refer to the Prop...

  • Page 52

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-35LabVIEW LEGO MINDSTORMS NXT ModuleRegIValueU8NXTOutput: read-writeNXTOutputMulti: write-onlyOptionalInteractive motors onlyLegal value range: [0, 255]This property specifies the integral term used in the internal PID control alg...

  • Page 53

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-36ni.comRegDValueU8NXTOutput: read-writeNXTOutputMulti: write-onlyOptionalInteractive motors onlyLegal value range: [0, 255]This property specifies the derivative term used in the internal PID control algorithm.Set the UPDATE_PID_V...

  • Page 54

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-37LabVIEW LEGO MINDSTORMS NXT ModuleBuilt-In I/OThe module provides access to several kinds of built-in I/O, including the following:•Manipulating files in a simple flash file system using the File Access Methods•Drawing to th...

  • Page 55

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-38ni.com•RTM—Built-in Try Me programs•RIC—Image (graphic) files for use with the NXTDrawGraphic system call method in RXE programs•RSO—Sound files•SYS—Internal NXT firmware files•CAL—Sensor calibration file•TX...

  • Page 56

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-39LabVIEW LEGO MINDSTORMS NXT ModuleFile HandlesYou must open a handle to a file before you can use read or write methods on the file. The NXTFileOpenRead, NXTFileOpenWrite, or NXTFileOpenAppend methods return a unique handle valu...

  • Page 57

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-40ni.comFile Access Status CodesFile access system call methods return a different set of status codes from most other system call methods. File access status codes are unsigned 16-bit integers rather than signed 8-bit integers. In...

  • Page 58

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-41LabVIEW LEGO MINDSTORMS NXT ModuleFile Access Performance IssuesWriting to flash memory is very slow compared to RAM access on the NXT brick. Writing to flash memory also ties up the CPU. File write operations are buffered in RA...

  • Page 59

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-42ni.comNXTFileOpenReadParameters:This system call method attempts to open the file specified by Filename for read operations.If the return value is zero, the file open operation succeeded. File Handle is assigned a unique handle f...

  • Page 60

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-43LabVIEW LEGO MINDSTORMS NXT ModuleNXTFileOpenWriteParameters:This system call method attempts to create a file with the name specified by Filename and size in bytes specified by Length, then keep the file open for write operatio...

  • Page 61

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-44ni.comNXTFileOpenAppendParameters:This system call method attempts to open the file specified by Filename for append (write) operations. This operation is useful only if a file already exists and has been closed before all of its...

  • Page 62

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-45LabVIEW LEGO MINDSTORMS NXT ModuleNXTFileResolveHandleParameters:The NXT firmware has a list of open file handles. This system call method searches the list of open file handles by Filename. To succeed, Filename must contain the...

  • Page 63

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-46ni.comNXTFileCloseParameters:This system call method closes the handle specified by File Handle.If the return value is zero, the method successfully closed the file handle and removed the file from the list of open files that NXT...

  • Page 64

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-47LabVIEW LEGO MINDSTORMS NXT ModuleNXTFileReadParameters:This system call method attempts to read Length bytes of data from the file opened with the handle specified by File Handle.If the return value is zero, the file read opera...

  • Page 65

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-48ni.comNXTFileWriteParameters:This system call method attempts to write Length bytes of data to the file opened with the handle specified by File Handle. If you use all of the memory allocated for the specified file, the NXTFileWr...

  • Page 66

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-49LabVIEW LEGO MINDSTORMS NXT ModuleNXTFileDeleteParameters:This system call method deletes the file specified by Filename.If the return value is zero, the delete operation succeeded. If the return value is non-zero, the delete op...

  • Page 67

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-50ni.comNXTFileRenameParameters:This system call method renames the file specified by Old Filename to New Filename.If the return value is zero, the rename operation succeeded.If the return value is non-zero, the rename operation fa...

  • Page 68

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-51LabVIEW LEGO MINDSTORMS NXT ModuleNXTListFilesParameters:This system call method lists the files on the NXT brick that have the file extension, or Pattern, you specify. You must wire an array to the File List input. This system ...

  • Page 69

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-52ni.comNXT Display MethodsUse the display methods to draw text, points, shapes, or graphic files to the built-in display on the NXT brick.NXTDrawTextParameters:This system call method renders the string Text at the coordinates spe...

  • Page 70

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-53LabVIEW LEGO MINDSTORMS NXT ModuleNXTDrawPointParameters:This system call method draws a single, black pixel at the coordinates that Location specifies.All draw coordinates are relative to the lower left corner of the screen on ...

  • Page 71

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-54ni.comNXTDrawLineParameters:This system call method draws a black line one pixel wide, from StartLocation to EndLocation.All draw coordinates are relative to the lower left corner of the screen on the NXT brick.Set the least sign...

  • Page 72

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-55LabVIEW LEGO MINDSTORMS NXT ModuleNXTDrawCircleParameters:This system call method draws a circle outline specified by Center coordinates and Radius in pixels.All draw coordinates are relative to the lower left corner of the scre...

  • Page 73

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-56ni.comNXTDrawRectParameters:This system call method draws a rectangle outline with one corner at the coordinates specified by Location. The Size cluster specifies relative coordinates of the corner opposite from Location.Set the ...

  • Page 74

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-57LabVIEW LEGO MINDSTORMS NXT ModuleNXTDrawGraphicParameters:This system call method renders the RIC-format graphic file (the LEGO standard image format) specified by Filename. Location specifies coordinates of the lower left corn...

  • Page 75

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-58ni.comNXTSetScreenModeParameters:This system call method sets a new mode for the display screen on the NXT brick. The only valid mode for the NXT firmware 1.05 is RESTORE_NXT_SCREEN (value: 0). Use this screen mode to restore the...

  • Page 76

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-59LabVIEW LEGO MINDSTORMS NXT ModuleNXT Button MethodUse the NXT button method to read the status of the built-in buttons on the NXT brick. Note that you can read only the top three buttons. The bottom button always aborts the pro...

  • Page 77

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-60ni.comSound Playback MethodsUse the sound playback methods to control the sound module on the NXT brick.NXTSoundPlayFileParameters:This system call method starts playback of the sound file specified by Filename. The file must be ...

  • Page 78

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-61LabVIEW LEGO MINDSTORMS NXT ModuleNXTSoundPlayToneParameters:This system call method starts playback of a tone specified by Frequency (Hz) and Duration (ms).Set Loop? to TRUE to loop playback automatically and indefinitely witho...

  • Page 79

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-62ni.comNXTSoundGetStateParameters:This system call method reads the internal state and flags of the sound module of the NXT brick. If Flags is non-zero, the sound module has playback operations pending or in progress. Normally, yo...

  • Page 80

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-63LabVIEW LEGO MINDSTORMS NXT ModuleNXTSoundSetStateParameters:This system call method writes new State and Flags values to the sound module of the NXT brick. NoteUse this system call method with caution because it directly influe...

  • Page 81

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-64ni.comBluetooth Communication MethodsUse the Bluetooth communication methods to send packets of information to other devices connected to the NXT brick through Bluetooth. You also use these methods to access the messaging queue s...

  • Page 82

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-65LabVIEW LEGO MINDSTORMS NXT ModuleNXTCommBTCheckStatusParameters:This system call method checks the status of the Bluetooth communication on the specified port.If the return value is zero, the port is idle and the last operation...

  • Page 83

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-66ni.comNXTCommBTWriteParameters:This system call method copies data from the buffer input to an internal Bluetooth buffer and instructs the NXT firmware to send the data to the device configured on the specified port.If the return...

  • Page 84

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-67LabVIEW LEGO MINDSTORMS NXT ModuleNXTBTPowerReturn value:This dynamic system call method turns the Bluetooth device power on or off.ParameterData CodeI/O DirectionDescriptionPower StateBooleaninputSignifies on or off

  • Page 85

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-68ni.comNXTBTConnectionReturn value:This dynamic system call method initiates or closes a connection to another device.ParameterData CodeI/O DirectionDescriptionActionU8input[0–Initiate connection, 1–Close connection]Partner Na...

  • Page 86

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-69LabVIEW LEGO MINDSTORMS NXT ModuleNXTMessageReadParameters:This system call method reads the oldest message available in the specified mailbox queue and optionally removes that message from the queue.If the return value is zero,...

  • Page 87

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-70ni.comNXTMessageWriteParameters:This system call method writes a new message to the specified mailbox queue. If there are already five messages in the specified queue, the oldest message is deleted.If the return value is zero, th...

  • Page 88

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-71LabVIEW LEGO MINDSTORMS NXT ModuleLow-Level System MethodsUse the low-level system methods to access miscellaneous low-level features of the NXT firmware system.NXTGetStartTickReturn Value:This system call method returns the val...

  • Page 89

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-72ni.comNXTKeepAliveReturn Value:This system call method resets the internal sleep timer in the NXT firmware and returns the current time limit in milliseconds until the next automatic sleep. Use this method to keep the NXT brick f...

  • Page 90

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-73LabVIEW LEGO MINDSTORMS NXT ModuleNXTRandomNumberReturn Value:This system call method returns a signed 16-bit random number. Internally, the NXT firmware selects new random seeds after every twenty calls to this system call meth...

  • Page 91

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-74ni.comNXTIOMapReadParameters:This system call method reads internal firmware module state information. This method is reserved for internal use only.ParameterData CodeI/O DirectionDescriptionStatus CodeI8outputUnusedModuleNamestr...

  • Page 92

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-75LabVIEW LEGO MINDSTORMS NXT ModuleNXTIOMapWriteParameters:This system call method writes internal firmware module state information. This method is reserved for internal use only.ParameterData CodeI/O DirectionDescriptionStatus ...

  • Page 93

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-76ni.comNXTSetSleepTimeoutReturn Value:This dynamic system call method used by NXT datalogging sets the brick sleep timeout during datalogging programs. This prevents the brick from going to sleep during datalogging.ParameterData C...

  • Page 94

    Chapter 2Extensions to LabVIEW© National Instruments Corporation2-77LabVIEW LEGO MINDSTORMS NXT ModuleUsing Dynamic System CallsDynamic system calls are custom functions that you create in the NXT firmware.NoteWhen you create a dynamic system call, ensure the ID of the system call is unique.You ...

  • Page 95

    Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-78ni.comUsing the NXTDynamicSyscall RefnumComplete the following steps to use the NXTDynamicSyscall refnum to access a dynamic system call you created.1.Create a new NXT VI.2.Place the NXTDynamicSyscall refnum on the front panel.3....

  • Page 96

    © National Instruments CorporationA-1LabVIEW LEGO MINDSTORMS NXT ModuleATechnical Support and Professional ServicesVisit the following sections of the award-winning National Instruments Web site at ni.com for technical support and professional services:•Support—Technical support at actionURI...

  • Page 97

    Appendix ATechnical Support and Professional ServicesLabVIEW NXT Modules Programming GuideA-2ni.comIf you searched ni.com and could not find the answers you need, contact your local office or NI corporate headquarters. Phone numbers for our worldwide offices are listed at the front of this manual...