Sei sulla pagina 1di 25

Lego

Interface
board
0.3
General Interface to
Lego NXT Motors & Sensors

Gary L Fernandes
Seattle University
Lego Interface Breadboard (LIB)

Lego Interface Breadboard

Revision History
Revision
Date
Rev 0.1
2/11/2001
Rev 0.2
2/23/2011
Rev 0.3
3/11/2011

Description
Created:
Updated everything.
Updated Altera Expansion Header info, Cleaned up everything.

Person
Gary L Fernandes, fernandg@seattleu.edu
Gary
Gary

Best viewing with =>Office 2007


Table of Contents
1.
2.
3.

Lego Interface Board Formats of Use ............................................................................................................................. 4


Lego Interface Breadboard Proto 1................................................................................................................................. 5
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

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.

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

Lego Interface Breadboard

2. Lego Interface Breadboard Proto 1.

Optional Power Switch


Banana jack Va to Vb
(useful for testing)

Vc

GND

6 - 9.5VDC

Light Sensor Adjust


Sound Sensor Adjust
Microphone

Light Sensor Detect LED


Sound Sensor Detect LED

Motor Test DIP Switches


For normal operation all
switchs must be set to OFF
(Open) position

Lego Light Sensor Port


Lego Motor Port 1

Lego Motor Port 2


Lego Touch Sensor Port 1

Lego Touch Sensor Port 2

Header1

Use this

header cable to interface


to microcontrollers or
Altera/Xilinx boards

Lego Interface Breadboard

3. Altera Expansion Header to Lego Interface Board Header


Altera
Expansion Header
JP2 (GPIO_1)
JP2 Pin
No.

Signal
Name

Lego Interface Board


Header1

FPGA Pin
No.

Header1
Pin No.

Signal
Type
Input
Output
Bi

Signal Name

Description

GPIO_1[0]

PIN_K25

Input

1,2EN

Motor Driver
See Motor Driver Function Table

GPIO_1[2]

PIN_M22

Input

1A

See Motor Driver Function Table

GPIO_1[4]

PIN_M19

Input

2A

See Motor Driver Function Table

GPIO_1[6]

PIN_N20

Input

3,4EN

See Motor Driver Function Table

GPIO_1[8]

PIN_M24

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

Lego Interface Breadboard

GPIO_1[1]

PIN_K26

Output

SDETECT

Sound Sensor Circuit


Non-debounced comparator output.
When a sound is detected output goes
HIGH. Normal LOW

GPIO_1[3]

PIN_M23

Output

DEBSDETECT

Sound Sensor Circuit


Debounced comparator output signal.
When a sound is detected output goes
HIGH for 5-20 ms. Normal LOW

GPIO_1[5]

PIN_M20

Input

DIGICI0

Light Sensor
Input to Lego Light Sensor.
HIGH = Enable Lego Light Sensor.
LOW = Disable Lego Light Sensor.

GPIO_1[7]

PIN_M21

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

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

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

Lego Interface Breadboard


24

GPIO_1[21] PIN_T20

24

26

GPIO_1[23] PIN_U25

26

28

GPIO_1[25] PIN_U24

28

30

GND

30

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

--

Input

BUZZ1

Piezo Speaker
Signal BUZZ1 is connected to a terminal 1
on a piezo element. Terminal 2 is tied to
Vc.

GND

GND

Digital GND

4. Xilinx Expansion Header to Lego Interface Board Header


No information.

5. PIC Board to Lego Interface Board Header


No information.

Lego Interface Breadboard

6. Code Examples and Tutorials Download Links


Altera DE2
Interface Projects
Lego Touch Sensor
Lego Light Sensor
Sound Sensor
Piezo Speaker
SN754410 Motor Driver
General Projects
Interface Projects
Bug Pen

Name of Code/Tutorial

Download Link
http://www.seattleu.edu/scieng/ece/projects.html
http://www.seattleu.edu/scieng/ece/projects.html
http://www.seattleu.edu/scieng/ece/projects.html
http://www.seattleu.edu/scieng/ece/projects.html
http://www.seattleu.edu/scieng/ece/projects.html

Name of Code/Tutorial

Download Link
http://www.seattleu.edu/scieng/ece/projects.html

Lego Interface Breadboard

7. Lego Interface Board Details


Motor Driver - TI SN754410 Driver
HEADER1
Pin No.
Signal
Type
1
Input
3
Input
5

Input

1,2EN
0
1
1
1
1
1
1
1
1

Function Table Motor 1


