My thanks go to Jeff Shmoyer. Experimenting with the PicBasic Pro Compiler Introduction The BASIC language has been popular since it’s conception in the. EXPERIMENTINGwiththe PICBASICPRO Y ByLesJohnson ACOLLECTIONOFBWLINGBLOCKS ANDWORKINGAPPLICATIONS USINGMELABS. Experimenting with the PicBasic Pro compiler PicBasic Pro компилятор. Read more Man-Made Materials (Experimenting With Everyday Science).

Author: Sagrel Vojinn
Country: Japan
Language: English (Spanish)
Genre: Love
Published (Last): 19 February 2007
Pages: 84
PDF File Size: 15.18 Mb
ePub File Size: 5.47 Mb
ISBN: 167-5-30680-904-4
Downloads: 71509
Price: Free* [*Free Regsitration Required]
Uploader: Mugore

Search the history of over billion web pages on the Internet. Although every effort has been taken with the construction of this book to ensure that any projects, designs or programs enclosed, operate in a correct and safe manner. The author or publisher does not accept responsibility in any way for the failure of any project, design or program to work correctly or to cause damage to any equipment that it may be connected to, or used in combination with.

Copyright Rosetta Technologies No part of this publication may be reproduced or experimentting in any form or by any means without the written permission of the author. The Microchip logo and name are registered trademarks of Microchip Technology Inc.

One of the main reasons for this is its ease of use and ability to make a project work within a matter of hours, instead of days or weeks. Moreover, when the BASIC language is in the form of a compiler; it combines both speed and ease of use.

MicroEngineering, Labs Inc have come up with the perfect medium for programming the PICmicro range of microcontrollers. It illustrates how to control experimentign available devices such as Analogue to Digital Converters, Digital to Analogue Converters, Temperature sensors etc, that may be complier into your own projects, as well as some complete projects.

In addition, tips and techniques are discussed which allow even more control over the PIC. Each experiment in the book has an accompanying program that shows exactly what is happening, or supposed to happen.

Most are in the form of subroutines, ready to drop into your own program. The majority of the projects will work on any of the bit core devices, however, unless otherwise stated, the PIC used is the ever popular PIC16F84 using a 4mHz crystal.

The accompanying CDROM has all the source listings for the experiments, as well as the manufacturers datasheets and application notes for the semiconductor devices used.

My thanks go to Jeff Shmoyer, not only for co-writing the compilers, but also for his advice in the construction of this book. I would also like to thank you for purchasing this book and I wish you every success in your future projects.

Keypad interfacing principals button Keypad interface. Experimenting with Serial Eeproms. Giving the PIC a memory. Experimenting with Analogue to Digital Converters. Experimenting with Digital to Analogue Converters. Experimenting with Remote Control. Sony infrared remote control Receiver.

Page Dallas 1-wire interface principals. Experimenting with Audio Control Devices. Programming techniques Integrating Assembly language into your programs. Powering up the PIC. Page Getting the most out of batteries. Multiple baud serial LCD controller. Driving multiplexed 7-segment displays.

Substituting common Anode LED displays. The serial LCD controller described here, simplifies the use of these displays even more, by enabling control of the LCD with a single wire. This is invaluable in debugging your latest masterpiece, as it opens up a window into your code.


By connecting it to an unused pin and using the DEBUG command at specific areas within the program, variables and registers can be viewed. When the PIC is powered up, the first thing It does is turn on the LCD and wait the appropriate time for the display to be fully initialised, this usually takes approximately ms. It then looks at the polarity switch, and jumps to the appropriate section of code and displays: If the character is a special escape characterthe next character is assumed to be a command.

Otherwise, the data will pass directly to the LCD. This allows the display to be cleared scrolled, etc. The DIL switch serves two purposes, first it configures the serial polarity mode inverted or true by pulling PortB. Sharing a pin like this is a common practice when spare pins are not available. Secondly, it stops the input from floating, floating means that the pin picbwsic neither set high or low. This is achieved by resistors R2 and R4.

