Need help on ‘enhanced’ interface circuit is used on a serial connection

Spirobot

New Member
Hi,
I have read the following information in a Post.

"From Picaxe manual 2, page 133

“When using the debug command to output 10 bit numbers, the electrical
connection to the computer via the serial download cable may slightly affect the ADC values. In this case it is recommended that the ‘enhanced’ interface circuit is used on a serial connection (cable AXE026, not required with USB cable AXE027 as this uses 5V logic anyway). The Schottky diode within this circuit reduces this affect.”

Also refer to manual 1 p.37."


I have read From Picaxe manual 2, page 133 and manual 1 p.37. I do not understand the term ‘enhanced’ interface circuit is used on a serial connection.

I do not seem to see any information on ‘enhanced’ interface circuit is used on a serial connection. What am I missing, is it as plain as the Serial Download Circuit on page 37 of manual 1 and its diagrams.

Assistance on this matter would be greatly appreciated.

Thanks Spirobot
 

BCJKiwi

Senior Member
Page 145 in the current manual 2

This is the enhanced circuit.
The 180R and the Bat 85 as shown change the 'standard' download circuit into the 'enhanced download circuit'
 

BeanieBots

Moderator
The significance of the "enhanced" download circuit is to prevent any negative current from entering the chip (which upsets the A2D conversion). If your serial comms uses 0v - 5v signal levels (as found on some laptops), then it is not required.

If the signals are closer to true RS232 levels, then you can achieve the same effect by putting any old diode in series with the serin line to prevent any negative currents. If using a diode to clamp the negatives (as shown in the PICAXE manual), then it MUST be schottky type.
 

john2051

New Member
@Beaniebots

Hi, sorry for interrupting, I take it there's no physical damage possible if the -5 to -12v gets to the serial input pin?

kind regards john
 

MPep

Senior Member
Not normally. Many people only ever use the standard download circuit from a serial port. Seeing as they can output anywhere between 0V and -12V, you should not experience problems.
 

Dippy

Moderator
Within reason, the killer is related to current.
Most PICAXE pins have clamping diodes which can 'take the excess away' as long as it doesn't have to dissipate too much power (and some other reasons). If the circuit didn't use high-ish Res values then it would be an early bath.

I always feel happier using the enhanced circuit though. I guess it's a kind of empathy ;)
 

Andy2No

Member
I bought quite a few prototype boards, and AXE092 school experimenter boards quite a while ago, plus a breadboard adaptor, all of which I haven't used yet. Rather than modify them all, can't I just build the enhanced circuit into my serial cable?

It looks like I can just cut wires in the cable and add the 180R resistor and the schottky diode. Am I missing something?

enhanced interface - 180R and Schottky protect PICAXE.jpg

How critical is the 180R value? I'm not sure if I have any. I could make close to that value by soldering a couple of what I have together.
 

nick12ab

Senior Member
The 180R value isn't critical. The serial port would still get a high/low signal even if you used a 1k or higher.
 

Andy2No

Member
Thanks, Nick.

Okay. I see the problem (must be the heat). The schottky diode has to be on the chip side of the 22k resistor. I can build the whole of that circuit into the serial cable instead, and fit a wire link instead of the 22k resistor on each board, but then they can only be used with the serial cable. I wouldn't be able to use them with a USB cable if I bought one. Not a big problem though, I suppose. They're more expensive anyway.

I can't help wondering why all of that circuit wasn't built into the cables, rather than having to be placed on each board.

Do I also need those components if I connect two boards together through the serial ports? E.g. to use the LCD module?

It seems quite awkward to have to shoe horn two extra components onto a lot of boards that weren't designed to take them.
 

Technical

Technical Support
Staff member
Why do you want to use the enhanced circuit - is it purely for work with 10 bit adc readings? If so a true logic level USB cable like the AXE027 will give you better results anyway, and would be a lot less hassle in the long run. If not adc/touch work, do you actually need the enhanced circuit at all - probably not!?
 

Andy2No

Member
I thought it was necessary to protect the newer chips from over voltage on the serial cable, not just for the 10 bit ADC readings.
 

nick12ab

Senior Member
I thought it was necessary to protect the newer chips from over voltage on the serial cable, not just for the 10 bit ADC readings.
That is only true when receiving RS232 signals on the _MCLR pin of PICAXEs where this pin is a normal input but without clamping diodes so applying a high RS232 voltage to this pin would put the PIC microcontroller in programming mode and you easily risk erasing the PICAXE bootloader by accident.
 

Andy2No

Member
Well, that does sound like something to avoid :)

Is there a relatively simple alteration I can make to my serial cable to avoid mishaps like that, and still use it with the original boards but with the newer chips? Should I be aiming to limit the serial in voltage to, say 0V-5V?
 

nick12ab

Senior Member
Well, that does sound like something to avoid :)

Is there a relatively simple alteration I can make to my serial cable to avoid mishaps like that, and still use it with the original boards but with the newer chips? Should I be aiming to limit the serial in voltage to, say 0V-5V?
Yes, add an external clamping diode. However the _MCLR pin is not the same as the programming pin so you don't need to add a clamping diode for normal programming - only if you are going to use RS232 comms on the pin. This pin can easily be identified because it is a)input-only and b)not the Serial In programming pin. For example it is pinC.6 on the 20X2.
 

Andy2No

Member
Okay. Thanks.

I've read in another thread that Microchip recommend that input voltages should be between -0.3V of GND and +0.3V of Vdd. It seems to me that wouldn't be the case here, unless the PICAXE was running at 5V and the COM port of the PC was only outputting 0V-5V signals.

I guess if it works, it works, but it makes me a bit nervous. Some sort of input conditioning on the cable would seem like a good idea, to me.
 

nick12ab

Senior Member
I've read in another thread that Microchip recommend that input voltages should be between -0.3V of GND and +0.3V of Vdd. It seems to me that wouldn't be the case here
It's different for the _MCLR pin (line because it is active low for reset). Also the clamping diodes are designed to allow higher voltages at low currents on ther pins.
 

Andy2No

Member
Okay. Thanks. Maybe I'll just add the 180R or so resistor on the serial out side of the cable, to the actual cable. I don't suppose there's any harm in doing that, and it's easy enough to do. I guess that's just meant to protect the pin from giving too much current.
 

nick12ab

Senior Member
I guess that's just meant to protect the pin from giving too much current.
Giving too much current? A lot of current will only come out of the pin if the attached load demands it. A serial port does not demand current. You only need resistors for things like LEDs where the voltage needs to be dropped and the current consumption is constant.
 

Andy2No

Member
Yes, I get that. If the serial port was shorted to ground, that would be a problem, but it's not going to be, hopefully.

I'm talking about the serial out pin of the PICAXE, so giving (i.e. sourcing) current makes sense to me. There has to be some reason why the 180R is thought to be necessary in some circumstances. That's the only reason I can think of.
 

mrburnette

Senior Member
Yes, I get that. If the serial port was shorted to ground, that would be a problem, but it's not going to be, hopefully.

I'm talking about the serial out pin of the PICAXE, so giving (i.e. sourcing) current makes sense to me. There has to be some reason why the 180R is thought to be necessary in some circumstances. That's the only reason I can think of.
OR ... use the RevEd USB cable or something like this: bub_ii. Peter Anderson in the U.S. also sells 'em already reprogrammed for "inverse" to suit the PICAXE serial protocol. http://www.phanderson.com/picaxe/

I bought a bunch of $0.99 clone Prolific USB adapters that cannot be reprogrammed (intended for Arduino) and I use a small NPN to invert the output signal for polarity... works great after I spent a weekend trying to find a working USB driver... but success was eventually mine. Might as well get used to it because new PCs rarely have a serial port especially notebooks. For any non-me projects, I just automatically factor in the cost of USB.

- Ray
 

Andy2No

Member
Thanks for the links, Ray.

As I live in the UK, the easiest solution would be to just buy a USB cable from techsupplies.co.uk, but I've just spent a chunk of money ordering bits from them, and I already have two PICAXE serial cables doing nothing, and two PCs with serial ports, so it seems a bit of an unnecessary expense, at the moment. I'm just wondering what's the best way to make use of what I've got.
 

mrburnette

Senior Member
Thanks for the links, Ray.

As I live in the UK, the easiest solution would be to just buy a USB cable from techsupplies.co.uk, but I've just spent a chunk of money ordering bits from them, and I already have two PICAXE serial cables doing nothing, and two PCs with serial ports, so it seems a bit of an unnecessary expense, at the moment. I'm just wondering what's the best way to make use of what I've got.
Well, use what you got and plan for the next PC that will not have RS232.

-Ray

Or... make your own USB interfaces vusb
 

Andy2No

