Shop OBEX P1 Docs P2 Docs Learn Events
STAMP stuck - Cat hungry — Parallax Forums

STAMP stuck - Cat hungry

TheRooDawgTheRooDawg Posts: 3
edited 2008-02-09 17:19 in BASIC Stamp
Hello all,

I've built a machine that will feed my cat a consistent amount every 6 hours; however, I am having some erratic problems with my Stamp.

I am using a BS2 and a Board of Education.· I have a 6V, 300mA wall transformer powering the board.

All my program does is pause for 6 hours and then runs a little motor for two·short cycles.· The motor comes from·an Errector Set from way back in the day.· The motor runs just dandy off two AA batteries (3V).· Pins 6, 7, 8 and 9 are outputs to different color LEDs that successively light up letting me know the program worked while I was not home.· There is some additional code that plays "Three Blind Mice" through a piezo buzzer (to let my cat know the food is about to dispense)·at pin 0, but I eliminated that here to save space.· The motor is operated by an NPN transitor when the stamp sends a High signal to the Base leg·of the transistor.· The Collector leg·is connected to Vdd and motor to the Emitter leg.

Previous versions have worked just fine when I·used a continuous rotation servo motor.· Now that I have this little DC motor, the stamp has started to freak out.· Sometimes the stamp will get stuck before it even turns on the first LED; however, most of the time the LED lights up, but either the motor doesn't turn or the motor turns continuously (i.e. program never gets to LOW 1 in the Feed subroutine.)

I am questioning whether I am simply trying to use too much power...· I replaced the wall adapter with a simple 9V battery, and things worked fine, but the battery went dead after about 6 hours.· Should I be using a 9V 300mA wall adapter?


[size=2][code]
' {$STAMP BS2}
' {$PBASIC 2.5}
hours VAR Word
minutes VAR Word
minute VAR Word
cycles VAR Word
cycle VAR Word
counter VAR Word
counter2 VAR Word

 
hours = 6           'Feed every # hours
minutes = hours*60  'Hours to minutes
minute = 59700      'Error compensated milliseconds per minute
cycles = 2          'Number of feeding revolutions
cycle = 1225        'On time for one revolution
 
FREQOUT 0, 200, 3000    'Initial beep & pause
PAUSE 5000
 
DO
LOW 9
HIGH 6
GOSUB work   'Breakfast

 
LOW 6
HIGH 7
GOSUB work   'Lunch

 
LOW 7
HIGH 8
GOSUB work   'Dinner

 
LOW 8
HIGH 9
GOSUB work   'Midnight

LOOP
 
' ---- Subroutine: Work ----------
work:
  GOSUB feed
  GOSUB time
RETURN
 
' ---- Subroutine: Time ----------
time:
FOR counter = 1 TO minutes
  PAUSE minute
NEXT
RETURN
 
' ---- Subroutine: Feed ----------
feed:
FOR counter = 1 TO cycles
  HIGH 1
  PAUSE cycle
  LOW 1
  PAUSE 1500
NEXT
RETURN


[/code][/size]
Another question, is there a cheaper chip I could use to accomplish this same type of program?· Seems like the Stamp is overkill for just pausing 99.99% of the day.· I know I could probably use a DS1302 to get more accurate timing, but it is not super critical - my cat doesn't own a watch.· Perhaps a SX chip?

·Any help appreciated!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-08 23:04
    There's a huge difference between controlling a servo motor with a Stamp and controlling a small DC motor with a Stamp.
    A servo motor is controlled by a logic level signal with no appreciable power required from the Stamp. A DC motor will draw
    way more power than a Stamp I/O pin is capable of providing (maximum 20mA and not too many at once please). You need
    to have the Stamp control a switching transistor and that can switch the power to the motor. If you need for the motor to
    go in both directions, you can either use a relay to reverse the power connections or use what's called an H-bridge.

    Download the StampWorks Manual and the Industrial Control Manual from Parallax's website. Use the search box on the
    main webpage and look for "StampWorks" and "Industrial Control". They have examples of circuitry and programs.
  • Mike CookMike Cook Posts: 829
    edited 2008-02-08 23:21

    As for a cheaper chip to run your program on, I would suggest the following:

    Develop the application on the Basic Stamp, if the BS2 can handle the application then you might take a look at the SX chips. You can purchase SX Proto Boards from Parallax for less than $10.00 each. Basic Stamp code is fairly easy to port to SX/B (Parallax's FREE Basic Compiler). Note: you will also need a SX Key or SX Blitz to program the SX Proto Board. Proto Boards come in two flavors SX28 and SX48, both the same price.

    Purchasing a SX Proto Board ($10.00), Blitz Programmer ($30.00), and using SX/B (FREE) is no cheaper than using a Basic Stamp. However the cost saving happens as you port more programs to SX/B and build more projects, you only have to purchase one programmer (unless you break it).

    If the project is one of those where you don't know how much "Horse Power" it will take to end up with a finished project, then the Propeller Proto Board($20.00) and a Prop Plug ($25.00) may be a better option.


    <EDIT>

    As for motor noise resetting my micro, when the micro and the motor shares the same power supply. I usually follow the attached document. Can't remember who I 'Hi-Jacked' this from but has worked well for me.

    </EDIT>

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike

    Post Edited (Mike Cook) : 2/9/2008 12:03:40 AM GMT
    656 x 843 - 107K
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-02-09 17:19
    You said the program worked on the 9V battery (albeit for a short time) but not on the 6V wall supply. This tells me the DC motor is sagging the supply and possibly browning out the Stamp Module. Also, your transistor configuration should be, emitter to ground (Vss), collector to one side of the motor and the other side to 9V (Vin). The base should be connected to the I/O pin though a 1K resistor and finally, the motor leads should have a diode across them in reverse bias. I hope this helps (your kitty). Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.