Originally Posted by
Dixi
Basically I have a conveyor belt system which has two sides '0' and '1' on each side of the conveyor, which will be running simultaneously there are 3 sensors. The first two sensors determine the size of the object on the conveyor. This is done by giving and output of 0 for no object a 1 for first sensor activation 2 for second sensor activation or 3 if a large object is on the conveyor therefore triggering both sensors. if a small object is detected then a gate that is 2.8 secs away from the second sensor needs to close for about 1 sec to allow the small object to be push off. If a large object is detected it should pass along the conveyor but the third sensor should be activated which comes after the gate, this is to count the number of large objects. The gate responds to 'setgates (1)' to close the '0' side and 'setgates (3)' to close the both gates at the same time, 'setgates (0)' raises the gate. Today i attempted one side of the conveyor and managed to get the the gate to operate knocking off small objects and letting large objects through using taskdelay after a sensor 2 activation to knock small blocks off and sensor 3 activation to make sure the gate is open for large objects. This is ok but has a limitation in that if there are two small ojects close together on the conveyor then the taskdelay would not be appropriate. This has lead me on to looking at something called watchtimer or watchdog :s Also these block need to be counts so for instance id like a = total blocks counted b = small block counted c = large blocks counted d = large block counted from third sensor as a checksum. Some of the coding has been done and i can call on those task from a separate .h file
Those are:
/* Sensor reading functions */
char readSizeSensors(char conveyor);
char readCountSensor(char conveyor);
void resetSizeSensors(char conveyor);
void resetCountSensor(char conveyor);
/* Gate & motor control functions */
void setGates(char state);
void startMotor(void);
void stopMotor(void);
If you could assist me or point me in some direction it would be much apprecitated as it has given me quite a headache. I think i need to do it in separate functions as today i attempted to do it all in one function and the coding got quite long.