need eeprom to save values


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: need eeprom to save values

    Quote Originally Posted by Amoque View Post
    I do not believe this is possible, unless there is some other indication from the system of an impending power loss (or I misunderstand the nature of your inquiry). Two ideas come to mind, either use an alternate power supply to power the PIC after shut-down and "detect" the loss of main power to activate the write or, write the values routinely in the main program and start from them on power up each time.
    You isolate the PIC power from the power supply with a diode. Place a large cap on the PIC side of that diode to power the PIC when the power fails, and interrupt the PIC & write the eeprom when power failure is sensed on the other side of the diode. Very possible. HTH
    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.

  2. #2
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: need eeprom to save values

    Quote Originally Posted by Archangel View Post
    You isolate the PIC power from the power supply with a diode. Place a large cap on the PIC side of that diode to power the PIC when the power fails, and interrupt the PIC & write the eeprom when power failure is sensed on the other side of the diode. Very possible. HTH
    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!

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: need eeprom to save values

    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

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,622


    Did you find this post helpful? Yes | No

    Default Re: need eeprom to save values

    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.

  5. #5
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: need eeprom to save values

    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.

Similar Threads

  1. Save a port number into the EEPROM?
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th August 2009, 10:06
  2. Save number cell in to EEprom
    By piombazzo in forum GSM
    Replies: 0
    Last Post: - 18th August 2008, 21:49
  3. Using serial eeprom to save data ?
    By iugmoh in forum General
    Replies: 4
    Last Post: - 8th February 2008, 09:36
  4. Replies: 5
    Last Post: - 29th January 2008, 10:19
  5. Replacing an ARRAY with EEPROM write to save space?
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th March 2005, 19:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts