0
\$\begingroup\$

I'm using a PIC to take information from a sensor and transmit it via xbee to control a relay, as well as through a gateway to an online program. Forgive the noobie question here (I've searched and can't find it, maybe because I dont really know how to word this)...How would I go about changing the 'control' parameter for the relay. Say for instance I want a relay to turn on my a/c when it gets too hot, and I want to change what "too hot" is via the custom web program. It seems to me that it would require re-programming the PIC, however I've seen these types of devices before and that's not necessary, so I don't know what I'd need to do instead. TIA!!

\$\endgroup\$
1
\$\begingroup\$

There are basically four ways to get nonvolatile storage in a modern micro.

  1. Internal EEPROM: Many (not all) micros have EEPROM on-chip. It's good for perhaps 100,000 operations (sometimes more) before it wears out and takes some milliseconds to write (but is fast to read).
  2. Flash memory: (EEPROM emulation). Some micros allow you to write a portion of the flash during normal operation. This can be an alternative if EEPROM is not provided. FRAM based micros have nonvolatile memory that has fewer limitations than flash, but they're not very common.
  3. External SEEPROM: Inexpensive and small serial EEPROMs are widely available. They typically use I2C, SPI or Microwire interface. A good alternative if the micro does not have EEPROM or you need more storage capacity.

  4. Battery or supercapacitor backup: Simply store the information in RAM and put the micro in a very low power state when it is not active. Batteries (even rechargables) eventually wear out.

Edit: See the datasheet here:

enter image description here

and here:

enter image description here

You can find many code examples on line for using the data EEPROM.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the explanation. So I've been looking at the pic16f1827 which has a flash memory, but it seems that it's not remotely programmable. Would something like the pic16f87x be necessary for that? \$\endgroup\$ – Mike Dec 13 '14 at 17:04
  • \$\begingroup\$ The PIC16F1827 has 256 bytes of data EEPROM- you can use that nonvolatile memory to store persistent states. You don't normally need (or want) to rewrite the program memory. \$\endgroup\$ – Spehro Pefhany Dec 13 '14 at 18:01
  • \$\begingroup\$ Ok, and I take it that the nonvolatile memory can be programmed remotely via xbee and a gateway? \$\endgroup\$ – Mike Dec 14 '14 at 18:08
  • \$\begingroup\$ Sure, once you write the code to do it. \$\endgroup\$ – Spehro Pefhany Dec 14 '14 at 18:13
0
\$\begingroup\$

PIC isn't my scene, but in general most modern microcontrollers have a small bit of non-volatile memory for the purpose of storage of data, and the contents of this storage can be modified at runtime. The trick is to write code such that it reads the control values from this storage, and can be directed to write new values to it if so directed.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.