Newbie wanting to learn about clocks and timed dispensers

Discussion in 'The Projects Forum' started by New2EE, Dec 15, 2013.

  1. New2EE

    Thread Starter New Member

    Sep 23, 2009
    19
    0
    I have an idea for a project, but I am a complete newb. I want to make a dispenser that dispenses an item according to a very specific set of rules (I will cross the programming bridge when I get there)

    Here is what I need it to be capable of:
    This device will only allow the user to activate it a set number of times per 24 hour period.

    The device will need memory to keep a running total of how many times it has been activated over the course of a 6 month period of time.

    It will need to display a counter of how many activations are left in the current day

    battery backup (for the clock and memory, not for mechanical actuation).

    I would really like to actually LEARN how to do all of this and then do it myself instead of someone saying "here's how you do it", so if you have any suggested reading beyond the textbook here (Or pages of the textbook that will pertain to what I'm doing) I would appreciate it. Another way would be to very vaguely explain the circuit I would need so that I can research the parts and what not.

    I imagine I would need 5v PS, a microcontroller that can be programmed from a PC (maybe a PIC can do this? I don't know).

    I imagine the display to just be an old school 2 digit LED, which I don't know how to make the numbers show up on...

    A digital switch and actuation system

    I don't know anything about memory, but I am going to read the chapter on it tonight :)

    and then the mechanics I think I can figure out.

    So, user presses switch, counter goes down 1 and product is dispensed. When counter is at 0, product will not be dispensed again until internal timer has gone through 24 hours. If device is unplugged or power goes out, it will not dispense, nor will it accept activation calls, but the timer and memory will stay protected until the power is back, and system resumes as normal.

    Thanks for any advice or input!
     
  2. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,871
    1,394
    Power supply + micro-controller + real time clock + LCD + servo + programming. Is that vague enough for you? :)
     
  3. New2EE

    Thread Starter New Member

    Sep 23, 2009
    19
    0
    Yes, I think that will be a good start lol. Any suggestions on brands/starting points? I have read about so many different starting kits (Arduino, Raspberry pi, etc) Maybe I can go from scratch as my needs are seemingly (perhaps deceptively) simple.

    On a side note, I just finished reading about delay lines, Williams Tubes, and core memory... Just blown away by the progression and ingenuity. Love it!
     
  4. New2EE

    Thread Starter New Member

    Sep 23, 2009
    19
    0
    Reading further, I think an EPROM will work for my memory needs Microprocessor has built in memory. Learning already :)
     
    Last edited: Dec 15, 2013
  5. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,871
    1,394
    I don't know much about any μC families except PICAXE and PICs. PICAXE is the easiest to get started with, but it lacks the speed necessary for some functions. There is more of a learning curve with PICs, but they are the most flexible. And you will have to choose a programming language, C, Basic, or something else.

    The project you described is very doable with PICAXE or PICs. It's likely that there is a PIC with enough data memory to store the data that you want to accumulate.
     
  6. #12

    Expert

    Nov 30, 2010
    16,345
    6,831
    I'm thinking about ways to arrange it.

    The way you described it was: Clock counts to 24 and issues x number of credits. Dispense button subtracts from balance. If balance = 0, no dispense.

    Clock issues one credit every x number of hours and dispense button issues a debit. If bal = 0, no dispense.

    Clock issues a dispense order every x hours, which eliminates the credit/debit programming.

    The machinery stops me cold. Probably because I'm not much of a mechanical designer.
    I don't think speed of processing is a concern.
     
  7. New2EE

    Thread Starter New Member

    Sep 23, 2009
    19
    0
    @Tracecom I think Pic might be the way I'll go. I've been looking for an excuse to learn C.

    @#12 Just wait until I explain the data routing in its entirety...

    So, I was reluctant to devulge all the specifics on my design on some vain pretense that someone will come along and "steal" my idea but, pfft, I just want it made.

    My idea is to make a device that will assist in addiction cessation. Cigarettes, Pills, etc. It may not be as effective for cigarettes as they are ubiquitous and simple to obtain outside of the controls, but in the case of painkillers or other drugs it could be quite effective to get someone back on track (Friend of mine was just informed that their liver is shutting down due to taking 10+ Lortab 10's daily for over a year)

    I was brainstorming about it some more, and I think what I want to achieve may even be possible with an old pc. Have a program that runs based on the current date, a key on the keyboard could be assigned to dispense, and the actuator could be controlled by the eject logic on the CD drive.

    Hmmm....

    It would still be nice to have a standalone unit that could be programmed to specific users' needs. I know people that go to methadone clinics and have to go every day for x amount of days to get their meds and then they go on probation etc... It would be interesting if a device that is sealed/impenetrable (without damaging the medication) could be prescribed that delivered the meds automagically in the patients own home. I don't want this to turn into a thread that discusses the ethics or legality involved here, just looking for ideas on how to implement it. I will start learning more about PICAXE and PIC's. So far they seem pretty interesting.
     
    Last edited: Dec 15, 2013
  8. #12

    Expert

    Nov 30, 2010
    16,345
    6,831
    Your intent was transparent to me. That's why I gave you some scenarios.
    The time setting on a computer can be easily spoofed. Not a security measure.
    Locked liquid dispensers are already available and in common use in hospitals. The difficulty from my point of view is making a reliable mechanical dispenser. Another difficulty is the requirement for a third party to control the key.
     
  9. New2EE

    Thread Starter New Member

    Sep 23, 2009
    19
    0
    All valid points.

    Computer based is out
    This idea will likely never become mainstream due to tampering
    Mechanical dispensing isn't all that difficult so long as pills are uniform

    I'm thinking a picaxe 08M2 or a 28X2. If the 08's 2048 KB ROM and 128 KB RAM will be enough space for my code, then obviously I would go with that, but at about 5 bucks a pop, the 28X2 wouldn't break the bank either.

    I have no idea how big programs are, but I imagine 2MB should be plenty for a 24 hour loop, plus a banking system to allow the user a certain level of "freedom" while staying within the confines of the recovery program.

    If using the picaxe, would I need to use an external clock? It doesn't necessarily have to line up with the current date, so long as it can keep accuracy to within a minute or two over the course of 6 months.
     
  10. #12

    Expert

    Nov 30, 2010
    16,345
    6,831
    More ideas: You could use a program that increases the time between doses gradually.
    I think a basic, one time period only program can be done in less than a kilobyte. Even if you program a timed rate of decrease, I don't think you can get to a megabyte. The problem here is that I haven't programmed in 30 years. You're going to have to pick a language and start fiddling about with flow charts. If you have programmed before, you can get functional in a day or two. If you haven't, you will need help with that part.
     
  11. New2EE

    Thread Starter New Member

    Sep 23, 2009
    19
    0
    I'm an Excel power-user so most of my programming experience is VB. It seems that picaxe is simple enough and that's how I'll be moving forward. Now to locate a good startup kit...

    Thanks for all the input guys! I'll post back here if/when I get more done on it.
     
  12. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,871
    1,394
    The least expensive way to get started is with a solderless breadboard, AXE-029, AXE-027, a 5V PS, and the PICAXE of your choice. I have had three or four "development" boards and still preferred the solderless breadboard.

    You might be interested in skimming this thread. Have a look at post #108.
     
    Last edited: Dec 16, 2013
    New2EE likes this.
  13. elec_mech

    Senior Member

    Nov 12, 2008
    1,513
    193
    Yes. The PICAXE is next to horrible when it comes to time-keeping. As Tracecom suggested, a external real-time clock (RTC) such as the DS1307 works well. It will keep track of time accurately and you can add a battery to keep memory during power outages. If you're trying to keep things as inexpensive as possible, I've just ordered some Microchip MCP7940M RTC's to play with which are next to identical to the DS1307 at a fraction of the price (under a buck vs. $3-4 USD). Using an RTC will ensure accuracy and require a lot less programming than trying to implement an accurate clock on a microcontroller.

    Based on your goals, a PICAXE will work well for this application. It is relatively cheap, super easy to program using the BASIC language, and start-up costs are minimal. I suggest a good breadboard and a cheap generic USB-to-TTL adapter which will cost less than the dedicated PIXACE programming cable. Got a couple different types coming in to test for another PICAXE project I'm helping another member out with, so I can make some suggestions later this week once I've verified operation.

    This looks like a fun project. If you'd like, I can put together a suggested list of parts and some suggestions to get you started.

    However you decide to proceed, I strongly suggest fully fleshing out the design before ordering parts, otherwise you'll be ordering multiple times and paying for shipping over and over.

    I have a buddy who wants something similar to limit his intake of candy bars at his office, so I'd be happy to help layout the electrical system and assist with programming if you care to share your thoughts on the mechanical aspect. :)
     
    New2EE likes this.
  14. New2EE

    Thread Starter New Member

    Sep 23, 2009
    19
    0
    Wow, I started reading that thread at 108, and ended up reading it through. The amount of information contained in this thread is enormous. Thank you Tracecom. I like your suggestion on what to buy individually, but I think for the sake of simplicity I'm going to get this Aztec Starter Kit for PICAXE Even if I give up on this project, I won't have any excuses to not get started right away if I have another idea down the road.

    I have wanted to get into electronics as a career my whole life, I even went to school and got all my academics completed for a BS in EE (With a 3.8 GPA I might add *smug*) I've made all kinds of excuses to give up on that dream (One being the constant shift towards disposable electronics)

    I'm assuming here that you are an EE (Forgive me if I'm wrong) What are your thoughts on the future for EE's?
     
  15. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,871
    1,394
    No, I am just a tinkerer, retired marketing director. My math skills are geared toward financial analysis, and not engineering math. Micro-controllers are the future of electronics, and discrete component construction will become less and less important. If wanted a career in electronics, I would focus on μCs: programming them and interfacing them with real world applications.

    BillO, a member here, is involved with the Aztec products, and will be pleased with your choice. It is quite a bargain.

    ETA: Note that elec_mech, who just posted in this thread, was the primary designer of the count-down timer project that I linked to.
     
    Last edited: Dec 16, 2013
  16. New2EE

    Thread Starter New Member

    Sep 23, 2009
    19
    0
    Well, the mechanical aspect will vary widely depending on the product. For cigarettes or pills, I think a hopper would be the best, but for candy bars it seems like the tried and true method would be an augur drive like a vending machine.

    Now that I've had some responses and talked about it, I guess I'm going to have to make one of these aren't I? :rolleyes:

    As this is a sensitive subject with some illegal aspects to it, you'll understand why I'm redesigning this project to dispense antibiotics. This particular antibiotic needs to be dispensed 10 a day for 3 weeks, and then 9 and 8 a day for 3 weeks each, then 7,6,5, 2 weeks a piece. 4 a day will be ongoing. Total duration until 4 a day: 15 weeks.

    I may need a more robust lcd display than an 8 seg so I can display how many are left for the day, what week it is, how long before the next week begins, and how many are banked (The banking system doesn't lend itself well to antibiotics but... I'll work that one out on my own lol)

    I picture a rectangle tube big enough for the pills to stack on top of each other horizontally, and long enough to fit 200+ at a time. The tube would have small slits cut in it to allow manual positioning of pills that have fallen in vertically. The dispenser at the end could be as simple as a rod that pushes the bottom pill out and when it returns to home position the stack simply falls. Life isn't always that simple though... You could just pick up the box and shake all the pills out, and the constant falling could damage them. The other idea I had would be the same slide idea, but with a paddle wheel that turns a fixed amount to dispense. The paddles would have to be precisely matched to the pills in order to slip between them naturally.

    If what I'm saying isn't clear, I can paint a picture real quick, but I haven't found a way to upload pictures... Are they only externally hosted?
     
    Last edited: Dec 16, 2013
  17. New2EE

    Thread Starter New Member

    Sep 23, 2009
    19
    0
    I guess that's a good point about the controllers. Sure, pc's are slowly turning into disposable tablets and phones, but if you want your phone to have a warm bath drawn, the lights dimmed, and the blinds closed when you get home, you'll need some microcontrollers :)

    Alright, I officially have "the bug". I'm going to order that kit in the next couple days (I'm in the process of moving too so, it'll be a slow start but my new house has a detached two car garage that has my name on it! LABORATORY! *Evil laugh*)
     
  18. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,871
    1,394
    Here is a photo of my 20x4 LCD being driven by a PICAXE. It is showing the date and time, the current temp, the 24 hour high, the 24 hour low, and what alarms have been activated. As you can see, there is quite a lot of space available for displaying info. I think it will easily fit your needs.
     
  19. elec_mech

    Senior Member

    Nov 12, 2008
    1,513
    193
    No need to elaborate further on the dispensing method - long as you got that covered, we can help with the electronics.

    Aztecmcu has the best deals on PICAXE parts that I've found so far. Do note if you're in the U.S., it will take a week or so to get to you, so don't expect it too soon.

    Would you like help with an electrical design or do you wish to go boldly forward on your own? ;)

    Aztecmcu sells a few other items you might want for your project - again, I strongly suggest coming up with a design and parts list before ordering anything if you wish to save money. I can put something together in a day or two if you're not in a rush.

    As far as the LCD, note the most common are 16x2 and 20x4. You can also get 40x4 if you need a lot of viewing space, but then they're physically large too.
     
  20. #12

    Expert

    Nov 30, 2010
    16,345
    6,831
    I like the idea of a pin poking a pill off the bottom of the stack. I'm thinking about a tube long enough to hold the whole hundred plus pills. Pills don't break very easily, so I don't think that is a problem. Putting a cap on the inventory tube would eliminate shaking the pills out. In fact, trying to shake the pills out could cause a jam and require a (nuisance) service call by the manager.

    There is nothing illegal about a person managing the dosing regime of his own prescriptions pills. If you could train a squirrel to trade you a pill for a peanut every 12 hours, that would be legal, as long as the squirrel does not move the inventory off the property.

    I was looking at how a coin sorter works. A thick, flat plate with the right size holes in it revolves. The inventory tube could be positioned above the flat plate or the plate could receive pills directly from a hopper. This eliminates needing a tube the right size for every pill size, but it requires a different flat plate with holes for the pill size of each customer. However, I think the poking method is cheaper and just as good.
     
    Last edited: Dec 16, 2013
Loading...