Serin Serout 08M Pin3

retepsnikrep

Senior Member
Why is the below reqd. I note the explanation but what does the diode do?

"`PICAXE-08/08M/14M - Due to the internal structure of input3 on these chips, an 1N4148 diode is required between the pin and V+ for serin to work on this particular pin (‘bar’ end of diode to V+) with this circuit. All other pins have an internal diode."
Also why does the Serout command need a bracket round the variable sent when Serin does not?
 

westaust55

Moderator
Why is the below reqd. I note the explanation but what does the diode do?

“PICAXE-08/08M/14M - Due to the internal structure of input3 on these chips, an 1N4148 diode is required between the pin and V+ for serin to work on this particular pin (‘bar’ end of diode to V+) with this circuit. All other pins have an internal diode”
Your quote gives the basic answer. That is, “All other pins have an internal diode”.
All other IO pins available as an input for use with the SERIN command have an internal diode. For example, if you look at page 38 of the PIC12F683 datasheet (as used for the PICAXE 08M) you will see that GP3 has an internal diode from Vss to the input pin whereas the other GPs on pages 36 to 38 (IO pins 0,1,2,4) have both the diode from Vss to the input pin AND an internal diode from the inpit pin to Vdd (supply rail)

The diodes are reverse biased (ie opposing the normal power supply polarity) and primarily act as ESD protection. If the signal voltage goes more than 0.6V greater than Vdd or 0.6V lower than Vss the diodes conduct to prevent excessive voltage excursions damaging the PIC chip.


Also why does the Serout command need a bracket round the variable sent when Serin does not?
Because that is the way Rev Ed has defined the command syntax.
 
Last edited:

inglewoodpete

Senior Member
Perhaps stating the obvious but "Serial Data" can mean + & -12v. This can work on the PICAXE chip with the addition of the 22k + 10k "serial download" circuit. The diode is a requirement when using 2 resistors as the interface, to stop +12v melting the input circuitry on pin3. The series resistor provides current limiting to the pin.
 

retepsnikrep

Senior Member
So if I have one 08M talking directly to another 08M via pin3 is it still required?

Both have a common ground and it would appear that should work without the diode?
 

Andrew Cowan

Senior Member
No - the diode is still required. And as I pointed out, it must be a 1N4148.

My test was with an 08M talking to a 28X.

A
 

hippy

Technical Support
Staff member
The external clamping diode is only required when the input voltage source is greater than the power supply, for example PC serial. When connecting two PICAXE's together on the same supply it is not required. If the PICAXE's are on separate power supplies it would be recommended to fit the diode.

When the voltage to pin 3 is higher than the supply, the excess voltage ( at low current due to the current limiting resistor ) needs to go somewhere. The internal diodes route this to the +V supply. When the diode isn't there this voltage has to be absorbed by the chip's other internal circuitry which is 'a bad thing' so an external diode has to be added.

That's not a perfect explanation but the general principle.

When the input voltage is less than or equal to the supply, if there were a diode in place, the diode would be neutrally or reversed biased so no current would flow. Thus the diode can be removed in those cases.
 
Last edited:

retepsnikrep

Senior Member
Thanks Hippy.

I just got a pcb made and forgot about the damm diode, but as it's two 08M's directly connected on the same supply I'll keep my fingers crossed.
 

Andrew Cowan

Senior Member
I was on mine - not sure why. I was powering a 28X and an 08M off separate 7805 regulators, with a common ground. Serouting from the 28X would only be received if the 08M had the 1N4148 diode - no other configuration worked. I can only assume that the voltage regulators were producing slightly different voltage levels.

A
 

hippy

Technical Support
Staff member
@ retepsnikrep : If both PICAXE's operate from the same power supply you should have no problems. If they are separately powered it would be recommended to fit the diode. It should be fairly easy to solder it on to the track side of the PCB between leg 4 and leg 1.
 

JSDL

Senior Member
Hi Hippy, just came across this post in my search to understand how the clamping diode works. When the voltage to the input pin (in this case pin 3) exceeds the supply voltage, the clamping diode routes it to +V. My question is, how does the diode "know" to route the voltage when this occurs? In other words, what makes this happen. Excuse my lack of knowledge in this area, just looking at the download circuit and trying to understand how it works.

How does this excess voltage which is rerouted not interfere with the supply voltage?

I think I may be looking at this the wrong way. Any simple explanations would be great. Thanks
 

BeanieBots

Moderator
A diode only conducts in one direction. It is an insulator in the other direction.
In that circuit, as soon as the anode of the diode becomes higher voltage than the supply rail (where the cathode is connected), the diode will start to conduct.
The supply needs to be capable of absorbing the extra current or it will increase in voltage.
The extra current from the download resistor is very small compared to the current used by the rest of the circuit so the supply will not raise.
 

hippy

