A race exhibit needs one timing value per animal per light: 8 animals x 48 lights = 384 values. Store them once as a 384-word table loaded by DLBL and LDLBL, and step one shared timer rung through the presets with the offset (animal - 1) x 48 + light. The article works the arithmetic and settles when a drum instruction or a shift register wins instead.
A race exhibit needs one light interval for every animal at every light. Eight animals and 48 lights come to 384 intervals, and entering them as logic means 384 LDR/OUTD pairs: 768 instructions to type and 768 to reopen at the first profile change. The shorter build treats the times as data. One 384-word table loaded by DLBL and LDLBL, one fetch routine that turns the selected animal and the light number into a table offset, and one timer rung shared by all 48 lights. This article sizes the table, works the arithmetic, and settles when a drum instruction or a shift register beats it.
What 384 timer rungs turn into
The count first. 8 animals x 48 lights is 384 interval values (8 x 48 = 384; if your worksheet says 304, the multiplication slipped). At one LDR/OUTD pair per value that is 384 x 2 = 768 timer instructions, each carrying one hardcoded number. Change one animal's acceleration and you reopen up to 48 of them.
The formula path is closed on this controller: the needed acceleration calculation does not run through MATHR on the 250-1, so the values must go in as entered data and the design question is how the rungs reach them. Split the program in two. The 384 times live in one data area, and one fetch routine converts animal number and light number into an offset. Whether to repeat a rung per device or loop over data is a general sequencing question; loops versus repeated rungs for multi-device arrays covers that trade-off, and the indexed build below takes neither extreme: 48 lights, 1 rung. When the sequence is fired from a panel instead of a photo-eye, the same one-table layout carries HMI step times and output bitmaps in one PLC table.
What you need
- The 8 acceleration profiles, each already calculated as 48 interval values in hundredths of a second. The TMRF in this exhibit counts hundredths, so worksheet and table share one unit.
- One data area of 384 words, laid out as 8 blocks of 48.
- DLBL, which starts a fixed data area at the end of the program, and LDLBL, which transfers that fixed data into the table the rungs read.
- One timer rung (a TMRF here), one step counter that runs 1 to 48, and a base register for the selected animal.
- Race control left as it is: the Ready, Set, Go timer, the two photo-eye inputs, and the two counters that already start and stop the run.
Build the table and the fetch routine
- Write the worksheet before touching the PLC. For each animal list 48 values in lane order, and decide what one value means: how long light n stays lit, or how long to wait before light n comes on. Either reading runs; pick one and use it for all 384 entries.
- Start the fixed data area with DLBL at the end of the program and enter the 384 values as 8 blocks of 48. Block 1 is animal 1, and word 1 of a block is light 1.
- Load the area with LDLBL when the program starts, so the rungs always read one loaded copy of the table.
- Map the animal selector to a base: base = (animal - 1) x 48. Animal 1 gives base 0, animal 3 gives 96, animal 8 gives 336.
- On the start photo-eye, set the step counter to 1, fetch word base + 1 into the TMRF preset, and run light 1 on that timer.
- On timer done, add 1 to the counter, fetch word base + counter into the same preset, and light the next one. One rung serves all 48 lights; add no rung per light.
- On the finish photo-eye, stop the timing, reset the counter to 0, and drop all 48 outputs before the next race.
- Handle the two odd cases in logic: a counter pushed past 48, and a race started with no animal selected.
One safety note: clamp the fetch. A counter past 48 reads words beyond the animal's block and puts an untested number on a timer, so clamp the offset at 384 and treat a missing selection as a stop before the first race with kids on the course.
Worked example: 8 animals x 48 lights
Inputs, with their source: 8 animals from the exhibit's selector; 48 lights, one per lane position; one interval per animal per light stored as one 16-bit word (0 to 65,535 counts); 0.01 s per count, the unit the TMRF counts and the unit the calculated times already use; one LDR/OUTD pair per interval under the old layout.
Rule in words: table size = animals x lights; the word for a given animal and light sits at (animal - 1) x lights + light; instructions replaced = 2 x table words.
Arithmetic: table size is 8 x 48 = 384 words. Animal 3, light 5 sits at (3 - 1) x 48 + 5 = 96 + 5 = word 101. Instructions replaced: 384 x 2 = 768, traded for 384 data words, one fetch routine and one timer rung. Range check per entry: 65,535 counts x 0.01 s = 655.35 s, about 10.9 minutes, so any single light interval below that fits one word.
Result: a 384-word table whose word 101 holds animal 3's interval for light 5, fetched at run time by offset alone.
Decision: build the full table whenever every animal has its own interval at every light. Two shortcuts move the threshold. If light 1 may come on only when acceleration ends, each animal needs 2 values instead of 48, and 8 animals fit in 2 x 8 = 16 entries. If two animals race identical profiles, point both at one block; 6 distinct profiles cut the table to 6 x 48 = 288 words.
Table, drum, or shift register
| Approach | Data it stores | Fits this race when |
|---|---|---|
| Indexed table (DLBL + LDLBL + pointer) | 8 x 48 = 384 interval words | Every animal has its own interval at every light |
| Drum instruction | Fixed steps and their output patterns | Step count reaches 48 and the time base reaches 0.01 s |
| Shift register | One position step per light | Uniform on/off pattern; re-test with all 48 intervals |
| Two-timer form | 2 values x 8 animals = 16 entries | Light 1 may mark the end of acceleration |
The drum instruction packs steps and their outputs into one instruction and suits repetitive processes with a finite number of steps; one documented drum sequencer offers 16 steps timed in milliseconds. It wins when one fixed pattern repeats with fixed steps. This race needs 48 steps at 0.01 s, so a 16-step drum means 3 chained drums, and per-animal timing would still need the 384-word table behind it.
The shift register represents the sequence position, one step per light. A working shift-register version of this race has been demonstrated on a 250-1 with 3 animals at arbitrary rates. It wins when the pattern is uniform and only the pace changes; before it replaces the table, expand it to 48 positions and re-test it against every animal's calculated intervals.
The two-timer form comes from placing light 1 at the end of acceleration: timer 1 runs the acceleration, timer 2 ticks the remaining 47 lights at the animal's top-speed interval. It wins only if the display may hold all lights off until acceleration ends.
Recommendation: build the indexed table for this exhibit: 384 words, 8 blocks of 48, presets in hundredths of a second, fetch offset (animal - 1) x 48 + light. Take a drum only if your drum's step count reaches 48 and its time base reaches 0.01 s. Take the two-timer form only if light 1 may mark the end of acceleration, which cuts the data to 16 entries. Take the shift register only after re-testing it with all 48 intervals for all 8 animals.
How to check it worked
- Offset check: with the race stopped, switch the selector from animal 1 to animal 3 and watch the first fetched word in the data view. It must jump by 2 x 48 = 96 words, from entry 1 to entry 97.
- Unit check: break the start photo-eye with a card and time light 1 with a stopwatch. A worksheet entry of 40 must hold the light for 0.40 s; if it holds about 40 s, the values went in as seconds.
- Total check: add one animal's 48 entries and multiply by 0.01 s. The result must match that animal's calculated run time, and the sequence must reach light 48 as the runner reaches the finish photo-eye.
- Boundary check: with the counter forced past 48, the clamp must hold the fetch at the block edge, and no light may come on from an out-of-range word.
- Reset check: at the finish photo-eye the counter returns to 0 and all 48 outputs drop; the next start then begins at entry 1 of the selected animal's block.
Questions
What happens if a preset is typed in seconds instead of hundredths?
The light holds 100 times too long. An interval meant to be 0.40 s entered as 40 stretches each light to 40 s; if all 48 intervals were 0.40 s, the run takes 48 x 0.40 = 19.2 s entered right and 48 x 40 = 1,920 s, about 32 minutes, entered wrong. A stopwatch on light 1 catches it in one step. Enter whole numbers: 0.40 s is the integer 40.
Do DLBL and LDLBL exist on every PLC?
No. They belong to the PLC family in this exhibit. The architecture travels: one fixed data area at the end of the program, one instruction that copies it into the working table, and pointer arithmetic on top. Whatever your manual calls the fixed-data loader, the table stays 8 blocks of 48 words and the fetch offset stays (animal - 1) x 48 + light.
Can one table word hold any interval the race needs?
One 16-bit word counts 0 to 65,535 hundredths of a second, so a single entry covers up to 655.35 s, more than 10 minutes per light. No race interval gets near that. If a profile ever needs longer, split the entry into two words (whole seconds and hundredths) and add the two after the fetch, or use a wider data type if your timer accepts one.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.