MBC Ranger 8-Way (TOF8) × EV3 clev3r

Read the Ranger 8-Way 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 obstacle's direction and distance 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.

Simulated sensor (seen from above, robot facing up): drag the obstacle and watch the output on the right

The simulation is only a sketch: direction and distance come from a simple position-based estimate, so a real sensor may differ by a step or two. Red sector = that sensor sees something; grey sector = it reads 120 (nothing that way). Sensors 4 and 5 both face straight ahead.

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 2 is the most used for avoiding: nearest direction [0], nearest distance [1], most open direction [2] and most open distance [3] all come together.
  2. Check the unit. Distances in modes 0, 1 and 2 use "1 step = 1.2 cm" (0 to 100, 100 = nothing there), 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 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 is negative, right is positive. ±8 = nothing around. 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), and each laser in millimetres. Modes 3 and 5 (millimetres) need sensor firmware v4.0 or later.