robotraffic software and programming aids
DESCRIPTION
Robotraffic software and programming aids. Robotics Laboratory Faculty of Mechanical Engineering Technion Israel Institute of Technology. Strip sensor. Distance Sensor. Servo Motor. PICKit 2. Reset. RS232. 5Vdc out. Run/Stop. Select rs232 or IrDA. Select rs232. Encoder. IrDA. - PowerPoint PPT PresentationTRANSCRIPT
RobotrafficRobotraffic
software and programming aidssoftware and programming aids
Robotics LaboratoryRobotics Laboratory
Faculty of Mechanical EngineeringFaculty of Mechanical Engineering
Technion Israel Institute of Technion Israel Institute of TechnologyTechnology
PICKit 2
RS232
IrDA
Encoder
Run/Stop
5Vdc out
Power input
Strip sensor Distance Sensor Servo Motor
DC Motor
Select
rs232 Select
rs232 or IrDA
BUS jumpers
Fuse 5A
Car main boardCar main board
Reset
PICKit 2 (J3)1 - pin Vpp2 – pin Vdd3 – pin Gnd4 – pin PGD5 - pin PGC
RS232 (J1)1 – pin RX2 - pin Gnd3 – pin TX
IrDA (J9)1 –pin Vdd2 – pin Gnd3 – pin RXIr4 – pin TXIr
Encoder (J13)1 – pin Vdd2 – pin Gnd3 – pin QEA4 – pin QEB5 – pin Index
Run/Stop (J15)Open RC2->HighClose RC2 -> Low
5Vdc out (J16)1 – pin +5Vdc2 - Gnd
Reset (J6)1 – pin Reset2 - Gnd
Power input (J2)1 – pin (+) Battery2 – pin (-) Battery
Strip sensor (J11)1 – pin Vdd2 – pin Gnd3 – pin Left4 – pin BL5 – pin BR6 – pin Right7 – pin Stop
Distance Sensor (J12)1 – pin Vdd2 – pin Gnd3 - pin Left4 – pin Right
Servo Motor (J14)1 –pin Vm2 – pin Input3 – pin Gnd
DC Motor (J10)1 – pin (+)Motor2 – pin (-)Motor
BUS jumpers
Fuse 5A
1-2 close RS232
2-3 close IrDA
Car main boardCar main board
PIC18F4431 external device connection jumpersPIC18F4431 external device connection jumpers
PIC18F4431 PORTAPIC18F4431 PORTA
TRISA = 0x00; TRISA0 = 0; PORTA = 0xFA; RA0 = 1;TRISA = 0xFF; TRISA0 = 1; char a = PORTA;
Exercise_1 Port setup
#include<htc.h>
char a = 0x55;
void main(void) { TRISA = 0xf0; // b11111111 all bits, are input TRISA6 = 0; // bit RA6 set to output
PORTA = a;
}
#include<htc.h>#include<htc.h>char a;char a;void initialization (void);void initialization (void);void interrupt ISR(void);void interrupt ISR(void);
/*==============================================================*//*==============================================================*/void initialization (void)void initialization (void)
{{/* Interrupt init *//* Interrupt init */
IPENIPEN = 1;= 1; /* Interrupt Priority Enable bit, 1 = Enable priority levels on interrupts /* Interrupt Priority Enable bit, 1 = Enable priority levels on interrupts */*/
/* 0 = Disable priority levels on interrupts *//* 0 = Disable priority levels on interrupts */ GIEHGIEH = 1;= 1; /* Enables all high priority interrupts *//* Enables all high priority interrupts */GIELGIEL = 1;= 1; /* Enables all low priority peripheral interrupts *//* Enables all low priority peripheral interrupts */
/* init TMR0 *//* init TMR0 */T0CONT0CON = 0x46;= 0x46; /* 16-bit 1:2 prescale value *//* 16-bit 1:2 prescale value */TMR0LTMR0L = 0x80;= 0x80; /* prescaler for the Timer0 module *//* prescaler for the Timer0 module */TMR0HTMR0H = 0x00;= 0x00; /* prescaler for the Timer0 module *//* prescaler for the Timer0 module */
TMR0IPTMR0IP = 1;= 1; /* TMR0 Overflow Interrupt Priority bit, High priority *//* TMR0 Overflow Interrupt Priority bit, High priority */TMR0IETMR0IE = 1;= 1; /* Enables the TMR0 overflow interrupt *//* Enables the TMR0 overflow interrupt */TMR0IFTMR0IF = 0;= 0; /* TMR0 Overflow Interrupt Flag bit *//* TMR0 Overflow Interrupt Flag bit */
/* I/O ports *//* I/O ports */TRISATRISA = 0xff;= 0xff; /* Port A data direction *//* Port A data direction */TRISBTRISB = 0x00;= 0x00; /* Port B data direction *//* Port B data direction */
}}/*==============================================================*//*==============================================================*/void interrupt ISR(void)void interrupt ISR(void)
{{if((TMR0IF)&&(TMR0IE))if((TMR0IF)&&(TMR0IE))
{{ PORTB = a;PORTB = a; a++;a++;
TMR0LTMR0L = 0x80;= 0x80; /* prescaler for the Timer0 module *//* prescaler for the Timer0 module */ TMR0HTMR0H = 0x00;= 0x00; /* prescaler for the Timer0 module *//* prescaler for the Timer0 module */
TMR0IFTMR0IF = 0;= 0; /* TMR0 Overflow Interrupt Flag bit *//* TMR0 Overflow Interrupt Flag bit */}}
}}
/*==============================================================*//*==============================================================*/void main (void)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) { { } } }}
ENHANCED UNIVERSAL SYNCHRONOUS ASYNCHRONOUS RECEIVER TRANSMITTER (EUSART)