count function

Nandino

Active member
Good evening, I have a hitch with the simulation of the count function, or taking an example from the manual: eg
main:
count C.1, 5000, w1
debug
goto main

When I do the simulation even if I quickly click on button 1 in the box of w1 nothing appears
Now if anyone could give me a concrete example like:
I press pin1 10 times in 7sec
Then it flashes pin 2 20 times
Here, a clearer example if possible
Thanks for your kindness
LUCA
 

lbenson

Senior Member
So far as I know, you can't simulate COUNT by clicking the pin indicated. For commands like this, the result you will get in simulation depends on the preset value of w1 in "values" pane of the simulation window. For me, that is set at 32000. If I change that value, that is what is reported after the COUNT command (with, e.g., sertxd("w1=",#w1,cr,lf) -- SERTXD in many cases will do better than DEBUG, which takes a long time to execute).
 

Nandino

Active member
Grazie ibenson, pensavo

Thanks ibenson, I thought the simulation had no limits .... So I ask for this help: using an 08m2 I would like to:
Pin3 on 1 time = pin 0 out 10 times
Pin3 on 2 times = pin 1 out 10 times
Pin3 on 3 times = pin 2 out 10 times
Thanks for exemple i hope you help me
 

lbenson

Senior Member
In the simulator, in the "values" pane of the simulation window, set the WORD value for C.3 to 1, then run your code. Then set it to 2 and run it; then to 3 and run it. You can test your conditions that way.
 

Nandino

Active member
In the simulator, in the "values" pane of the simulation window, set the WORD value for C.3 to 1, then run your code. Then set it to 2 and run it; then to 3 and run it. You can test your conditions that way.
Perfetto, grazie mille, così funziona
 

Nandino

Active member
Thanks , indeed I take this opportunity to ask you something, I have 2 picaxe 08m2 and I would like that with the pin 2 of the picaxe1 used as out go to command the second picaxe using Pin3 as in, example from picaxe1, I send 3 pulses to picaxe2, the question is, can I make a direct connection between the two or do I have to put some pull down resistor between the two, I hope I have explained myself. Thank you very much for helping
 

Aries

New Member
Two things to bear in mind:
(1) it is wise to have either a pull-up resistor (to V+) or a pull-down resistor (to V0) to define the default situation (that is: when nothing is happening, do you want the pin to see a 0 or a 1). 10K is usually adequate

(2) you ought to include a resistor between the pin of one Picaxe and the pin of the other Picaxe (in your example, between pin 2 of Picaxe1 and pin3 of Picaxe2). Use 330 ohm or a bit larger. The reason is to avoid the possibility that one pin is connected to 5V through the Picaxe (for example, using HIGH) and the other pin is connected to 0V through the Picaxe (for example, using LOW). A direct connection would probably damage one or both Picaxes. Using a resistor avoids the problem. Even if you are "sure" you will never have the situation I describe, it is better to be safe than sorry.
 

lbenson

Senior Member
Typically when connecting from one picaxe to another you should use an "in-line" resistor (not pullup or pulldown) to prevent the situation where one pin is an output high and the other is an output low, which could cause excessive current, burning out one or the other pin. In the case of connecting to an 08M2 pin3, that shouldn't strictly be required, as pin3 can never be an output. I'd put in the current-limiting inline resistor anyway.
 
Top