Counter triggering counter
Hey,
I'm trying to get a counter to trigger another counter... So far I'm not having much success...
What I have:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
I'm trying to get a counter to trigger another counter... So far I'm not having much success...
What I have:
DO
FOR counterone 1 to 60
HIGH 14
PAUSE 500
LOW 14
PAUSE 500
NEXT
IF counterone = 60
THEN countertwo + 1
LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
counterone VAR Byte countertwo VAR Byte init: counterone = 1 cntr_one: HIGH 14 PAUSE 500 LOW 14 PAUSE 500 counterone = counterone + 1 if counterone < 61 then cntr_one cntr_two: countertwo = countertwo + 1 goto init
What SSteve is saying, is that the line that reads "IF counterone = 60" is redundant, because the "FOR counterone 1 to 60"
loop automatically takes care of this.
' {$STAMP BS2} ' {$PBASIC 2.5} counterone VAR Byte countertwo VAR Byte DO FOR counterone = 1 to 60 HIGH 14 PAUSE 500 LOW 14 PAUSE 500 NEXT countertwo = countertwo + 1 'IF counterone = 60 THEN countertwo = countertwo + 1 LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
counterone VAR BYTE countertwo VAR Byte DO FOR counterone = 1 TO 60 HIGH 14 PAUSE 500 LOW 14 PAUSE 500 DEBUG ? counterone IF IN3 = 1 THEN FOR eepromAddress 0 TO 58 STEP 2 FOR eepromAddress, Word counterone, Word countertwo NEXT countertwo = countertwo + 1 DEBUG ? countertwo LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
Post Edited (pcrobot) : 4/7/2006 7:15:54 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
http://www.parallax.com/dl/docs/books/edu/wamv2_2.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
counterone flashes an LED on 500ms, then off 500ms. When it does that 60 times, countertwo adds 1, and counterone resets. I just want to send the value of each counter to the eeprom when the pushbutton is pressed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
· By checking for a button-push you have to stop counting or account for it in your PAUSEs, by writing to eeprom you have to stop counting long enough to perform that operation.
· Why don't you get a PocketWatch-B which will run all the time?· Have your program query the PW-B for the time when there is a button-push and write that to eeprom.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
' {$STAMP BS2} ' {$PBASIC 2.5} But1 PIN 0 LED PIN 1 counter VAR byte index VAR byte do IF But1 = 1 THEN exit HIGH LED PAUSE 500 IF But1 = 1 THEN EXIT LOW LED PAUSE 500 counter = counter + 1 IF counter = 60 THEN counter = 0 index = index + 1 endif loop WRITE 0, counter WRITE 1, index
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
... now... how do I save multiple values? (several values of counter, and index.)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I've been working at it for at least an hour!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
Here's a coding tip. Instead of
IF IN3 = 1 THEN WRITE eepromAddress1, month IF IN3 = 1 THEN WRITE eepromAddress2, day IF IN3 = 1 THEN WRITE eepromAddress3, hour IF IN3 = 1 THEN WRITE eepromAddress4, minute
write it like this:
IF IN3 = 1 THEN WRITE eepromAddress1, month WRITE eepromAddress2, day WRITE eepromAddress3, hour WRITE eepromAddress4, minute ENDIF
With the current version, you'll only get a partial timestamp if the button is released between statements.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
IF IN3 = 1 THEN WRITE eepromAddress, month WRITE eepromAddress + 1, day WRITE eepromAddress + 2, hour WRITE eepromAddress + 3, minute ENDIF
Then you only have one address to increment by 4 each time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
When I press the pushbutton (and it sends the variables to the EEPROM) then it starts the program over again...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
http://www.parallax.com/detail.asp?product_id=28152
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 4/21/2006 2:13:31 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robotics
ro-bot-ics (noun)
the science or technology of robots, their design, manufacture, application, use, etc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com