Hello Group.
I've got a problem that seems simple enough. I've built this cat feeder which uses an 08M chip to essentially turn the feeder on and off every 12 hours. The feeder uses a pvc drum which rotates 360 degrees (filling at one point and dumping at another). I've had a problem with timing of the drum rotation as it does not always run at the same speed when chunks of cat food get caught in the cracks. And so picking "x" number of seconds for the rotation did not work well over time.
So, I decided to add a switch which is simply a set of contact points - activated by a lever on the drum. When activated, the switch sends power to pin 3 of the chip. My program tells the motor that if pin 3 goes high, run it for a few more seconds to get the drum in the right position for the next feeding and then turnoff. This usually works fine but at times, the contact does not seem to be registered and the motor keeps turning or prematurely stops. The problem may be that when the contacts are made (contact lasts about .5 second), the program is currently ignoring that particular command which again tells the motor to stop. But I was figuring the program is cycling pretty fast through the "away" portion of the code (see below) that 1/2 second of contact time would be plenty.
This is the area of code as written:
AWAY:
HIGH 2 'RUN MOTOR TO TURN FEEDER DRUM
IF PIN3=1 THEN TURNOFF 'IF PIN 3 GOES HIGH, TURN OFF MOTOR VIA TURNOFF ROUTINE
IF PIN3=0 THEN AWAY 'KEEP RUNNING MOTOR IF PIN 3 IS LOW
TURNOFF:
PAUSE 6200 'WAIT 6.2 SECONDS FOR CONTACTS TO DISENGAGE AND RESET DRUM
LOW 2 'STOP MOTOR
GOTO CLOCK 'BEGIN TIMER FOR NEXT 12 HOUR CYCLE
CLOCK:
FOR B1 = 1 TO 200 'START COUNTER
PAUSE 60000 'PAUSE FOR 60 SECONDS PER CYCLE (200 CYCLES = 3 HOURS 20 MINUTES)
NEXT B1
FOR B2 = 1 TO 200 'START COUNTER
PAUSE 60000 'PAUSE FOR 60 SECONDS PER CYCLE (200 CYCLES = 3 HOURS 20 MINUTES)
NEXT B2
FOR B3 = 1 TO 200 'START COUNTER
PAUSE 60000 'PAUSE FOR 60 SECONDS PER CYCLE (200 CYCLES = 3 HOURS 20 MINUTES)
NEXT B3
FOR B4 = 1 TO 119 'START COUNTER
PAUSE 60000 'PAUSE FOR 60 SECONDS PER CYCLE (119 CYCLES = 1 HOUR 59 MINUTES)
NEXT B4
PAUSE 50000 'PAUSE FOR 50 SECONDS MORE
GOTO AWAY 'START OVER AND BEGIN RUNNING MOTOR UNTIL PIN 3 GOES HIGH AGAIN
Any ideas for better code would be appreciated. PS: The contacts are clean and work fine. Pin 3 has a pull-down resistor.
Thanks.
Gene Darby
I've got a problem that seems simple enough. I've built this cat feeder which uses an 08M chip to essentially turn the feeder on and off every 12 hours. The feeder uses a pvc drum which rotates 360 degrees (filling at one point and dumping at another). I've had a problem with timing of the drum rotation as it does not always run at the same speed when chunks of cat food get caught in the cracks. And so picking "x" number of seconds for the rotation did not work well over time.
So, I decided to add a switch which is simply a set of contact points - activated by a lever on the drum. When activated, the switch sends power to pin 3 of the chip. My program tells the motor that if pin 3 goes high, run it for a few more seconds to get the drum in the right position for the next feeding and then turnoff. This usually works fine but at times, the contact does not seem to be registered and the motor keeps turning or prematurely stops. The problem may be that when the contacts are made (contact lasts about .5 second), the program is currently ignoring that particular command which again tells the motor to stop. But I was figuring the program is cycling pretty fast through the "away" portion of the code (see below) that 1/2 second of contact time would be plenty.
This is the area of code as written:
AWAY:
HIGH 2 'RUN MOTOR TO TURN FEEDER DRUM
IF PIN3=1 THEN TURNOFF 'IF PIN 3 GOES HIGH, TURN OFF MOTOR VIA TURNOFF ROUTINE
IF PIN3=0 THEN AWAY 'KEEP RUNNING MOTOR IF PIN 3 IS LOW
TURNOFF:
PAUSE 6200 'WAIT 6.2 SECONDS FOR CONTACTS TO DISENGAGE AND RESET DRUM
LOW 2 'STOP MOTOR
GOTO CLOCK 'BEGIN TIMER FOR NEXT 12 HOUR CYCLE
CLOCK:
FOR B1 = 1 TO 200 'START COUNTER
PAUSE 60000 'PAUSE FOR 60 SECONDS PER CYCLE (200 CYCLES = 3 HOURS 20 MINUTES)
NEXT B1
FOR B2 = 1 TO 200 'START COUNTER
PAUSE 60000 'PAUSE FOR 60 SECONDS PER CYCLE (200 CYCLES = 3 HOURS 20 MINUTES)
NEXT B2
FOR B3 = 1 TO 200 'START COUNTER
PAUSE 60000 'PAUSE FOR 60 SECONDS PER CYCLE (200 CYCLES = 3 HOURS 20 MINUTES)
NEXT B3
FOR B4 = 1 TO 119 'START COUNTER
PAUSE 60000 'PAUSE FOR 60 SECONDS PER CYCLE (119 CYCLES = 1 HOUR 59 MINUTES)
NEXT B4
PAUSE 50000 'PAUSE FOR 50 SECONDS MORE
GOTO AWAY 'START OVER AND BEGIN RUNNING MOTOR UNTIL PIN 3 GOES HIGH AGAIN
Any ideas for better code would be appreciated. PS: The contacts are clean and work fine. Pin 3 has a pull-down resistor.
Thanks.
Gene Darby
Last edited: