If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Yes, thank you. For some reason I assumed the OP was suggesting that the PIC would be without power - in such a case writing to EEprom is clearly impossible. A battery or capacitor is an ideal solution - providing power AFTER the main is switched off. Yours (and others?) suggestions to provide power via a cap is a very efficient answer - allowing, with careful design - the ability to control the shutdown and perhaps even position the servo in a non-destructive position before exhausting the supply. Thanks again!
Please let me ask an obvious question. Why does the data have to be stored when power is taken away? Why can't it be stored then it is actually changed?
Dave Purola,
N8NTA
EN82fn
Hi,
If you go the ADC route I suggest putting a voltage divider in between Vdd and the ADC input. Otherwise you're overdriving the ADC input, the internal protection diode from the input to Vdd may be forward biased (depending on its actual Vf compared to the 1N4148 or whatever).
If the PIC has a comparator you may want to use that instead of the ADC because then you can set it up to trip an interrupt when the comparator output toggles - may be better than continously sampling the ADC. (The voltage divider still applies though.)
/Henrik.
Thanks all for responding. All good ideas that I will be sure to use in the future.
I looked back at my project, which was to automate a 1/87 scale (HO train scale) dump truck so it's box would dump, reset, then dump again. For this I was using a servo with a sweep motion of about 90 degrees, not the full range of the servo (180 deg from stop to stop). This worked well except when I would shut off power and power-up. The servo would immediately jump to one of the stops, which was out of range of my sweep, then the program would run and everything would be fine. If the dump truck box had been connected, the servo would have lifted the entire truck off the layout. This is why I was wondering how I could save the last value I sent to the servo, power off, and when power came back on again, the servo would know where to start. (I put the initial value at the beginning of my program but this did not work: the servo still swung to one of the limits. In other words it did this BEFORE the program could actually run).
So...employing the KISS principle (Keep it Simple Stupid), I decided there was a MUCH simpler way. I was so happy to be controlling servos, my judgement became cloudy. My solution is to use a simple DC gear motor under PWM control (easy with a PIC 12F1501), and operate the truck box with a crankshaft coming off the motor, basically an eccentric. Voila! Smooth operation, total speed control (and lots of torque thanks to PWM), no extra electronics required.
All the ideas you gave me guys are still useful and I will use them in the future. I ain't done with servos.
Bookmarks