Count command in simulator

Tyro

Member
I have tried to use the “count” command in some code but when I try to simulate it, the count did not work as expected. It still does not simulate even with the bare bones code directly copied from the manual. The version is 5.2.7

main:
count 1, 5000, w1 ‘ count pulses in 5 seconds
debug w1 ‘ display value
goto main ‘ else loop back to start

I am manually toggling input 1 on a 08M picaxe and expect w1 to increment but nothing happens.

What am I doing wrong?
 

Tyro

Member
I don't understand? I am trying to simulate the count command by inputting a series of ON and OFF signals via the input 1 switch in the simulator.
 

MPep

Senior Member
Hi Tyro,

I have just tried your simple program in the simulator.
As Phil says, you need to use Generic.

If you increment this the count will increase in B2 and B3 (=> W1).
Still the 5s don't appear to work, mind you I have never used COUNT before. :)

Remember also that the simulator is quite good but not perfect.

I changed the code to the following:
Code:
main:
count 1, 5000, w1 ' count pulses in 5 seconds
sertxd (#w1,13,10) ' display value
goto main ' else loop back to start
Note that instead of DEBUG I use SERTXD. Many people use this as then only the required info is output. Works in Simulator too.
 

hippy

Technical Support
Staff member
As Phil75/MPep notes you cannot set the COUNT value by toggling a pin on and off, you have to set the 'generic' value which will in turn set the COUNT value ( and values for other commands which may be used ).

The reason for this is that it would otherwise be impossible to simulate COUNT which was reading a high frequency input and had a short sample time; you would simply not have enough time to click the pin on and off to get a realistic COUNT value while simulating.
 
Last edited:
Top