In this section we discuss everything about programming the PIC and include the complete list of programs you have loaded (which could be found in the days when they were made). How well clarified
previously, we will schedule our PIC (by choice) in a programming language called BASIC . programming language is a language that is used to control the behavior of a machine, in our case the PIC. consists of a set of symbols, instructions and rules of syntax and semantics that define its structure, operation, interpretation and meaning of its elements and expressions.
The syntax rules are those that tell us how it should be written a program in this nguaje him. For example:
In C all instructions, declarations and / or functions must end with a semicolon, and control structures and routines mark their start and end with brackets so a good C program could be well:semantics gives the notion of such statements should be written instructions and / or functions. For example:
void main (void) {
char variable;
printf ("Hello world!");
getch ();}
variables in C are declared as follows: NAME data_type, "so a good variable declaration in C is:programming languages \u200b\u200bcan be classified according to their" level " , where a high level language is one that is closer to human notions of syntax and semantics and a lower level language is one that departs most of these notions. Therefore a lower level language is more difficult to interpret for a human (obviously the best interpretation for the machine). BASIC is a high-level language (the C language is given in the exemplifications also high level but not as much as BASIC). Programming languages \u200b\u200bare translated into machine code (1's and 0's) to then be actually performed by the machine, this sometimes is done through a program called "compiler program" . Ours is the PIC BASIC PRO (PBP). We'll explain the basics of the language applied to programming PIC's.
char variable;
VARIABLES: serve to store and manage data can have varying sizes, from one bit to a couple of bytes. Must be declared as follows: NAME SIZE VAR. Example: DOG VAR BYTE . We just created a variable to which the rest of the program as DOG call when we want to use and its size is 1 Byte (8 BIT's).
INPUT / OUTPUT: These are usually pin PIC ports or channels can be named according to their location and position. Example: portb.2 . Where what goes after the dot indicates the port B Bit used (the ports are generally 8 bits, so is 0 to 7). Also you can name them as variables. Example: VAR BUTTON portb.2 . In this way each time you say BUTTON compiler interprets it as the Bit 2 of port B.
CONTROL STRUCTURES: are those that allow us to interpret and compare data and act according to these interpretations. There are several very intuitive and therefore not dwell in each, which are used IF, WHILE and REPEAT-UNTIL and its structure is:
STATEMENTS: are those who work in the program by changing variables, statements and reports, ie the action commands that trigger a sequence of steps in the microcontroller. Example1: Example2 portb.1 HIGH: DOG = DOG +1.
IF (CONDITION) THEN
DECLARATION STATEMENT A Z B
ELSE STATEMENT
1
DECLARATION DECLARATION DECLARATION N 2
ENDIF
Explanation: If it happens running condition A, B and Z. If not, run 1. 2 and N, then ended and the program continues normally. REPEAT
Declaration1
Declaration2
DECLARACIONx
UNTIL (CONDITION)
Explanation: Repeat statements 1, 2 and x until the condition indicated. This condition usually go giving in to the statements in the loop (a variable that increases to a certain value, etc..).
WHILE (CONDITION)
Declaration1
Declaration2
DECLARACIONx
WEND
Explanation: When the condition is executed statements 1, 2 and x, once it no longer meets the condition, exits the loop.
This was the basic introduction that we hope will understand the programs that we will be doing. Below are all the programs made by the group:
All Programs - Upload a Document to Scribd Read
0 comments:
Post a Comment