User manual

19
the variable A. This leads to quick counting up of the starting condition. When releasing, the last
counter reading is retained. Due to the high counting speed, you have no influence on the result,
which therefore is random.
Address
Command
Data
Comment
30
5
4
Port = A
31
C
E
S1 = 1?
32
7
1
A = A + 1
33
3
3
Jump –3
Listing 4: Random generator
Briefly push the button to reactivate a new random result. Test the random function by
generating a statistic of the results. After a sufficient number of runs, it should be clear that all
results are about equally frequent. The programme is also suitable as a game where you need
to try to get, e.g., 1111.
At the same time, the programme is a counter with the maximum possible working speed
because no waiting command is used. Therefore, you can use this example to examine the
working speed of the TPS controller. While the button is pushed, the output A1 shows a
rectangular signal with a frequency of approx. 133 Hz and a period duration of 7.5 ms. The port
changes its condition after 3.75 ms each. The programme goes through four commands in the
counting loop. About one millisecond is required per command. The last output A4 shows a
frequency of 16.6 Hz, which is still visible as a flicker.
If time-critical tasks require higher working speeds, you can increase the cycle speed of the
controller by reducing the resistance at Osc1. 100 kO provides a cycle rate of 2 MHz. Replace
the resistor with a 27 kO one. This will lead to an almost four times higher cycle rate and a
command time of approx. 0.25 ms. In the usual case, however, the controller should run at 100
kO at Osc1. Thus, a low current intake and safe work are also ensured at a low operating
voltage down to 2.2 V.
6 Impulse Length Measurement
E4 at GND starts an example programme to measure an impulse length after a reset. Again, the
condition at the input S1 is evaluated.