HOME - - - - - - - - - Other material for programmers - - - - - - - - - Pascalite Tutorial Table of Contents

Pascalite hardware: How to Use It


This is not finished... you'll soon see that! However, while I apologise for typos, bad phrasing, etc, I still think this is something *I* would want as an aid if I had a new Pascalite I wanted to get to grips with. Decide for yourself!

Getting started with Pascalite

I wrote this tutorial to help users quickly master the various features of the Pascalite.


If you have just received your Contol Plus Pascalite, and want....

to get it unpacked and set up....

with minimal fuss....

and maximum chance of avoiding damaging mistakes...

.... then I suggest you visit....

        Pascalite: First Steps. Besides helping you set things up, it shows you how to attach an LED and current limiting resistor so you can see output, and how to attach a switch and pull-up resistor so you have an input.


This material (c) T K Boyd, 3/03. I hope you will establish links to this for me... but please do not re-distribute it. It is for your personal use. If you are a teacher, please feel free to make properly credited copies for use by your own pupils until August 2004, at which time the license lapses. Please revisit this site to see how things stand then.


This is written especially for the Pascalite Plus, and software version 2.60C... but much of what appears here will apply equally to the other Pascalites and other versions of the software.

I suspect most users will already have the software installed, but if you want help with that, see First Steps.

I have tried to cover things that neophytes will need to know. Let me know if you were left without an answer to something. Experienced users: Please be patient?!

I have no formal connection to Control Plus, though I hope, through this and other efforts to build up some "good will" credit with them!

====
I have (at least!) two other pages relating to the Pascalite. The first is essentially "advertising"... something to tempt you towards the fun I've been having. (That page also talks about the BASICStamp and at least one alternative PIC compiler.) The other page has general tutorials on Pascal programming, but they are written to run without modification within the free Pascalite environment. You don't need the Pascalite hardware to work through the tutorials.

Why you want a Pascalite (or BASICStamp) This is probably a better place to start if you don't have a Pascalite, unless you are especially interested in the hardware aspects, in which case the details below of how to access various features of the splendid Pascalite may be what you want.

Pascal Programming- using a free compiler.

====
Jump to the bottom of the page if you want to run without bothering to walk first. There are links to more advanced topics.

====
The following assume you've got your Pascalite set up and have successfully made a few very simple tests. (Lit an LED on d0, tested an input on d4. If you need help, see First Steps.) The following hopes to take you through more exercises and tests which will...

     a) Further introduce you to your Pascalite
     b) Test it in a logical and "first things first" sequence.

=======
Now... if you have the LCD module... and it is working.. you can skip the following, but I think it is better to write this introduction so that as many people can use it as possible, and so that one thing can be tested at a time.....

Connect three more LEDs, each with a resistor, to d1, d2, and d3.

NB: The pages in the manual giving which-pins-connect-to-what-signal are easy to confuse, and the connections for a Pascalite Pro are NOT the same as for a Plus.

Enter the following program:

program IntTut3;
var bCnt:byte;
begin
def_out(d0,d1,d2,d3);
repeat
for bCnt:=0 to 15 do begin
  write(portd,bCnt);
  delay(200);
  end;
until 4=5;
end.
You should see 0, 1, 2, 3... 13, 14, 15, 0, 1, 2... appearing on the LEDs in binary. Limited output... but adequate to give a preliminary test of many things. Of course, you have to be able to read binary numbers to "fully" use this "output device"... but don't worry if you can't. ("When I was a boy", I spent many hours feeding binary numbers into a PDP-8 with mechanical switches. Not a lot of fun, and programs take a while to develop, but it did teach me binary!)

========
Now we're going to modify the previous program so that if you DO have the LCD module, it too will be displaying 0, 1, 2, 3...

Plug the module in CAREFULLY: You don't want the I2C connector rotated from it's correct orientation.

program IntTut3b;
var bCnt,bNum:byte;
begin
def_out(d0,d1,d2,d3);
repeat
for bCnt:=0 to 9 do begin
  write(portd,bCnt);
  bNum:=bCnt+48;
  write(LCD,bNum);
  write(LCD,"  ");{two spaces}
  delay(200);
  end;
until 4=5;
end.
You should see 0, 1, 2, 3... 8, 9, 0, 1, 2... in the upper left of the LCD display.

The tiresome stuff about +48 arises to translate from a number to the code for a digit.

