general interface to lego nxt motors &...

25
Lego Interface board 0.3 Gary L Fernandes Seattle University Lego Interface Breadboard (LIB) General Interface to Lego NXT Motors & Sensors

Upload: votram

Post on 19-Aug-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface board 0.3

Gary L Fernandes

Seattle University

Lego Interface Breadboard (LIB)

General Interface to Lego NXT Motors & Sensors

Page 2: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Revision History

Revision Date Description Person

Rev 0.1 2/11/2001 Created: Gary L Fernandes, [email protected]

Rev 0.2 2/23/2011 Updated everything. Gary

Rev 0.3 3/11/2011 Updated Altera Expansion Header info, Cleaned up everything. Gary

Best viewing with =>Office 2007

Table of Contents 1. Lego Interface Board Formats of Use ............................................................................................................................. 4 2. Lego Interface Breadboard Proto 1................................................................................................................................. 5 3. Altera Expansion Header to Lego Interface Board Header ............................................................................................. 6

Altera Expansion Header JP2 (GPIO_1) .......................................................................................................................... 6 4. Xilinx Expansion Header to Lego Interface Board Header .............................................................................................. 8 5. PIC Board to Lego Interface Board Header ..................................................................................................................... 8 6. Code Examples and Tutorials Download Links ................................................................................................................ 9 7. Lego Interface Board Details ......................................................................................................................................... 10

Motor Driver - TI SN754410 Driver ................................................................................................................................... 10 Function Table Motor 1 ................................................................................................................................................ 10 Function Table Motor 2 ................................................................................................................................................ 10 SN754410 Absolute Maximum Ratings ......................................................................................................................... 11 Complete Datasheet ..................................................................................................................................................... 11 Breadboard Test DIP Switches ...................................................................................................................................... 11

Pulse Width Modulation Introduction .............................................................................................................................. 12 Sound Sensor Circuit ......................................................................................................................................................... 14 Touch Sensor ..................................................................................................................................................................... 15

Lego Touch Sensor Schematic ....................................................................................................................................... 15 Example 1: Touch Sensor Switch Bounce When Pressed ............................................................................................. 16 Touch Sensor Debounce Circuit .................................................................................................................................... 18

Light Sensor ....................................................................................................................................................................... 22 Light Sensor Function Table .......................................................................................................................................... 22 Lego Light Sensor Schematic ......................................................................................................................................... 22

Piezo Speaker .................................................................................................................................................................... 23 8. Robot Applications ........................................................................................................................................................ 24

Page 3: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

WARNING

Vc must be > 6 < 9.5 Vdc

Set proper power supply voltage BEFORE connecting the Lego Interface

Board.

To avoid damage to Lego products to not change or disturb circuits or

operate without proper instruction, supervision, or EE knowhow.

If a wire or component has come loose please have a supervisor repair

before connecting power.

Page 4: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

1. Lego Interface Board Formats of Use The Lego Interface Board (LIB) provides an easy interface to motors, touch sensors, light sensor, breadboard sound

sensor and a piezo speaker. Extended cable lengths are also available for tethered applications.

Altera, Xilinx, or other development kits Microcontrollers or other Breadboard Circuits

Robot Applications

Example Youtube Robot Apps

Page 5: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

2. Lego Interface Breadboard Proto 1.

Vc

6 - 9.5VDC

Light Sensor Adjust

Sound Sensor Adjust

Light Sensor Detect LED

Sound Sensor Detect LED

Lego Light Sensor Port

Lego Touch Sensor Port 1

Lego Touch Sensor Port 2

Lego Motor Port 1

Lego Motor Port 2

Motor Test DIP Switches

For normal operation all

switchs must be set to OFF

(Open) position

Optional Power Switch Banana jack Va to Vb

(useful for testing)

Header1 Use this

header cable to interface

to microcontrollers or

Altera/Xilinx boards

GND

Microphone

Page 6: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

