SIGforum.com    Main Page  Hop To Forum Categories  The Lounge    Microcontroller programming question
Go
New
Find
Notify
Tools
Reply
  
Microcontroller programming question Login/Join 
W07VH5
Picture of mark123
posted
Is there a way to set a non-volatile variable in a microcontroller?

Basically, I'm running a latching relay with a microcontroller and I want to give the end user the ability to choose whether the relay is opened or closed upon power up.

I'm using Microchip's PicKit3 and I have pic12f675 chips on hand but can change the chips if necessary.

I can add a physical jumper to the circuit if that's a better plan.

This message has been edited. Last edited by: mark123,
 
Posts: 45373 | Location: Pennsyltucky | Registered: December 05, 2001Reply With QuoteReport This Post
Member
posted Hide Post
I could do it with a PLC, not familiar with those chips.


NRA Life Endowment member
Tri-State Gun collectors Life Member
 
Posts: 2794 | Location: Ohio | Registered: December 18, 2014Reply With QuoteReport This Post
W07VH5
Picture of mark123
posted Hide Post
quote:
Originally posted by Aquabird:
I could do it with a PLC, not familiar with those chips.
The final PCB has to be 2" square or smaller.
 
Posts: 45373 | Location: Pennsyltucky | Registered: December 05, 2001Reply With QuoteReport This Post
Member
Picture of btgoanna
posted Hide Post
quote:
pic12f675


Never used this part - but based on it's data sheet and app note AN879 , you could probably do this.

The app note says there is an ultra low power sleep mode , so this means you could store the data (mode you want) in a register and have it respond accordingly on "power up"
The trick is to keep the data alive when it is asleep.
A super cap or battery can be used here - depending on how long you want it retained.

If all that is too complex , then use a jumper on a pin as you suggest Wink

What is application , and what are constraints - answer will change .....

Another thought - use a form C relay and keep the latching code etc simple - the user chooses the relay contacts based on need .



.
 
Posts: 832 | Location: Central Texas | Registered: November 19, 2006Reply With QuoteReport This Post
Member
posted Hide Post
I know with Arduino you can write to eeprom & have it persist (0.5-4kb, depending on model).
I would assume PIC is similar.
 
Posts: 3297 | Location: IN | Registered: January 12, 2007Reply With QuoteReport This Post
Member
Picture of btgoanna
posted Hide Post
quote:
Originally posted by snidera:
I know with Arduino you can write to eeprom & have it persist (0.5-4kb, depending on model).
I would assume PIC is similar.


Looks like it has 128 bytes EEPROM.
so this is good approach.
typically you can't write individual bytes , you need to do block writes. Should be documented as to approach required.



.
 
Posts: 832 | Location: Central Texas | Registered: November 19, 2006Reply With QuoteReport This Post
W07VH5
Picture of mark123
posted Hide Post
Thanks. I'm looking into writing and reading to eeprom. I've never used it before.
 
Posts: 45373 | Location: Pennsyltucky | Registered: December 05, 2001Reply With QuoteReport This Post
Member
Picture of btgoanna
posted Hide Post
Don't use EEPROM for storing data that changes frequently.
It typically has life of 100,000 writes. (sounds a lot but that is once every 5 min for a year !! )

For storing config data like you want it is good choice.



.
 
Posts: 832 | Location: Central Texas | Registered: November 19, 2006Reply With QuoteReport This Post
W07VH5
Picture of mark123
posted Hide Post
quote:
Originally posted by btgoanna:
Don't use EEPROM for storing data that changes frequently.
It typically has life of 100,000 writes. (sounds a lot but that is once every 5 min for a year !! )

For storing config data like you want it is good choice.
Technically I only need one bit of data that may never change or may change once. Depends on if the end user wants the circuit to be off or on when power is applied.
 
Posts: 45373 | Location: Pennsyltucky | Registered: December 05, 2001Reply With QuoteReport This Post
Member
Picture of btgoanna
posted Hide Post
quote:
Originally posted by mark123:
quote:
Originally posted by btgoanna:
Don't use EEPROM for storing data that changes frequently.
It typically has life of 100,000 writes. (sounds a lot but that is once every 5 min for a year !! )

For storing config data like you want it is good choice.
Technically I only need one bit of data that may never change or may change once. Depends on if the end user wants the circuit to be off or on when power is applied.


Yes - for your application it is a good choice - just making sure you don't get too creative and store other changing info there ....



.
 
Posts: 832 | Location: Central Texas | Registered: November 19, 2006Reply With QuoteReport This Post
Member
posted Hide Post
I use picbasic as the compiler. Simple read and write commands.

This message has been edited. Last edited by: nshumway,
 
Posts: 1072 | Location: Ohio | Registered: August 22, 2008Reply With QuoteReport This Post
W07VH5
Picture of mark123
posted Hide Post
I'm running MPLAB XC8.

I'm ok with C but I'm using the free version of XC8 and it doesn't optimize the assembly code. In fact, it looks like the free version purposely bloats the code to make us want to pay for the paid compiler.

Any suggestions on other compilers to use with PicKit3?
 
Posts: 45373 | Location: Pennsyltucky | Registered: December 05, 2001Reply With QuoteReport This Post
  Powered by Social Strata  
 

SIGforum.com    Main Page  Hop To Forum Categories  The Lounge    Microcontroller programming question

© SIGforum 2024