Watch dog cog
in Propeller 1
Hello All,
I am trying to write code for a watch dog cog for my project.I have tested the code and it runs with no issues. What it does is
it monitors Ina[21] and if it is "0" for more than 5.0 secs - it does try to correct it.
code starts with a "Repeat while Ina[21] == 0 " statement.When I start a new cog - cognew statement,the rest of the project works but
the watch dog cog does not seem to seem work although I have LED attached to pin 21 and is off for more than 5 secs.
I have placed the method in many other parts of the program.When placed in a method with a "Repeat loop" the watch dog method work s
but it will not execute the rest of the loop even if I make Ina{21] == 1.
I cannot figure out the problem and any help is appreciated.
Thank you
Siri
I am trying to write code for a watch dog cog for my project.I have tested the code and it runs with no issues. What it does is
it monitors Ina[21] and if it is "0" for more than 5.0 secs - it does try to correct it.
code starts with a "Repeat while Ina[21] == 0 " statement.When I start a new cog - cognew statement,the rest of the project works but
the watch dog cog does not seem to seem work although I have LED attached to pin 21 and is off for more than 5 secs.
I have placed the method in many other parts of the program.When placed in a method with a "Repeat loop" the watch dog method work s
but it will not execute the rest of the loop even if I make Ina{21] == 1.
I cannot figure out the problem and any help is appreciated.
Thank you
Siri

