Shop OBEX P1 Docs P2 Docs Learn Events
Program is out of control — Parallax Forums

Program is out of control

Mike2545Mike2545 Posts: 433
edited 2009-02-17 05:06 in BASIC Stamp
I am building a "jumping water fountain". There are 12 solenoids around an indoor pond with 1/4"water jets that will each shoot a pulse of water. I have the water and electric installed and I have just finished the control box.

I am working on the program and I'm sure that it can be condensed. I am already using 86% of the memory and want to write more.
It will be motion actuated, so when someone walks by it will start the action.
I have used a lot of Debugin routines to fine tune the timing when I get the control box on site.
The part I think can be condensed is the solenoid firing routines.
Please give me some pointers.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike2545

This message sent to you on 100% recycled electrons.
640 x 480 - 161K
640 x 480 - 211K

Comments

  • Carl HayesCarl Hayes Posts: 841
    edited 2009-02-16 08:00
    Looking at your code, I'd guess that 50% or more of the space it takes is the text of the debug statements. Try abbreviating. Instead of "Jump 3", say "J3". Instead of "Waiting", say "W". Stuff like that. And eliminate any debug statements that aren't actually needed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
  • SRLMSRLM Posts: 5,045
    edited 2009-02-16 08:34
    I haven't seen the ':' operator used in the solenoid control routine before, but it looks like you can condense it to something like:

    IF mynum =0 THEN GOTO program_mode 
    HIGH mynum
    PAUSE timeon
    LOW mynum
    GOTO solenoid_control
    
    



    Your test, Jump2-5 routines can each be condensed by putting everything into a loop, and having a lookup table to determine which pins to turn on/off. It will reduce 48 lines of your test routine to 7 lines, for example.
  • Mike2545Mike2545 Posts: 433
    edited 2009-02-16 15:58
    Carl: I have reduced the text and it shaved about 18%, Thanks

    SRLM: I was thinking about the Lookup/lookdown commands but have not used them in a program before. Guess I'll hvae to play around with that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • Mike2545Mike2545 Posts: 433
    edited 2009-02-16 19:37
    That's more like it! tongue.gif

    I have reduced the long string of information to 7 lines using LOOKUP smile.gif
    Total program space 54%.
    That leaves plenty of room to add more solenoid firing routines.

    If you can find a way to shave off more memory please let me know.

    I have some more pictures to share and I'll post video on You tube when its done.

    Thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
    640 x 480 - 220K
    640 x 480 - 118K
    640 x 480 - 211K
  • SRLMSRLM Posts: 5,045
    edited 2009-02-16 20:07
    You can probably reduce all your jump routines to a single routine, and just input different values. I'd store the sequences in the EEPROM as data, and have a pointer to each section. Then, you just select the pointer you want to use and READ the for a set number of iterations. However, this method requires that each sequence has the same format (duration, number of solenoids on simultaneously, etc.). Looking good.
  • Mike2545Mike2545 Posts: 433
    edited 2009-02-16 20:19
    Yeah, I had to overcome the dual solenoid "on" commands with a second frog_number as is.
    I think that for the sake of versatility I'll keep the format like it is. (With the ability to run 1 or 2 solenoids & different numbers of them)
    I can write enough different firing routines with the available memory to keep it changed up.
    & I learned about LOOKUP

    Thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • ercoerco Posts: 20,256
    edited 2009-02-16 20:37
    Cool project, Mike! Looking forward to seeing your Youtube vids. I'm curious what type of valves you are using for this project. Presumably something heavier-duty than ordinary sprinkler valves, which take a lot of beating from water hammer when they close suddenly. Hydraulics is an unforgiving and brutal science!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • Mike2545Mike2545 Posts: 433
    edited 2009-02-16 20:49
    I got an e-bay special, 25 Parker solenoid valves for $36.00, with shipping it came out to around $3 per valve.
    Sprinkler valves open and close too slowly. I have tested out the valves (before trenching) and water hammer is not an issue.

    These valves have 1/4 inch NPT threads and 24 volt coils.
    Rated 1900 KPa which is about 275lbs/sq in
    Brand new valves for $3 each! I can't hardly believe that!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • SRLMSRLM Posts: 5,045
    edited 2009-02-16 21:00
    What I thinking is that you store the values of which valves are on/off as words in the main memory. Then, you can have all the valves on or off or any combination thereof at any one moment in time. You just then use OUTS to turn the solenoids on or off. It will take a bit more work to get started, but it's much more extensible after that.
  • Mike2545Mike2545 Posts: 433
    edited 2009-02-16 21:41
    The basic stamp is driving .2 milliamps per transistor/relay combo so I can drive all of them at once and only draw 2.4 milliamps.
    The solenoids are running at .46Amps, the transformer is 2A. I can have up to 4 on at one time without overloading the transformer.
    I would need a 6 amp transformer to turn them all on at once. So I'm limited in that respect but I think it will be OK (visually).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • Mike2545Mike2545 Posts: 433
    edited 2009-02-17 00:08
    I shot a short video of the control box executing its programs.

    I hope to have it up and running this week, although I only have a short window of time, I may have to put it off till next week.



    www.youtube.com/watch?v=a-llFTYLhig

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • MrBi11MrBi11 Posts: 117
    edited 2009-02-17 05:06
    How about pre-programmed patterns in EEROM?

    [noparse][[/noparse]see attached]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Smile ... It increases your face value!
Sign In or Register to comment.