Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

rs232 resetting Pic ?

Status
Not open for further replies.

Wp100

Well-Known Member
Hi,

Having problems with my 18F4520 when its connected to the PC via the rs232 link ( fine otherwise)

Its a standard max232 connected by just the 0v and TX output to a pc via 10 mtrs of cable.

Whenever the PC is powered on the Pic program resets and starts the program code again.
Though the whole pc system causes this, have found that the newish laser printer is the worst offender.

Scoping the incoming signal you can see a 4 to 5v spike up to 1ms long when the laser is switched on or off, though a bit surprised how that can get all the way back to reset the 18f4520.

I have the pic board on a separate mains ring , powered by a transformers; the 0v is not tied to mains Earth.
Mclre is tied to +5v via 10K etc for icsp.

Just a bit lost as how best to cure the problem, have see the isolator in the other recent rs232 post but would that stop the spikes ?

thanks
 
It sounds like it is picking up interference on the external wires. I had this problem when I built a PC controlled washing machine.

Bung a few 0.1uf and 1uf ceramic capacitors as close to the PIC power pins as possible and see if that helps at all. Some 5v3 zeners on any PIC input pins may also help.
 
Hi,

Thanks, the whole circuit is on a pcb and I already have 100nf across each chip / power rails plus all inputs have a cap/ferrite T filter and pulled up with 5 or 10k.
The other odd unused pins are set as low outputs.
The mains transformer, serving the dc / micro board only, has a Schaffner filter fitted on its mains input.
 
You seem to have most bases covered. What would happen if the PC sent a malformed RS232 byte/bytes ?

Is there anything in the code which would stall / reset the PIC if it started getting garbled data ?
 
Hi,

The simple usart serial output routine is just sending 60 bytes once per minute at 9600 baud, there is no serial input code.
The max232 Rx pin is disconnected from the data cable and tied to 0v.

Thats why I am a bit surprised how the pcs power on noise is getting back down the data cable and though the max232 to then knock the pic into reset condition.

No other household devices affect the pic and one of its functions is to switch a 1000w heater regularly and even that is not causing any reset problems.

All the code is eeprom backed up to allow a clean reset /restart should it happen, though clearly do not want it happening regularly in case some damage occurs.
 
Hi,

Do not have an exact diagram as its a slight adaptation of an earlier design but this is very close.

This is the basic circuit, though the glcd has been changed for a standard 16x2 lcd and the FT232 has become the max232. plus the extra input filters mentioned above.
Only 2 of the 3 switches were used and are on board.

The psu pcb is a typical 15v transformer with 05 and 12v regs.

The pcb layout is below, with a couple of noted errors.


Anything in particular you would be suspecting ?
 
Have you checked the RCON register to find the source of the reset? Do you have BOR turned off?

Mike.
 
Have you checked the RCON register to find the source of the reset? Do you have BOR turned off?

Mike.

Hi,

No, had not checked RCON, afraid its a feature / function I had not really been aware of, though can program it to be transmitted out by the link to the pc as see what is happening, though too late for tonght.

Yes, have BOR turned off, full config below.


CONFIG OSC=INTIO67, PWRT=ON, BOREN=OFF, WDT=OFF, MCLRE=ON, LPT1OSC=OFF, PBADEN=OFF
CONFIG LVP=OFF, XINST=OFF, DEBUG=OFF
 
Last edited:
... Do not have an exact diagram as its a slight adaptation of an earlier design but this is very close.

This is the basic circuit, though the glcd has been changed for a standard 16x2 lcd and the FT232 has become the max232. plus the extra input filters mentioned above.
....

Does your MAX232 have all the required caps, there should be quite a few caps there and none are shown.

The reset is likely a ground line issue when the PC is turned on, you could try adding a series resistor on each of the RS232 lines to the PC serial port (gnd and TX) try about 470 ohms each but if that is too high and you lose comms you might need to reduce to 270-180 range. Also increase the decoupling cap size on the MAX232 and/or add another cap like a 47uF tantalum cap or 220uF electro at its power pins.
 
Do you have BOR turned off?
That was going to be my best guess; but you already ruled it out. I would still check the RCON register to let you know what caused the reset. You can display it t the beginning of the program through the LCD - a normal power up should show different from a reset condition.

From the schematic there is very little to infer from the power supply. I would offer a few hints. Every time you are interfacing between two "supply" worlds; that is every time you can be joining different "potentials" (because grounds are different, not shared, you name it), you should isolate the lines using some series element. You are using an FT232 (it looks like); but even then I would have a small series resistor on the TX and RX lines (say 100ohms). Somehow I doubt that may help much; it looks like your power supplies are on a different board. So you have to makes sure all the decoupling resides on both the power supply and the PIC board. From the schematic it is hard to tell; but I would make sure the PIC and FT-232 have decoupling caps at their supply pins (i.e. right next to them). Also, you may want the 0.1uF for high frequency decoupling and 1 or 10uF for low frequency energy storage. These last ones may be needed because it looks you may have long ground runs (i.e. no real ground plane - so cap to ground really looks like cap in series with significant inductance to ground). Another option would be to place very nice bus wires to between the PIC ground (and FT232 gnd) and the power supply ground to make sure your ground return is "beefed up".
 
Hi All,

Many thanks for the helpful info, I will try and examine Rcon plus the resistors inline and extra caps as mentioned, and let you know the results.


MR RB
Does your MAX232 have all the required caps, there should be quite a few caps there and none are shown.

Yes, its the standard max232 chip with 1uf caps, 4 on the voltage doubler plus 1uf on the +5v rail as Maxim show plus a 100nf; though seems , as you say, it needs a much bigger value, easily corrected



Languer

The FT232 has been replaced with the Max232.
The board does have 100nf on every chip but most were smd so hard to see on that pcb layout.
(The diagrams were just for personal reference so not complete in every detail. )

Again, as with Mr.RB, looks as if I should have fitted more higher value decouplers, which I can still do along with the stronger ground wire you mention.


One point that may have some relevance, though I can never get to the bottom of, the Pics psu has the +5v and 0v line, typically refered to a ground.
Should this 0v 'ground' be connected to mains Earth or should they be kept separate, using the Earth for cable shielding etc ?
Currently Earth is not connected to 0v Ground
 
Hi,

Success !

Ran all the mods suggested earlier this morning and voila , no more resets regardless of how often I switch the laser printer or the whole PC system on or off.

Just got in and switched on the pc and every things still clean; the RCON register just keeps returning its power up value of 0x9C , which I think is ok if I interpret its bits 4 - 0 correctly.


Thanks to you all for the help .
 
Status
Not open for further replies.

Latest threads

Back
Top