Shop OBEX P1 Docs P2 Docs Learn Events
How to pause output but not time keeping ? — Parallax Forums

How to pause output but not time keeping ?

lockadoclockadoc Posts: 115
edited 2009-09-25 03:04 in Propeller 1
I'm making an eight channel·light timer program, in one clog the output will be timed, but when an input goes high an other clog will·take over the output for three minutes than return control back to clog one. how can I make clog two control the output while clog one still keeps its timming, but not change the output during that three minutes?



The main goal I'm going for in this program is an Eight channel light timer for some party lights.
···· I have a four hundred foot long chain of 120 volt lights. the controller will be in the middle with
···· four channels (red,blue,yellow,green)to the left and four to the right using 8)25amp solid state relays.All the lights will
···· come on at dusk,than at 11:00pm 2 channels will go off, at 12:00am 2 more cannels will go off, than at 1:00am
···· 2 more channel will go off. Leaving the two remaing channels on until dawn.

·Added features:
···· 1- Have some preprogrammed light displays· (something like the Experiment #7:"A Lighting Controller"
········ from the book basic stamp book StampWorks and the "Mother of all LED sequencers" from the Propeller
········ object exchange) that run for a few minutes than return to the default light timing control
····· 2- A tv remote control to change the light display ( buttons 1-9 would change the way the lights would flash)
····· 3- With the push of a button (one on the contoller box with an other on the Tv remote control)
········· all lights will go back on for one hour then return to the default timing control.




thanks BillyS

