Shop OBEX P1 Docs P2 Docs Learn Events
sleep — Parallax Forums

sleep

mmorelandmmoreland Posts: 89
edited 2011-12-24 21:58 in General Discussion
I'm having trouble with the SLEEP command. There are two output pins with loads when the BS2p is put to sleep, so I have set the pins low just before sleeping to be reset high when the Stamp wakes, but the Stamp will not wake after SLEEP. Must I do more than just set the pins low? Is this enough information for anyone to give me advice about the SLEEP function? I have read the manual and read articles, but I'm stumped by the behavior of the Stamp..

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-01 20:43
    SLEEP (and NAP) is similar to PAUSE in that the program stops for a specified amount of time. The difference is that the Stamp goes into low power mode with SLEEP (and NAP). One of the side effects of SLEEP and NAP is that the PBasic interpreter needs to check its timing every so often and, in doing so, the I/O pins float for a short time regardless of their state as set by your program. You'll need to have some kind of external circuitry to maintain the state of any output pins that are critical when the Stamp is sleeping. This could be as simple as a pull-up or pull-down resistor depending on the needs of your program.
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2011-12-01 23:36
    What do you mean by, "Stamp will not wake after SLEEP"? Mike may have answered your question, but I remain confused about how you reached your conclusion about SLEEP and what is happening with the pins that remain low.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-12-02 00:06
    The pins set LOW before SLEEP, will remain LOW when SLEEP ends unless there is some active code to do otherwise. That might lead one to thinking the device is still in SLEEP mode.
  • mmorelandmmoreland Posts: 89
    edited 2011-12-02 08:04
    Mike didn't exactly answer my question probably because I didn't ask it very clearly. Is the use of resistors to prevent the interruption of the pin functions during the 18ms or is it to prevent the malfunction of SLEEP? The pins in question are (1) serving a solid state relay, and (2) sending pulse values to a motor controller, neither of which needs to occur during SLEEP, and that's why I set the pins low. Upon the LOW command, the relay opens, the motor power supply shuts down, and the motor controller hibernates. To answer Loopy, after the SLEEP command, the code commands the pins to go HIGH which they do if I use PAUSE instead of sleep. To answer Tracy, if I use the SLEEP command, the Stamp never wakes to resume any of its functions (check GPS, get a tilt angle from an accelerometer, interpret the info, etc.), nor do the pins in question go HIGH. I've been using short SLEEP commands in testing the code (1-30 seconds), but I wish to put the device to sleep for 11 hours overnight, so PAUSE isn't an option. I will install a couple of resistors although I find the concept confusing esp. on output pins, and I don't know how to figure out resistor size, but if you have any other thoughts, I'd be pleased to read them.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-02 08:30
    There is no malfunction of SLEEP other than the documented interruption of I/O pin functionality. If you're seeing some kind of anomalous behavior that's not due to the I/O pin behavior, it must have something to do with either your circuitry or your program. For example, letting the I/O pins float may cause power surges that cause the Stamp to reset. Posting a schematic and program code would be helpful.

    A pulldown resistor value of 10K may be enough depending on your circuit and the amount of electrical noise present nearby.
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2011-12-02 08:51
    You can do a simple test of the SLEEP command by itself, while hooked up to the programming port:
    DEBUG CR,"top"
    DO
      LOW myPin
      SLEEP 10
      HIGH myPin
      DEBUG CR,"I'm back"
      PAUSE 1000  
    LOOP
    

    The desired behavior is messages on the screen and the pin goes high and low. You can attach an LED to "myPin" to see the result.

    The solid state relay should not need even a pulldown resistor, because it requires a solid current to operate (but having a 10k pulldown resistor is still a good idea). It is lighting the LED--You won't see any flash during the 10 second sleep period. The motor controller may or may not need the resistor, depending on how it is implemented inside, but again the 10k pulldown is a good precaution.

    Those measures have nothing to do with operation of the SLEEP command. Run the test program. If SLEEP works, you can discard the notion that there is something wrong with the Stamp and look instead for some hidden bug in your program.
  • mmorelandmmoreland Posts: 89
    edited 2011-12-02 10:20
    Thanks. I'll install two resistors, and by that I assume you mean a 10k resistor between each of the output pins and Vss. I will post the program code a little later, esp. if the problem persists. Posting a schematic may be beyond my present ability, but I'll give it a try, and finally, I'll perform the test described above. I agree that in all likelihood there is at least one hidden bug in my program. Responding to Tracy: Is there a part of your reply left out between the closing parenthesis and the word "It..."?
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2011-12-02 13:55
    Do you mean the "it" in this sentence?
    "The solid state relay should not need even a pulldown resistor, because it requires a solid current to operate (but having a 10k pulldown resistor is still a good idea). It is lighting the LED--You won't see any flash during the 10 second sleep period."

    Most solid state relays work by having an LED on the input side, and light from the LED couples across an isolation gap to the high voltage AC side. By "it" I meant that your circuit is providing current to light an LED. It is the same idea between an LED you can observe on a circuit board or an LED you can't see inside the solid state relay. In either case, the LED will not inadvertently light up when the Stamp periodically during SLEEP briefly makes that pin an input.

    Mike also mentioned a power surge as a possible cause of the problem. Do you have this on the bench, or is it out connected to your solar array?
  • mmorelandmmoreland Posts: 89
    edited 2011-12-02 16:02
    Thanks. That was helpful. There is no LED in the relay that I'm using, but the power supply has an LED, and that's what I observe when the pin is switched from LOW to HIGH and back. I'll report on my findings which I find somewhat inconclusive. I took out a separate Board of Education and tried your bit of code using the BS2p that I'd taken from the working board. It did not pass the test. After from two to six returns of "I'm back," it stopped, returned another "top" from outside the loop and a couple times a Greek letter which probably was an Epison. I rewrote the program for a BS2 that I have, and it worked perfectly for 20 or more returns of "I'm back." I tried again with a BS2pe, and it, too, worked perfectly for 20 or more times. I put in a second BS2p to find that it worked by returning "I'm back" consistently without jumping the track, but from time to time it took twice as long as the coded SLEEP time to return. Putting that BS2p on the working board, it worked better, but after 5 or 6 returns, it would stop and fail to wake up.

    Putting a resistor on the motor output pin didn't change a thing, so I went back to using the BS2pe which doesn't appear to have any problems with SLEEP. The program is running perfectly now although I haven't had time check whether or not it will wake up after 11 hours SLEEP. I'll know that in the morning.

    What puzzles me is that all the code, all 18 pages of it, works fine on all the p type Stamps when I use the PAUSE command instead of SLEEP, and the BS2pe works fine with SLEEP. I modify the day and hour results to try every day of the year, every hour of the day, and the code runs without a hitch. I'll bring down the PC I'm using for this project and add a copy of the first few pages of code in case anyone is interested in checking it out...that will be later this evening. (Can't do this because the pc is monitoring the stamp overnight...tomorrow sometime.)

    I'm testing it on the bench. I've taken everything out of the solar array to work out these bugs, but I'm using all the actual parts and devices that will be running the array, the motor, relay, power supplies, accelerometer and Stamp.
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2011-12-02 17:27
    The BS2p draws quite bit more current than the BS2 or the BS2pe, and the current surges from the power supply more when it wakes up. It sounds like you have a marginal brownout condition when the BS2p is in the circuit. Try installing an electrolytic capacitor, something like 100µF, from Vin to ground, close to the BS2p. What is your power supply?

    The fact that it is showing "top" means that the chip is doing a hard reset as it tries to wake up. The observation that it works fine with the BS2pe suggests that it is not a problem with an external device, such as a kickback from the motor.
  • mmorelandmmoreland Posts: 89
    edited 2011-12-02 20:14
    The 24 vdc power supply has the name TDK-Lambda LS100-24. It's 5" by 7" by 1.5" in a substantial metal cage. The stamp power supply is a 7.5 vdc wall adapter sold by Parallax. In years past I noticed that when my friend Bob Blick made electronic components, he used lots of capacitors, and I understand their "capacity" to even out spikes and surges, but I wouldn't have had sufficient confidence to know where to install one, and Bob was rude enough to move to Santa Rosa a decade ago. Joking aside, I was wondering today if an appropriately placed capacitor might not solve some of my problems. I'll give it a try tomorrow or early next week. Thank you.

    I just remembered that the power supplies are pictured in another thread titled "thanks!" which is currently on page 6 of this "General Discussion" group. I had stopped reading that post after Matt Gilliland commented figuring that was the end of it, but I see that you and a couple other kind folks added comments. At that point the array was working independently, but there were two matters I wanted to change. It had the BS2pe in it, and I was less happy with the way the e interpreted information from the accelerometer than I was with the BS2p, and the movement control was set up to move a couple degrees, recheck and move again, and I wanted to rewrite that portion causing the stamp to calculate the total required move and issue a pulse value that would cause the motor to make the appropriate move in one long, continuous motion. I got the move code working well, but I got into trouble by re-introducing the BS2p due to its unresolved conflicts with the SLEEP command. If I can work this out with a capacitor, I'll put the 2p back in and save my e for another project.

    So, belatedly, thanks for your comments on that other thread. This project has energized me as you said. I'm turning 70 in a short while, and it has been a tremendous boost to have designed, built and animated this project even if I have had to solicit the help of hordes of brilliant, generous people to do so. In its first year the array generated more than the total electrical needs of the two households on this property.
  • mmorelandmmoreland Posts: 89
    edited 2011-12-05 20:32
    Reply to Tracy Allen's post midway above: How does one post code in a box with a scroll bar as you've done here?
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-05 21:17
    You use [ code ] and [ /code ] tags around the code. Don't include the extra spaces inside the brackets.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-12-05 22:02
    Electronic Goldmine has some 5Volt latching relays that Erco mentioned to me.

    These change state by a pulse rather than being held in one position or another. And in some cases, are ideal for using with sleep mode.

    http://forums.parallax.com/archive/index.php/t-132685.html

    The output would use pull-down resistors.
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2011-12-05 22:17
    Also, if you are editing in the "advanced" window, you will see a button that looks like "#" on the formatting palette. Select a block of text or code by dragging across it, or by clicking at the beginning and shift-clicking at the end, then click on the #. That will insert the "code" tags.

    Ah, I remember Bob Blick. He used to be very active on these forums. I remember visiting him at his office at Mendocino High School, and seeing him at an embedded systems expo where he had come with some of his students (and a visit to the Parallax booth there too). I'm sure he'd be interested in your project. One of his famous contributions to the forums was a DIY h-bridge driver.
  • mmorelandmmoreland Posts: 89
    edited 2011-12-06 15:10
    I will look into the latching relay. I wish I could see a schematic with the relay, the output pin and the pull-down resistors. I'm still struggling with the concept of the wiring you suggest. In this case the relay is only just sort of running the motor. It's really just a work-around caused by the fact that the motor needs for the Stamp pin to be set high before the motor turns on, so the stamp turns on, begins the code, activates the relay, and it's ready to work. It's only needed on start up, so the latching relay seems like a real winner in this case. As long as I'm using the BS2pe, there are no SLEEP problems, but now smooth operation is troubled by bad data from the accelerometer. Perhaps it wasn't meant to send data over long wires, and in this case the accelerometer is about 15' of wirelength from the Stamp. On the bench it works fine, but the transmission distance is about eight inches. I'm giving up on the accelerometer since I bought a replacement that doesn't work at all, and I'm planning another approach. Since the motor I'm using is capable of knowing where it is once it has an initial set point which it can find every morning by moving to a limit switch, I'm going to rewrite the code to use a formula to calculate every move and pulse the motor accordingly. In the end it will be a lot more accurate, and I'll be able to move a degree at a time if I wish.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-12-07 19:56
    http://en.wikipedia.org/wiki/Relay#Latching_relay

    Try the above link to get some background info on latching relays. They can vary quite a bit in how they work - some are DC input, others AC input; some only require one input, others require two separate inputs for different directions.

    Go to the thread I previously mentioned or contact Erco about how the one's from Electronic Goldmine work.

    The big ones general require the extra inputs as they have magnets that hold the position and these require different electrical polarity to move in different directions. The little ones are generally one input, either DC or AC.
  • mmorelandmmoreland Posts: 89
    edited 2011-12-24 21:58
    For what it's worth, I'll include some code below. It will be code from the first two of eight full slots on a BS2pe that's controlling the solar array. As I predicted above, trouble with bad data from the accelerometer caused me to eliminate it as a means of getting tilt angle information and sending tilt angle commands. In its place I've installed a homing switch. When the Stamp wakes in the morning, it commands the motor to move the array toward the switch which, when activated, sets the origin for that day's moves. All the angles are represented by position values that in turn represent distances from the origin. The remaining six slots are filled with select case commands for day of the year and hour of the day with corresponding angles that are related to the position values by a look down and look up table. This arrangement appears to be far more accurate, and it afforded me extra space so that I could increase the number of position moves each day.

    Slot 0:

    [/SIZE]
    
    [SIZE=1]GPSpin          PIN     0               ' GPS serial input
    T4800           CON     188             ' Baud rate for GPS (typical)
    gpsLock         VAR     Byte            ' test for valid string from GPS before downloading
    DayOne          VAR     Byte            ' first day integer from spstr string
    DayTwo          VAR     Byte            ' second day integer from spstr string
    MonthOne        VAR     Byte            ' first month integer from spstr string
    MonthTwo        VAR     Byte            ' second month integer from spstr string
    Day             VAR     Byte            ' both day integers together into day of month
    Month           VAR     Nib             ' both month integers together into month of year
    DayofYear       VAR     Word            ' calculated day of the year out of 365
    HourOne         VAR     Byte            ' first hour integer from spstr string
    HourTwo         VAR     Byte            ' second hour integer from spstr string
    HourofDay       VAR     Byte            ' both hour integers together into hour of day
    MotorMov        PIN     6               ' Motor controls to watch state of mot pin 4
    MotorPwr        PIN     15              ' Pin 15 will activate SSR to energize pwr supply
    MotorOut        CON     1               ' Pin 1 sends directions to motor
    MotorBaud       CON     84              ' ditto
    Enable          CON     "("             ' Turn on motor waiting for a p value
    Disable         CON     ")"             ' turn off motor waiting for a p value
    pValue          VAR     Word            ' motor move position value
    TimeOut         VAR     Byte            ' loop breaker for motor position failure
    GoTilt          VAR     Word            ' desired tilt for a specific hour and day
    result          VAR     Word
    
    Init_Motor:
      HIGH MotorOut                         'Set Stamp pin 1 high for motor
      PAUSE 500
      HIGH MotorPwr                         'Power up motor by activating SSRelay
      PAUSE 500
      INPUT MotorMov                        'Make Stamp pin 6 an input to monitor motor moves
      PAUSE 500
      SEROUT MotorOut, MotorBaud, 100, [Disable, CR]          'Turn off motor servo-ing
      PAUSE 500
      SEROUT MotorOut, MotorBaud, 100, [Enable, CR, "|", CR]  'Move to find origin and stop at 65 deg
      Timeout = 0
        DO WHILE MotorMov = 0 AND Timeout <5
        DEBUG "MotorMov is ", DEC MotorMov, CR
        Timeout = Timeout+1
        PAUSE 100
      LOOP
      IF Timeout >= 5 THEN
      DEBUG CR, "Move failed to start.", CR
      SEROUT MotorOut, MotorBaud, 100, [Disable, CR]
      GOTO Init_Motor
      ENDIF
      Timeout = 0
      DO WHILE MotorMov = 1 AND Timeout <100
        DEBUG DEC MotorMov
        Timeout = Timeout+1
        PAUSE 200
      LOOP
      IF Timeout >= 100 THEN
      DEBUG CR, "Move failed to finish.", CR
      SEROUT MotorOut, MotorBaud, 100, [Disable, CR]
      END
      '  GOTO Init_Motor
      ENDIF
      DEBUG CR, "MotorMov is ", DEC MotorMov, CR
      PAUSE 500
      SEROUT MotorOut, MotorBaud, 100, [Disable, CR]
    
    '  PAUSE 5000                            'Wait for origin search to complete
    '  SEROUT MotorOut, MotorBaud, 100, [Disable, CR]
    
    RUN 1
    


    Slot 1:
    [/SIZE]
    
    [SIZE=1]Init_GPS:
    'DEBUG "Enter a number for HourofDay (0 to 23) and press return", CR
    'DEBUG "Enter a number for DayofYear (1 to 366) and press return", CR
    'PAUSE 500
    'DEBUGIN DEC HourofDay
    'PAUSE 500
    'DEBUGIN DEC DayofYear
    'PAUSE 1000
      DO UNTIL gpsLock = "A"        'wait for valid data on GPS
      SERIN GPSpin, t4800, 2000, init_gps, [WAIT("GPRMC,"), SKIP 11, gpsLock]
      LOOP
      DEBUG gpsLock, CR
    
      SERIN GPSpin, T4800, 2000, No_GPS_Data, [WAIT("GPRMC,"), SKIP 43, WAIT(","), SPSTR 4]
      GET 0, DayOne, DayTwo
      GET 2, MonthOne, MonthTwo
      SERIN gpspin, T4800, 2000, No_GPS_Data, [WAIT("GPRMC,"), SPSTR 65]
      GOTO Get_Hour
    
    No_GPS_Data:                    'Pause while GPS module warms up/not sure it's needed now
      PAUSE 2500
      GOTO Init_GPS
    
    Get_Hour:
      GET 0, HourOne, HourTwo
      Day = ((DayOne-"0")*10) + (DayTwo-"0")     'put two day bytes into a single day byte
      Month = ((MonthOne-"0")*10) + (MonthTwo-"0")     'put two month bytes into a single month byte
      DayofYear = (Month-1*30) + (Month/9+Month/2)-(Month MAX 3/3*2)+Day 'find day of the year
      HourofDay = ((HourOne-"0")*10) + (HourTwo-"0")      'put h, hh into a single hr byte in UTC
      HourofDay = HourofDay + (16)//24          'convert UTC into PST
      IF HourofDay >= 16 THEN                   'cause day of year to roll over at midnight PST
        DayofYear = DayofYear -1
        ELSE
        DayofYear = DayofYear
      ENDIF
      DEBUG "Hour of Day = ", DEC HourofDay, CR    'check current local hour
      DEBUG "Day of Year = ", DEC DayofYear, CR    'check current day of the year
    
    Get_Season:                         'choose the current season
      SELECT DayofYear                  'choose the current day of the season
        CASE 1 TO 14, 335 TO 366        'Dec 1 to Jan 14; 45 days in Slot 1 (Run this page)
          SELECT HourofDay              'Winter Solstice period; same tilt for 45 days
            CASE 0 TO 10, 14 TO 23
              GoTilt = 65
            CASE 11 TO 13
              GoTilt = 62
          ENDSELECT
        CASE 15 TO 64                     'Jan 15 to Mar 5, 50 days in Slot 2 (Run 2)
          RUN 2
        CASE 65 TO 106                    'Mar 6 to Apr 16; 42 days in Slot 3 (Run 3)
          RUN 3
        CASE 107 TO 146                   'Apr 17 to May 26; 40 days in Slot 4 (Run 4)
          RUN 4
        CASE 147 TO 150                   'May 27 to May 30; 4 days in Slot 1 (Run this page)
          SELECT HourofDay
            CASE 0 TO 5, 18 TO 23
              GoTilt = 65
            CASE 8, 14
              GoTilt = 10
            CASE 9 TO 12
              GoTilt = 17
            CASE 13
              GoTilt = 14
            CASE 6 TO 7, 15 TO 17
              GoTilt = 6
          ENDSELECT
        CASE 151 TO 196                   'May 31 to Jul 15; 46 days in Slot 1 (Run this page)
          SELECT HourofDay                'Summer Solstice period; same tilt for 46 days
            CASE 0 TO 5, 19 TO 23
              GoTilt = 65
            CASE 6 TO 7, 15 TO 18
              GoTilt = 6
            CASE 8
              GoTilt = 8
            CASE 9
              GoTilt = 14
            CASE 10
              GoTilt = 16
            CASE 11
              GoTilt = 17
            CASE 12
              GoTilt = 16
            CASE 13
              GoTilt = 13
            CASE 14
              GoTilt = 9
          ENDSELECT
        CASE 197 TO 200                     'Jul 16 to Jul 19; 4 days in Slot 1 (Run this page)
          SELECT HourofDay
            CASE 0 TO 5, 18 TO 23
              GoTilt = 65
            CASE 8, 14
              GoTilt = 11
            CASE 9, 13
              GoTilt = 15
            CASE 10 TO 12
              GoTilt = 18
            CASE 6 TO 7, 15 TO 17
              GoTilt = 6
          ENDSELECT
        CASE 201 TO 204
          SELECT HourofDay                  'Jul 20 to Jul 24; 4 days in Slot 1 (Run this page)
           CASE 0 TO 5, 18 TO 23
              GoTilt = 65
            CASE 6 TO 7, 15 TO 17
              GoTilt = 6
            CASE 8, 14
              GoTilt = 12
            CASE 9, 13
              GoTilt = 16
            CASE 10 TO 12
              GoTilt = 19
          ENDSELECT
        CASE 205 TO 208
          SELECT HourofDay                  'Jul 25 to Jul 28; 4 days in Slot 1 (Run this page)
            CASE 0 TO 6, 18 TO 23
              GoTilt = 65
            CASE 7, 15 TO 17
              GoTilt = 6
            CASE 8, 14
              GoTilt = 13
            CASE 9, 13
              GoTilt = 18
            CASE 10 TO 12
              GoTilt = 20
          ENDSELECT
        CASE 209 TO 246                   'Jul 28 to Sep 3; 38 days in Slot 5 (Run 5)
          RUN 5
        CASE 247 TO 284                   'Sep 4 to Oct 11; 38 days in Slot 6 (Run 6)
          RUN 6
        CASE 285 TO 334                   'Oct 12 to Nov 30; 50 days in Slot 7 (Run 7)
          RUN 7
      ENDSELECT
      DEBUG "Go tilt = ", DEC2 GoTilt, CR
      GOTO Get_pValue
    
    Get_pValue:
      LOOKDOWN Gotilt, [65,64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,
                        43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,
                        21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5], result
      DEBUG DEC result, CR
    
      LOOKUP result, [0,-72,-144,-216,-293,-370,-446,-523,-600,-677,-754,-835,-917,-998,
                      -1080,-1162,-1243,-1325,-1411,-1498,-1584,-1670,-1757,-1843,-1930,
                      -2016,-2107,-2198,-2290,-2381,-2472,-2563,-2654,-2746,-2837,-2928,
                      -3019,-3110,-3202,-3298,-3394,-3490,-3586,-3682,-3778,-3874,-3970,
                      -4066,-4162,-4258,-4354,-4450,-4546,-4642,-4738,-4834,-4930,-5021,
                      -5112,-5203,-5294], pValue
      DEBUG SDEC pValue, CR
      PAUSE 1000
    
    Motor_Move:
      SEROUT MotorOut, MotorBaud, 100, [Enable, CR, "P3=",SDEC pValue,"00", CR, "[4", CR]
        Timeout = 0
      DO WHILE MotorMov = 0 AND Timeout <10
        DEBUG DEC MotorMov
        Timeout = Timeout+1
        PAUSE 200
      LOOP
      IF Timeout >= 10 THEN
    '  DEBUG CR, "Move failed to start.", CR
      SEROUT MotorOut, MotorBaud, 100, [Disable, CR]
      GOTO Choose_Sleep
      ENDIF
      Timeout = 0
      DO WHILE MotorMov = 1 AND Timeout <120
        DEBUG DEC MotorMov
        Timeout = Timeout+1
        PAUSE 400
      LOOP
      IF Timeout >= 120 THEN
    '  DEBUG CR, "Move failed to finish.", CR
      SEROUT MotorOut, MotorBaud, 100, [Disable, CR]
      GOTO Choose_Sleep
      ENDIF
    DEBUG DEC MotorMov, CR
    PAUSE 500
    SEROUT MotorOut, MotorBaud, 100, [Disable, CR]
    
    Choose_Sleep:
      SELECT HourofDay
        CASE 0 TO 18, 20 TO 23
          SLEEP 600                      'wait 10 minutes to check hour and tilt
          GOTO Init_GPS
        CASE 19
          LOW MotorPwr
          PAUSE 500
          LOW MotorOut
          PAUSE 500
          SLEEP 36000
          PAUSE 2000                     'wait ~10 hours to check time and tilt
          RUN 0
      ENDSELECT
    
Sign In or Register to comment.