Technical Support
Staff member
When the voltage to the input pin (in this case pin 3) exceeds the supply voltage, the clamping diode routes it to +V. My question is, how does the diode "know" to route the voltage when this occurs? In other words, what makes this happen.
My first opportunity for an odd analogy in 2017 ...

I'd think of two water tanks joined by a pipe. When the input pin tank is higher than the V+ tank the water runs out into V+, the input tank level is brought down to the V+ level.

Code:
 Input       V+ Tank
|~~~~~|
|      \|~~~~~~~~~~~~~~~|
|                       |
|     |\                |
`-----' |               |
        `---------------'
Now put a one-way valve in the pipe so water can't flow out of the V+ tank when the input level is lower.
 

westaust55

Moderator
The key to the diode working and not "burning out" due to high current when the input signal is higher than Vcc / supply voltage is the series resistor.

The resistor value needs to be sufficiently high to limit the current flow.
For the standard programming circuit the 22 kOhm resistor serves that purpose.

Where detecting serial data superimposed on a 16 Volt supply, I have successfully used a 33 kOhm resistor for the current limiting requirement.
 

JSDL

Senior Member
A diode only conducts in one direction. It is an insulator in the other direction.
The supply needs to be capable of absorbing the extra current or it will increase in voltage.
Okay I am starting to understand how this works a little better. Why though does the + supply absorb the current, and it not go into the input pin? Path of lesser resistance?
 

inglewoodpete

Senior Member
Okay I am starting to understand how this works a little better. Why though does the + supply absorb the current, and it not go into the input pin? Path of lesser resistance?
Inputs on a PIC are CMOS gates: very high impedance. Practically no current flows into an input pin's gate. When the potentials are right, current can flow through a protection diode.

Current will flow where it can, limited by any resistance it encounters in its path. Assuming two RS232 cases; +12 and -12v with a 22k ohm series resistor:
The +12v case: I = (+VRS232 - Vcc - Vdiode)/Rseries Amps = (12 - 5 - 0.6)/22000 A = 6.4/22 mA = 0.29mA

The -12v case: I = (-VRS232 + Vdiode)/Rseries Amps = (- 12 + 0.6)/22000 A = -11.4/22 mA = 0.52mA

In other cases, where the chip is not powered via its supply pins and a foreign voltage is applied to an input pin, the chip can boot and/or run using power from the input pin and protection diode. Most annoying when you don't want it to happen!
 

JSDL

Senior Member
Inputs on a PIC are CMOS gates: very high impedance. Practically no current flows into an input pin's gate. When the potentials are right, current can flow through a protection diode.
Is the reason for very little current flowing through a CMOS gate because they are voltage controlled devices? Also when you refer to protection diode are you talking about the clamping diode? Thanks for the explanations they are great, still got a lot of learning to do but getting there!
 

AllyCat

Senior Member
Hi,

Basically yes. The input (MOSFET gate) connects only to a very thin insulator (glass), so no dc current should flow (similar to a capacitor). The MOSFET can be considered as being controlled by "static electricity" (i.e. electrostatic field strength).

Each pin has two diodes (one to the supply rail and one to ground) but their primary purpose is for "(chip) protection", although some may use them to "clamp" (or catch) an intended current flow. Normally, each diode is reverse-biassed (so very little current can flow) but if the applied input voltage tries to stray outside of the normal operating range (e.g. 0 - 5v), then one of the diodes comes into conduction, to prevent any higher voltages destroying the gate insulator by "electrostatic breakdown".

Cheers, Alan.
 

JSDL

Senior Member
When the potentials are right, current can flow through a protection diode.
Just a question regarding this statement. My understanding of a diode is that when forward biased(positive side connected to VCC, negative side connected to ground or 0V), then the diode will conduct. However, when reverse-biased, the diode becomes and insulator. Looking at the protection diode schematic, it appears to me that the diode is reversed-biased (negative side connected to VCC). I guess what I am looking for is:

When the input voltage is, for example, 12v, does the diode breakdown and shunt excess current (limited by the 22K resistor) to VCC

or

Am I looking at this the wrong way in that the diode is reverse biased only until the voltage at the positive side of the diode (that which is connected to the input pin of the Picaxe) becomes higher (in this example 12V) RELATIVE to the voltage at the negative side of the diode (in this case VCC which is 5V)?

I believe the problem is that I was not looking at this from the perspective that potential is simply the difference between to points, and that it is relative. When the positive side of the diode is at a higher potential than the negative side, regardless of what the actual voltage is, it becomes forward biased.

Please correct me if I am wrong. Thanks
 

techElder

Well-known member
Is this what you're looking for? Reverse current?

2. For a bias less than the PIV, the reverse current is very small. For a normal P–N rectifier diode, the reverse current through the device in the micro-ampere (µA) range is very low. However, this is temperature dependent, and at sufficiently high temperatures, a substantial amount of reverse current can be observed (mA or more).
-- https://en.wikipedia.org/wiki/Diode
If you're wondering about forward current, there is a point before the forward threshold voltage where the diode is basically a resistor.
 

