1 of 44

Quick Announcements

  • Access to Cory 125 has been granted as of today
  • We will have lecture later around 9:20 pm
  • Please continue on assembly till then

2 of 44

IEEE Micromouse DeCal

Lab 3: Encoders

​

3 of 44

Micromouse Hardware Kit

4 of 44

Micromouse Electronics

What electronics do we need to control our robot?

  1. Microcontroller
  2. Motors
  3. Motor drivers
  4. Sensors (distance, velocity)
  5. Battery

​

5 of 44

Micromouse Electronics

What electronics do we need to control our robot?

  1. Microcontroller
  2. Motors
  3. Motor drivers
  4. Sensors (distance, velocity)
  5. Battery

​

6 of 44

Micromouse PCB Parts

Raspberry Pi Pico (Microcontroller)

7 of 44

Micromouse PCB Parts

Motor Driver

Motor

Motor

8 of 44

Motor Driver

Why do we need a motor driver?

  • Why can’t we drive motors directly from our Pi Pico?

​

9 of 44

Motor Driver

Why do we need a motor driver?

  • Why can’t we drive motors directly from our Pi Pico?

​

It’s designed to only do logic with low current signals -- motors require more current than the Pi Pico is able to supply

10 of 44

Motor Driver

11 of 44

Motor Driver

Direction

IN3

IN4

Forward

HIGH

LOW

Reverse

LOW

HIGH

Brake

HIGH

HIGH

Neutral

LOW

LOW

12 of 44

Sensing

How do we...

  • Identify how far our mouse has traveled?
  • Find what direction our mouse is facing?
  • Check the speed of our mouse?
  • Make sure our mouse is driving straight?

​

13 of 44

Encoders!

1: M1 - Motor +

2: VCC - Encoder +

3: C1 - Encoder A Phase

4: C2 - Encoder B Phase

5: GND - Encoder -

6: M2 - Motor -

Measures rotation and direction

14 of 44

Gear Ratios

Motors are geared down 10:1, so we need 10 rotations of the motor for one rotation of the wheel

15 of 44

Encoders!

Generally – how do we measure position using this thing that spins?

We want to keep track of how many times it has spun and in which direction.

16 of 44

Encoders!

Relevant idea: forget the magnet stuff for a minute.

Imagine this is literally just a metal disc that spins and can be connected to some other circuitry.

How would we keep track of rotations?

17 of 44

Idea: Mechanical Encoder

We might want to keep track of one “spot” on the disc and measure every time it passes by

Physically implement this: add a “bump” on the disc and have it close a switch every rotation!

18 of 44

19 of 44

Idea: Mechanical Encoder

That’s great and all, but our resolution of measurement is low: we have no way of knowing what fraction of the disc we stopped at, all we know is the last complete revolution.

Say we’re just completing our 5th revolution:

5 ticks!

also 5 ticks!

6 ticks!

also 5 ticks!

20 of 44

Idea: Mechanical Encoder

That’s great and all, but our resolution of measurement is low: we have no way of knowing what fraction of the disc we stopped at, all we know is the last complete revolution.

​

Solution: add more bumps per revolution!

21 of 44

22 of 44

Idea: Mechanical Encoder

Now, every time a bump hits the switch we know it has gone that far around the disc. We can figure out how many bumps there are per revolution in order to track revolutions by counting bumps!

​

​

23 of 44

Going back to our encoders:

bumps/rev ⇒ ticks/rev :) ⇒ Pi Pico code

​

⇒

​

​

Instead of requiring physical contact with a switch, our encoders work by sensing the strength of magnetic field (via Hall effect sensors)

*Note: the bar magnet shown would correspond to 1 tick/revolution

*

24 of 44

Going back to our encoders:

The higher-resolution equivalent here is a magnetic disc with many N/S poles per revolution

(the magnetic equivalent of bumps)

25 of 44

26 of 44

Encoders!

27 of 44

Encoders!

B

A

Two Hall effect (magnetic field) sensors mounted 90 degrees apart

Magnet that spins with the wheel

28 of 44

Quadrature Encoding

  • Each sensor measures the magnetic field at a different part of the encoder wheel
  • Offsetting each encoder by 90o phase lets us see direction of rotation.

www.edn.com

A

B

clockwise

counterclockwise

29 of 44

Quadrature Encoder Animation

s

B Channel

A Channel

A

B

30 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

31 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

32 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

33 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

34 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

35 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

36 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

37 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

38 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

39 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

40 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

41 of 44

Quadrature Encoder Animation

B Channel

A Channel

A

B

42 of 44

Today: Encoders

  • Lab 3 on Github repo
  • Tips
    • The lab assumes that the left motor is the one plugged in (but both of yours are)

​

​

43 of 44

Questions?

44 of 44

Attendance Form →

Password for today: magnetic

​

​

​

​

​