sleep
mmoreland
Posts: 89
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:
Slot 1: