Introduction to PICBasic Pro - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Introduction to PICBasic Pro

Description:

Students will be able to control LEDs with a microcontroller. ... (Apostrophe) Used for comments, explanations, etc. 6. Bit (1-bit) Byte (8-bits) (0 to 255) ... – PowerPoint PPT presentation

Number of Views:616
Avg rating:3.0/5.0
Slides: 21
Provided by: OTIS4
Category:

less

Transcript and Presenter's Notes

Title: Introduction to PICBasic Pro


1
Introduction to PICBasic Pro a LED binary
counter circuit (day 1 of 2)
  • Day 3

2
Objectives
  • Students will be able to have a basic
    understanding of writing a program in PICBasic
    Pro.
  • Students will be able to convert between 8-bit
    binary to decimal.
  • Students will be able to control LEDs with a
    microcontroller.
  • Students will be able to wire a microcontroller
    onto a breadboard.

3
PICBasic Pro
  • The PICBASIC PRO Compiler is the easiest way
    for you to program the fast and powerful
    Microchip Technology PICmicro microcontrollers.
    PICBASIC PRO converts your BASIC programs into
    files that can be programmed directly into a
    PICmicro MCU.

http//melabs.com/products/pbp.htm
4
Insert slide about opening On a computer MPLAB
IDE?
5
What functions/command will you learn today in
PICBasic Pro?
  • Comments
  • Variable declaration
  • For.Next
  • Line labels
  • Goto
  • High/Low
  • Pause
  • Referencing pins
  • TRISC (register)

6
Comments
  • (Apostrophe)
  • Used for comments, explanations, etc.

7
Variables
  • Bit (1-bit)
  • Byte (8-bits) (0 to 255)
  • Word (16-bits) (0 to 65535)
  • Not case sensitive, letters and number permitted,
    can not start with a number
  • Sample code
  • bob var word

8
Fornext
  • Used to loop a specific number of times.
  • Must use a variable
  • Variable can be used inside the loop
  • Sample code
  • bob var byte
  • For bob 1 to 100
  • Next bob

9
Line labels
  • Used to mark statements that may be referenced
    with a GOTO or GOSUB
  • Not case sensitive, letters and number permitted,
    can not start with a number
  • Sample code
  • Start

10
Goto
  • Will goto a line label when implemented
  • Some what archaic
  • Can be used to loop
  • Sample code
  • Start
  • Goto Start

11
High/Low
  • High - Makes a pin output and sets it high (5
    volts)
  • Low Makes a pin output and sets it low (0
    volts)
  • Can be used to turn on an off LEDs
  • Sample code
  • High 16
  • High PORTC.0

12
Pause
  • Used to pause the program for a specific amount
    of time.
  • Each measure is 1 ms
  • Dependent on oscillator.
  • If the oscillator is other then 4MHz, use OSC
    frequency of the oscillator that is being used.
  • Sample code
  • Pause 200

13
Referencing to pins
  • Option 1 Use the pin number
  • Option 2 Use port and register number (refer to
    documentation)
  • Sample code
  • High 10
  • High PORTB.7

14
Combining commands
Demo
  • Sample code
  • Start
  • High PORTC.0
  • PAUSE 100
  • Low PORTC.0
  • PAUSE 50
  • Goto Start

15
Binary
16
Register (TRIS)
  • Bit 1, set as input
  • Bit 0, set as output
  • Example PIC16F690
  • Has 3 ports, A, B, and C
  • PORTA is 6-bits (U,U,5,4,3,2,1,0)
  • PORTB is 4-bits (7,6,5,4,U,U,U,U)
  • PORTC is 8-bits (7,6,5,4,3,2,1,0)
  • Sample code
  • TRISA 00111000
  • TRISB 0
  • TRISC 256

17
1st Program Binary Counter
  • Counter var byte Initializes variable
  • TRISC 0 Initializes port c to outputs
  • Start
  • For Counter 0 to 255
  • PORTC Counter Sets some pins to High
  • Pause 250 Pauses for 250 ms
  • Next Counter Increments Counter up by 1
  • Goto Start Starts over again

18
1st Program Binary Counter (Schematic)
19
Assignment 2
  • Begin assignment 2.

20
Review
  • Comments
  • Variable declaration
  • For.Next
  • Line labels
  • Goto
  • High/Low
  • Pause
  • Referencing pins
  • TRISC (register)
Write a Comment
User Comments (0)
About PowerShow.com