3. Altera Expansion Header to Lego Interface Board Header

Altera Expansion Header

JP2 (GPIO_1)

Lego Interface Board

Header1

JP2 Pin No.

Signal Name

FPGA Pin No.

Header1 Pin No.

Signal Type

Input→ ←Output

Bi ↔

Signal Name Description

1 GPIO_1[0] PIN_K25 1 Input→ 1,2EN Motor Driver See Motor Driver Function Table

3 GPIO_1[2] PIN_M22 3 Input→ 1A See Motor Driver Function Table

5 GPIO_1[4] PIN_M19 5 Input→ 2A See Motor Driver Function Table

7 GPIO_1[6] PIN_N20 7 Input→ 3,4EN See Motor Driver Function Table

9 GPIO_1[8] PIN_M24 9 Input→ 3A See Motor Driver Function Table

11 VCC5 11 N.C.

13 GPIO_1[10] PIN_N24 13 Input→ 4A See Motor Driver Function Table

15 GPIO_1[12] PIN_R25 15

17 GPIO_1[14] PIN_R20 17

19 GPIO_1[16] PIN_T23 19

21 GPIO_1[18] PIN_T25 21

23 GPIO_1[20] PIN_T21 23

25 GPIO_1[22] PIN_U26 25

27 GPIO_1[24] PIN_U23 27

29 VCC33 29

31 GPIO_1[26] PIN_R19 31 N.C. TACHOA0 From Motor 1 not wired at this time.

33 GPIO_1[28] PIN_U20 33 N.C. TACHOA1 From Motor 1 not wired at this time.

35 GPIO_1[30] PIN_V26 35 N.C. TACHOA2 From Motor 2 not wired at this time.

37 GPIO_1[32] PIN_V24 37 N.C. TACHOA3 From Motor 2 not wired at this time.

39 GPIO_1[34] PIN_W25 39

Page 7: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

2 GPIO_1[1] PIN_K26 2 ←Output SDETECT Sound Sensor Circuit Non-debounced comparator output. When a sound is detected output goes HIGH. Normal LOW

4 GPIO_1[3] PIN_M23 4 ←Output DEBSDETECT Sound Sensor Circuit Debounced comparator output signal. When a sound is detected output goes HIGH for 5-20 ms. Normal LOW

6 GPIO_1[5] PIN_M20 6 Input→ DIGICI0 Light Sensor Input to Lego Light Sensor. HIGH = Enable Lego Light Sensor. LOW = Disable Lego Light Sensor.

8 GPIO_1[7] PIN_M21 8 ←Output LDETECT Light Sensor Debounced Signal. When reflected light is detected LDETECT goes LOW. Normal HIGH. Sensitivity is adjustable by POT.

10 GPIO_1[9] PIN_M25 N.C N.C. ADC_C0 Light Sensor Analog Not wired at this time. Analog Output from Lego Light Sensor. Open Collector Output.

12 GND -- 12 GND GND Digital GND

14 GPIO_1[11] PIN_P24 14 ←Output TOUCHSEN1 Touch Sensor 1 Non-debounced Signal. HIGH = Sensor Switch Open. LOW = Sensor Switch Closed.

16 GPIO_1[13] PIN_R24 16 ←Output DEBTOUCHSEN1 Touch Sensor 1 Debounced Signal. LOW = Sensor Switch Open. HIGH = Sensor Switch Closed.

18 GPIO_1[15] PIN_T22 18 ←Output TOUCHSEN2 Touch Sensor 2 Non-debounced Signal. HIGH = Sensor Switch Open. LOW = Sensor Switch Closed.

20 GPIO_1[17] PIN_T24 20 ←Output DEBTOUCHSEN2 Touch Sensor 2 Debounced Signal. LOW = Sensor Switch Open. HIGH = Sensor Switch Closed.

22 GPIO_1[19] PIN_T18 22

Page 8: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

24 GPIO_1[21] PIN_T20 24

