- - - - - - - - - Other material for programmers
- - - - - - - - - Pascalite Tutorial Table of Contents
Sketches of some ways to use a Pascalite
This is one of many chapters in a Pascal programming tutorial. While some of you will know that already, others will have arrived via links set up to promote the Pascalite hardware and software from Control Plus, who do not, by the way, employ me! I liked the product, and I thought it deserved publicity. (I also have a page devoted to that.) The Pascalite is a microcontroller. The software, including a simulator, is free to download, less than half a meg, well behaved, from Control Plus's site. The Pascalite is programmed in Pascal, the basis of Delphi. (Learn Pascal, and you're well on the way to Delphi programming.) A kit with the basic hardware, with which you can do useful things, cost about $75 in the summer of 2002.
In this "tutorial", unlike most of the others, I'm not going to give you blow-by-blow instructions for how to do things. Rather, I will describe in varying degrees of detail things that could be done with a Pascalite. Some of the projects would involve external electrical / electronic devices, but nothing exotic, expensive or difficult. I may not answer all of your questions here, but I promise not to propose anything that isn't reasonably achievable.
You could make a wind speed monitor, an anemometer. You'd need to make or buy one of the little "spinners", one that "pushes" a switch once for each revolution. (For minimum friction, a reed switch is normally used. See my weather monitoring page if you want help with this part of the project.
Once you have the spinner thing, you wire the switch in it to the Pascalite's counter. The basis of the program would be as follows:
The following would take care of counter overflow, which would be more and more likely the bigger you made the number in the wait statement...
You could also monitor the temperature using one of the analog inputs. Wind direction would be easy, too, but a bit of a pain to write up here!
You can buy electric strikeplates for doors. This "unlocks" a door when electricity is supplied. You can wire a keypad to the Pascalite. Put the keypad outside the door, the Pascalite inside. Once you've got this in place, you can make the "Open Sesame" as complex as you programming allows and paranoia requires. It would be very simple to program the system to open if, say, 1 then 5 then 3 were pressed. This, however, rather invites unwelcome visitors. Either they can get the number by trial and error, or they oversee you entering the keys.
A more secure entry code would work as follows: You first press and hold say the 1 key. You then press the 5 key. Only then (if you want the door to open!) do you press the 5 key. And finally, after releasing the 5, you press the 3.
Still not satisfied? How about this: Put some LEDs above the keypad. If the LEDs show "2", you press 3. Once you've done that, the program would change the LEDs. Perhaps they now show 5. You press 5. LEDs change again, now showing 9. You press 8. Get it? Add one to the first number, zero to the second, subtract one from the third number.
All of the above could be done quite easily with the Pascalite. The real fun will come when you not only write the program for a Pascalite-as-lock, but also devise the cunning scheme that lets you get past the lock but doesn't let the unauthorized user get in.
Remember 7 segment displays? You can still buy them, even though LCDs have become common. Each diode in the array of seven can be controlled by one of the Pascalite outputs, e.g. d0,d1,d2... etc. If you had a need to show digits, and you didn't want to use a few LEDs to be read in binary, you could connect d0 to d6 to the segments of a 7 segment display, and use that as an output device. You should write the "show number" code as a procedure. This keeps it tidy, and easily exportable as a module to be plugged into subsequent programs you write which have a need for a digit display
One source of fun, to me, of working with modern digital electronics is all the choices you have. At one end of the spectrum, you could of course make your own 7 segment display out of discrete diodes. One step up is the basic 7 segment module I was talking about in the previous paragraph. But your choices don't end there! There are many devices, single digit and multidigit which have some built-in intelligence. Usually you are trading cost and programming complexity and i/o line requirements (low is good, but comes at the price of hurting you on the other parameters.
For example, though I'm making this one up, it would be quite possible to have a 4 digit display. It would have 4 bits of input to tell it WHAT digit to display, 2 bits to say WHERE to display the requested digit, and one bit which would normally be called a "latch", which is normally kept low. As long as the latch is low, changes on the other pins are ignored. To show 1234 on the display, you would...
Set the WHAT pins to 0001 (1)
Set the WHERE pins to 11
Make the latch pin go high briefly, then returning it to low. This is called "pulsing the latch line"
Set the WHAT pins to 0010 (2)
Set the WHERE pins to 10
Pulse the latch line
Set the WHAT pins to 0011 (3)
Set the WHERE pins to 01
Pulse the latch line
Set the WHAT pins to 0100 (4)
Set the WHERE pins to 00
Pulse the latch line
... sound like a lot of work? Maybe... but you don't want to know what it would take to display 4 digits on 7 segment displays by a more software intensive approach. Don't forget: With the "fancy" device, you can set a digit, and the leave the display module's electronics to keep it showing. There are schemes you might use that would require your program to constantly re-display your number, "sneaking" the other work of the program in between revisits to the LEDs.
Of course, you can always buy yourself an LCD module to display things.
You can buy a real time clock module for your Pascalite. Alternatively, a circuit to pulse the counter at a regular frequency, say once per second, isn't complicated or expensive. Once that "tick, tick..." is coming in, keeping track of the time of day isn't hard. If you want to economize on LEDs used to display the time, or memory used for storing it, you could invent your own unit of time. If that unit of time was about 6 minutes long, you could tell the time of day as "minutes since midnight", without bothering with the idea of hours. Eight LEDs would be enough to show any time from midnight right the way 'round to 23:59.
I once worked in a boarding school. My classroom was next to an outside door the children were always leaving open for various periods of time. To convince the authorities to spend the money for an auto-closer, I put a burglar alarm type reed switch on the door, and connected that to a computer. It then built up records of how many times the door was opened and shut promptly, opened and left open for up to a minute, opened and left open for from 1- 5 minutes, opened and left open for more than 5 minutes.
Such a program could be written for a Pascalite. One input would be needed for the door open sensor. There are enough I/O lines on a Pascalite that I would go for the following simple scheme: 8 I/O lines would be used to display a number. Four would be used to select which output is to be given. So: Press the first button, and the 8 LEDs show (binary number) how many times the door was opened and shut promptly. Press the second button, and the LEDs display how many times the door was opened and left open for up to a minute. Etc. If no buttons are pressed, the LEDs show the data for the button most recently pressed. Press buttons 1 and 4 simultaneously and the totals for the different opening periods go back to zero.
Two terrible old chestnuts: A simulation of traffic lights, and control of a model train. If attempting the latter, be very careful about feedback into the Pascalite from the train. I have wrecked PICs connecting them to trains, and never really figured out why. I suspect it has something to do with electricity coming out of the train's DC motor when the power is turned off. As I was using pulse width modulation to control the train's speed, there were rather a lot of power off/ filed collapsing events.
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
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!
to visit editor's freeware, shareware page.
Link to editor's (Arunet) homepage
How to email or write this page's editor, Tom Boyd