#### joed9988

Joined Dec 18, 2021
20
Hi Guys I'm a licensed Electrician i usually deal witch wiring Commercial Business or houses so small electronics is pretty new to me I've never used an adreno board or built any robots but i understand circuits and voltages and resistances. So that my experience level now let me explain what i'm trying to do and why if you don't care about the why just scroll down to the question.

The Why
About a year ago my mother was diagnosed with a form of dementia she has a hard time remembering any longer then 10 mins its very sad and frustrating at times she also has been a smoker for 50 years and I've tried helping her quit but she gets depressed and locks her self in her room and and tells me she has nothing to live for if she cant smoke not remembering the fact that it was her idea to quit it was like groundhog day every day would have to explain to her the situation. finally I decided that I would rather have her moving around the house happy and smoking then locked in her room all day. shes 72 she still has some years left in her i would like her to enjoy them. but i also don't want her to over smoke since she cant remember the last cigarettes' she had if i give her a pack it will be gone in a day and I'm trying to limit her to half a pack a day i feel that is a good compromise and since i cant always be around and hand her cigarettes' and i feel its demeaning to have her begging me for cigarettes' and also annoying to me every 20 mins have her asking i wanted to build a cigarettes' dispenser that would shout out a cigarettes' every hour. my design if fairy simple and i think have the design part figured out just a timer board and an actuator to push out the cigarettes every hour. but then i realize what if she hasn't taking the cigarette yet or we are out of the house doing something how can i stop it from just keep pushing them out so i thought a sensor or a momentary switch.

The Question
So here is the Question what would be the best way to detect the cigarette still on dispenser? the weight of the cigarette is the problem they are so light weight that i need something that can detect less then a gram of force. a momentary switch with a long lever? they have these thin film sensors that react to force but i need to add resistors and adreno board? even thought of maybe a photo eye that would detect light and if the cigarette covers up a hole that was allowing light to enter the senor? what do you guys think anyone with experience using these type of sensors or that have a better idea please comment any help would be appreciated.

#### LesJones

Joined Jan 8, 2017
3,701
I think the optical sensor is a good solution. There are 2 types. One detects the beam between the light emitter (Either visible light or infra red.) and the sensor being broken by the object. The other detects the light reflected back from the object. (In this case the light source is on the same side of the object as the detector.) One possible reflective sensor is the Vishay CNY70.

Les.

#### sghioto

Joined Dec 31, 2017
3,058

#### joed9988

Joined Dec 18, 2021
20
when i looked at the first sensor seemed like you had to program it with code. this is not something ive had any experience with I've never done anything with an adreno board. if you think it will work perfect for my application i will learn and make it work i guess thats part of the fun learning new things and stuff. but i also could be wrong i was hoping for just just a sensor that acted like a switch opening and closing the circuit mechanically.

#### sghioto

Joined Dec 31, 2017
3,058
No you don't have to use an Arduino or code but the second unit is a much better choice.
This should provide the on-off control you want but probably will require a relay or solid state device depending on your design.

#### LesJones

Joined Jan 8, 2017
3,701
As sghioto say's none of the sensors require programming. I suggested the Vishay CNY70 as it is quite small. This is a link to how I mounted a similar sensor on the end of a piece of 1/4" paxolin rod to feed a tachometer on my drill press. It is under the heading "Maplin SY-CR102 reflective opto sensor mounted on drill press" You would need a transistor or comparator chip (Such as an LM393.) to convert the output to a logic level. Are you planning to use relay logic or cmos ICs for the control circuit ? (This is the part that would be simpler using a microcontroller of some kind.)

Les.

#### MisterBill2

Joined Jan 23, 2018
11,556
A standard industrial beam-break photo switch can do the sensing task with just a bit of a mask to provide a narrow beam of light. And it should be durable enough to survive rough handling. OR you can just have a timer that is latched to run for the needed delay to prevent another dispense cycle. That way there will not be any unrequested dispensed cigarettes, and always the time delay as the minimum time between. And using all industrial parts, the pushbutton switch, the timer, and a solenoid to dispense, it will not be easy to break Breaking is often a problem with folks who do not remember to be gentle with hardware. And only delivering one, when requested, might slow her down.
You will also need a good set of smoke alarms for the fires that get started.

#### joed9988

Joined Dec 18, 2021
20
thank you all for the great idea and help i'm just a dumb electrician install lights and plugs so some of these idea are a lil advanced for me but i will figure it out!

#### MisterBill2

Joined Jan 23, 2018
11,556
Lack of experience does not make one dumb, only inadequately experienced. Big difference there.

#### joed9988

