Download presentation
Presentation is loading. Please wait.
Published byNathaniel Cummings Modified over 9 years ago
1
Robotraffic software and programming aids Robotics Laboratory Faculty of Mechanical Engineering Technion Israel Institute of Technology
4
PICKit 2 RS232 IrDA Encoder Run/Stop 5Vdc out Power input Strip sensorDistance SensorServo Motor DC Motor Select rs232 Select rs232 or IrDA BUS jumpers Fuse 5A Car main board Reset
5
PICKit 2 (J3) 1 - pin Vpp 2 – pin Vdd 3 – pin Gnd 4 – pin PGD 5 - pin PGC RS232 (J1) 1 – pin RX 2 - pin Gnd 3 – pin TX IrDA (J9) 1 –pin Vdd 2 – pin Gnd 3 – pin RXIr 4 – pin TXIr Encoder (J13) 1 – pin Vdd 2 – pin Gnd 3 – pin QEA 4 – pin QEB 5 – pin Index Run/Stop (J15) Open RC2->High Close RC2 -> Low 5Vdc out (J16) 1 – pin +5Vdc 2 - Gnd Reset (J6) 1 – pin Reset 2 - Gnd Power input (J2) 1 – pin (+) Battery 2 – pin (-) Battery Strip sensor (J11) 1 – pin Vdd 2 – pin Gnd 3 – pin Left 4 – pin BL 5 – pin BR 6 – pin Right 7 – pin Stop Distance Sensor (J12) 1 – pin Vdd 2 – pin Gnd 3 - pin Left 4 – pin Right Servo Motor (J14) 1 –pin Vm 2 – pin Input 3 – pin Gnd DC Motor (J10) 1 – pin (+)Motor 2 – pin (-)Motor BUS jumpers Fuse 5A 1-2 close RS232 2-3 close IrDA Car main board
6
PIC18F4431 external device connection jumpers
8
PIC18F4431 PORTA TRISA = 0x00; TRISA0 = 0; PORTA = 0xFA; RA0 = 1; TRISA = 0xFF; TRISA0 = 1; char a = PORTA;
9
Exercise_1 Port setup #include char a = 0x55; void main(void) { TRISA = 0xf0;// b11111111 all bits, are input TRISA6 = 0;// bit RA6 set to output PORTA = a; }
14
#include<htc.h> char a; void initialization (void); void interrupt ISR(void); /*==============================================================*/ void initialization (void) { /* Interrupt init */ IPEN= 1;/* Interrupt Priority Enable bit, 1 = Enable priority levels on interrupts */ /* 0 = Disable priority levels on interrupts */ /* 0 = Disable priority levels on interrupts */ GIEH= 1;/* Enables all high priority interrupts */ GIEL= 1;/* Enables all low priority peripheral interrupts */ /* init TMR0 */ T0CON= 0x46;/* 16-bit 1:2 prescale value */ TMR0L= 0x80;/* prescaler for the Timer0 module */ TMR0H= 0x00;/* prescaler for the Timer0 module */ TMR0IP= 1;/* TMR0 Overflow Interrupt Priority bit, High priority */ TMR0IE= 1;/* Enables the TMR0 overflow interrupt */ TMR0IF= 0;/* TMR0 Overflow Interrupt Flag bit */ /* I/O ports */ TRISA= 0xff;/* Port A data direction */ TRISB= 0x00;/* Port B data direction */ }/*==============================================================*/ void interrupt ISR(void) {if((TMR0IF)&&(TMR0IE)) { PORTB = a; PORTB = a; a++; a++; TMR0L= 0x80;/* prescaler for the Timer0 module */ TMR0H= 0x00;/* prescaler for the Timer0 module */ TMR0H= 0x00;/* prescaler for the Timer0 module */ TMR0IF= 0;/* TMR0 Overflow Interrupt Flag bit */ }}/*==============================================================*/ void main (void) { initialization (); initialization (); TMR0ON = 1; /* Timer0 On/Off Control bit, 1 = Enables Timer0 */ TMR0ON = 1; /* Timer0 On/Off Control bit, 1 = Enables Timer0 */ while(1) while(1) { }}
16
ENHANCED UNIVERSAL SYNCHRONOUS ASYNCHRONOUS RECEIVER TRANSMITTER (EUSART)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.