Barn door code (really concrete plant)
[Deleted User]
Posts: 0
dave,
·does this make it any more readable
thanks
Post Edited (truckwiz) : 10/27/2006 3:03:26 PM GMT
·does this make it any more readable
thanks
Post Edited (truckwiz) : 10/27/2006 3:03:26 PM GMT
Comments
Edit:· Earlier, this topic was "Concrete Plant".· Now, it's "Barn Door".· I still don't see a question.
Post Edited (allanlane5) : 10/26/2006 2:08:17 PM GMT
·here's the problem , if any of the animals stop in the doorway they will keep being counted, anybody have any thought's on this.
Thank's Brian
' {$STAMP BS2}
' {$PBASIC 2.5}
'this is a program that let's my farm animals in & out ,they all use their own doors
' some move faster & slower than each other , a couple are ready to have babies
doorcnt·· VAR Word
dogs····· VAR Word
cats····· VAR Word
pigs····· VAR Word
horses··· VAR Word
door1···· VAR Word··········· 'is door 1 open
door2···· VAR Word··········· 'is door 2 open
door3···· VAR Word··········· 'is door 3 open
door4···· VAR Word··········· 'is door 4 open
dogcnt··· CON 5············ 'number of dogs
catcnt··· CON 6············ 'number of cats
pigcnt··· CON 7············ 'number of pigs
horsecnt· CON 9············ 'number of horses
INPUT 1··················· 'dog door photoeye
INPUT 2···················· 'cat door photoeye
INPUT 3···················· 'pig door photoeye
INPUT 4···················· 'horsedoor photoeye
INPUT 15··················· 'timer on doors
LOW 5······················ 'dog door lock
LOW 6······················ 'cat door lock
LOW 7······················ 'pig door lock
LOW 8······················ 'horse door lock
allDoorshut:
· IF IN15 = 1 THEN allDoorshut·················· 'is it time to open doors ?
· OUT5=1········································ 'open dog door
· OUT6=1········································ 'open cat door
· OUT7=1········································ 'open pig door
· OUT8=1········································ 'open horse door
· doorcnt =%0000································ 'all doors open
· DO
· GOSUB cntdog
···· IF dogs => dogcnt THEN door1 = %0001······· 'is dog door closed
· GOSUB cntcat
···· IF cats => catcnt THEN door2 = %0010······· 'is cat door closed
· GOSUB cntpigs
···· IF pigs => pigcnt THEN door3 = %0100······· 'is pig door closed
· GOSUB cnthorses
···· IF horses => horsecnt THEN door4 = %1000··· 'is horses door closed
···· IF dogs => dogcnt THEN OUT5=0·············· 'if all dogs in close door1
···· IF cats => catcnt THEN OUT6=0·············· 'if all cats in close door2
···· IF pigs => pigcnt THEN OUT7=0·············· 'if all pigs in close door3
···· IF horses => horsecnt THEN OUT8=0·········· 'if all horses in close door4
······ doorcnt = door1 | door2 | door3 | door4·· 'check all doors
···· IF doorcnt= %1111 THEN allDoorshut········· 'are all doors shut,if they are go wait at alldoorshut
·· LOOP
·· cntdog:
··· IF IN1 = 1 THEN addDogCnt··················· 'count dogs
···· RETURN
····· addDogCnt:
······ dogs = dogs + 1
······· RETURN·································· 'check other animals
· cntcat:
·· IF IN2 = 1 THEN addCatCnt···················· 'count cats
··· RETURN
···· addCatCnt:
····· cats = cats + 1
······· RETURN·································· 'check other animals
·· cntpigs:
··· IF IN3 = 1 THEN addPigCnt··················· 'count pigs
···· RETURN
····· addPigCnt:
······ pigs = pigs + 1
······· RETURN·································· 'check other aninmals
·· cnthorses:
···· IF IN4 = 1 THEN addHoresCnt················· 'count horses
····· RETURN
······ addHorescnt:
······· horses = horses +1
········ RETURN·································· 'check other animals
Post Edited (truckwiz) : 10/26/2006 7:32:53 PM GMT
And when you no longer 'see' a dog, set the 'SeeDog' variable to zero, so the NEXT time you see a dog, you'll increment the count again.
THANK YOU very much,
Brian
ok next problem, as you can see from my attachments this program is not for my farm animals , the code does not reflect the fact that my next step is to hook up a touch screen , can i use the stamp plc's sin & sout for this or do in need to use 2 in & out pins ?
I found the code serin16 & serout16 , but where does tx & rx hook to· ?
Post Edited (truckwiz) : 10/27/2006 3:01:48 PM GMT