Shop OBEX P1 Docs P2 Docs Learn Events
Mini vending machine: here's what im doing... please help! — Parallax Forums

Mini vending machine: here's what im doing... please help!

hmillerhmiller Posts: 17
edited 2011-08-15 19:03 in BASIC Stamp
Hi,

I've been wanting to build a miniature vending machine to stick on my counter that dispensed
small candy bars. I have gotten the servo length and pushbutton right but now I can't seem to figure out how to get the display to show the text "vending..." and "thank you!". I made the positioning right and have it all good to go but i cant get the sequence for "vending..." to align with the servo correctly. please help!

Here's my code so far:

' {$STAMP BS2}
' {$PBASIC 2.5}

DEBUG ? IN1

counter VAR Word

' press button to start vend
IF IN1 = 0 THEN


DEBUG "Vending...", CR

' display "vending..."
HIGH 15
SEROUT 15, 84, [17, 22]
SEROUT 15, 84, [" vending..."]


' start vend
FOR counter = 1 TO 50
PULSOUT 2, 1000
PAUSE 20
NEXT

' display "thank you"
HIGH 15
SEROUT 15, 84, [17, 22]
SEROUT 15,84, [" Thank you!"]
PAUSE 5000
SEROUT 15, 84, [12]

DEBUG "Thank you!", CR

' clear display
SEROUT 15, 84, [12]

ENDIF


Thanks in advance!

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-08-09 09:01
    ...I can't seem to figure out how to get the display to show the text...
    What are we using for a display?
    A serial LCD? Whose? Is it set up for 9600?

    ...align with the servo correctly.
    What's all this then?
  • hmillerhmiller Posts: 17
    edited 2011-08-09 10:57
    I'm using a parallax serial Back-lit display and yes it is set up on 9600. Also, what I mean't by "align with the servo correctly" was how do I get the text to stay on the screen while the servo is running. It takes all text off of the screen when the servo starts.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-08-09 12:15
    how do I get the text to stay on the screen while the servo is running?

    There's no reason (in programming) that it should go out.

    Maybe your servo knocks out 5V to the LCD, when it starts up it makes the 5V (Vdd) sag?
    What happens if you disconnect the servo and run the program?

    Are you using a BoE?
    Are you running your LCD out of one of the BoE servo ports?
    http://forums.parallax.com/showthread.php?133376-Parallax-2x16-Serial-LCD-(Non-Backlit)-suddenly-stopped-working
  • Jimmy LiebJimmy Lieb Posts: 46
    edited 2011-08-09 13:00
    Like PJ said, It is almost certainly a problem having to do with insufficient power. Are you using a 9 volt battery? An adapter plug? make sure the amp rating is high enough
  • hmillerhmiller Posts: 17
    edited 2011-08-09 17:03
    I'm using an 8 volt power adapter which is plenty of power for it. I don't think it could be a power issue cause even when I disconnect the servo it doesn't show any text at all and the light on the display goes out. It has to be something to do with my code.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-08-09 17:35
    So, you're saying that the LCD displays Vending... , if only briefly, and that it blanks out when the servo routine begins?
    I don't see anything in your program to account for that.

    An "8V power adapter" doesn't mean a lot without a current specification to go with it.
    If you have a voltmeter then place it on the 5V at the LCD connector and see what happens there.

    Are you using a Board of Education or what?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-08-09 17:43
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    counter VAR  byte
    
    DEBUG "Vending...", CR
    
    HIGH 15
    SEROUT 15, 84, [17, 22]
    SEROUT 15, 84, [" vending..."]
    
    FOR counter = 1 TO 50
     PULSOUT 2, 1000
     PAUSE 18
     NEXT
    
    DEBUG "Thank you!", CR
    HIGH 15
    SEROUT 15, 84, [17, 22]
    SEROUT 15,84, [" Thank you!"]
    PAUSE 5000
    SEROUT 15, 84, [12]
    


    Just the LCD stuff --
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    DEBUG "vend", cr
    
    HIGH 15
    SEROUT 15, 84, [17, 22]
    SEROUT 15, 84, [" vending..."]
    
    PAUSE 5000
    
    debug "thanx", cr
    HIGH 15
    SEROUT 15, 84, [17, 22]
    SEROUT 15,84, [" Thank you!"]
    PAUSE 5000
    SEROUT 15, 84, [12]
    
  • hmillerhmiller Posts: 17
    edited 2011-08-09 19:37
    I'm using a basic stamp homework board and the voltage its giving is 4.98 volts on standby and when the servo runs the voltage goes down to as low as .1 volts but changes sometimes and can only go down to .5 or above. (If that makes sense), so it would be a power issue, Even though when I took out the code that ran the servo:

    FOR counter = 1 TO 50
    PULSOUT 2, 1000
    PAUSE 20
    NEXT
    It still didnt want to display "vending..." even with the servo not running, and what are the two boxes of code you listed above?
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2011-08-09 21:47
    Which revision of the HomeWork board are you using? It will say somewhere on the board.

    The voltage regulator on the newer models can only provide a max of about 500mA, and the older models only about 50mA, so this may be your problem.
  • hmillerhmiller Posts: 17
    edited 2011-08-10 20:18
    Revision E, if that soumds right
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-08-10 20:32
    That HWB has limited 5V capability.
    It can probably run the LCD, but only with the backlight off.
    Try that.
  • hmillerhmiller Posts: 17
    edited 2011-08-15 18:44
    ok thanks, ill try that!
  • hmillerhmiller Posts: 17
    edited 2011-08-15 19:03
    ok, so this is really odd. I noticed something that I must have added a little after I posted this thread...

    After the line of code:
    SEROUT 15, 84, [" vending..."]

    I added this line of code:
    SEROUT 15, 84, [12]

    Which obviously clears the display, so I took out "SEROUT 15, 84, [12]"... I click the run button in the parrallax basic stamp editor to lauch the new code to the stamp. It runs like it should. It displays the the "vending..." WITH BACKLIGHT WHILE SERVO IS RUNNING, but when I go to click my button on the vending machine it just runs the servo and says "Thank you!" but doesn't display vending like it did right when I launched it. WHAT IS GOING ON?!?!
Sign In or Register to comment.