INPUTS
OUTPUTS
MOTOR FUNCTION
1A
2
1Y
2Y
OFF
OFF
COAST
0
0
LOW
LOW
BRAKE
1
1
HIGH
HIGH
BRAKE
1
0
HIGH
LOW
FORWARD (FULL SPEED)
0
1
LOW
HIGH
REVERSE (FULL SPEED
PULSE WIDE MODULATION (PWM) Try using a frequency of 100Hz with chip SN754410
PWM
0
PWM
LOW
FORWARD, SPEED = DUTY CYCLE
0
PWM
LOW
PWM
REVERSE, SPEED = DUTY CYCLE
PWM
1
PWM
LOW
FORWARD, SPEED = INVERSE DUTY CYCLE
1
PWM
LOW
PWM
REVERSE, SPEED = INVERSE DUTY CYCLE

Header1
Pin No.
Signal
Type
7
Input
9
Input
13

3,4EN

Datasheet http://focus.ti.com/lit/ds/symlink/sn754410.pdf
MOTOR 1 CONTROL
SN754410 SN754410 PIN FUNCTION
PIN NAME
Pin No.
1,2EN
1
ENABLE MOTOR DRIVER OUTPUTS 1 & 2
1A
2
INPUT 1
1Y
3
DC MOTOR OUTPUT 1
2A
7
INPUT 2
2Y
6
DC MOTOR OUTPUT 2
Breadboard motor driver circuit includes 10K pulldown resistor on all SN754410 inputs

Input

MOTOR 2 CONTROL
SN754410 SN754410 PIN FUNCTION
PIN NAME
Pin No.
3,4EN
9
ENABLE MOTOR DRIVER OUTPUTS 3 & 4
3A
10
INPUT 3
3Y
11
DC MOTOR OUTPUT 3
4A
15
INPUT 4
4Y
14
DC MOTOR OUTPUT 4
Breadboard motor driver circuit includes 10K pulldown resistor on all SN754410 inputs

INPUTS
3A

4A

Function Table Motor 2


OUTPUTS
3Y
4Y
Same as Function Table Motor 1 respectively

MOTOR FUNCTION

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

1,2EN

1A

2A

3,4EN

3A

4A

LOW
10K Pulldown
LOW
10K Pulldown
LOW
10K Pulldown
LOW
10K Pulldown
LOW
10K Pulldown
LOW
10K Pulldown

HIGH
1K Pullup
HIGH
1K Pullup
HIGH
1K Pullup
HIGH
1K Pullup
HIGH
1K Pullup
HIGH
1K Pullup

Note
LOW = DISABLE MODE,
HIGH = ENABLE DEVICE

LOW = DISABLE MODE,


HIGH = ENABLE DEVICE

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

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

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

LM324
Signal Name

LM324
Pin No.

Description

Note

Input
Output
Bi

Output

SDETECT

Output

DEBSDETECT

Non-debounced comparator output.


When a sound is detected output goes HIGH.

Comparator
Output,
Normal LOW

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

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

TS Signal Name

74HC14 Pin
No.

Description

Note

Direct from
Sensor

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

10K Pullup

Debounced Signal.
LOW = Sensor Switch Open.
HIGH = Sensor Switch Closed.

Schmitt Inverter
Output.
Normal LOW

Input
Output
Bi

14

Output

TOUCHSEN1

16

Output

DEBTOUCHSEN1

Touch Sensor (TS) 2


Header1
Pin No.

Signal
Type

TS Signal Name

74HC14 Pin
No.

Description

Note

Direct from
Sensor

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

10K Pullup

Debounced Signal.
LOW = Sensor Switch Open.
HIGH = Sensor Switch Closed.

Schmitt Inverter
Output.
Normal LOW

Input
Output
Bi

18

Output

TOUCHSEN2

20

Output

DEBTOUCHSEN2

Lego Touch Sensor Schematic

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

Lego Interface Breadboard

Example 1: Switch Bounce When Released. Yellow = TOUCHSENx

Example 2: Switch Bounce When Released. Yellow = TOUCHSENx

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.

Lego Interface Breadboard

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

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

Lego Interface Breadboard

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

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

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)

Lego Interface Breadboard

Header1

Light Sensor
Circuit consists of a LM324 comparator to convert the Lego light sensors analog signal to digital bit

Header1
Pin No.

Signal
Type

Signal
Name

Description

Note

Input
Output
Bi

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

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

INPUTS
DIGICI0
LOW
HIGH
HIGH

Light Sensor Function Table


CONDITION
REFLECTION
DONT CARE
NO
YES
Lego Light Sensor Schematic

OUTPUT
LDETECT
HIGH
HIGH
LOW

Lego Interface Breadboard

Header1

Header1
Pin No.

Piezo Speaker
Signal
Type

Signal
Name

Description

BUZZ1

Signal BUZZ1 is connected to the negative terminal on the


LIB piezo element. The positive terminal is tied to Vc.

LIB Note

Input
Output
Bi

26

Input

Continued below

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.

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.

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

Potrebbero piacerti anche