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

Pascalite Programming: Features, Project Ideas

The following are special features of the Pascalite. Similar features may be present in other Pascals you might use, but don't expect them to work exactly as they do on the Pascalite.

Real Time Clock (RTC). This term causes beginners difficulties for a number of reasons. We'll get to a discussion of the Pascalite RTC in a moment, but first, for those who don't know: "Clock" in this context also implies calendar. The "not real time" clock that necessitates the qualification is the "tick tock" inside every computer that is like an orchestral conductors baton, keeping the orchestra playing sychronously. That clock, the "system clock" doesn't worry about "how long has it been since...". It merely provides a beat for the different circuits to use in keeping in step with each other.

The Pascalite RTC: You can say GetTime or GetDate.... even if only using the free software with its simulation of the Pascalite hardware.. the RTC is simulated. When you say GetTime or GetDate, the current time or date is put into variables. So, let's say you want to make an alarm clock to wake you at 7am. The heart of that program would be as follows. Just turning on an LED connected to d0 isn't likely to produce a very effective alarm clock. Creating a circuit to make a wake up noise when d0 goes high isn't hard, but explaining it here would be a distraction.
program AlarmClock;
var hr,min,sec,hun:byte;
if (hr=7) and (min=0) and (sec<30) then set(d0) else reset(d0)
until 4=5;

We've had tutorials involving counting things by general valid methods. The Pascalite has special provisions for counting. On the hardware, there is a pin you can connect an input to. When that pin's voltage changes from 0 to positive, which known as a "positive edge", then in the special place inside the Pascalite called "the counter", the number stored goes up by one... UNLESS the number previously there was 255. If the counter previously held 255, then it goes back to 0 when the next positive edge arrives.

You can read what's in the counter as follows, assuming you've done var bCount:byte; at the start of the program:
You can store, say 25, in the counter with....
There is a special procedure called "interrupt" that is associated with the counter. Before the following will make sense, you need to understand the material in tutorial qnum about creating custom procedures. In a nutshell: You can create "new words" for the language. So, if you wanted a quick way to double numbers, you could make something up so that when you said bAns:=DoubleIt(bThingie); then after that had been done, in bAns you would have two times whatever was in bThingie. All this could work fine... once you've provided your program with the "DoubleIt" procedure. (Which isn't hard, and being able to do such things is an important skill.) Anyway... back to counters. With Pascalite, after you have defined a procedure called Interrupt, whenever the number in the counter goes back to 0 because of another positive edge occurring on the input when "counter" is already at 255 whatever you've made the "Interrupt" procedure be happens. (Don't worry... I'm going to re-write that sentence one day. Hope it didn't take too long to unravel?) This is really cool! It means that the Pascalite does NOT have to stay lockstep on the rails of whatever program you have written, which is what it will ordinarily do. With the counter, something external wired to it, and a suitable (written by you) Interrupt procedure, you can get your program to respond to external events asychronously. You could look at the Interrupt procedure as giving you a way to have one computer do two jobs, essentially simultaneously. I haven't explained it very well.... but it IS useful, in some projects. I'll try to do some examples of ways to use it.

Not only does the the simulation of the hardware supplied with the free Pascalite software include a way to simulate inputs to the counter, there's even a simulation of an external signal that is continually going on/ off/ on/ off/ on..... And you can vary the frequency! (This is called the square wave generator.) I have had cases while simulating the execution of little programs where the simulator failed to notice some of the virtual pulses I requested. This problem is diminished by slowing down the program execution, using the simulator's "slow" / "med" /"fast" setting. I never saw the simulator miss a pulse that was coming from the square wave generator.

As this is introductory material, forgive me (advanced readers) if I spend one paragraph explaining some basics? "Digital" electronics is a poor choice of terminology. What is called "digital" might better have been called "binary". Most of the circuits in computers, including the Pascaline, can have various voltage levels, but for lots of good reasons, everything is treated as "on" or "off", which map nicely onto the "0" and "1" of binary aritmetic. However, LIFE isn't so easily squeezed into just two states. We have radios that play at very soft, soft, medium, loud, very loud and teenage (oops... sorry... I hope some readers won't get in a strop?) We have weather that is cold, warm, hot. We have cars that travel slow, moderate, fast. All of these examples are of analog things, the complement of "digital".

Fear not! The electronics engineers made a little device called an analog to digital converter, or ADC. Some models of the Pascalite hardware have them built in... 8 of them in one case. You can connect, say, a temperature sensor (or two, or eight), and then your program can ask what the reading is whenever you like. You do have to make a sacrifice: If you are using the device's ADC capabilities, you have to give up using some of the pins which would otherwise be assigned for digital inputs or outputs. (This would usually be called giving up some digital I/O capabilities.)

Let's say you want your Pascalite to operate as a thermostat for a big house with a heated garage. You want the main house to stay at 68 degrees, and the garage to stay above 45 degrees. You'd need to wire the heating system's controls to the Pascalite so that heat would come on in the main house when d0 became high, and in the garage when d1 became high. For the sake of simplicity, the following example assumes you've found some sensors which return a number equal to the temperature. You are unlikely to be so lucky, but that's a minor detail.
program Heaters;
var bTTureHouse, bTTureGarage:byte;
if bTTureHouse>68 then reset d0 else set d0;
if bTTureGarage>45 then reset d1 else set d1;
until 4=5
By the way: I'd never name a variable associated with some temperature as "Temp" something or other, because having "Temp" and "Tmp" in reserve for things that are "temporary" in nature is something you'll find endlessly useful.

The free Pascilite, which includes the simulation of the hardware, has a splendid simulation of the analog inputs for you.

The Pascalite can communicate over an RS232 channel. This allows it to be connected to a PC. I haven't yet quite mastered how the simulator deals with this feature, but there are indications that the simulator can simulate this feature properly.

The Pascalite has some EEPROM. Why do you care? If you are using it in an application which means you need it to remember some numbers EVEN IF SWITCHED OFF, then the EEPROM facility is going to be useful to you. Suppose you needed to watch temperatures in various parts of a big warehouse. You could have several Pascalites, each of them connected to a temperature sensing device. You would put a different serial number into one part of each Pascalite before setting them out around the warehouse, each plugged into mains electricity in it's working location. As it watched the temperatures, it would record important times/ temperatures in the EEPROM. From time to time, you'd unplug the units, bring them back to a PC, connect them up, and get the little computers to tell the big computer all the temperature secrets that the little computers had gathered. Very do able, thanks to the EEPROM. Oh yes... there's "only" room for 24,576 bytes of data, and you whouldn't try to change what's stored more than 100,000 times. You're not going to be able to throw away your hard drive yet, but you'll be able to record enough data for some jobs!

Last, and fairly least, unless we're talking about the prize for exotic features: The Pascalite can communicate with I2C devices and 1-Wire / iButton / MicroLan (trademarks for one device family) from Dallas / Maxim / Dalsemi (again... one company.)

These are Cool things that I'll try to write more about in another place, but details would be inappropriate at this point. People who know what I2C and the Dallas chips are can consult the Pascalite help file. I'm afraid that the support for the iButton devices is pretty limited AT THE MOMENT (May 2002)... but I hope better support will emerge. The PAscalite is great, the 1-Wire family is great... now if they would just get to know one another a little better.... What you CAN already do is read the unique serial number inside a 1-Wire device.

To search THIS site.... (Go to the site's above, and use their search buttons if you want to search 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