brown out resets


Closed Thread
Results 1 to 23 of 23
  1. #1
    Join Date
    Aug 2009
    Posts
    63

    Default brown out resets

    hey again guys, ive managed to create my program eventually.. the pic is basically the controller of the rectifier controller of a wind turbine... :P everything works nice and smooth and how id like it to.

    however there is one last thing i want to implement. im trying to display total kilowatt hours on the LCD, however obviously when the wind dies then the pic has no power and therefore turns off... but when the wind revives the pic restarts due to the brown out reset.

    however when the brown out resets occurs i will have lost all temporary data in the ram. i was wondering if there was a way to use some form of brown out interupt to quickly save the data of "total energy accumulated" before the voltage goes so low that the pic turns off. and then when the reset occurs the energy accumulated is then taken from flash and carried on counting the energy?

    or if there is another way of doing this effectively

    thanks :P

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    What I'd recommend is to use an early warning signal. The raw voltage input to the 5V regulator would be a good point to monitor the power. Use this voltage to signal a power failing and if this is set properly, you can get sufficient time to put your counter to EEPROM. Your 5V should be bypassed sufficiently to allow the write to complete.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This might give you an idea or two
    http://www.picbasic.co.uk/forum/showthread.php?t=11567
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    thanks guys, unforuantely i didnt really understand much of what was going on in that thread mack! it seems a bit advanced for me..

    i havnt actually got a voltage regulator, or ever used one... so they take the input and then give me an output voltage which i can send to the pic? how would i measure the output voltage, just use an ADC port?

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    OK, lets back up and tell how you are powering the PIC. Voltage and voltage source(source is from wind machine) but it has to be brought down/up to PIC levels.

    If you are still on the same PIC and project I think you are running at 20Mhz, so I will assume you are getting around 5 volts from some place. ????
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    well basically we have got the analogue high voltage part of the circuit which is converted to a 5v voltage for the CAP inputs and the ADC measuring voltages.

    we also have a DC 12v supply from another part of the power electronics which i attach to a 12DC to 5DC converter... this is wheree i get the voltage to power the pic

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    OK, that gives you plenty to work with. You should be able to adapt the schematic in the thread I linked you to.

    What we are basically doing is monitoring the 12 volt in this case. An ADC could be used but you will have to keep checking it in your code. If you use the interrupt on change then it all happens for you...

    Either way, the trick is having large enough caps to run the PIC long enough to write the data to eeprom. When the voltage coming to the PIC or the power supply drops beyond a certain point your software will jump to a SAVE/SHUT DOWN routine.

    The problem I see happening with you setup is the voltage drops enough to go to the SAVE routine then comes back up before the PIC actually stops from lack of voltage.
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    how do these interupts on change work? is this the DT instant interupt stuff? are there any specific brown out reset interupts?

    edit: actually just found it in data sheet, looking through it now
    Last edited by robertpeach; - 23rd September 2009 at 09:29.

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    You can use DTs stuff for this but regular interrupts should be fast enough.
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    ok thanks, ill just use normal interupts! im gonna look around and try and make some code to use interupts

  11. #11
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    ok ive made my code, probably got some errors in, however thats not the problem. ive been thinking about this whole trouble with if the voltage is idling on a point lower than my low voltage detection level but not low enough that it causes a reset... problem is.. if it gets too that point my program starts looping because the interupt keeps getting set off by the low voltage.

    i was thinking since when the wind turbine actually gets slow enough that the voltage is about 2-3 volts, its not actually giving out any power (if it does then its completely negligible). so when i get to a low point can i just turn off the pic? and get it too restart when the power gets higher?

  12. #12
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    You might be able to use an external comparator to watch the voltage and kill the PIC that way....

    What about a small rechargable battery pack to run the PIC for a few hours then the PIC is always on.
    Dave
    Always wear safety glasses while programming.

  13. #13
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    im gonna look into the battery idea actually, but flaws with it could be that over 20 years a rechargeable battery will have effectively "lost its ability to recharge" and also there will be points where the wind is dead for longer than the battery can keep the pic and lcd running...

    are there any commands to just turn off the pic and then get it back going when the voltage is high enough? cos surely if the pic is turned off... how can it be turned back on again? since the software is obvioulsy not running because the pic is off :S

  14. #14
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    actually does the power on reset turn the pic back on after i have turned it off? if i put the mclr pin to Vdd, it will detect a rise in voltage? and cause a reset?

    if i turned the pic off at a certain voltage... and then when the pic detects a rise in voltage the power on reset occurs and turns my pic back on and restarts the program?

  15. #15
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by robertpeach View Post
    im gonna look into the battery idea actually, but flaws with it could be that over 20 years a rechargeable battery will have effectively "lost its ability to recharge" and also there will be points where the wind is dead for longer than the battery can keep the pic and lcd running...
    Pros and cons no matter what. I have one of the "smart thermostats" at the house. It runs on two AA batteries that need changed once a year or so. Might have to be a bit of upkeep for the end user???? I know, not good.
    are there any commands to just turn off the pic and then get it back going when the voltage is high enough? cos surely if the pic is turned off... how can it be turned back on again? since the software is obvioulsy not running because the pic is off :S
    There is the sleep command but that just puts the PIC in low power mode.

    I have a feeling that the best way to go will be an external comparator working a latching relay or FET on the 12 volt line. Rig it so when the voltage drops below X the relay stays off untill the voltage comes back up to Z. Give a little range between the two points.

    Then the interrupt thing should work. If the PIC shuts down only from lack of power it will restart.

    Just thinking.... Or is it babbling
    Dave
    Always wear safety glasses while programming.

  16. #16
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    no ive been thinking and the ways that you describe are the only two ways i can think of doing it... the battery thing would work nicely i just dont think a customer would be too happy having to change batteries much...

    im gonna try out ur second example with the comparator! thanks for your help once again mack! ill let u know how it goes

  17. #17
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    update:

    well basically dave i looked into the whole idea... and basically it just seemed all a bit much for one thing. ive decided on the simplest option, even if it is a bit time consuming and not as efficient for the pic. im just gonna save the data to eeprom every 0.25 kwh instead of only saving when pic powers down... this will require a bit more pic power and wont be as accurate since it could be 0.24kwh through when the pic dies... and that 0.24 kwh is not actually added on... this could happen quite alot if the wind is low and the turbine keeps starting and stopping...(although it wont matter that much since the energy out at those stages is pretty negligible anyway) but will be cheaper and easier probably! less things to go wrong in my case

  18. #18
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    One more thought....
    To keep from missing that last bit of good data you could have the code do a last write when the power, speed or what ever drops to a certain point. Anything below that point and you do not write data. Once the machine is running above a certain point it goes back to writing every 0.25kwh. That way the starts and stops will not bother.
    Dave
    Always wear safety glasses while programming.

  19. #19
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    thanks mack thats actually a good idea, ive already got the code for when the low voltage detection, so ill just implement that in. would i bother resetting the interupt flag once an interupt for low voltage detection is made? because that would cause an endless loop of the interupt if the wind turbine was at a speed low enough for low voltage detection but not low enough for a reset...

    additionally ive come across another problem which is actually just me being stupid...

    if ive got a power output which is being updated on my pic at a high frequency (power output is found from comparing the revolutions of the wind turbine per minute). how would i get a total energy accumulation value?

    since the power will be changing over time... it means the rate that my total energy accumulation is increasing will change also... would i find the average poweer over lets say 10 seconds and then multiply that by 10 to get the total energy accumulated over 10 seconds?

    additionally since ive only got picbasic pro and not pbpl it means i cant use LONG. this means i can only get up to 65536, whereeas the number of kwh is gonna be about 200,000 over the 20 years... any ideas on this one? if im gonna be wanting to use a decimal e.g 655.25 kwh then thats gonna mean im gonna get a max of 655 kwh...

    its goonna be about 10,000 kwh a year... over 20 years thats 200,000... so if i write to eeprom every 0.25kwh then thats 800,000 writes... and a pic can only take a million erases?

  20. #20
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I would try something like.
    If rpm is less than X then disable the INTCON.

    Calculating power from the RPMs. Setup a timer to read the rpm evert so many seconds, after maybe a 100 reads average the RPMs giving aveage power over that time span??? If the wind is not changing much it should be pretty accurate.

    Of you have PBP then you have LONGS. Using MCS? Tell it to compile using PBPL. That can be found under one of the options in the tool bar. MPLAB? When you set the language it should b there.

    Yup, the EEPROM has some limits. I have been using a SD card for data logging.
    Add a RTC if you do not have one in the project and you have plenty of room on a SD to save the time, RPM, power and what ever else. When you want to just pop it into a PC and chart, display or what ever. Easy way to get data from PIC to PC.

    Yup, more babbling
    Last edited by mackrackit; - 24th September 2009 at 13:08. Reason: If you have PBP 2.5 or greater you have LONGs.
    Dave
    Always wear safety glasses while programming.

  21. #21
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    since ive only got picbasic pro and not pbpl it means i cant use LONG. this means i can only get up to 65536, whereeas the number of kwh is gonna be about 200,000 over the 20 years... any ideas on this one?
    I don't have long either, this is my turn around:

    Code:
    AA var word
    BB var word
    CC var word
    DD var word
    
    Long:
    AA=0
    While AA<>BB
    AA=AA+1
    CC=CC+1
    If CC=0 then DD=DD+1
    wend
    
    Return
    You place your reading in variable BB and gosub long, here your reading will be accumulated in variable CC and DD, that you can save at your discretion.
    Reading back the long is simple just (DD x 65536)+CC

    Al.
    All progress began with an idea

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


    Did you find this post helpful? Yes | No

    Default More of my rambling

    Hi Robert,
    To get a clean PIC reset you could tie the MCLR pin to ground using an NPN transistor and a resistor to + , then on the transistor's base circuit feed it with a suitable capacitor, tied to the generator, when it spins up the transistor will pull the mclr pin low until the cap charges and then turn off.
    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.

  23. #23
    Join Date
    Jun 2007
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Just use a simple voltage drop detector. I use a 4.5v detect on the supply of my odometers and I've tested the crap out of this application and NEVER fails to write the value to EEPROM once power is disrupted. The volt detector is nothing more than a "switch" to ground thus when it's supply which shares the supply of the pic, goes to 4.5 volts or lower, it will switch any input selected on the pic to low to activate your "save data" routine. Use a capacitor of 220uf to slowly drain the power while giving time to do the action. Once your action is complete, use a resistor or load to complete the cap drain...

Similar Threads

  1. 16f877a porta.5 resets chip
    By lecoind in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 1st October 2009, 18:29
  2. Device Resets / erratic operation - 16F88
    By turbokinetic in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 11th April 2009, 03:08
  3. servo motor resets 16f877a
    By burak450 in forum mel PIC BASIC Pro
    Replies: 85
    Last Post: - 19th October 2008, 22:25
  4. PIC resets every now and then
    By passion1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th June 2007, 21:41
  5. Freqout resets port pins?
    By MikeLewis in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th July 2004, 04:29

Members who have read this thread : 1

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

Posting Permissions

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