Member
Yep. So the consensus is that it's okay to just use the original 22k/10k resistor circuit with the bare serial cable for programming all versions of the PICAXE, despite what the Microchip datasheets seem to say about input voltages?
 

mrburnette

Senior Member
Yep. So the consensus is that it's okay to just use the original 22k/10k resistor circuit with the bare serial cable for programming all versions of the PICAXE, despite what the Microchip datasheets seem to say about input voltages?
I vote, Yes... RevEd has not withdrawn the circuit and numerous users worldwide seem to be getting away with it. But, I suspect the brains at RevEd may have taken a different path if they were just starting out today.

- Ray
 

Andy2No

Member
Okay. Thanks, Ray and Nick. I guess I'll just do that and not worry about it for now. Solutions that don't involve me having to do any extra work are always my favourites anyway :)

FWIW, the "enhanced" circuit, and Armp's circuit for connecting to a PICAXE running at 3.3V, from that other thread -



- only takes care of the low end of the input voltage, clamping it to GND-0.3V or so. To add a belt to the braces, you'd need a second schottky diode connected to Vdd (to clamp it to Vdd+0.3V), which couldn't be done as part of a modifcation to the cable without adding an extra wire, though the rest of Armp's circuit could.
 

Andy2No

Member
I get the idea though. The 18k resistor (R1) forms a potential divider with the original 10k resistor, which is fine if you know the limits of the input voltage (+15V, presumably), and the maximum voltage you want at the serial in pin.

Adding a second Schottky diode (to Vdd) would be less dependant on the voltages involved, and you could reduce his R1 to a smaller value that just protects the PCs serial port from a short circuit - e.g. I'd guess 100R would be fine, and shouldn't affect anything else.
 

MPep

Senior Member
Okay. Thanks, Ray and Nick. I guess I'll just do that and not worry about it for now. Solutions that don't involve me having to do any extra work are always my favourites anyway :)

FWIW, the "enhanced" circuit, and Armp's circuit for connecting to a PICAXE running at 3.3V, from that other thread -



- only takes care of the low end of the input voltage, clamping it to GND-0.3V or so. To add a belt to the braces, you'd need a second schottky diode connected to Vdd (to clamp it to Vdd+0.3V), which couldn't be done as part of a modifcation to the cable without adding an extra wire, though the rest of Armp's circuit could.
I can't see that circuit working as you have created a voltage divider with the 18k and 10k resistors.The 22k is still acting as a current limit for the internal diode.
 

Andy2No

Member
A voltage divider was what Armp had in mind, I think, MPep. His circuit was designed for programming a PICAXE fed from 3.3V and he was trying to make sure the voltage fed to it stayed inside Microchip's specs. It looks about right to me.

However, if R1 was smaller, the effect on the voltage seen by the serial in pin would be less. If a smaller resistor was used (e.g. as small as 100R), in conjunction with a second Schottky diode with the cathode connected to Vdd, the pair of Schottky diodes would limit the voltage to roughly GND-0.3V to Vdd+0.3V, and the resistor R1 would protect the output of the PCs serial port from being shunted to one or other power rails by the diodes.
 

mrburnette

Senior Member
'tis would work for true RS232 +/- 12-15V signaling
'tis does not look like it will work for FAUX 5V RS232 signaling

Enhanced @5V RS232.jpgEnhanced @15V RS232.jpg

$ 1 5.0E-6 12.050203812241895 50 5.0 50
r 160 208 304 208 0 18000.0
d 304 288 304 208 1 0.305904783
w 304 288 160 288 0
w 304 288 384 288 0
w 384 288 496 288 0
r 384 288 384 208 0 10000.0
w 304 208 384 208 0
r 384 208 496 208 0 22000.0
d 496 288 496 208 1 0.805904783
d 496 208 496 128 1 0.805904783
R 496 128 496 96 0 0 40.0 5.0 0.0 0.0 0.5
g 160 288 160 336 0
w 496 208 544 208 0
R 160 208 112 208 0 5 400.0 5.0 0.0 0.0 0.5
o 12 64 0 35 10.0 9.765625E-5 0 -1
http://www.falstad.com/circuit/

Note: I modified the diode (BAT85) in the simulation to have a 0.3V drop
Such simulations do not accurately portray the input dynamics, but do assist in rationalizing what is happening sometimes. Best to prototype the real thing, use your scope and signal source (I keep an 08M2 programmed as a "fox" RS232 generator). Guessing rarely works.

- Ray
 