You should see digits printing across the LCD. Change the number of spaces in the WRITE(LCD," "); line for amusing effects.

=========
Modify the previous program as follows:
program IntTut3c;
var bCnt,bNum,bIn:byte;
begin
def_out(d0,d1,d2,d3);
write(LCD,255);{clears LCD}
repeat
for bCnt:=0 to 9 do begin
  write(portd,bCnt);
  bNum:=bCnt+48;
  gotoxy(0,0);
  write(LCD,bNum);
  write(LCD,"  ");{two spaces}
  delay(200);
  repeat
    read(portd,bIn);
  until (bIn and 16)=16;{This line optional}
  end;
until 4=5;
end.
This just tidies a few things, shows you how others are accomplished. The optional line will allow a switch on input d4 to pause the looping through the numbers... if you still have the switch from program IntTut2.pas attached.

This program is poorly designed: It can "fall over" if bNum holds something other than 0 to 9 before 48 is added to it. The next program deals with that problem.

A minor pity: You can only put numbers after GotoXY. You can't put variables in their place. That seems a pity, at first, but with the sort of displays we have, it really isn't a problem.

=========
It is time to use a procedure. In essence, this is a way to make up new words for the language. Don't be alarmed at the "large" (relative to what we've done so far) chunk of code added. Once it is working, you only have to think about "NumToLCD" any time you want to send a NUMber TO the LCD to be displayed. (This "big" program only uses 6% of the space in an 8k Pascalite.)

For those who've done some programming before: A little disappointment: The compiler does not permit variable names to be re-used for local variables. In other words, in the following program, as bNum is declared as a global variable, you cannot have another bNum within the procedure NumToLCD.

Modify the previous program to create....

program IntTut4;
{Be careful not to insert extra semi-colons in this}
var bCnt,bNum:byte;

procedure NumToLCD(bDisp:byte);
{It must be possible to do a better job, but
 this does work!}
var bTens,bTmp2,bTmp:byte;
begin
gotoxy(0,0);{It appears that the parameters of GOTOXY cannot be variables.}
write(LCD,"   ");{3 spaces}
gotoxy(0,0);
if bDisp>199 then begin
  write(LCD,"2");
  bDisp:=bDisp-200;
  end {was>199} else
    if bDisp>99 then begin
      write(LCD,"1");
      bDisp:=bDisp-100;
      end {was >99} else write(LCD," ");
{100's digit now done}
bTens:=bDisp DIV 10;
bTmp2:=bTens*10;
bTmp:=bDisp-bTmp2;
bTens:=bTens+48;
write(LCD,bTens);
bDisp:=bDisp-bTmp2;
{10's digit now done}
bDisp:=bDisp+48;
write(LCD,bDisp);{And finally: Write units digit}
end; {of procedure}

begin
def_out(d0,d1,d2,d3);
write(LCD,255); {Clears LCD}
repeat
for bCnt:=0 to 255 do begin
  write(portd,bCnt);
  NumToLCD(bCnt);
  delay(90);
  end;
until 4=5;
end.
You should see now see the Pascalite counting from 0 to 255, and then starting again endlessly. Sorry: The program prints leading 0s when printing 0-9.

========
Now that we have a way to show the outside world what's inside the Pascalite... onward! To keep this information digestible, I've split some material off onto their own pages...

(You can show numbers on the LCD if you have one, but the following programs will also send at least part of every number to the four LEDs for those of you without an LCD display.)

Pascalite Counter: A useful feature: counts things happening even when your program isn't "looking".

Pascalite Real Time Clock: So what's "unreal" time? RTCs give you the date and time of day.

Some Like It Hot: Measuring temperatures

RS-232: Serial communications: first program- transmit RS232

RS-232: Serial communications: More advanced- receive RS232

Analog to Digital conversion Monitoring non-digital signals



Sorry folks! That's it for now. I'll try to get back to it, tidy it up. General feedback welcome. Don't worry (yet) about telling me about isolated typos. If you find anything actually WRONG, please DO let me know so I can weed it out, hoping to get it gone before some poor neophyte wastes time struggling.....


To search THIS site.... (Go to the site's above, and use their search buttons if you want to seach them.)... Way to search this site without using forms
Search this site or the web powered by FreeFind

Site search Web search

Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows pc) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Link to editor's (Arunet) homepage
How to email or write this page's editor, Tom Boyd