eeprom counting

Roy Spiller

New Member
Hi I have a program running a machine and all is working well. I am trying to add a counter that will stop the machine after a set amount, at the moment I can only get it to count up to 255 then stop. In the program if i want to count large numbers possibly 5 to 10,000. I use the W as apposed to B however I cannot find any information on doing a similar thing with the eeprom locations. I have included a similar part of the program which is spread about in my working program.

Main:
read 0, w1
if w1 = 200 then goto main
high d.6
if pinb.5 = 1 then low d.5 w0 = w0 + 1 endif
if pinb.5 = 0 then high d.5 endif
write 0, w0
goto main
test:
end


Regards
Roy
 

hippy

Ex-Staff (retired)
You need to use the WORD qualifier as described under the READ and WRITE commands in "PICAXE Manual 2 - Basic Commands" -

Read 0, WORD w1

Write 0, WORD w0

It is not recommended to do a lot of writes to Data Eeprom when that can be avoided because it only has a limited write capability. It's actually quite a high write capability but running at full speed it can be exceeded.

You can either code things so Data Eeprom isn't written if the value hasn't changed or check if it already holds value to be written -

Code:
; Write w0 to Data Eeprom
Read 0, WORD wTmp
If w0 <> wTmp Then
  Write 0, WORD w0
End If
 
Top