~~~~~~~code help~~~~~~~
Spragmatic
Posts: 59
· Please see code attached-· A few questions I have.
#1--· I'm wondering if I can stop the timing sequence after PButton2 is pressed by pressing PButton2 again anytime during the sequence(during RCTIME)?· Hope that made sense?· I need to be able to stop the program during the pause for safety reasons if possible.· (This is·the closing of a panel.)···
#2--· At this point I need to press PButton1 to go fully open again while making PButton2·non-functional until completely open again.· (This only allowing the panel to open again·no matter·if you try and·keep pressing PButton2 to close.)·
#3--· Then able to close and back to program start.
· Not quite sure how to make this happen.· Thanks!!·
······························ Greg
Post Edited (Spragmatic) : 3/22/2010 3:07:26 PM GMT
#1--· I'm wondering if I can stop the timing sequence after PButton2 is pressed by pressing PButton2 again anytime during the sequence(during RCTIME)?· Hope that made sense?· I need to be able to stop the program during the pause for safety reasons if possible.· (This is·the closing of a panel.)···
#2--· At this point I need to press PButton1 to go fully open again while making PButton2·non-functional until completely open again.· (This only allowing the panel to open again·no matter·if you try and·keep pressing PButton2 to close.)·
#3--· Then able to close and back to program start.
· Not quite sure how to make this happen.· Thanks!!·
······························ Greg
Post Edited (Spragmatic) : 3/22/2010 3:07:26 PM GMT


Comments
Greg
INTERRUPT 100_000 ' 10us "ticks" Interrupt_Handler: Update_RC_Time_But_Only_If_Flag_Set: IF doRCflag = 1 THEN IF rcPin = 1 THEN ' it did not fall to 0 yet (or rise to 1 depending on your circuit) INC rcTimer ' best as Word to get a decent amount of possible time ENDIF ELSE INC rcTimer ' to track charge time ENDIF Update_User_Delay_Time_If_Flag_Set: IF doUserDelay = 1 THEN INC userTimer ' best as Word to get a decent amount of possible time ENDIF RETURNINT Main_Program: ' the important think here is that the main loop keeps whipping through everything all the time ' and sets flags, pin states, clears counters, as needed... Track_RCtime_Decay: IF doRCflag = 1 THEN ' are you in the middle of measurement? IF rcPin = 0 THEN ' pin finally fell, check and save the reading... doRCflag = 0 rcValue = rcTimer HIGH rcPin ' OUTPUT and high rcTimer = 0 ENDIF ELSE ' otherwise wait 2ms charge time (or whatever you want) IF rcTimer > 200 THEN ' 2ms/10us INPUT rcPin ' set to measure rcTimer = 0 ' clear the count doRCflag = 1 ' set the flag ENDIF ENDIF ' so at this point, you always have the most recent current reading from the RCTIME circuit in rcValue Track_User_Button_Stuff: IF button0pin = 0 THEN ' active low doUserDelay = 1 IF userTimer > 50_000 THEN ' half second of "holding" button ' do something ELSEIF userTimer > 5000 THEN ' 50ms hold (so everything is debounced) ' do something else ENDIF ELSE ' released state, clear timer userTimer = 0 doUserDelay = 0 ENDIF Do_Something: IF rcValue > 10_000 THEN ledPin0 = 1 ELSE ledPn1 = 0 ENDIF Etc: Done: GOTO Main▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 3/22/2010 10:52:47 PM GMT
Greg
The "main" program occasionally reads this count to see how much time has passed, and to reset the counter to zero. The rest is keeping track of what's going on, and making some decisions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Greg
IF rcValue > 10_000 THEN
HIGH Led2
ELSE
LOW Led2
ENDIF
I don't what or how your RC circuit is setup, so besides waiting for debounce on Pb2, the above would also require that the RC time is above 100_000 micro seconds (10ms).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
I've tried moving things around with your Interrupt code from above and still can't get PButton2 to function. I've ran program in debug and I get confused on what's going on. If I leave it in debug for to long all LED's come on and all relays energize and program locks up? Not sure what is happening there?
I'm willing at this point to pay someone for their time to correct this problem.·
INC rcDivider
IF rcDivider >= 100 THEN
rcDivider = 0
INC rcCounter
ENDIF
That would effecticly scale the count up by 100, so you'd have a max time count of around 65.5 seconds.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe
When all else fails.....procrastinate!