JSDL

Senior Member
Actually was just wondering if I was on the right track with my understanding of the forward/reverse bias of the protection diode as explained in my post. Thanks
 

techElder

Well-known member
I just misread your original post. Sorry.

When the positive side of the diode is at a higher potential than the negative side, regardless of what the actual voltage is, it becomes forward biased.
Simply, your statement is correct, but remember that the diode has to have a potential difference greater than its threshold voltage. There is a non-linear region that occurs before this happens. In most diodes we say that threshold voltage is 0.7 volts, but some have lower threshold voltages. Etc. etc.
 

inglewoodpete

Senior Member
Am I looking at this the wrong way in that the diode is reverse biased only until the voltage at the positive side of the diode (that which is connected to the input pin of the Picaxe) becomes higher (in this example 12V) RELATIVE to the voltage at the negative side of the diode (in this case VCC which is 5V)?

I believe the problem is that I was not looking at this from the perspective that potential is simply the difference between to points, and that it is relative. When the positive side of the diode is at a higher potential than the negative side, regardless of what the actual voltage is, it becomes forward biased.
I think you're on the right track. Have a look at the attached circuit diagram. A diode will conduct when its anode is (about) 0.7 volts more positive than its cathode.
InputProtection.JPG

Using a pedantic description, the device's CMOS input gate will be protected by the protection diodes for the following two cases:
  1. When the input (and anode of the upper diode) has a potential of Vcc + 0.7v with respect to 0v/Gnd, the upper diode will start to conduct. The 22k resistor will limit the current flowing through the input and therefore the current flowing through the upper diode, preventing this diode from being damaged. The lower diode will be reverse biased.
  2. Similarly, when the input (and cathode of the lower diode) has a potential of -0.7v with respect to 0v/Gnd, the lower diode will start to conduct. Once again, the 22k resistor limits current flowing through the input and through the lower diode. The upper diode will be reverse biased.
 

JSDL

Senior Member
ok I get it now, just to clarify, when you say
with respect to 0v/Gnd
, "Gnd" can either mean 0V (typically), or an arbitrary reference point to measure voltage from, in the case of the upper diode, VCC. Would this be correct?
 

JSDL

Senior Member
thanks everyone for the great explanations, I searched Google but never fully understood it until now. Much appreciated!!
 

JSDL

Senior Member
Just out of curiosity, how does the input impedance of a Bi-Polar Junction Transistor compare to the high input Impedance of a FET? I am assuming that they have lower input impedance because they are current controlled devices and thus put more demand on the driving circuit, but not sure if my understanding is correct.

Also, what does it mean for an output to be High/Low impedance as opposed to an input? And if impedance only relates to AC, how is it that we can relate it to MCU inputs, being that they use DC? I find the topic of impedance a bit tricky to grasp. Thanks again.
 

inglewoodpete

Senior Member
Just out of curiosity, how does the input impedance of a Bi-Polar Junction Transistor compare to the high input Impedance of a FET? I am assuming that they have lower input impedance because they are current controlled devices and thus put more demand on the driving circuit, but not sure if my understanding is correct.

Also, what does it mean for an output to be High/Low impedance as opposed to an input? And if impedance only relates to AC, how is it that we can relate it to MCU inputs, being that they use DC? I find the topic of impedance a bit tricky to grasp. Thanks again.
This area can get very complex due to the dynamics of how a transistor works. With less than the forward conduction voltage of the Base-Emitter junction (Ie < 0.6 to 0.7v), the impedance is quite high due to the junction not conducting. Similarly, when the base voltage reaches the magic number, around 0.6 volts, the current that can flow is typically quite large, so the impedance is seen as quite low. The collector-emitter current also has a small effect on the base's input impedance.

In a digital circuit, the impedance of the base will vary depending on if it is being driven 'on' or 'off'. The situation for AC circuits is much more involved.

Impedance is a mathematically complex number derived from Resistance and Reactance/Reluctance. Impedance relates to AC, DC and changes in DC, so is relevant to both.
 

JSDL

Senior Member
and when we talk about outputs having high/low impedance, what exactly does that imply on the rest of the circuit?
 

rossko57

Senior Member
and when we talk about outputs having high/low impedance, what exactly does that imply on the rest of the circuit?
It's like a power supply or battery ; as you add load (draw more current) the output voltage droops. A low-impedance source has less droop than a high-impedance source. In general then, a low-impedance output is a Good Thing. But very often it won't matter if you are not loading it much anyway i.e. you've linked a high-impedance output to a couple of high-impedance inputs.

AS ever it is more complicated blah ... sources inevitably have some kind of maximum point, where current is limited or a fuse blows or something catches fire. Picaxe outputs are limited to around 20mA.
 
Top