Shop OBEX P1 Docs P2 Docs Learn Events
I need help making a servo open a hatch for a period of time then closing. Once a day — Parallax Forums

I need help making a servo open a hatch for a period of time then closing. Once a day

greenanolegreenanole Posts: 13
edited 2012-05-14 17:09 in BASIC Stamp
Do ya'll have any ideas on how to accomplish this...?
«1

Comments

  • tobdectobdec Posts: 267
    edited 2012-05-07 23:29
    hatch meaning? your question is pretty vague...
  • IroneIrone Posts: 116
    edited 2012-05-07 23:46
    If you want a pin to go high for a period of time and then go low a pause command will work. How close to you want once a day to be held?
  • greenanolegreenanole Posts: 13
    edited 2012-05-08 05:52
    I am sorry. The servo will open the hatch.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-08 05:59
    Do you already have a microcontroller in mind you want to use?

    What kind of power source do you have? Does this need to be powered by a battery?

    How precise does it need to be?

    BTW, Welcome to the forum.
  • greenanolegreenanole Posts: 13
    edited 2012-05-08 06:28
    Basic stamp. I am not too experienced.
  • greenanolegreenanole Posts: 13
    edited 2012-05-08 06:30
    It will be battery powered. It needs open the door at the same time everyday. Just say if you have any questions.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-08 06:51
    Have you learned how to control a servo with a Basic Stamp yet?
  • tobdectobdec Posts: 267
    edited 2012-05-08 09:35
    I guess my question was is it a car hatch or a small door on a project? If it is a car hatch you have a totaly new issue at hand.
  • greenanolegreenanole Posts: 13
    edited 2012-05-08 10:17
    I think I know how to control the servo. It's just timing it to move to a certain position is what I can't figure out.
  • greenanolegreenanole Posts: 13
    edited 2012-05-08 10:18
    I am going to get a basic stamp kit and start experimenting.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-08 10:19
    It partly depends on what you mean by "the same time every day". If you don't need accuracy ... if the time can drift a couple of minutes a day, then you may be able to use PAUSEs to create the time delay needed. If you need more accuracy than that, then you will need some kind of external real-time clock. There are examples of this in the Nuts and Volts Columns available from Parallax (click on the Resources tab on their main webpage). Keep in mind that we get tired of playing "twenty questions". The more detailed information you can supply, the better the answers and advice you will get. SparkFun sells several different real-time clock "breakout boards" that are very nice to work with and come already with a backup battery and battery holder. Most use the I2C protocol for connecting to a Stamp or whatever. The BS2 doesn't have the built-in I2C statements of some of the other Stamp models, but the Nuts and Volts Columns have sample code for handling I2C devices using a BS2.
  • greenanolegreenanole Posts: 13
    edited 2012-05-08 14:04
    tobdec wrote: »
    I guess my question was is it a car hatch or a small door on a project? If it is a car hatch you have a totaly new issue at hand.

    It is a small door on a project that flips open. Like a door in a house. Does this make sense...??? I'm not sure.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-05-08 14:10
    greenanole wrote: »
    It is a small door on a project that flips open. Like a door in a house. Does this make sense...??? I'm not sure.

    That can mean a lot of different things. Small is relative. It is best to give some approximate dimensions. If you can't do that then compare the size to something that is commonly known such as - "a door the size of a pack of playing cards".
  • tobdectobdec Posts: 267
    edited 2012-05-08 17:37
    greenanole wrote: »
    It is a small door on a project that flips open. Like a door in a house. Does this make sense...??? I'm not sure.
    Like is it a doll house, a dog house, a real life size house, a model car or airplane, an ant farm, ET's space craft being repaired lol.
  • greenanolegreenanole Posts: 13
    edited 2012-05-08 18:54
    Let me just take it from the top to clarify things. My friend has a reptile and he wants me to make an automatic cricket dispenser. (Sounds odd!)
    I need to build a box that has a 2 x 2 in door on it. (The door will open from the bottom of the box)
    I will need it to open at a certain time of day for x amount of seconds. I don't need it to be extremely accurate. I still need to figure how long it needs to be open by trial and error.
    The box itself is about a 1 foot square. 5-6 in deep.
    The problem is, it needs to be powered from the wall most likely because he goes out of town for weeks at a time.
    So I basically need info on making it turn a servo 45-70 degrees once a day. The arrow in the CAD is pointing to the door which will open about about 45-70 degrees. Exact angle has not been determined yet.
    If this does not clarify my project, just tell me. (I'm new to this forum and not too experienced)
    Thank you

    Sorry for not being detailed at the start.
    Screen shot 2012-05-08 at 9.12.23 PM.png
  • W9GFOW9GFO Posts: 4,010
    edited 2012-05-08 19:33
    Good explanation.

    Powering from the wall is not a problem. This power supply would work well: http://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/73/Default.aspx?txtSearch=power+supply

    I would consider a different mechanism for opening the door. It seems that it would be better to have a small hole in the wall separating the cricket chamber from the electronics rather than a slot that little crickets can get through. I would use a push rod to actuate the door. Much the same way as is used on RC airplanes to control the control surfaces.

    attachment.php?attachmentid=92341&d=1336530836
  • W9GFOW9GFO Posts: 4,010
    edited 2012-05-08 19:40
    As far as the timing...

    Does it matter if the time off day gets shifted a bit each day? The Basic Stamp can keep approximate time. It will accumulate errors. For example, you might program it to actuate every 24 hours but in reality it may operate every 23 hrs and 55 minutes (gross estimate, I have no idea how much off it would be). After a few weeks it would be hours off. This may be of no consequence in this application. Also, you can tune your timing based upon observation to better match the real time.
  • greenanolegreenanole Posts: 13
    edited 2012-05-08 20:05
    So I could find a mechanism for RC planes on the web and just attach a servo on the outside. I would want it to open in the middle of the day so it would be opened when his lizard is awake. The push rod will work a lot better then my first plan. He wanted the crickets to drop from the top of the cage. Thanks for that info. It help alot. :)
  • IroneIrone Posts: 116
    edited 2012-05-08 21:16
    So how many crickets are necessary for feeding? You could measure the weight of 10 or 15 crickets and divide by the number of crickets and find how much a normal cricket weighs. Then you could have a strain gauge attached to close the door (slowly) so you would not overfeed the reptile(s). You could also use a light activated transistor to open the door at first light with a capacitor and resistor arrangement to eliminate lightning strikes at night and a pause command to get you through the day. If the reptile(s) cannot find the crickets when they are hungry they should die of stupidness. (This dictionary does not consider stupidness a word and needs to be updated)
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-08 21:29
    Look at pictures of R/C servos if you haven't already. They have either a disc mounted on the shaft or a cross-like "4-horn" adapter, either shape with holes for piano wire which becomes the "push rod". As the servo shaft turns, the piano wire can push / pull the door so it opens and closes. The "What's a Microcontroller?" tutorial and the "Robotics with the BoeBot" tutorial discuss how servos work and gives lots of examples. Both are included in the help files when you install the Stamp Editor which includes the Parallax Basic compiler. You can also download the tutorials by going to Parallax's main webpage and clicking on the Downloads button. On the downloads page, these will be under "Educational Tutorials & Translations". You can also download the "Basic Stamp Syntax and Reference Manual" under "Stamp Documentation". To wait 24 hours, you'd do:
    hours   var   byte
    minutes   var   byte
    seconds   var   byte
    
    for hours = 1 to 24
       for minutes = 1 to 60
          for seconds = 1 to 60
             pause 1000
          next
       next
    next
    
    To move the servo through somewhere from 90 to maybe 120 degrees you'd do:
    servo   pin   1   ' or whatever I/O pin the servo is connected to
    count   var   byte
    
    for count = 1 to 50   ' allow 1 second for the servo to move to the open position
       pulsout   servo, 500   ' this number could be as low as 250 depending on the servo
       pause 20   ' servos need about 20ms between pulses
    next
    for seconds = 1 to 15   ' whatever number of seconds the door should be opened
       pause 1000
    next
    for count = 1 to 50   ' again, allow about 1 second for the servo to move to closed position
       pulseout servo, 1000   ' this number could be as high as 1250 depending on the servo
       pause 20  ' servos need a 20ms pause between successive pulses
    next
    
    Somewhere in your program's initialization, you'd need to make sure the door is closed. Have
    another copy of the last 4 lines above to do this.
  • greenanolegreenanole Posts: 13
    edited 2012-05-08 21:45
    I have done some research and found its complicated to use a basic stamp as a long term timer due to errors. Is there a different controller that would work the best?
    Never mind this post.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-09 06:32
    It's not really complicated. I had an application very similar to yours except that I had to turn on a drainage pump roughly every 24 hours for one minute. I used a BS1 I had around ... worked great. The time would drift. The program was a little different and adjusted for the time the pump was on. You'd turn it on, the pump would run, then wait until 24 hours later and repeat. If the time drifted too much, all you had to do was to turn it off and on when you wanted it to start over again. Over a week, it drifted a couple of minutes.
  • tobdectobdec Posts: 267
    edited 2012-05-09 19:07
    What if you used something like this http://www.amazon.com/Fish-Mate-F14-Aquarium-Feeder/dp/B000YK5W18/ref=pd_sim_sbs_k_3 in conjunction with your stamp by modifying the compartments and the stamp auto loading the crickets? Lets face it..the BS2 is horrible at keeping time.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-05-09 19:32
    tobdec wrote: »
    Lets face it..the BS2 is horrible at keeping time.

    A couple minutes drift over a week (per Mike Green) is not horrible at all in my opinion, pretty good actually.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-09 20:00
    If you haven't chosen a microcontroller yet, you ought consider the Propeller. I think it would be a better time keeper and it could easily interface with a real time clock module or even a GPS unit (a BS2 could also be used with a RTC or GPS). Plus you can buy two Propeller QuickStart boards for about the same price as one BS2. They're even less expensive than a BS1 (and way more powerful).
  • OrbilusOrbilus Posts: 10
    edited 2012-05-10 10:02
    The middle of the day is easier to determine than "once a day". you could have your BS2 activate the door an ammount of time after sunrise, determined by a solar cell or similar sensor outside. A solar cell could also be used to charge batteries if you don't want to plug it in to the wall. I suppose it all depends on if you live in Alaska or Arizona how much sun you get each day... lol. Other inexpensive time keepers include lighting timers like you would use for turning on and off house lights while you are away.
  • greenanolegreenanole Posts: 13
    edited 2012-05-14 11:45
    The problem is, sometimes he need it for 1-2 weeks. I could do it for one day but even a few days is tough because it needs to be alive. There are timers that can be used. All I would need to do regulate the current and build the holding box for the crickets. What do y'all think?
  • greenanolegreenanole Posts: 13
    edited 2012-05-14 11:53
    Have y'all heard of the seconds timer from mistking? Do you think that I could use it to power a motor instead of a mister?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-14 12:14
    The problem you'll have no matter what kind of timer you use is the need to control the motor.

    Servos, are very easy to use with a microcontroller.

    I don't know how precise time kept by a Propeller wouild be but it should keep it will enough it keep your friends reptile happy.

    You could use QuickStart board and use its LEDs as a binary countdown to feeding time. If the time were noticeably off, you could use the touchpads to correct the time.

    I used the QuickStart's touchpads as inputs to control a servo in my QuickStart servo tester. I also used its LEDs as a way to indicate the various parameters of the tester.
  • greenanolegreenanole Posts: 13
    edited 2012-05-14 17:09
    The mist king seconds timer is used to power a pump continuously. Not turn a motor this way then that way. How about when the timer goes off, it triggers a vacuum of some sort that pulls them into the cage. That way I would have an idea of how many crickets went in instead of assuming that they were just going to fall, which they might not.
Sign In or Register to comment.