SPLat Logo

MultiTrack (Advanced): Multi-channel operations

NOTICE: Our web site is being updated, but is currently experiencing extreme slowness due to host issues. Please contact us directly.
NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map
SPLat will be shut down for the Christmas Holiday season from Friday 20 December 2024 through Tuesday 7 January 2025. We will check emails periodically and will continue to process orders but at a slower pace. Santa hat

MultiTrack (Advanced): Multi-channel operations

An extremely innovative feature of MultiTrack is its special support for multi-channel operations. Say for example you have 4 identical channels of lighting controls. The multi-channel feature will allow you to use one single copy of your program and very easily process the 4 channels independently.

The magic is done using a special register called J. With J you can launch several copies (called instances) of a task, each with a different value of J. When an instance of a task is executed, the J value for the particular instance is automatically added to all RAM and I/O addresses referenced by the task.

The syntax for launching an instance of a task with a specified value of J is

	LaunchTask	MyTask,3

This will launch an instance of MyTask with J set to 3. In LaunchTask the J argument is optional. If you leave it out (which is what we've been doing up to this point), J is set to 0 and has no effect.

You can also use the LaunchTaskX instruction, which takes the J value from the X register and pops the register stack.

	LaunchTaskX	 MyTask

This will launch an instance of MyTask with J set to whatever number is in X.

Example:

The following program is my boring old light on/light off example. Each time a button on input 0 is pressed, a light on output 4 will alternate its state, i.e. if it's off it turns on, if it's already on it turns off:

(Click here for some tips for working around problems with copy and paste out of Internet Explorer and HTML-help (.chm) files)

        LaunchTask      Toggle
        RunTasksForever

Toggle:
        WaitOnK         0
        On              4
        WaitOnK         0
        Off             4
        GoTo            Toggle

All I have to do to change this to a 4-channel switch, controlling 4 lights, is to launch 4 separate instances of Toggle, each with a different J value. The program still only contains one copy of Toggle, but there are 4 instances running, with each instance accessing different I/O points. Here it is ...

        LaunchTask      Toggle,0  ;Handles input 0, output 4
        LaunchTask      Toggle,1  ;Handles input 1, output 5
        LaunchTask      Toggle,2  ;Handles input 2, output 6
        LaunchTask      Toggle,3  ;Handles input 3, output 7
        RunTasksForever

Toggle:
        WaitOnK         0
        On              4
        WaitOnK         0
        Off             4
        GoTo            Toggle

Copy this program into SPLat/PC and study its operation. Display the registers (menu Window>Registers or CTRL+R) and you will see the J register. As you single-step the program you will see J changing. For each of the instructions that access I/O, J is added to the I/O address in the instruction.

If you are familiar with SPLat's index register, I (as in letter 'eye'), the principle of J will be fairly familiar. If not, don't worry. The index register can be used with selected RAM and I/O instructions to alter which address is actually accessed. The number in I gets added to the instruction address. This is called indexed addressing. Similarly, in a MultiTrack task J gets added to addresses. Hence we call it jndexed addressing (pronounce that however you like, I say "jindexed")