Joined Dec 18, 2021
20
so i can kind of relate this to when i do a lighting circuit with a motion sensor. normally i will have a power pack which is just a relay that i brink 120/277v and then it have a load side i bring to my lights on the other side i have the low voltage connection for the motion sensor wich is a + and - wire plus a signal wire. so i guess if i was going to use something like this Proximity sensor what could i use for a control relay to open and close the power to my actuator? these are the timer and actuator i ordereractuator and timer

#### Irving

Joined Jan 30, 2016
2,524
Not so dumb.. you've figured out the what & how... now you have a learning exercise on the detail of the 'how' - and its not that difficult. A small microcontroller of the Arduino variety would encompass the timer, actuator, sensor and display elements (you need something to show what's happening, even if its just a few flashing lights - you can never have too many flashing lights!).

TinkerCAD Circuits is a great place to experiment with simple Arduino setups and code without spending any money. To whet your appetite, here is a screen shot of a simple simulation (and the few lines of code) using a push-button, a green LED and a servo.

Pushing the button when the LED is on rotates the servo 180 degrees (pushing a cigarette out) and 5secs it later it returns to zero and the LED goes out. A few seconds later (10, but could be a minute, an hour or any time you desired) the LED comes back on and the pushbutton is enabled for the next dispense. It would be a matter of seconds to add a sensor to determine if the cigarette has been removed or not.

#### Irving

Joined Jan 30, 2016
2,524
Incidentally, I'd use a low-force roller microswitch for the 'removal' detector, operating against a counter roller. The cigarettes are held in a v-shaped hopper and drop one by one by gravity into a chamber. There a servo-operated plunger pushes it along a chute between the counter-roller and the microswitch roller until it partially emerges from the casing so the user can pull it out when needed... Mass of cigarette is irrelevant, as long as roller tension is light enough not to crush the cigarette. The servo doesn't need to push it more than a 1/3 to 1/2 of the length before retreating out of the way - when the cigarette is pulled out that allows the next to drop into the chamber.

#### MisterBill2

Joined Jan 23, 2018
11,556
How about just a solenoid to bump a cig out the end of the v-bottom bin.that happens when the person pushes the button. Also the 20 minute timer starts that opens up the power for the solenoid. No reason to sense that a product is dispensed and then removed, if it just sits there then it will wait until the user wants it and grabs it. Remember that the purpose is to limit consumption, NOT to automate it. This is a vending machine, not a production machine. The button is the clue as to what to do to get one.

#### joed9988

Joined Dec 18, 2021
20
well in my head the idea was to give her 1 cigarette every hour but at night when shes sleeping or when we go out of the house and shes not there to snatch one up i wanted to it to sense that there was no need to dispense another cigarettes so my initial idea was pretty much to have a hopper with a funnel system to que up a cigarette and then have the timer activate the actuator and push one out every hour. and then have some sort of sensor to switch the circut open when there was still a cigarette sitting there that had been dispensed. if i wanted to let her smoke whenever she wanted i would give her a pack and it would be gone in a day plus the way her memory she would have to learn to push the button and keep re learning it.

#### MisterBill2

Joined Jan 23, 2018
11,556
Written instructions and a light by the button. And still the timer, but instead of dispensing in an hour it would only ALLOW dispensing another after the hour. That solves a bunch of problems. Pushing the button would reset the timer and no more could be dispensed until the timer timed out. And starting the timer will need to inhibit the reset. A really small simple PLC would be the good choice because they already have the I/O, and they are all far more rugged than the arduino could ever dream of being.

#### joed9988

Joined Dec 18, 2021
20
i will have to label this button in big letters for her, before i had this idea i bought a small plastic box thing made in china that would hold her cigarettes and to open it you had to push a button and pull the box open at the same time it didn't really work out that great she would forget her cigarettes where in the box so we labeled it with big letters MOM'S CIGGARETTS then she would complain she couldn't open the box and it was broken part because she couldn't remember she had to hold the button and open the box at the same time and part because there was no indication of time the last time she opened it. so she would smoke and then try and smoke 5 mins later and it was to soon.

#### joed9988

Joined Dec 18, 2021
20
could you suggest a PLC ? this one ?

#### MrSalts

Joined Apr 2, 2020
1,506
I'd get rid of the sensor.
I think a timer function where she can push a push a momentary button and that button only works if one hour has passed since the previous successful button press.
Specifically,
A button press will do nothing if one hour hasn't passed.
If an hour has passed, a button press resets the timer AND gives access to a cigarette.

#### Irving

Joined Jan 30, 2016
2,524
While I don't disagree that an industrial PLC may be arguably more physically robust, my experience is that the cheap ones at $40-70 are an order of magnitude more expensive than an Arduino and the issues of chinglese documentation, when it exists at all, and support software are common problems, plus the requirement, in many cases, for a 24v supply which adds more$. A fully supported PLC with proper documentation seems to run at \$150+.

Online plc training/simulation software:
PLC Fiddle
PLC.net