Comments
Pub WatchDog |OffTime, Correction Repeat while(Ina[21] == 0) OffTme := 0 Correction := 0 Repeat 5 ' 5 sec count down- OffTime++ delay(1) '5 sec. count down starts if OffTime => 5 'if OffTme is => 5.secs Repeat 2 ' Correct 2 times outa[21]~~ outa[22..23]~ pause(500) 'Inspir for 0.5 secs outa[21]~ outa[22..23]~~ ' valves P22 & P23 opens pause(500) 'delay for 0.5 secs outa[22..23]~ Correction ++ If( Correction => 2) quitThanks,Siri
Pub WatchDog |OffTime, Correction Repeat while(Ina[21] == 0) OffTme := 0 Correction := 0 Repeat 5 ' 5 sec count down- OffTime++ delay(1) '5 sec. count down starts if OffTime => 5 'if OffTme is => 5.secs Repeat 2 ' Correct 2 times outa[21]~~ outa[22..23]~ pause(500) 'delay for 0.5 secs outa[21]~ outa[22..23]~~ ' valves P22 & P23 opens pause(500) 'delay for 0.5 secs outa[22..23]~ Correction ++ If( Correction => 2) quitThe method I use -using correct way to post codeSiri
REPEAT
in the first line and indent the rest of it.
Since it is supposed to be a watchdog you do not want to run this just one time, don't you?
Enjoy!
Mike
No luck and watchdog do not work. Any other idea.
Siri
anything like as much power.
Also, can you describe exactly what you want the code after the "Repeat 2 ' Correct 2 times" statement to do.
You are right,the watchdog cog is suppose to monitor pin21 and set it high if it has been low for more than 5 secs.
After "Repeat2" statements- the code is suppose to continue as the the problem is corrected.To continue with this
code running in another cog(Valve timing code)- see below
Pub ValveControl 'CONTROL SOLENOID VALVES DURING INTAKE dira[21..23]~~ 'Set solenoid pins as outputs dira[14]~~ outa[23]~~ 'bypass solinoid is made open to avoid pressure issues from pump relief pressure 'avoid back pressure as there will be NO out let if this solenoid is closed. pause(10) dira[MotorPin]~~ pause(10) outa[MotorPin]~ 'Start BLDC motor Repeat 'Valve CONTROL CODE If Pressure1 < Intake{settable on the fly varible-global} outa[21]~~ 'Intake Valves open between HIGH and LOW pressures( pressure1 =>0 {Pressure1 is a global variable} outa[22]~ outa[23]~ outa[14]~ 'Intake phase - Pump valve open/ and exhaust valves close - pressure relief valveP14 closes elseif Pressure1 => Exhaust {also a settable on the fly global variable} outa[21]~ 'Exhaust Valves open between HIGH and LOW pressures outa[22]~~ ' Exhaust phase ---> pump valve closes/exhaust valve opens. outa[23]~~ outa[14]~~ 'BOTH Relief valves @22&23 open If Pressure1 > 15 'In case of inadvertant pressure rises > 12cm.H2O - pump is bypassed and outa[21]~ outa[22..23]~~ outa[14]~~ ' both pressure relief valves open to AIR pause(1000)I hope this helps to solve the issue.
Thanks for the Help.
Siri
The watch dog cog issue still remains unsolved.I am in need of solution so please give it
a little effort.
Thanks,
Siri
Pub WatchDog |OffTime, Correction repeat NEED THIS REPEAT TO KEEP WATCHDOG COG RUNNING Repeat while(Ina[21] == 0) OffTme := 0 Correction := 0 delay(5) ' REPLACES THE 4 INSTRUCTIONS COMMENTED OUT BELOW } ' Repeat 5 ' 5 sec count down- ' OffTime++ ' delay(1) '5 sec. count down starts ' if OffTime => 5 'if OffTme is => 5.secs Repeat 2 ' Correct 2 times outa[21]~~ ' WHY ARE YOU TRYING TO SET PIN 21 HIGH? IT HAS NOT BEEN SET AS AN OUTPUT outa[22..23]~ ' HAVE THESE PINS BEEN SET AS OUTPUTS SOMEWHERE? pause(500) ' delay for 0.5 secs outa[21]~ ' outa[22..23]~~ ' valves P22 & P23 opens pause(500) 'delay for 0.5 secs outa[22..23]~ { THE 2 INSTRUCTIONS COMMENTED OUT BELOW ARE NOT NEEDED. THE "Repeat 2" STATEMENT WILL ONLY EXECUTE THE STATEMENTS BELOW IT 2 TIMES } ' Correction ++ ' If( Correction => 2) { WHY QUIT AT THIS POINT? TYPICAL WATCHDOG TIMERS WOULD STOP OR SHUT OFF THE EQUIPMENT, SET OFF AN ALARM, OR RESET THE SYSTEM AT THIS POINT } quitThank you helping me. I tried your changes to the code but still it does not work
The only other cog that sets the P21 is in the following code that runs in a another cog I am using only 4 other cogs
When put the code in ValveControl loop it works but then VaalveControl stops working - only the watchdog code works
continuously.
Itried with and with out the "quit" - still no luck.
Pub ValveControl 'CONTROL SOLENOID VALVES DURING INTAKE & EXHAUST PHASE dira[21..23]~~ 'Set solenoid pins as outputs dira[14]~~ outa[22..23]~~ 'bypass solinoId is made open to avoid pressure issues from pump relief pressure 'avoid back pressure as there will be NO out let if this solenoid is closed. pause(10) dira[MotorPin]~~ pause(10) outa[MotorPin]~ 'Start BLDC motor Repeat 'Valve CONTROL COD If Pressure1 < Intake outa[21]~~ 'Intake Valves open between HIGH and LOW pressures outa[22]~ outa[23]~ outa[14]~ 'Intake phase Pump valve open/bypass valve closed and exhaust valves close elseif Pressure1 => Exhaust outa[21]~ 'Exhaust Valves open between HIGH and LOW pressures outa[22]~~ ' Exhaust phase ---> pump valve closes/bypass valve opens. outa[23]~~ outa[14]~~ 'BOTH Relief valves @22&23 open elseif Pressure1 > 15 'In case of inadvertant pressure rises > 12cm.H2O - pump is bypassed and outa[21]~ outa[22..23]~~ outa[14]~~ ' both pressure relief valves open to AIR pause(1000)Thanks kwinn
Siri
Thanks for the help.
Siri