Programming: SPLatty's repertoire expands

This newsletter coincides with the release of dialect 12 of the SPLat language.

Dialect 12 adds some extremely useful instructions. These fall in 3 major groups:

Semaphores

There are 11 instruction in this group. They allow very easy use of single-bit logical variables, which we call semaphores. Alternative names for semaphores are flags or switches, or if your background is with relay logic, internal relays. All of RAM can be used for semaphores. That would mean 1024 possible semaphores in 128 bytes of RAM. However, we have also increased the available user RAM to 192 bytes, so you could potentially have 1536 semaphores.

There is a new tutorial devoted to semaphores.

Multitasking support

These are just two instructions, but they will have a profound effect on advanced programmers using SPLat. The instructions are called Suspend and Resume. They allow you to Suspend the execution of a subroutine and remember ("bookmark") where you left off. Later, when you call the subroutine again, you can Resume where you left off. This makes it very much easier to write multitasking applications with SPLat. A multitasking program is one that appears to be performing 2, 3 or more separate tasks simultaneously.

There is a new, very comprehensive tutorial on multitasking in the SPLat Knowledge Base

New timing instructions

The 8 standard timers in SPLat, plus the Pause (and related) instructions and various clever tricks have served well over the years. However one objective has been difficult to achieve: Counting up a long succession of short-ish timer intervals to make up longer intervals, for example accumulating seconds to make minutes, hours and days, without getting cumulative errors. The errors come about because there is an inevitable delay between a timer expiring and the program detecting it and restarting the timer.

Two new instructions make it much easier to get non-cumulative errors. They are called GetTick10 and GetTick100. These work on a 10mS and 100mS cycle respectively. Each provides an 8-bit counter that counts up every time interval, and can be read out. Each time it is read out it is counted down by one. The counter cannot count up past 255 or down below 0. The result is your program can have a backlog of up to 2.55s or 25.5s worth of ticks, and still not incur any lasting errors. The resultant timing accuracy is directly related to the board's timing crystal, which typically is 0.01% or better.

The more accurate timing is also significant if you are doing PID control, because it will help you make your sampling interval more accurate.

Enhanced I/O

In dialect 12 we have enhanced the byte-wide I/O instructions InputFM and OutputM. From dialect 12 on these no longer have to be on a byte boundary, i.e. 0, 8, 16 etc. You can for example now do an InputFM 12 and it will read inputs 12 through 19.

The CPU device

We have also introduced a new onboard peripheral, namely the CPU (the SPLat processor itself). What we have done is make certain attributes of the controller itself accessible to your SPLat program. Initially we have exposed:

These will allow a program to sense what environment it is running in, and modify its behaviour accordingly. This might allow you for example to use the same program in entry level and up-market versions of your product, using different SPLat boards. We expect to add to the list of CPU attributes over time. These are not directly dialect related things, so we could well add to the list without declaring a new dialect. The documentation is in the SPLat Knowledge Base.

Upgrade existing boards free

All SL99s and any MMi99s with Firmware V3.3 or later can be reFlashed to the new dialect. Please contact us regarding upgrading custom controllers.