TIMER (Please Help)
albert
Posts: 10
I'm trying to make a timer that counts while somepin is high, in this example its supposed to count up at a frequency determined by a constant named PRECITION and then get read and reset each time somepin goes low, the value the gets read is put on a memory address to get read by another cog. My problem is that it isn't counting up at all. Is there some error in this code or is the problem somewhere else? I can't find any tutorials for timers.
ctra[30..26] := %11010 ctra[5..0] := somepin frqa := clkfreq/PRECITION 'some code phsa~ 'some more code repeat if not somepin LONG[someaddress] := phsa phsa~
Comments
You might want to look at the file for using counter modules. See attachment.
You might want to post your entire code, too, so people can see exactly what's going on.
What you want to do is read phsa only once for each time somepin goes high. In other words, look for a change in somepin from 1 to 0.
Use PULSIN_Clk from "BS2 Functions" in the Object Exchange as an example of how to do this: You'd simply call this like