repackage them into HP PCL sentences and send them out over TCP to a LaserJet
amazing! what is that engine's purpose? sort of printer? plotter?
The IBM 1130 (my first computer) had a Calcomp 565 plotter badged as an IBM 1627 plotter. The plotter accepted 6 bit commands which represented both motion and pen control (Pen Up, Pen Down, X+, X-, Y+, Y-). Each motion command moved the pen 0.01" in the appropriate direction (vertical, horizontal, 45 degree diagonal). The plotter library worried about how to interpolate a line segment (and there are a lot of line segments in text strings).
This was pretty heady stuff in '70..'72 when I had unlimited access and got to hang out with aircraft designers, and other engineers while still a lowly undergrad. Oddly, there was only one other group making extensive use of the two machines and we were the only people using the plotters. I think the department head was happy to have me use his machines because it helped justify their purchase!
I also had a copy of the IBM Electronic Circuit Analysis Program (ECAP), one of the early circuit analyzers. What it lacked was output to a plotter. It could save the results to punch cards (I believe) and, one way or the other, I hooked it to the plotter. My Bode' plots were pretty realistic. Homework was a lot more fun. Oh, and we had log-linear and log-log paper - very cool!
http://ibm1130.org/hw/io/The goal of my IBM1130 emulation is to run all IBM software unchanged. That's the driving criteria - unchanged! There is no way I want to patch a 27 pass Fortran compiler written in assembly language.
The mbed task is pretty simple (in concept): If the pen is up, the code arithmetically accumulates steps in all directions until the pen is commanded down. The code then generates a single PCL sentence to move the LaserJet 'pen' to the appropriate position and lowers it. If the pen is down, the code still accumulates steps as long as they are in the same direction. When the direction changes or the pen is lifted, the code generates a PCL sentence for the LaserJet 'pen' to draw the line segment and lift the pen (if commanded). So it takes just 4 sentences to draw a box regardless of size but the real plotter had to deal with 100 steps per inch of the box perimeter.
The LPC1768 mbed has 2 16kB reserved memory blocks. I used one to enqueue the incoming motion steps from the FPGA via SPI and the other to build and enqueue packets for TCP transmission. The packets are around 512 bytes (I always complete a sentence even if it runs a bit beyond 512 bytes).
I have attached a scan (.pdf) of a typical plot. This particular problem was encountered in one of my grandson's early algebra classes and I added a bit of calculus (slope goes to 0, area goes to maximum).
I have also attached the 268 lines of Fortran (PlotArea.txt) that it takes to create the graph.
ETA: I should point out that variable names were restricted to 5 characters. Unless otherwise declared, variables that start with the letters I,J,K,L,M,N are integers and those that start with any other letter are real. This is a variant of Fortran IV. The system itself was released for sale in 1965, more than 50 years ago. I started using it in '70 so I'm coming up on 50 years myself. And I'm still using it from time to time!
The system was available with up to 32k words of 16 bits (our two machines had just 8k, my emulation has 32k). It had a disk operating system along Fortran, Cobol, RPG, APL and Assembly languages. I played with RPG but never actually encountered Cobol. We had the APL keyboard setup on one of the machines but I never used it. I used Fortran almost exclusively. We also had the slow processors with 3.6 us core or a cycle time of about 280 kHz. It seemed quick at the time!
ETA: I have attached a PDF showing the instruction timing. Just pay attention to the T=00 column, those are the 'short' instructions.
Remember, the HP35 hadn't been invented and we were all using sliderules!