26 GPIO_1[23] PIN_U25 26 Input→ BUZZ1 Piezo Speaker Signal BUZZ1 is connected to a terminal 1 on a piezo element. Terminal 2 is tied to Vc.

28 GPIO_1[25] PIN_U24 28

30 GND -- 30 GND GND Digital GND

32 GPIO_1[27] PIN_T19 32

34 GPIO_1[29] PIN_U21 34

36 GPIO_1[31] PIN_V25 36

38 GPIO_1[33] PIN_V23 38

40 GPIO_1[35] PIN_W23 40

4. Xilinx Expansion Header to Lego Interface Board Header No information.

5. PIC Board to Lego Interface Board Header No information.

Page 9: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

6. Code Examples and Tutorials Download Links

Altera DE2

Interface Projects Name of Code/Tutorial Download Link

Lego Touch Sensor http://www.seattleu.edu/scieng/ece/projects.html

Lego Light Sensor http://www.seattleu.edu/scieng/ece/projects.html

Sound Sensor http://www.seattleu.edu/scieng/ece/projects.html

Piezo Speaker http://www.seattleu.edu/scieng/ece/projects.html

SN754410 Motor Driver http://www.seattleu.edu/scieng/ece/projects.html

General Projects

Interface Projects Name of Code/Tutorial Download Link

Bug Pen http://www.seattleu.edu/scieng/ece/projects.html

Page 10: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

7. Lego Interface Board Details

Motor Driver - TI SN754410 Driver Datasheet http://focus.ti.com/lit/ds/symlink/sn754410.pdf

HEADER1 MOTOR 1 CONTROL

Pin No. Signal Type

SN754410 PIN NAME

SN754410 Pin No.

PIN FUNCTION

1 Input→ 1,2EN 1 ENABLE MOTOR DRIVER OUTPUTS 1 & 2

3 Input→ 1A 2 INPUT 1

1Y 3 DC MOTOR OUTPUT 1

5 Input→ 2A 7 INPUT 2

2Y 6 DC MOTOR OUTPUT 2

Breadboard motor driver circuit includes 10K pulldown resistor on all SN754410 inputs

Function Table Motor 1

INPUTS OUTPUTS MOTOR FUNCTION

1,2EN 1A 2 1Y 2Y

0 - - OFF OFF COAST

1 0 0 LOW LOW BRAKE

1 1 1 HIGH HIGH BRAKE

1 1 0 HIGH LOW FORWARD (FULL SPEED)

