No, the difference between the two codes is the limit switch inclusion. I ran out of development time before I went away for the New Year and so as a quick fix I used the motor run timer Code A.
The pause in Code A is the motor run time, in B it's to allow the limit switch to open before it's checked for position. That way I only use one switch, not two for up/down.. The High motorup starts the motor and the pause leaves it running then the program enters the Low phase. The Counter prevents cycling from one to another. Both conditions, LDR and Counter have to be correct for it to run. That was another anomaly, I tried 'AND' which just didn't work, i resorted to a small Loop. All most odd.
I tried the Code B with Pause inclusions where the Serout commands were in Code A but still it doesn't run correctly, the motor just runs in the Open phase non stop and ignores the limit switch.
The addition of the limit switch is to make the close and open positions identical. Using Code A and run time I found the door positions changed ever so slightly over time due to not refining the run times. The different run times is for motor torque, in the down run the additional weight of the door makes it close faster than the up cycle.
It all runs Ok at the moment with Serout commands in the Code B but I'm curious as to why it needs the Serout commands for it to work correctly. Bear in mind they are useless commands, there's no LCD connected, the N9600 is incorrect for the clock at 4Mhz anyway.
The Tris commands are incorrect above but correct in code, the copy and paste to forum seems to have removed the percent and a couple of 0's and 1's.
Bookmarks