tu storm the tu storm robot controller: innovation first mini robot controller (microchip...
DESCRIPTION
● Start MPLAB IDE ● File -> Open Workspace… ● Select the.mcw file from the TU-STORM project you downloaded. ● Double-click user_routines.c in project window. ● Scroll down and edit Default_Routine(). ● Project -> Make ● Verify BUILD SUCCEEDEDTRANSCRIPT
![Page 1: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/1.jpg)
TU STORM
The TU STORM Robot Controller:Innovation First Mini Robot Controller
(Microchip PIC18F8520)Programmable in CUsing MPLAB IDE
![Page 2: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/2.jpg)
Installing MPLAB● Use C-Bot CD to install:● Step 1: MPLAB IDE● Step 2: C18 Compiler● Download IFI Loader from
TU-STROM Web site and install it.
● Download default TU-STORM Project code for TU-STORM Web site.
![Page 3: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/3.jpg)
● Start MPLAB IDE● File -> Open Workspace…● Select the .mcw file from
the TU-STORM project you downloaded.
● Double-click user_routines.c in project window.
● Scroll down and edit Default_Routine().
● Project -> Make● Verify BUILD SUCCEEDED
![Page 4: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/4.jpg)
Download Code to Robot Controller
● Connect serial cable from PC to IFI Controller.● Power up IFI Controller● Start IFI_Loader.● Browse to find the .hex file that was just compiled.● Click DOWNLOAD.
![Page 5: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/5.jpg)
Why C?
● Modular● Powerful● Industry standard● Fast and efficient
![Page 6: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/6.jpg)
TU-STROM Project● .c -Source Files● .h -Header Files● .lib -Library Files● .lkr -Linker Scripts● Edit the .c and .h files● Compile● Link TUStormCode.hex
![Page 7: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/7.jpg)
Variables in C
unsigned char left_motor; /* range: 0 to 255 */
char left_motor; /* range: -128 to 127 */
unsigned int Left_BW_Sensor; /* range: 0 to 65535 */
int Left_BW_Sensor; /* range: -32768 to 32767 */
![Page 8: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/8.jpg)
C is case-sensitive
int left_motor;
(is not the same as)
int Left_motor;
![Page 9: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/9.jpg)
Assignments= operator
Shoulderx = 0.0;
count = count + 1;
General assignment:
variable_name = expression ;
![Page 10: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/10.jpg)
Arithmetic Operations
C arithmetic operators: + , - , *, /
Can group together expression with parentheses.
result = (a + b) * c;
![Page 11: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/11.jpg)
Control Structures
if ( condition ) { ... ... // The "then" block of statements. ... } else { ... ... // The "else" block of statements. ... }
![Page 12: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/12.jpg)
Control Structures
if ( condition_1 ) { ... ... <-- "then" block_1; ... } else if ( condition_2 ) { ... ... <-- "then" block_2; ... } else { ... <-- "else" block; }
![Page 13: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/13.jpg)
Conditionals
Conditionals are either true or false. Conditionals <- relational / logical operators. Relational operators: ==, !=, >, <, >=, <=.
logical operators: &&, ||, and !
![Page 14: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/14.jpg)
Control Structures
if ((TopSw==ON)&&(MidSw==OFF)&&(BotSw==OFF)){ if ((RightBW < RgtBWThreshold) || (Flag == 1)){ RightMotor = RightIdle; LeftMotor = LeftIdle; } else { RightMotor = RightIdle + Speed; LeftMotor = LeftIdle - Speed; }}
![Page 15: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/15.jpg)
Definition of C Functions
return_value_type func_name( declaration_of_arguments list ){ ... return_value_type return_value; // declare return value variable and type ... . //Block of function statements. ... return return_value;}
![Page 16: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/16.jpg)
Sample Function
int Doubled_Number(int num2double ){ unsigned int result; // Local variable result = 2 * num2double; // Funtion Calculations return result; // Return value}
![Page 17: TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE](https://reader035.vdocuments.mx/reader035/viewer/2022062223/5a4d1b247f8b9ab0599966d8/html5/thumbnails/17.jpg)
Output to the Screen
printf() command to display the values of Lmotor, Rmotor.
/* printf example */ unsigned char Lmotor, Rmotor;....printf("Lmotor = %d, Rmotor = %d\n", (int)Lmotor,(int)Rmotor);
Note: (Lmotor, Rmotor) are of type unsigned char. Must be typecast as int to work with printf().