« Back to “DSO Quad”

Pawn scripting language

Huh, it was quite a crunch. For the past 3 months, I've been working on implementing a Pawn interpreter for the DSO Quad. This should make application programming simple enough.

Background

There are a few big applications that the Quad needs. A good oscilloscope app of course. Maybe even a logic analyzer. But then there are also a whole bunch of smaller things that could be very useful: LCR meter, battery capacity tester, data logger, servo tester, and so on. For these small applications, the C environment is too clumsy and debugging is a pain.

Of course I could have developed a set of nice libraries with C or C++, and it would have made application programming easier. However, I fear that even then the limited number of application slots (4, of which 2 are taken by the default app) would have hurt the application ecosystem. Instead, I decided to go with an interpreted language, and Pawn is probably one of the smallest ones in existence, with the bare interpreter being just 6 kB in size.

Size is constantly a problem when programming for the Quad. A single application slot has just 32 kB of ROM space, which requires a quite small libc and constant consideration of code size. The Pawn programs, however, can use the 2 MB flash disc for storage. Pawn allows code overlays and dynamically loads the required functions from the disc, kind of like swapping.

Pawn itself is a somewhat limited language, which does not have a concept of types, structures or dynamic memory. Instead it has a syntax similar to C, good symbolic error facilities and robust design to detect mistakes at the compilation time. To actually be useful, it is complemented with a set of C libraries I have specifically written for the DSO Quad. They allow capturing of waveforms, implement user interface utilities and have varying signal processing tools.

Current stage

To demonstrate the capabilities of the platform, I have ported my old frequency response application to a new Pawn version. This isn't even pushing the limits yet, and I have added a plenty of features I never bothered to implement in C. I have added a cursor for reading the values numerically, a configuration dialog and a square wave measurement mode.

The runtime system is quite stable already, and should have the facilities necessary for most programs. I will iron out the bugs and add necessary APIs, just drop me a note if you need something. Now I just wish that it is picked up by the people interested in programming for the Quad, but who have been pushed away by the complexity of the task and the poor documentation of the low-level software.

Future development

Now I'm just eagerly waiting whether anyone is interested to actually write any applications. Otherwise this will probably just stay as my own experimentation platform, and I'll write some random apps as I need them. Right now I could really use a battery capacity tester.

If I'm exceptionally fortunate and this actually gains some user base, I will of course expand the standard libraries to meet demand. I only have about 3 kB of ROM left currently, but I can always find pieces to optimize. Most probably I'll add an interface for loading custom FPGA images as soon as I figure how to do it. That should allow writing e.g. a 4-channel serial port sniffer.

Downloads

The code and everything is hosted on GitHub. You will find a Getting Started guide there.

– Petteri Aimonen on 6.5.2012

Comment on this page (16 comments so far)