Case 4 - Detect the angles the encoder motor shaft rotates

Part 1   Objective

After you compile the program, the stage displays the angles the encoder motor shaft rotates in real time.

6.gif

Part 2   Preparation

  • MegaPi x 1

  • MegaPi encoder/DC motor driver x 1

  • MegaPi RJ25 adapter x 1

  • RJ25 cable x 1

  • Battery holder x 1

  • Photoelectric encoder motor 25mm x 1

  • Plastic wheel 90T x 1

  • Shaft connector 4mm x 1

  • Grub screw x 2

  • Encoder motor cable 25mm x 1

  • USB cable (Type-B) x 1

  • Computer with network access x 1

Install the MegaPi RJ25 adapter on MegaPi, connect the encoder motor to MegaPi by using the RJ25 cable, connect the battery holder to MegaPi, connect MegaPi to the computer by using the USB cable, open mBlock 5 (PC client or web version), click +add, select Ultimate 2.0 from the Device Library, click Connect, and select the Live mode.

7.gif

8.gif

9.gif

Update the firmware of Ultimate 2.0.

10.gif

Part 3   Programming

In Live mode, you can create a variable to get the angle the encoder motor shaft rotates in real time.

11.gif

Part   4 Practice

Try to write a program to see the speed at which the encoder motor shaft rotates in real time.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.