Pecket Watch B for the Basic Stamp

Discussion in 'The Projects Forum' started by dpkatz, Mar 3, 2006.

  1. dpkatz

    Thread Starter New Member

    Mar 3, 2006
    2
    0
    I am making an automatic pill dispenser which will be placed in bins with stepper motors, the stepper motors will turn and drop them through a photosensor which will make them stop. I also have attached a user interface (Keypad and LCD). I want to make the user put in at what times they want the pills to drop, so I want to use a Pocket Watch B and I want to interface it with my Basic Stamp. I only have two I/O ports left, is that enough to hook it up? Also, I need to turn some stepper motors (already hooked up to the stamp) at specific times, is there a way to program the Pocket Watrch B to turn the stepper motors independently at specified times with or without th Pocket Watch B that will use rwo or less ports.
    I also need to make a menu pop up on my LCD which asks questions as how many pills and what pills you need to take. If so can someone help me with any of these issues concerning the code and/or schematics, it will be greatly appreciated. THANX!!!
     
  2. Papabravo

    Expert

    Feb 24, 2006
    9,910
    1,724
    I'd like to help but

    (1) I'm not familiar with a Pocket Watch B. If it has a serial interface with data and clock then the answer is maybe.

    (2) I'd suggest that the Stamp be aware of the time from the Pocket Watch B and control the motors based on this information and its programming. In controls engineering it is considered VERY BAD PRACTICE to have more than one thing controlling any kind of "output" function. Multiple independent control points is a prescription for disaster and chaos.

    (3) We can help but I think you need to get used to the idea that you're going to have to do the heavy lifting here.
     
  3. dpkatz

    Thread Starter New Member

    Mar 3, 2006
    2
    0
    That's fine, where can I start the menu then? do you have some kind of sample?
     
  4. Papabravo

    Expert

    Feb 24, 2006
    9,910
    1,724
    Not exactly. I think I can get you started.

    You should think of your LCD display as a two dimensional grid: row and column. If you assign each row a row number and each column a column number then every character that you put on the display will have a row and a column number.

    In many programming languages there is a statement similar to:

    printf("Hello World\n") ;

    which is used to demonstrate the construction of a trivial program.

    In your menu system a similar function might look like

    displayf(1,1,"Hello World") ;

    The "1,1" stands for Row=1 & Column = 1.

    If you can get some graph paper or use excel to print out a grid with the appropriate number of squares you can try different arrangements of constant text strings and variable to see how you like them.

    Once you have an arrangement you like you turn it into code as follows

    ...
    clear_screen() ; /* Clear the display by writing blanks to each position */
    displayf(1,1,"Pills.....") ; /* Put the first display item at (1,1) */
    ...
    displayf(4,12,"OK?") ; /* Put the last display item at (4,12) */

    You should make one of these sequences for each of your screens.

    The next thing to realize is that the coordinates do not have to be constants. If they are variables then doing things like scrolling become possible. Only you know what is in your head and what will work for you and what you think looks good. What I think about these style issues doesn't matter.

    Hope this helps.
     
Loading...