When the polarity is configured for inverted mode, the left switch in the DIL package is closed, which means that the right switch is open, thus allowing only R4 to be connected to the input, this pulls the serial input pin slightly towards ground. And when true polarity is selected, the left switch in the DIL package is open and the right switch is closed, bringing R2 into circuit, but as R2 has a lower resistance than R4 the serial input pin is pulled more to the supply line.

Without these resistors, random characters would be displayed when the input was not connected to picbsaic. Simple serial LCD controller. The baud rates are selectable from to and both inverted and non-inverted serial data is accepted.

The circuit is, in essence the same as the Simple controller, but with the exception of a clever little switch called a Decimal Rotary DIL, figurel. It has ten rotary positions, numbered 0 to 9, and these numbers are represented as BCD outputs on pins, 1, 2, 4 and 8.

Because of the higher baud rates involved, a 16F running at 12mHz is used. Therefore, the first thing the program does is make PortB. The program now sits in a loop, receiving data and outputting it to the LCD. Bargraph option The Bargraph display is initiated by sending the control byte along with xeperimenting position to start displaying from, and then the length of the bar: The Bargraph subroutine is in the form of an include file, which is loaded in after the LCD has initialised.

The code is fully commented.

BAS demonstrates the use of the bargraph option. Contrast increases as the pot is turned towards ground and the voltage on Pin Vo decreases. Alternately, a fixed resistor with a value of a few hundred ohms can be connected compiper Vo to ground. VR1 50k gnd Figurel. As shown in figurel.

Switch-mode negative voltage generator. This is of course impractical therefore, multiplexing is almost universally adopted. As most of you will already know, multiplexing is accomplished by driving each display in sequence. As each display is turned on, the segment data from the PIC is set to the expfrimenting pattern for that digit. The patterns for each digit are shown in table 1. To illustrate how a single digit is displayed, we will compilet at digits 4 and 5.


Binary relationship to illuminated segments. F connect to the pins in between. The decimal point is connected to bit-7 of the same port.

Experimenting with the PicBasic Pro compiler

In this demonstration, we shall be using common cathode displays. As the name suggests, all the cathodes for the individual segment LEDs are connected together internally, as shown below in figurel.

Individual LEDs within a common cathode display. To multiplex more than one display, requires us to take control of their individual cathodes. This is achieved by a compier acting as witu switch, as shown in figurel. A logic high on the base of the transistor will switch it on, thus pulling the common cathodes to ground.

Compiper limits the current that can flow between the individual segment LEDs. R1 limits the voltage supplied to the base of the transistor. We now have the means to switch each display on in turn, as well as the information required to illuminate a specific digit.

Experimenting with the PicBasic Pro Compiler by Les Johnson

BAS shows a way of displaying a five-digit number on five, 7-segment displays. The first thing the program does is initiate a TMRO interrupt as shown in the programming techniques section to generate an interrupt every 1. To calculate the repetitive rate of the interrupt use the ppicbasic formula: This way each display is turned on for approx 1.

A check is then made of the variable DP which holds the decimal point placement. If DP holds the value of the display we are currently using, the decimal point is turned on by setting bit-7 of PortC. The display itself is then turned on by setting the particular bit of PortB high. DP may hold a value between While the interrupt gives us a means of displaying five digits, the subroutine DISPLAY does the processing of the actual number to display. After all the digits have coompiler processed, the interrupt is re-enabled and the subroutine is exited.

To aid in the use of multiplexing the displays, several include files have been developed for use with 2 to 5 displays. BAS file has been included. The second variable, DP holds the position of experimenring decimal point INC is for use when 4 displays are required. Wihh, DP now has the range INC are for use with 3 and 2 displays respectively.

BAS demonstrates the use of 2 to 5 multiplexed displays, by uncommenting the required tge file. The program increments a bit variable, which is displayed on the 7-segment LEDs. However, this loop could easily be replaced by the ADCIN command for displaying the voltage converted.