LEGO Mindstorms EV3


Graphical Block Implementation Examples

X3 NXT Sound Sensor (example taken from NI document "X3 Sensor Blocks.docx")

  Sound Block:  Volume Value - Immediate return of sound volume in percent dB

    Params      Type        Range                 Notes
    --------    --------    ------------------    --------------------
    PORT        List        1..4                  Static param on top
    VALUE       Number      0..100                [%]


      Implementation Notes:

      Compiler work:  if PORT parameter is static (compiler must generate following variables):
                      LAYER  = 0 ??????           // [0..3]
                      NO     = (PORT - 1)         // [0..3]
                      TYPE   = 3                  // NXT sound sensor
                      MODE   = 0                  // NXT sound sensor mode dB
        
        
      Byte codes:     opINPUT_READ, LAYER, NO, TYPE, MODE, VALUE,

opINPUT


X3 Ultrasonic Sensor

  Distance Block:  Distance Cm - Immediate return of distance in cm

    Params      Type        Range                 Notes
    --------    --------    ------------------    --------------------
    PORT        List        1..4                  Static param on top
    VALUE       Number      0..255                [cm]


      Implementation Notes:

      Compiler work:  if PORT parameter is static (compiler must generate following variables):
                      LAYER  = 0 ??????           // [0..3]
                      NO     = (PORT - 1)         // [0..3]
                      TYPE   = 30                 // X3 ultrasonic sensor
                      MODE   = 0                  // X3 ultrasonic sensor mode continuously ping
                      VALUE                       // floating point variable
        
        
      Byte codes:     opINPUT_READSI, LAYER, NO, TYPE, MODE, VALUE,     // read distance in SI units [meter]
                      opMULF, VALUE, 100, VALUE,

X3 Color Sensor

  Color block:  Color value - Immediate return of classified color

    Params      Type        Range                 Notes
    --------    --------    ------------------    --------------------
    PORT        List        1..4                  Static param on top
    COLOR       Number      0..6                  Numbers dependent on HW and FW


      Implementation Notes:

      Compiler work:  if PORT parameter is static (compiler must generate following variables):
                      LAYER  = 0 ??????           // [0..3]
                      NO     = (PORT - 1)         // [0..3]
                      TYPE   = 29                 // X3 color sensor
                      MODE   = 0                  // X3 color sensor mode color
                      VALUE                       // floating point variable
        
        
      Byte codes:     opINPUT_READSI, LAYER, NO, TYPE, MODE, VALUE,     // read color number

X3 MOTOR (example taken from NI document "X3 Output Blocks.docx")

  Move Block:   For Degrees - Motor action with rotation duration. Block waits for completion

    Params      Type        Range                 Notes
    --------    --------    ------------------    --------------------
    PORT        List        A,B,C,D,AB,...,ALL    Static param on top
    FORWARD     Boolean     0..1
    SPEED       Number      0..100
    DEGREES     Number      0..2147483647         
    BRAKE       Boolean     0..1


      Implementation Notes:

      Compiler work:  if PORT parameter is static (compiler must generate following variables):
                      LAYER  = 0 ??????           // [0..3]
                      NOS    = Bitfield           // [0..0xF]
                      STEP1  = 0                  // No ramp up
                      STEP2  = DEGREES            // Run for degrees
                      STEP3  = 0                  // No ramp down


      Byte codes:     opOUTPUT_STEP_SPEED, LAYER, NOS, SPEED, STEP1, STEP2, STEP3, BRAKE,
                      opOUTPUT_READY, LAYER, NOS,

opOUTPUT


X3 SOUND

  Sound Block:  File - Play a sampled sound file.

    Params      Type        Range                 Notes
    --------    --------    ------------------    --------------------
    NAME        String                            Useful to see on block
    VOLUME      Number      0..100                
    WAIT        Boolean     Wait/Continue         Defaults to wait


      Implementation Notes:

      Compiler work:  none 
      
      Byte codes:     opSOUND, PLAY, VOLUME, NAME,
                      opSOUND_READY,                // only if wait are true

LEGO® Robotics Firmware Documentation
Confidential Information © 2013 The LEGO Group