lbenson
Senior Member
Here is an update of the post of BeanieBots from April, 2004, concerning the timing of statements http://www.picaxeforum.co.uk/showthread.php?t=1128 . The rig is shown attached--two JRHackett 08M modules on a cut-down breadboard strip 11 pins high. The code to be timed is put between a "high 2" and a "low 2". In the other 08M, the time that the pulse is high is measured with pulsin. These are the timings I made:
0.77ms high 1: low 1
0.53ms high 1
0.71ms b13 = 255
0.90ms if b13 = 255 then : endif
0.94ms if b13 <> 255 then : endif
0.74ms inc b0
1.53ms pause 1 (presumably 1ms of this is the paused time)
0.68ms b0 = b1
1.33ms if b0 = 128 then : b0 = 255 : endif (after b0 has been set to 128)
0.93ms if b0 = 128 then : b0 = 255 : endif (b0 was set to 255 by prior statement)
0.94ms if b0 = 255 then truecondition : b0 = 0 : truecondition:
And then a chunk of code after b3 = 0: b2 = 250 (the "not equal" condition in the loop was +not+ true)
3.57ms
These timings are a bit high relative to the common citation of about 2,000 statements per second, or .5ms per statement, but they include some part of the preceeding "high 2" and trailing "low 2". Putting a string of 10 repetitions together and dividing by 10 would give a better figure.
The code of the sender is as follows:
The timing code is:
Thanks to BB for the idea.
0.77ms high 1: low 1
0.53ms high 1
0.71ms b13 = 255
0.90ms if b13 = 255 then : endif
0.94ms if b13 <> 255 then : endif
0.74ms inc b0
1.53ms pause 1 (presumably 1ms of this is the paused time)
0.68ms b0 = b1
1.33ms if b0 = 128 then : b0 = 255 : endif (after b0 has been set to 128)
0.93ms if b0 = 128 then : b0 = 255 : endif (b0 was set to 255 by prior statement)
0.94ms if b0 = 255 then truecondition : b0 = 0 : truecondition:
And then a chunk of code after b3 = 0: b2 = 250 (the "not equal" condition in the loop was +not+ true)
Code:
do
b0 = b2 ' get the settings of the contacts
if b0 <> b2 then ' we have a change
b3 = 0
endif
inc b3
pause 1
loop until b3 >= 0
These timings are a bit high relative to the common citation of about 2,000 statements per second, or .5ms per statement, but they include some part of the preceeding "high 2" and trailing "low 2". Putting a string of 10 repetitions together and dividing by 10 would give a better figure.
The code of the sender is as follows:
Code:
' 08SndTim sends a pulse surrounding code to be timed
' in another picaxe (08TimeIt)
#picaxe 08M
main:
do
do while pin3 = 0 : loop
pause 100 ' debounce
do while pin3 = 1 : loop
pause 100 ' debounce
b1 = 1
serout 4,N2400_4,(#b1) ' first test
pause 200 ' wait .2 seconds
high 2
high 1
low 1
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
high 2
high 1
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
high 2
b13 = 255
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
high 2
if b13 = 255 then
endif
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
high 2
if b13 <> 255 then
endif
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
high 2
inc b0
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
high 2
pause 1
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
high 2
b0 = b1
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
b0 = 128
high 2
if b0 = 128 then
b0 = 255
endif
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
high 2
if b0 = 128 then
b0 = 255
endif
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
b0 = 255
high 2
if b0 = 255 then truecondition
b0 = 0
truecondition:
low 2
pause 2000 ' wait 2 seconds
inc b1
serout 4,N2400_4,(#b1) ' next test
pause 200 ' wait .2 seconds
b3 = 0
b2 = 250
high 2
do
b0 = b2 ' get the settings of the contacts
if b0 <> b2 then ' we have a change
b3 = 0
endif
inc b3
pause 1
loop until b3 >= 0
low 2
loop
Code:
' 08TimeIt reads a pulse sent another picaxe (08SndTim) and reports on the
' time on sertxd
#picaxe 08M
pause 2000
sertxd ("Starting",cr,lf)
main:
do
pulsin 4,1,w5 ' get time in 10s of microseconds
if w5 > 0 then ' we didn't time out
w4 = w5 / 100 ' number of milliseconds
w5 = w5 // 100 ' number of microseconds / 10
sertxd(#w4,".",#w5,"ms",cr,lf)
endif
loop
Attachments
-
104.5 KB Views: 32
-
51.4 KB Views: 33