[fpc-pascal] Challenging port of Borland Pascal program to FPC

John Youngquist johny at iaw.com
Mon Jan 18 07:37:20 CET 2010

Interesting response.

I routinely implement large systems on the 8051 chip in assembly language
which I can write faster than Pascal. Assembly is a minimum of 500% 
faster than
C on the 8051. I hate C anyway.

The machine is a pick & place machine designed to assemble SMT
circuit boards. It was originally controlled by a Borland Basic program 
written in
Japan without any useful comments. With 5 or 6 statements per line 
without even
a single space it looked like Japanese to me. Initially I needed to fix 
a few bugs
and add a few features so I studied the code for while - all 100K 
statements of it.
I decided rewriting it from scratch would be faster that figuring it 
out. In exactly 2 weeks
I had replicated and enhanced the original functionality with 3K lines 
of Pascal. I still
had to study the code to figure out how drive their special hardware, 
but over the years
all of it has been replaced with simpler stuff. Numerous enhancements have
swelled the code to 8K lines using less than 2 64K blocks of memory.
The before/after size ratio shows how poorly the basic was done.
As implemented in BP it works very well. The multi-tasking part handles
functions that are not time critical, operating air cylinders that don't 
know what a mSec
is. The fast motion is handled independently by Animatics Smart motors.

I have never explored the multimedia timers. I drive the LPT int to get 
my own periodic
interrupt because the multi-task code already uses the timer. As you 
know there are 3
timers in the timer chip but only one will generate an interrupt.

One problem I have yet to solve is the BP IDE when it hits a breakpoint 
kills my LPT interrupt.
Nothing but an IDE restart will restore it. It sure cramps your 
debugging style.

Thanks for your ideas.


Jeff Wormsley wrote:
> John Youngquist wrote:
>> I would like to port the program as is, but eventually get a PCI 48 
>> I/O line card to escape
>> the ISA bus and also talk USB as well. Getting it to run on later 
>> versions of Windows might
>> be useful. This program controls a machine on a single purpose 
>> computer. Windows is used
>> to handle files, networks, and little else. Most of the time only 
>> this program is run. A port to
>> Linux might be acceptable if that would solve some problems.
>> Are these insurmountable obstacles?
> Probably not if you're willing to spend a ton of time and money, but 
> you might be better off moving the bulk of this system off of a PC and 
> on to a dedicated micro controller board, and just using a PC to 
> handle UI and files/network and things that don't have any real time 
> requirements.  The STM-32 Cortex chips in the 144 pin package should 
> probably have enough I/O and speed to do what you want, with built in 
> ram/rom.  Coupled with FreeRTOS, you can have a quite capable system 
> for not a lot of money (you should be able to build a board to replace 
> the PC hardware for a couple of hundred dollars, depending on how 
> sophisticated the 48 port I/O board is).
> I'm surprised the current system ran properly on a Win98 DOS box, 
> considering how badly Windows messes up real time (those 10ms breaks 
> should have probably been much longer on occasion when the Windows 
> kernel was busy doing stuff with interrupts disabled).  Until I found 
> out how to use the multimedia timers, I couldn't get better than 55ms 
> response out of Windows, even from a DOS box.
> Jeff.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> .

More information about the fpc-pascal mailing list