MBC Ranger 2-Way (TOF2) × EV3 clev3r

Read the Ranger with clev3r in three steps

A clev3r (EV3 BASIC) program goes in this order. First create the project and pick the port. Then set the sensor mode. Last, read values and show them on the EV3 screen. Follow the steps on the left, and the program on the right grows with you. Drag the left and right obstacle distances under the sensor simulator to see what the EV3 screen shows.

1

Create the project, pick the port

clev3r needs no extension and no files to import. On the EV3, the sensor pretends to be the LEGO infrared sensor (type 33), so you read it with the normal Sensor commands. The first line, folder, sets the folder the program goes into on the EV3.

  1. Install clev3r (we tested version v1.7.1.0).
  2. Turn on the EV3 first. Then plug the sensor into the port you pick below.
  3. Make a new program and write the lines below.
  4. Press "Compile and download". On the EV3, open the file menu and run it from the folder that starts with MBC_.
Which port is the sensor on?

The first number in the program (for example Sensor.SetMode(1, 0)) is the port. 1~4 are the EV3 ports 1~4.

2

Set the mode

The sensor has several "modes". Each mode sends back a few numbers at once. Sensor.SetMode(port, mode) picks one. Use only one mode in a program: the EV3 needs about 1.1 s every time it changes mode.

Pick a mode (if you pick a reading from another mode in step 3, this changes too):

3

Read and show on the screen

Sensor.ReadRawValue(port, which one) takes one number from the current mode (counting starts at 0). LCD.Text writes it on the EV3 screen. The EV3 screen can only show English letters and numbers, so the labels are short English words. Click a reading, and the program and screen change to its example.

Sensor simulator (seen from above, front of the robot facing up): drag the left and right obstacle distances and watch the output on the right change

The simulator is only a picture: the distance comes straight from where the obstacle is on the screen. A real laser can be off by 1 to 2 cm and only updates about every 0.1 seconds. 120 = nothing in front (or farther than 120 cm).

An example for every reading

Full examples


        

!


        

!


        

!

Good to know

  1. Use only one mode in a program. The EV3 waits about 1.1 s every time it changes mode. Mode 5 is the handiest: left eye [0] and right eye [1] come together, in millimetres.
  2. Check the unit. Modes 0 and 1 use "1 step = 1.2 cm" (0 to 100, 100 = nothing ahead), so cm = number × 1.2. Modes 3 and 5 use millimetres (0 to 1200).
  3. Unplugged = 0. In clev3r, Sensor.ReadRawValue gives 0 when there is no data, and the program keeps running. 0 looks like "very close", so an avoiding program keeps backing up. Be careful. To check the cable, use Sensor.GetType from the "Is the sensor plugged in?" card.
  4. Direction: stand behind the robot and look forward (left and right as seen from behind the sensor: left = J5, right = J3): the left eye is on the left, the right eye on the right. The EV3 screen only shows English letters and numbers, so use short English labels in LCD.Text.
  5. What clev3r cannot read: whether each laser started up or has a fault (SPIKE only). Modes 3 and 5 (millimetres) need sensor firmware v4.0 or later.