EN206 Robot Competition

Guidelines for Board Construction and Interfacing

Subsystems of the Processor Board
J3 U6 VIN GND 1 2 C9 C HEADER 2 C10 C C11 C 1 VOUT 3 R16 R C21 C
LO LO LO

R4 R

SW1

0
R1 R D50 LED U2 R17 R SENS59150-SPST

78XX/SM

2

0
D7 LED PIC RESET R3 R D18 DIODE R2 R

POWER SUPPLY
0
C20
LO

Q1 BC548

C 16 U4 P1 1 6 2 7 3 8 4 9 5 CONNECTOR DB9

0 0

C C14

0
Y1 CRY STAL Timer1/Counter1 Input PWM1 PWM2 SCL Motor1Dir1 Motor1Dir2

0

LO

18F452

VCC

R2OUT T2IN

9 10

RX-TTL TX-TTL

0

PIC RESET
LO

7 8 C C19 2 1 3 4 5 6

C

C15

T2OUT R2IN V+ C1+ C1C2+ C2V-

MAX232 T1IN R1OUT R1IN T1OUT GND 11 12 13 14

0

C16 C C17 C C18 C

Use Female Foot print

15

0

J24 1 2 3 4 5 6 7 8

RS232 LEVEL CONVERTER

J29 1 2 3 4 5 6 7 8

J9 SDI SCL SDO SS LED1 LED2 LED3 LED4 1 2 3 4 5 6 7 8 9 10

J6

HEADER 10 1 2 3 4 5 6 7 8 9 10

J10 1 2 3 4 5 6 7 8 9 10
LO

HEADER 8

Analog1 Analog2 Analog3 Analog4 Analog5 Analog6 Analog7 Analog8

HEADER 8

SPI INTERFACE

HEADER 10 J11

0

Analog Port
HEADER 10 1 2 3 4 5 6 7 8 9 10

0

HEADER 10 J12 1 2 3 4 5 6 7 8 9 10
LO

Processor Board
D14 LED1 LED2 LED3 LED4 D15 D16 LED D17 LED LED LED R9 R10 R12 R R13 R R R

J7
LO

HEADER 2 J8

R14 R 1 2

R15 R Timer1/Counter1 Input Timer0/Counter0 input

Encoder/Counter Interface

HEADER 10

0

Digital Port

0

LO

1 2 3 4 5 6 7 8 9 10

Digital1 Digital2 Digital3 Digital4 Digital5 Digital6 Digital7 Digital8

0 0 0 0
Size B Date: Title <Title> Document Number <Doc> Monday , July 09, 2007 Sheet 1 of 1 Rev <Rev Code>

Indicators

HEADER 10

LO

0

PWM1 PWM2 Motor1Dir1 Motor1Dir2 Motor2Dir1 Motor2Dir2

0

LO

0

Analog1 Analog2 Analog3 Analog4 Timer0/Counter0 input Analog5 Analog6 Analog7 Analog8

MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VDD VSS OSC1 OSC2 RC0 RC1 RC2 RC3 RD0 RD1

RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VDD VSS RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2

Digital1 Digital2 Digital3 Digital4 Digital5 Digital6 Digital7 Digital8 LED1 LED2 LED3 LED4 RX-TTL TX-TTL SDO SDI Motor2Dir2 Motor2Dir1

0

LO

LO

Detailed Plan of the Processor Board
5V Regulator I/O Bus (Analog/Digital) Reset Switch Ground Bus Power Supply (9V – 24V) 5V Bus I/O Bus (Digital)

Power Indicator

Indicator LEDs

PIC Micro controller (18F452)

DB9 Serial Connector

Max232 Level converter

Encoder Interface

Motor Driver Interface

I/O Bus (Digital)

Tracks of the PCB of the Processor Board

Recommended Steps for Construction (1) 1. Solder the power supply
• • • Check if the indicator LED lights up Verify that the supply voltage is 5V Check if the voltage between the VDD and GND pins of the microcontroller is 5V

2. Solder the IC base for the microcontroller

Recommended Steps for Construction (2) 3. Solder the microcontroller circuit, the indicator LED’s and the encoder/counter interface
• Write a simple program for the microcontroller to make the LED’s connected to IO pins D7-D4 blink. Use this to check the circuit.

Recommended Steps for Construction (3) 4. Solder the RS232 interface
• • • Write a simple program for the PC to write a character to the RS232 port and read a character from it. Write a program for the microcontroller to read the RS323 port and echo the character it receives. Verify the performance of the system and use the oscilloscope to check if the voltage levels are correct.

Recommended Steps for Construction (4) 5. Solder the remaining interface pins
• If any of the stages do not pass the diagnostic tests specified, do not proceed without correcting the fault at that stage.

mikroC
• Syntax very similar to C/C++ • High level programming language
– Complex low level operations are abstracted (eg. RS232 interfacing)

• Versatile

Sample Program – LED Blinking
void main() { PORTD = 0xA0; TRISD = 0; while(1) { PORTD = ~PORTD; Delay_ms(1000); } }

Sample Program – RS323
unsigned short i; void main() { USART_init(2400); // initialize USART module // (8 bit, 2400 baud rate, no parity bit... while (1) { if (USART_Data_Ready()) { // if data is received i = USART_Read(); // read the received data USART_Write(i); // send data via USART } } }

Motor Driving Board
Motor 1

Interfacing to Processor Board

L298 Motor Driver IC (2A Max) Power Connector

Motor 2

Motor 3

Interfacing to Processor Board Motor 4

The Sonar Sensor
• SRF05

Operation of the Sonar Sensor
• Range detection using ultrasound

Ultrasound Pulse

Echo Sonar Sensor Object

Interfacing the Sonar Sensor
short i; void main() { PORTB = 0; TRISB = 0xFD; // Pin B0 is input Pin B1 is output TRISD = 0; // Port D - Output PORTB.F1 = 0; i = 0; do { // Send Trigger Pulse PORTB.F1 = 1; Delay_us(10); PORTB.F1 = 0; Delay_ms(1); i = 0; while (PORTB.F0 == 1) { if (i<0xFE) {i++;} if (i == 0xFF) {break;} Delay_us(2); } Delay_ms(100); PORTD = i; } while(1); }