Basis commands count

Jacobsen

New Member
I have tried Basis commands introducition with count page 14

loop:
count 1, 5000, w1
debug w1
goto loop

The code does not work. Why not?

Can you give me a example
I would be happy to if you send a example. ;-)

regards
Monie
 

hippy

Technical Support
Staff member
When you say it does not work; in what way does it not work ?

There are a number of reasons why it might not work -

* Wrong input pin specified
* Signal not connected to correct input pin
* Signal not actually changing
* Signal changing too slowly
* Signal changing too fast
* Signal has wrong voltage level
 

Jacobsen

New Member
I’m try only to test PICAXE manual 2 - Basic commandos (count)

loop:
count 1, 5000, w1
debug w1
goto loop

And hop Oput 1 LED was on

regards
Monie
 

Jacobsen

New Member
Can you please give me an example of this Basic code "count",
so I can learn how to use this command.

regards
Monie
 

hippy

Technical Support
Staff member
What you have is the definitive example as to how to use the COUNT command.

I am still at a loss as to what isn't working. I am not sure what Output Pin 1 LED has to do with it; if that LED is wired between the output pin and 0V then it should not have come on when the program ran, but if it is wired between output pin 1 and +V then it would come on and stay on when the PICAXE is reset. The output pins are entirely unaffected by the COUNT command.

Perhaps if you could explain what you are expecting the COUNT command to do then someone may be able to tell you why your program isn't working.

Edited by - hippy on 11/24/2005 2:57:48 PM
 

Charliem

Senior Member
Hi Monie,

The count Command counts a High-Low Pulse on a input pin.So you need a device to make a pulse and then you can perform a action based on the number of pulse per minute,second or what ever.
 

andrewpro

New Member
If youve got no device to generate pulses (function generator would be best) then use a low quality pushbutton ;-).

It will bounce like hell, and if you set the count timeout for 10 seconds or so, then push the button alot, youll almost invariably see more button pushes than you actually made. I used this to demonstrate switch bounce to a small group of 8th graders who jsut couldn't grasp it, and they all get it now :)

--Andy P
 

andrewpro

New Member
Actually the bounce was the point I was after ;-). Gives nice fast pulses..alot more than you could actually push the button. It's kind of a random pulse generator sorta thing.

--Andy P
 

Jacobsen

New Member
My code :
main:

w1=w1+1
(Is it possible to get Clock Timer DS1307 to reset the variable “w1” every minute a this place?) Could anyone show me an example…..

high 0
label_8: gosub prc_TIMER 'Do Procedure
high 0
high 1
low 2
gosub prc_TIMER 'Do Procedure
low 0
high 1
high 2
gosub prc_TIMER 'Do Procedure
high 0
low 1
high 2
goto label_8
prc_TIMER:
readadc 0,b8 'read A0 to b8
debug b8
let b7 = b8 'Expression command
label_5: let b6 = b6 + 1 'Inc command
if b7 = b6 then label_7 'Compare command
goto label_5
label_7:
let b6 = 0 'Expression command
return 'End

Regards Monie
 

andrewpro

New Member
You never return to Main: . Is this on purpose? The only way your going to increment w1 in this manner is on program start from initial power on or a reset, in which case it's only going to go to 1.

Aside from that, I'm confused as to what your doing. It seems as if your making a binary counter of sorts with a small delay based on the reading of the ADC?

Edit: Misread stuff, edited out the stuff I said wrong!

--Andy P

Edited by - andypro on 11/27/2005 5:27:48 PM

Edited by - andypro on 11/27/2005 5:31:14 PM
 
Top