1 0 1 LOW HIGH REVERSE (FULL SPEED

PULSE WIDE MODULATION (PWM) Try using a frequency of 100Hz with chip SN754410

1 PWM 0 PWM LOW FORWARD, SPEED = DUTY CYCLE

1 0 PWM LOW PWM REVERSE, SPEED = DUTY CYCLE

1 PWM 1 PWM LOW FORWARD, SPEED = INVERSE DUTY CYCLE

1 1 PWM LOW PWM REVERSE, SPEED = INVERSE DUTY CYCLE

Header1 MOTOR 2 CONTROL

Pin No. Signal Type

SN754410 PIN NAME

SN754410 Pin No.

PIN FUNCTION

7 Input→ 3,4EN 9 ENABLE MOTOR DRIVER OUTPUTS 3 & 4

9 Input→ 3A 10 INPUT 3

3Y 11 DC MOTOR OUTPUT 3

13 Input→ 4A 15 INPUT 4

4Y 14 DC MOTOR OUTPUT 4

Breadboard motor driver circuit includes 10K pulldown resistor on all SN754410 inputs

Function Table Motor 2

INPUTS OUTPUTS MOTOR FUNCTION

3,4EN 3A 4A 3Y 4Y

Same as Function Table Motor 1 respectively

Page 11: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

SN754410 Absolute Maximum Ratings Complete Datasheet http://focus.ti.com/lit/ds/symlink/sn754410.pdf

Motor Supply Voltage Vcc2 36 V

Digital Supply Voltage Vcc1 36V

Motor Output Current OUTxx *1.1 A (Continuous)

Logic Input Voltage xEN, xA 36 V

* This data is from the TI datasheet. Do not expect to meet these value using a breadboard circuit!

The SN754410 is a favorite hobby chip used, probable because it is one of the rare chips still in production that come in

a thru-hole package. Only good for hobby stuff. Very inefficient when used as a motor driver

Breadboard Test DIP Switches

The Lego Interface board includes a DIP switch for testing motors.

Be sure all switches are in the OFF (OPEN) position when interfacing with other boards.

DIP SWITCH SN754410 SIGNAL OFF = OPEN ON = CLOSED Note 1 1,2EN LOW

10K Pulldown HIGH

1K Pullup LOW = DISABLE MODE, HIGH = ENABLE DEVICE

2 1A LOW 10K Pulldown

HIGH 1K Pullup

3 2A LOW 10K Pulldown

HIGH 1K Pullup

4 3,4EN LOW 10K Pulldown

HIGH 1K Pullup

LOW = DISABLE MODE, HIGH = ENABLE DEVICE

5 3A LOW 10K Pulldown

HIGH 1K Pullup

6 4A LOW 10K Pulldown

HIGH 1K Pullup

Page 12: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Pulse Width Modulation Introduction Figure 2a shows a PWM signal at a 10% duty cycle. That is, the signal is ON for 10% of the period and OFF the other 90%. Figures 2b and 2c show PWM outputs at 50% and 90% duty cycles, respectively. The longer the signal is ON compared to the OFF periods, results in higher power supplied to the motor.

Figure 2a

Figure 2b

Page 13: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Figure 2c

The duty cycle is defined as the percentage of digital ‘high’ to digital ‘low’ signals present during a PWM period.

Common modulating frequencies range from 1 kHz to 200 kHz with real motor drivers.

PWM can be produced by common microcontrollers or even a 555 timer circuit. http://www.eetimes.com/discussion/beginner-s-corner/4023833/Introduction-to-Pulse-Width-Modulation

Page 14: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Header1 Sound Sensor Circuit

Board circuit consists of a LM324 comparator and MIC. Datasheet: http://www.national.com/ds/LM/LM124.pdf

Header1 Pin No.

Signal Type

Input→ ←Output

Bi ↔

LM324 Signal Name

LM324 Pin No.

Description Note

2 ←Output SDETECT 1 Non-debounced comparator output. When a sound is detected output goes HIGH.

Comparator Output,

Normal LOW

4 ←Output DEBSDETECT 7 Debounced comparator output signal. When a sound is detected output goes HIGH for 5-20 ms

Comparator Output,

Normal LOW

POT 1 allows for sensitivity adjustment

LED 1 flashes ON when a sound is detected

This circuit is meant for simple clap trigger event applications

Page 15: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Header1 Touch Sensor (TS) 1 Circuit uses a 74HC14 Schmitt Inverter to debounce signal from sensor. See circuit.

Header1 Pin No.

Signal Type

Input→ ←Output

Bi ↔

TS Signal Name 74HC14 Pin No.

Description Note

14 ←Output TOUCHSEN1 Direct from Sensor

Non-debounced Signal. HIGH = Sensor Switch Open. LOW = Sensor Switch Closed.

10K Pullup

16 ←Output DEBTOUCHSEN1 6 Debounced Signal. LOW = Sensor Switch Open. HIGH = Sensor Switch Closed.

Schmitt Inverter Output. Normal LOW

Touch Sensor (TS) 2

Header1 Pin No.

Signal Type

Input→ ←Output

Bi ↔

TS Signal Name 74HC14 Pin No.

Description Note

18 ←Output TOUCHSEN2 Direct from Sensor

Non-debounced Signal. HIGH = Sensor Switch Open. LOW = Sensor Switch Closed.

10K Pullup

20 ←Output DEBTOUCHSEN2 4 Debounced Signal. LOW = Sensor Switch Open. HIGH = Sensor Switch Closed.

Schmitt Inverter Output. Normal LOW

Lego Touch Sensor Schematic

Page 16: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Example 1: Touch Sensor Switch Bounce When Pressed (1 ms per division zoom-in capture) Yellow = TOUCHSENx

Example 2: Switch Bounce When Pressed. Yellow = TOUCHSENx

Page 17: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Example 1: Switch Bounce When Released. Yellow = TOUCHSENx

Example 2: Switch Bounce When Released. Yellow = TOUCHSENx

Page 18: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Touch Sensor Debounce Circuit

Touch Sensor Pressed & Released

Non-debounced signal TOUCHSENx (Yellow) and debounced signal DEBTOUCHSENx (Green) (5 ms per division zoom-out capture)

This is typically what you should expect.

Page 19: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Switch Pressed & Released: No Capacitor C1: Yellow = TOUCHSENx, Green = DEBTOUCHSENx

Switch Pressed: No Capacitor C1: Yellow = TOUCHSENx, Green = DEBTOUCHSENx

Page 20: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Switch Released: No Capacitor C1: Yellow = TOUCHSENx, Green = DEBTOUCHSENx

Switch Pressed: With Capacitor C1: Yellow = TOUCHSENx, Green = DEBTOUCHSENx

Page 21: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Switch Released: With Capacitor C1: Yellow = TOUCHSENx, Green = DEBTOUCHSENx

Switch Pressed & Released

This is what to expect on TOUCHSENx (Yellow) & DEBTOUCHSENx (Green)

Page 22: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Header1 Light Sensor Circuit consists of a LM324 comparator to convert the Lego light sensor’s analog signal to digital bit

Header1 Pin No.

Signal Type

Input→ ←Output

Bi ↔

Signal Name

Description Note

6 Input→ DIGICI0 Input to Lego Light Sensor. LOW = Disable Lego Light Sensor (Turns Output LED OFF) HIGH = Enable Lego Light Sensor (Turns Output LED ON)

10K Pulldown

8 ←Output LDETECT Debounced Signal. When reflected light is detected LDETECT goes LOW. Normal HIGH.

Sensitivity is adjustable by POT2. You may need to adjust POT2 for different colors and glossy-flat finishes.

LED 2 is ON when light has crossed threshold

Output from Comparator

Light Sensor Function Table

INPUTS CONDITION OUTPUT

DIGICI0 REFLECTION LDETECT

LOW DON’T CARE HIGH

HIGH NO HIGH

HIGH YES LOW

Lego Light Sensor Schematic

Page 23: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Header1 Piezo Speaker

Header1 Pin No.

Signal Type

Input→ ←Output

Bi ↔

Signal Name

Description LIB Note

26 Input→ BUZZ1 Signal BUZZ1 is connected to the negative terminal on the LIB piezo element. The positive terminal is tied to Vc.

Piezo buzzers require an oscillating frequency in the audible range in order to generate sound similar to a speaker but with much higher impedance, hence does not require much current.

Continued below…

Page 24: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

8. Robot Applications

Controlled by breadboard

microcontroller or Altera

Board.

Six D size batteries provide

power to both the Altera

DE2 and motors-sensors.

Best to use NiMH batteries.

Always monitor battery

voltage before use under

load condition.

Page 25: General Interface to Lego NXT Motors & Sensorsfac-staff.seattleu.edu/fernandg/web/AlteraProjects/Robots/Lego... · Lego Interface board 0.3 Gary L Fernandes Seattle University Lego

Lego Interface Breadboard

Extended cable lengths are also available for tethered applications.

Altera DE2 interfaced to Lego products: http://www.youtube.com/watch?v=sIWRuqNM3Xc

iphone controlled Lego : http://www.youtube.com/watch?v=7pIS69teEvw&feature=related