Andy2No

Member
That's impressive, Ray, though i've no idea what those numbers mean :)

However, Armp's 18k resistor was chosen for Vdd = 3.3V, and i think 12-15V RS232. Also, the second Schottky diode was my suggestion, but that was for a much smaller resistor, doing a different thing - I suggested 100R to protect the serial port from being shunted to ground or Vdd, not to limit the voltage as Armp was trying to do. I've no idea whether that's essential, but it seemed like a reasonable precaution... i'd also pictured the second Schottky diode being connected to the same point as the first, though now you mention it, just having them connected to the input pin would save having to have the small resistor

So, neither of us actually suggested the exact circuit you've just simulated :) Thanks anyway though...

Are your diodes at the input representing clamping diodes built into the chip?
 

srnet

Senior Member
That's impressive, Ray, though i've no idea what those numbers mean :)
Me neither.

By the time I learn to trust numbers like that as meaning something, I thing I will be long gone.

And if it runs under plastic double glazing, forget it.
 

Andy2No

Member
Okay. I get it. The numbers are what you pasted into the File->Import box, in that applet.

Here it is again with the 5V changed to 3.3V for Vdd (purely using trial and error)

enhanced Armp 18k.jpg

Code:
$ 1 5.0E-6 12.050203812241895 50 5.0 50
r 160 208 304 208 0 18000.0
d 304 288 304 208 1 0.305904783
w 304 288 160 288 0
w 304 288 384 288 0
w 384 288 496 288 0
r 384 288 384 208 0 10000.0
w 304 208 384 208 0
r 384 208 496 208 0 22000.0
d 496 288 496 208 1 0.805904783
d 496 208 496 128 1 0.805904783
R 496 128 496 96 0 0 40.0 3.3 0.0 0.0 0.5
g 160 288 160 336 0
w 496 208 544 208 0
R 160 208 112 208 0 5 400.0 5.0 0.0 0.0 0.5
o 12 64 0 35 10.0 9.765625E-5 0 -1
So it still only gets the serial in input up to 1.79V, with a pulse of 5V peak. I'll wade through datasheets to see if that's enough another time. TTL is normally 2.2V minimum for high, I think. I don't know what the requirement is for a PIC. or if the logic high level is allowed to be lower when the PIC is running off a lower voltage. Even so, I think Armp stated that he was desiging it for a 12-15V input.

Simply scrapping the 18k resistor, and the Schottky diode on the left, and putting our own clamping Schottky diodes at the serial in input, would seem to be the easiest solution, and should work for any reasonable input voltage. Although the PIC has some already, putting nice big chunky ones of our own on would remove any worry.

I'd be interested to know how you drew that, Ray. Is it hard to do?
 

Andy2No

Member
Are the 22k/10k resistors still needed/used if the AXE027 PICAXE USB Download Cable is used instead of the serial cable?

As the levels are presumably already 5V, I assume there's no need for them, but does having them there create any problems?
 

mrburnette

Senior Member
I believe the answer would be Yes for the 10K and No for the 22K if you know for certain that the levels are 5V.

- Ray

SPICE is fun, ugh? "I'd be interested to know how you drew that, Ray. Is it hard to do? " ... the applet drew the circuit via drag 'n drop. See Paul's nice YouTube video for an introduction: http://www.youtube.com/watch?v=3JaOmdH9z0g
 
Last edited:

Andy2No

Member
I see. So I can't make PICAXE boards that are compatible with both types of cable - the old serial one and the new USB one?

I still can't figure out how to use that applet. It just keeps giving me messages like "Matrix error" or "4 bad connections", whatever I try to draw.
 

mrburnette

Senior Member
@Andy2No:
application error sounds like a Java VM issue... perhaps having to do with Windows RAM allocation/paging. My 4G machine is not a good one to use to find issues... I'll try later on a 512K Windows XPSP3 box.
I saw another link in the forum recently to a SPICE online program but I have no experience with this one: https://www.circuitlab.com/editor/#

So I can't make PICAXE boards that are compatible with both types of cable - the old serial one and the new USB one?
Well, you could have a board with a "bridge" to cut for using the older cable, said bridge shorting out the 22K. You could also (maybe as I have not run this through SPICE) use a 4.3V zener to clip voltages higher than 5V. I found this reference...
http://electronics.stackexchange.com/questions/25691/measuring-frequency-of-a-signal-above-5v-with-a-microcontroller




- Ray
 
Last edited:
Top