sleep
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
A pulldown resistor value of 10K may be enough depending on your circuit and the amount of electrical noise present nearby.
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.
"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?
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.
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.
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.
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.
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.
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.
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 1Slot 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