Post Edited (lockadoc) : 9/22/2009 4:01:28 AM GMT

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-16 15:37
    Hello Billy,

    I'm unsure if I understand right. You wrote "clog" do you mean "clock" a time measuring and time displaying "machine"
    or do you mean "cog" which means one of the 8 processors-cores of the propellerchip ?

    The answer to your question depends on your meaning of "clog".

    If you have any lines of code - even if they don't compile - create an archive using the file-archive-function of he propellertool and attach the archived code with the attachement-manager
    to a posting.

    best regards

    Stefan
  • dMajodMajo Posts: 855
    edited 2009-09-16 16:30
    lockadoc, are you sure you want to use 2 cogs? The application cannot fit just one?

    If you need 2 then eg.:
    cog·1 will manage the outa(1) according to your timing scheme. It will look over ina(2) and while it is high·will keep the dira(1) in input state thus·leaving complete control over out(1) to cog1. While the out(1) becames input the cog·1 can still continue in it's timing writes to outa(1) register without afecting the phisical state of the prop pin.
    cog·2 will continuously copy the ina(1) to the outa(1). While the ina(2) is low the dira(1) will be·input otherwise it will be output (for 3 minutes)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · Propeller Object Exchange (last Publications / Updates)

    Post Edited (dMajo) : 9/16/2009 4:38:03 PM GMT
  • TimmooreTimmoore Posts: 1,031
    edited 2009-09-16 16:54
    Another option is to use the way pin outputs are ored. When cog 1 has control, it sets dira to output and cog 2 sets it to input. When cog 2 has control, cog 1 sets dira to input and cog 2 sets dira to output. Then cog1 and 2 just update outa when they have control.
    Look at figure 1-2 in the prop manual
  • AribaAriba Posts: 2,690
    edited 2009-09-16 17:23
    Another way:
    Use 1 pin for cog1, and another for cog2 and combine theme with a resistor as in the attached picture.

    While the cog2 pin is an input, the cog1-pin has the control over the output level.
    If cog2 needs to control the Light, set the cog2-pin as output and then you can overwrite the state of cog1
    with high or low.

    Andy
    174 x 77 - 455B
  • lockadoclockadoc Posts: 115
    edited 2009-09-17 00:38
    Ok here is what I want to do
    at dusk all 8 channels come on,than about three hours later 2 channels go off, than one hour later two more channels go off, than one more hour until two channels go off. the last two remaining channels stay on until dawn. but when an input button is pressed all 8 channels do a razzle dazzle display for three minutes

    Thanks BillyS

    Post Edited (lockadoc) : 9/17/2009 12:44:21 AM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-17 13:59
    Hello Billy,

    so now it is much clearer what you want to do.

    For this you can use one single cog. In another way two cogs

    The main thing is to use TWO different variables that contain the bits set or cleared.

    with these two variables you make the bitwise logical operation "OR"

    example

           10010
        or 11100
    result 11110
    
    



    by bitwise "or-ing", if a bit in variable 1 OR in variable 2 is set, the result is: bit set

    at the beginning all 8 channels on

    %11111111
    now in your program you have one cog running a loop that checks if 3 hours are passed: channel 1 channel 2 off
    new value %00111111

    since start 4 hours passed channel 3 and channel 4 off
    new value %00001111

    since start 5 hours passed channel 5 and channel 6 off
    new value %00000011

    the second cog has a loop watching the inputpin

    if input pin is high
    set value of variable 2 to all 8 channels on %11111111
    start 3 minute timer
    after three minutes set value of variable 2 to %00000000

    in cog 1 inside the loop you calculate the result of the bitwise or of variable 1 and variable 2

    example

    three minutes on (variable 2 has value %11111111)
    variable 1 %00000011   bitwise or with
    variable 2 %11111111   
    result     %11111111
      
    after three minutes off again (variable 2 has value %00000000)
     
    variable 1 %00000011    bitwise or with
    variable 2 %00000000
    result     %00000011
    
    



    that's the basic principle

    if you need more help on programming this
    post your first attempt of code - even if it does not compile - and ask questions whatever you like

    by posting YOUR code you show the forum what you have tried and how far you did get with it.
    it doesn't matter if you have just gone 0,001 inch or half the way it just shows you DID what you could do
    on your own.

    best regards

    Stefan

    Post Edited (StefanL38) : 9/17/2009 2:08:01 PM GMT
  • lockadoclockadoc Posts: 115
    edited 2009-09-18 03:12
    Thanks it will take me a day or two to chew on your input.

    BillyS
  • lockadoclockadoc Posts: 115
    edited 2009-09-18 17:40
    Here·is the code that I've so far,, Its still a work in the beginning stages.

    At present I have all the hardware set up, and tested to see if they work, just they are not tied together for my needs.
    If I can just be pointed to the right·direction for each question I ask ( I'm only going to ask one at a time·so i can work on it),,
    I'd love to get this up and running Now. but I·don't want the answers given to me so it most likely going to take a month or two, I'm trying to teach myself how to do this.
    I'm not finding this easy to do·, I do love the challenge. File Is Attached "TIMER-LIGHT"
    BillyS
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-18 22:30
    Hello Billy,

    I took a quick look into your code.
    From looking at it 3 minutes I don't understand the concept
  • lockadoclockadoc Posts: 115
    edited 2009-09-19 02:32
    Ok thanks that does make sense, I'll try to redo it.But what if the object has way more than I need? I thought stream lining code·was a good thing to save space.

    Thanks for your support and input.

    BillyS


    Post Edited (lockadoc) : 9/19/2009 2:38:30 AM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-19 06:49
    Hello Billy,

    as long as your not running out of longs (I mean RAM) it doesn't matter.
    When RAM gets short or if the development is finished comment out lines of "PUBs" that you don't need

    best regards

    Stefan
  • lockadoclockadoc Posts: 115
    edited 2009-09-20 02:24
    Thanks

    I'm working on making the changes you suggested, that makes it a lot easier to work it out.

    BillyS
  • JonnyMacJonnyMac Posts: 9,198
    edited 2009-09-20 16:23
    You seem to be using a very old timer object that I wrote and I'm going to suggest a new one. When I worked in the irrigation industry designing sprinkler timers we treated time of day as a value between 0 (midnight) and 1439 (11:59 PM). To that end I've added a method to my new timer called todmins() -- this will return the time of day expressed in minutes.

    Still, you don't have to use this object for time of day, you could use it to keep track of elapsed time. When you detect dark (dusk) you call the .reset() method to clear the registers. You can then poll the .todmins() method to schedule your other events (3 hrs = 180 mins, etc.). In a loop I would call the .getsecs() method and when it's zero do the other checks. Based on what you're doing checking every thing once a second should be fine.

    The only possible problem could be a reset of the program when dark, because you would never see the light-to-dark transition that kicks off the lights.

    I've attached my new timer and a demo so you can see how it works.
  • lockadoclockadoc Posts: 115
    edited 2009-09-21 06:18
    Thanks to all

    I'm working on using all the input given so far.



    BillyS
  • lockadoclockadoc Posts: 115
    edited 2009-09-21 08:25
    With all the input I've gotten ,I am starting over
    My first question Is
    How do I get· the first set of lights to go off after three minutes?
    I think if i see how its done I can work on·getting the rest of my timing taken care of
    JonnyMacs timing program is just what I needed(·I really like the total Minutes of the day part.)
    Thanks BillyS

    Post Edited (lockadoc) : 9/21/2009 3:59:52 PM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-21 17:22
    Hello Billy,

    you mentioned you would like to find out the coding yourself.
    according to this I give you some hints to work it out.
    If YOU want to have more help ask whatever you like

    you have to take a snapshot of the time when the lights should go on or all 8 lights are switched on

    then RELATIVE to this timestamp you calculate the time that has passed in a loop

    if actualtime - timestamp => 2 '(hours) or 120 minutes
    actualPattern := Light1

    if actualtime - timestamp => 3 '(hours) or 180 minutes
    actualPattern := Light2

    for easy testing change to minutes or even 5 second steps so you don't have to wait for hours until something changes

    if you want me to compile your code use the archive-function of the propellertool
    (main-menu file - archive - project

    the zip-archive will include ALL files that are nescessary to compile the whole project
    regardless of where the files are stored

    best regards

    Stefan
  • lockadoclockadoc Posts: 115
    edited 2009-09-21 21:39
    Thanks

    This is what I needed.You will see a big difference next time I post here.

    Thanks Again

    BillyS
  • JonnyMacJonnyMac Posts: 9,198
    edited 2009-09-21 21:59
    If you're just doing relative timing from the last event you can call the .reset() method in my new timer and then check the .todmins() -- that will tell you how long it's been since the last time it was reset. If you have multiple events related to some start point then Stefan's advice is best.

    [noparse][[/noparse]Edit] You might want to spell out your full requirements for the program (in detail) and let others have a whack at it. You seem very new, and this is a bit sophisticated. Seeing solutions from several sources will help you develop your programming skills without getting too bogged down.

    Post Edited (JonnyMac) : 9/21/2009 10:04:27 PM GMT
  • lockadoclockadoc Posts: 115
    edited 2009-09-22 03:57
    Yes I am new to programing,,I started with the basic stamp Boe-Bot than· got the BS2 devlopment board ,started playing with that and thought·of Idea of making this timer and realized I would be taxing the stamp for what I wanted to do.Thats what brings me to the PROP.·The more I read about the prop the more I'm amazed at what it can do. I do find it hard to learn on my own, but thats part of the fun. As far what I'm trying to do I thought I stated it in the begining of the program I'm trying to write.






    ·The main goal I'm going for in this program is an Eight channel light timer for some party lights.
    ···· I have a four hundred foot long chain of 120 volt lights. the controller will be in the middle with
    ···· four channels (red,blue,yellow,green)to the left and four to the right using 8)25amp solid state relays.All the lights will
    ···· come on at dusk,than at 11:00pm 2 channels will go off, at 12:00am 2 more cannels will go off, than at 1:00am
    ···· 2 more channel will go off. Leaving the two remaing channels on until dawn.

    ·Added features:
    ···· 1- Have some preprogrammed light displays· (something like the Experiment #7:"A Lighting Controller"
    ········ from the book basic stamp book StampWorks and the "Mother of all LED sequencers" from the Propeller
    ········ object exchange) that run for a few minutes than return to the default light timing control
    ····· 2- A tv remote control to change the light display ( buttons 1-9 would change the way the lights would flash)
    ····· 3- With the push of a button (one on the contoller box with an other on the Tv remote control)
    ········· all lights will go back on for one hour then return to the default timing control.

    Without the input from from these forums I think I might have giving up on trying to learn programming when I first got the Boe-Bot.
    Thanks to all the people that have·answered my question over the years.

    Thanks From BillyS in Louisville Ky.
    ·
  • JonnyMacJonnyMac Posts: 9,198
    edited 2009-09-22 15:22
    Well, that's just a re-hash of what you posted before... and it lacks a lot of specifics (and has them where it doesn't matter, like the length of the light strings and the colors). Do you have a dusk detector in mind? What happens if the program gets reset in the middle of the night and can't see the light-to-dark transition? Should it go into a fail safe mode? What is the sequence of the output patterns? What is the timing between each?

    I'm quite sure you have this all perfectly clear in your head, but just ask you can't see what I'm wearing we can't see what's inside your head. tongue.gif
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-22 18:07
    Hello Billy,

    you attached a first program that contains a line

      repeat until minutes <3 then light1
    
    



    From this line of code I can guess you might want help how to code the light switching. If you post a concrete question you will get answers very quickly.

    You can post a new question every hour (REALLY)
    and you will get answer after answer. I really enjoy this way of posting.

    There is only one thing that I (and I guess the other forum members too) don't like:

    I don't like posting a 100 pages tutorial "all about programming the propeller from A to Z"

    So it is up to you to post a clear statement what kind of help you want to have as next step as a CONCRETE question.

    best regards

    Stefan
  • lockadoclockadoc Posts: 115
    edited 2009-09-24 15:32
    Well guess I have to break my learning down to little steps.

    right now I'm just trying to call a method· with out passing any parameters, and don't see

    anywhere to do it from the PROPELLER EDUCATION KIT LABS:FUNDAMENTALS book

    Can someone show me how its done with what I've written?

    I know it must be something simple,(so simple that I will most likely will·slap my head)
    when·I try to load it I get an error the object I'm trying to load I got from the object exchange.

    Thanks
    ··· BillyS

    Post Edited (lockadoc) : 9/24/2009 3:59:13 PM GMT
  • photomankcphotomankc Posts: 943
    edited 2009-09-24 15:40
    Well, starters would be using lightshow.(method name) not lightshow|(method name). Also when communicating with others it will help if you refer to Objects as Objects and not Programs. Lightshow is an object that is included in the code to your program when it is compiled.

    Post Edited (photomankc) : 9/24/2009 3:45:11 PM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-09-24 23:14
    Hello Billy,

    first of all: use the archive function of the propeller-tool to attach code

    You find this function in the propeller-tool in the main-menu
    under file - archive -> project...

    make that tab the actual tab that contains your main subroutine
    then click

    file - archive -> project...

    by using the archive-function ALL files were zipped together that are nescessary to compile your project

    from your single file test2.spin where you refer to another *.Spin-File called "LedSequencer_asm.spin"

    I can't help you because I cannot see what is INSIDE the file "LedSequencer_asm.spin" .....

    You have luck as I have the file from the general installation of the propeller-tool

    OK the file "LedSequencer_asm.spin"
    has a method
    PUB Main
       cognew(@Step000,@Pat1)     ' asm routines always start in a new cog
    
    



    this method does NOT fullfill the quasi-standard how methods in objects should be named

    EVERY object SHOULD have a method named "Start"

    you should modify the file that you have these two methods

    VAR
      long  cog                     'cog flag/id
    
      
    PUB Start : okay
      stop 'avoid double starting by first stopping
      okay := cog := cognew(@Step000,@Pat1) + 1
    
      
    PUB stop
      '' Stops and frees a cog
    
      if cog
        cogstop(cog~ - 1)
    
    




    and in your file test2.spin you refer to your object "lightshow" by

    Pub main
    
    dira[noparse][[/noparse]16..23] := %11111111                                      ' turns pins 16-23 as outputs
        repeat
          outa[noparse][[/noparse]16..23] := %11111111                                ' turns pins high
          repeat until ina[noparse][[/noparse]26]                                     'keeps pins high until button 26 is pushed
            lightshow.Start                                        ' TRYING TO CALL NEW PROGRAM
    
    



    in the exact same way as you start the timer-object.

    You only have to call the start-method ONCE as the start-emthods starts another cog in which the PASM-code is running in a loop itself

    best regards

    Stefan
  • lockadoclockadoc Posts: 115
    edited 2009-09-25 03:04
    Hello Stefan Thanks for all your support.

    I made the adjustments you stated,they did not work out for the LedSequencer.BUT I DID USE YOUR

    LESSON WITH SOME OTHER OBJECTS AND THEY WORKED·and that taught me how to do it.

    thank you.
    I have no question this time, it would be great to use this object for my display,but for now I'll just work with displays I can make.


    ··· This is what happened when I tried out the new Test2 all the leds lit up but nothing happened when the button was pushed
    When I ran the LedSequencer by itself·with the outputs being·16-23 only 17-22 came on, then after almost two minutes 23 came on
    then·about minute later 16 came on , they (16 and 23)·did blink from then on but at avery slow rate 30-60 seconds.

    Again thank-you
    BillyS

    Post Edited (lockadoc) : 9/25/2009 4:15:40 AM GMT
Sign In or Register to comment.