View Full Version : Strange pic 16f877a memory loss
DavyJones
- 1st July 2009, 16:18
Hi, Well I had a really strange thing happen to my pic controller (http://www.futurlec.com/PIC16F877_Controller.shtml) last night. For some reason or another the program was entirely erased off the pic or it became corrupted to the point it no longer functioned. I've been using the above controller with my program as a test for the past couple of months and it's been working fine without incidence until this morning that sometime in the night it died. I uploaded my program and everything is working fine now. My question would be what can cause something like this that would wipe the program out or corrupt it? Could it be the fact that almost all of the pins are wired directly to headers and nothing is tied to ground that is not in use? Could it just be a faulty pic? A little over a week ago we had a near miss on our house with lightning and we did have some damage to some electrical appliances in the home but the pic didn't seem to be affected directly at that time since it had continued to work for over a week after the storm. I didn't think the lightning damaged it but maybe a delayed damage?
I know the controller board you will see if you follow the link above is for a 16f877 but I mounted a spare 16f877a on it, and it's always worked fine. I am careful with my program to make sure I have the correct things turned on and off for the 877a so thats never been an issue.
If anyone has any ideas or suggestions they are appreciated.
David
Jumper
- 1st July 2009, 16:42
Hi,
Did you try to read out the program memory from the faulty pic? How do you know you really had a problem? Do you have brown out turned on or off?
Sometimes if BOR is off and the pic gets crazy pulling the plug on it might not be enought to reset it properly if BOR is turned off. The pic will continue runing on the charge in caps and power adapters. Pulling MCLR to GND will help :-)
Also make sure low voltage programming is turned off or if you use that function make sure that pin is controlled properly ( if 877A has that feature)
AND make sure you program is set up properly for the 877A. You can not run the same program on a 877 as an 877A without getting problems :-)
One time is a freak accident.... 2 times is a bad habit
DavyJones
- 1st July 2009, 20:50
Hi,
Did you try to read out the program memory from the faulty pic? How do you know you really had a problem? Do you have brown out turned on or off?
Sometimes if BOR is off and the pic gets crazy pulling the plug on it might not be enought to reset it properly if BOR is turned off. The pic will continue runing on the charge in caps and power adapters. Pulling MCLR to GND will help :-)
Also make sure low voltage programming is turned off or if you use that function make sure that pin is controlled properly ( if 877A has that feature)
AND make sure you program is set up properly for the 877A. You can not run the same program on a 877 as an 877A without getting problems :-)
One time is a freak accident.... 2 times is a bad habit
'16F877A specifics and Defines
@ DEVICE pic16F877A, HS_OSC ' System Clock Options
@ DEVICE pic16F877A, WDT_ON ' Watchdog Timer
@ DEVICE pic16F877A, PWRT_ON ' Power-On Timer
@ DEVICE pic16F877A, BOD_ON ' Brown-Out Detect
@ DEVICE pic16F877A, LVP_ON ' Low-Voltage Programming
@ DEVICE pic16F877A, CPD_OFF ' Data Memory Code Protect
That board has a reset on it and the first thing I did was a simple reset and that did nothing. I unplugged it and left it unplugged for a minute or two then plugged it back in and still got nothing. I hplugged the RS232 in because I did have my program outputting some stats and I got nothing. So after trying reset a few more times and unplugging it a couple of times thats when I decided to load the program back on it. I did try and do a download but I have to be honest I had no idea if it downloaded the same program or not. Winpic indicated it was donwloading something and there was garbage in the HEX window but I've no way of knowing if it was garbage or was the original program I loaded, I did not save it. I uploaded my program again and it just went back to working like before.
I am making sure I have the correct codes for the 877a I've never hd a problem before and the programmer I have won't program this unless LVP is on. I am wondering now what "Data Memory Code Protect" is perhaps that should be on. This is the first time I have every had a problem like this with these pic's.
Thanks
David
comwarrior
- 1st July 2009, 21:00
I've seen eproms program correctly, and then verify without fault...
But as soon as you take them out of the programmer they loose their contents like ram...
Turns out it was a faulty batch... :confused: :confused: :confused:
DavyJones
- 2nd July 2009, 00:41
I've seen eproms program correctly, and then verify without fault...
But as soon as you take them out of the programmer they loose their contents like ram...
Turns out it was a faulty batch... :confused: :confused: :confused:
The thing about this is that it's been running non-stop without incident for a couple of months so I doubt this was a bad batch. I'm thinking it might have had something to do the storm and the close proximity lightning strike we had or perhaps the fact that most of the pins are left hanging tied to nothing. Maybe there was a build up or something.
Thanks
David
Darrel Taylor
- 2nd July 2009, 01:26
I've seen that happen several times.
Most of my stuff is on Yachts and Oil rigs, so they take a lot of lightning strikes.
Occasionally, a few bit's in both Flash (program memory) and/or EEPROM will get erased (to a 1). Not whole bytes, just random individual bits. Depending on which bits get erased, almost any problem imaginable can happen. Sometimes only one function doesn't work right anymore, other times it's just dead, locked up in a loop somewhere. Sometimes other components are black and crispy, other times all components are fine and only the memory got changed.
Too bad you didn't save the download, a comparison with the original hex could have confirmed the hypothesis.
I originally started out with Basic Stamps, which were a lot worse than PIC's. Their program corrupts if a butterfly farts nearby. And lightning usually takes them out completely.
The PIC's were always fine, just reload and go.
I've tried all kinds of MOV's, and Transient suppressors, and gas discharge tubes, but it still happens. Since a nearby strike normally enters through the "ground" on a boat, there's nowhere to shunt it to. So I stopped using them all together, because they create problems of their own as well.
It's amazing that the lightning strike seems to affect the boat captains memory too. It's not till he finds out that there won't be any repair cost, that he suddenly remembers, oh yeah, it must have been that lightning strike we took. (lightning damage isn't covered by the warranty).
<br>
Ioannis
- 2nd July 2009, 08:24
Darrel, do you have your devices in metal enclosures?
I had similar effects on devices placed in the car parkings and were exposed in the open. But were built in plastics...
I wonder why the other electronics on-board still work, or not?
Ioannis
Darrel Taylor
- 2nd July 2009, 09:55
Nope, they're in a NEMA4 PVC enclosure, although that enclosure is inside a metal frame.
And when they do fess up, I've heard that Radar and navigation were knocked out too, but the radio's still work fine. (but who knows for sure)
<br>
mackrackit
- 2nd July 2009, 10:22
I have had similar problems in machine shops around welders
and plasma cutters. A metal enclosure with a good earth ground
normally helps. Have to add another ground rod a lot of times.
How do you earth ground a boat? :)
sayzer
- 2nd July 2009, 10:34
...
How do you earth ground a boat? :)
You wire a long cable to the shore :)
If you can't find one long enough, use a wireless hub to make it. Everything goes wireless these days.:D
Acetronics2
- 2nd July 2009, 12:22
How do you earth ground a boat? :)
Hi, Dave
No Problem ... Darrel's boat always stay along its Wharf ... Web Terminals do not work past the Harbour !!!
You also could use the anchor ...
BTW ... I thought sea water was conductive ... isn't it ???
Alain
Archangel
- 2nd July 2009, 18:31
How do you earth ground a boat? :)Boats usually have Zinc electrolysis plates on their bottoms to which all metal is grounded.
comwarrior
- 3rd July 2009, 16:59
How do you earth ground a boat? :)
run it up onto the beach...
Sorry, couldn't resist...
Seawater is conductive (depending on voltage) but also very corrosive...
i think their is a metal (possibly zinc) strip to the bottom of a boats keel...
As for using the anchor, you can't... corrosion on each individual chain loop will cause insulation...
The fun comes when you try to figure out how to earth a plane... :confused::confused:
Ioannis
- 3rd July 2009, 19:00
The fun comes when you try to figure out how to earth a plane... :confused::confused:
Hmm, and why should you? It is floating isn't it??
Ioannis
comwarrior
- 3rd July 2009, 23:44
lightning will still strike a plane...
Melanie
- 4th July 2009, 02:12
Yes, but theoretically shouldn't do any damage as the aircraft is itself 'floating' and not connected to a 0v 'Ground'. The engines, chassis and all metal surfaces are bonded together along with busses to provide a local electrical return path. Composites (such as Carbon Fibres) usually (though not always) have an integral mesh or carrier strip which is bonded to the vehicle 'ground'. In flight it could be quite common for an aircraft to be charged at quite a high potential - so it's 'ground' is not at 0v, but some arbitrary 'floating' (pun intended) value.
You could connect a PICs Vdd to several hundred kV (and happilly run it) - providing Vss is never more than say five volts lower than Vdd... I have an application for a domestic boiler Gas Ignition board using a PIC where Vdd is actially 0v (Ground) and Vss is -5v (it's easier then to use Comparators to detect if you have a flame as it creates negative ions). You can mess things around quite happilly providing you stay overall within the Datasheet parameters.
aratti
- 4th July 2009, 08:51
Have you forgotten the Faraday cage principle?
Al.
DavyJones
- 4th July 2009, 16:56
Thanks everyone for your input. It appears this lightning strike was the cuplrit. If I ever see this again I plan on saving the downloaded code to see how much it actually deviates from the original source.
Appreciate everyones time on this.
David
Acetronics2
- 5th July 2009, 09:52
Yes, but theoretically shouldn't do any damage as the aircraft is itself 'floating' and not connected to a 0v 'Ground'. .
Hi, Mel
Only theoretically ...
Ten years ago thunder striked my house ...
and I got damaged electronics aboard one of my model planes : a receiver and two servo amps were damaged.
the model ( wood built ) was hung to a metal tube ( connected to ground ) of the central heating by a piece of string ...
so it was really " floating " ...
I do think cables act like a transformer secondary if lightning passes closer enough ! a good magnetic shielding of the enclosure looks necessary too ...
Alain
Ioannis
- 6th July 2009, 06:59
Alain, were you inside the house when the thunder stroke?
Ioannis
sayzer
- 6th July 2009, 08:37
Alain, were you inside the house when the thunder stroke?
Ioannis
I will do my best guess:
I guess he was outside his home trying to test his hand made volt meter to see whether he could take a reading from the lightning or not.
(and If so, to see what the deviation could be)
Am I close?
Acetronics2
- 6th July 2009, 13:17
Alain, were you inside the house when the thunder stroke?
Ioannis
Hi, Ioannis
I quietly was sleeping in my bed ... and was awaken by an unusual "bang".
Thunder striked in my wife's father room ... making a nice hole in the plaster of the wall, to reach the grounded central heating tubing.
Of course there was plaster powder spread everywhere !!! ... somewhat funny. my father in law appearance was funny too ...
I saw for the first time what happens to transformer windings : every turn is cut into two parts and thrown everywhere... astonishing !
Also Noted Aluminium shielded TV cable takes fire ( dangerous ! ) ... but not Copper shielded one !
My scope ( plug was not connected ) trace also was disturbed for seveal month ... not to say more than a year ... ( Trace rotation : 3-4 ° + small sine for Grounded input instead of the line )
Neibours told me they had seen the Fireball come to the house ... had like to see it too !!!
Hi, Sayzer
you're totally out on this one ... I was experimenting with Mel's Leyden Jars !!!
I wonder was to try your wonderful Turkish invention ( remember : a 12 kW laser to make a solar Windmill rotate ... video + distinguished professor interview provided ...)
ROFL
Alain
Ioannis
- 6th July 2009, 18:50
Amazing how you make it out of it.
I am sure neighbours had an impressive show. I don't know about you though!
Have you thought of installing an lightning arrestor? People think that the thunder will not strike twice but I 've heard otherwise very often.
Ioannis
Acetronics2
- 6th July 2009, 20:27
Hi, Ioannis
a Thunder Arrestor is a soltion for High buildings, Castles, Churches ... I always heard a couple of Birch trees make it well ... If no mains lines around.
Now, Thunder is like water: you can channel them, but never stop them ...
Why wouldn't thunder strike twice at the same place ??? ... if everything rebuilt as it was ... no reason !!!
But as clouds are randomly placed and constituted ... difficult to get twice the same HV Generator characteristics !!!
Regards
Alain
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.