i would like to design a circuit to count tablets and when it counts a certain number of tablets (i.e 30 tablets) a gate opens to direct the tablets to a nozzle to fill a jar.
the above photo shows the part of the machine, I would like to make.
the following photo is circuit diagram.
when the IR count the specific number of tablets (i.e. 30 tablets) the relay triger the solenoid which move the gate.
is there any one who can help me in coding or suggest a project do the same.
Thankyou
To create a program that counts to 30 and then triggers a solenoid is an easy task. The programming seems to be the easiest part, it's more about the "real" world issues:
How and how quick are the tablets moved in front of the IR obstacle detector?
How are they seperated to be counted one by one?
Is there a requirement to stop moving tablets when 30 has been reached?
How long must the gate be opened to allow all tablets to fall?
And wouldn't it be easier to use a scale and the weight of 30 tablets (if they are of the same kind)?
I would use a MOSFET to power the solenoid instead of a relay. The relay coil will need an external power supply. The MOSFET is more reliable and efficient power wise.
I would use a light gate where the pill pass between the emitter and detector instead of a reflective sensor like is pictured.
Use an I2C enabled LCD. It requires only the 2 I2C pins instead of 6 pins. Install the hd44780 library. It is the best LCD library currently available and makes using an I2C display as near plug and play as possible.
It would not be hard to modify the reflective sensor in the picture to a light gate. Carefully unsolder the emitter from the little PC board. Add short wires to it and solder the other ends back to the board. Then you can place the emitter across from the sensor so that the IR beam is broken by a pill passing by.
Thanks for the additional information. That makes things much clearer.
You might consider to prototype the part where the pills are separated and fall through the pipe to find the optimum position and sensitivity of the light gate. That seems to me to be one of the critical functions, provided that the gate is constructed in a way that it can not get stuck by a moving tablet during switching.
I second also @groundFungus's suggestion to change from reflective measurement to light gate.
The timing of switching the gate and the distance between the position of the sensor and the gate will also have to be measured and have an influence on the maximum tablet/pill speed.
Do you already have more concrete concepts for the mechanical construction?
You're probably right: in my head the lcd had its own pot on the back. But if so, @haleemrayan you could consider using a pot to do as I suggested as well, to make your machine more versatile and not have to edit the code to change the quantity.