Serial comms voltage divider

I spent the last couple of nights troubleshooting a frustrating problem with serial commuications. No matter what I tried, I could not get an 18X receive data from my PC on any pin other than the programming serial in pin. I could send data, I could program the Picaxe, I just couldn't get the Picaxe to hear the PC using the SERIN command.

I looked through the forums and found some older threads about troubleshooting the serial inteface and tried all the things mentioned in there. I did all of the following:

  • Make sure the 18X could be programmed, it could.
  • Set up another Picaxe and run serial comms through it. That worked fine.
  • Loopback the serial cable and test that characters sent from the terminal came back to the terminal. They did.

Finally, I checked the idle voltage on my serial cable. I use an Airlink 101 USB-to-serial adapter, and it showed an idle voltage around -6 volts. I dug up an old "Getting Started With Electronics" book I have (by Forrest Mimms!) to look up voltage dividers and figured out that my Picaxe was seeing 1.875 volts instead of 3.75 volts.

Thinking that may be the problem, I reversed the resistors in the voltage divider on the serial input pin. If I figured it out right, now my Picaxe is seeing 4.125 volts.

Switching the resistors on the voltage divider worked, and my Picaxe is now receiving data from the PC. The problem is, I'm not sure if what I did was the right thing. Every serial circuit I've seen for the Picaxe has a 22K resistor in front of the input pin and a 10K resistor to ground. By swapping them am I putting my Picaxe in danger? If so, what should I do instead?

Thanks,
Chuck
 

hippy

Technical Support
Staff member
Your download and every other SERIN interface should look like this ...

Code:
                           .------------.
                _____      |            |
PC In >---.----|_____|---->| SI         |
          |      22K       |            |
         .|.               `------------'
         | | 10K               PICAXE
         |_|
          |
         _|_ 0V
It's not and never has been a voltage divider. The 22K is a current limiting resistor which stops excessive voltage from damaging the PICAXE. The 10K is only there to stop the line foating high when the cable is removed.

If your PC / interface isn't putting out the right voltage it may be necessary to reduce the 22K value.
 
Last edited:
I could have swore I read that it was a voltage divider. I trust you, however.

So what you're saying is that now I've pulled the input down to ground with the 22k and am using the 10k to limit current, right?

Any suggestions for what to replace the 22K with?
 

BeanieBots

Moderator
Definitely NOT a potential divider.
If you have the pull-down on the correct side of the current limiter, there will be no voltage drop at all except any that might result from the input clamp diode.
You should not need to change any of the values unless your PICAXE and/or PC are putting out low voltages.
If you MUST drop the current limiting 22k, then be careful that you choose a value that will not exceed either the maximum input current for the PICAXE or the MINIMUM current ever drawn by the supply should the serial connection ever be made to a PC +/- 12v serial comms.
IMHO, you should limit input current to 2mA absolute max.
The tricky one to get right is not to exceed the supply minimum.
If you are using a regulator for the supply, putting 12v via a current limit resistor into the input COULD raise the entire supply rail and cause damage.
What value resistor you use depends on the rest of your circuit and what voltages you run at.
 
Last edited:

Mycroft2152

Senior Member
Yup, all votes are in amd it's definitely not a voltage divider.

Unfortunately some PC's are a little loose with the serial port voltages and changing the resistor values is a quick fix.

I have an old laptop that worked fine with 08M's and the 22k/10k interface, but the same laptop would not work with 18x unless the values were reversed. It was definitely a voltage issue. Another fix, is to build a buffer circuit from some gates.
 
OK, not a voltage divider. I knew the programming serial input wasn't a voltage divider -- I wish I could retrace the steps that took me down the garden path to believing the SERIN circuit was a voltage divider, then I could figure out where I went wrong. Oh well.

Using 12 volts as the "normal" serial voltage levels, and knowing that my laptop serial port puts out just over 6 volts, using Ohm's law says the current limiting resistor should be 12K-ish. But from what BeanieBots says, I should be careful not to make it too low so I don't have to build a new circuit for another PC. What I think I'll do is try a descending series of resistors 'til I get the one with the highest value that lets the Picaxe see the PC's signals.

I have one unanswered question, however. If the programming input pin and a general-purpose input pin both use the same circuit, why does the programming input pin work and the general-purpose input pin not work?

Chuck
 

BeanieBots

Moderator
Your question is a good one.
Are you absolutely sure you don't have the resistors forming a potential divider?
If your serial is 6v, then the PICAXE will see about 5.5v with the rest being clamped by the internal clamp diode. 22k should be perfectly OK with 6v from the PC.
Try removing the 10k pull down. (it will be OK as long as the PC remains connected).
If it works without the 10k but not with it, then it looks like you still have a potential divider and not a current limit with pull-down.
 

hippy

Technical Support
Staff member
I wish I could retrace the steps that took me down the garden path to believing the SERIN circuit was a voltage divider
22K/10K = Divide by 3, 15V/3 = 5V so it's a logical assumption to make. When I got my first PICAXE I convinced myself the diagram in the manual was wrong :)

Using 12 volts as the "normal" serial voltage levels, and knowing that my laptop serial port puts out just over 6 volts, using Ohm's law says the current limiting resistor should be 12K-ish. But from what BeanieBots says, I should be careful not to make it too low so I don't have to build a new circuit for another PC.
That's the real problem; go too low and when you do put +/-12V in there's too much current sourced into the input pins. One solution is to use the 10K/22K and put another 22K in parallel with the 22K plus a Molex link so you can insert/remove it as required. Or 12K + 10K in series.

I haven't been able to find a recent Microchip datasheet which states what the maximum injection current into a pin can be. AN521 for the old 16C5x says the limit was +/-500uA and can go as low as 30uA and still work. 12V/22K = 545uA.

You could use a 12K plus 10K linear pot in series and wind it down until it starts to work.

If the programming input pin and a general-purpose input pin both use the same circuit, why does the programming input pin work and the general-purpose input pin not work?
It could be because SI ( Leg 3 ) is internally Schmitt gated, whereas others are TTL ? You could try by using In6-In7 which are also Schmitt on the 18X, In0-In2 are TTL.

22k should be perfectly OK with 6v from the PC.
I'd have thought so too ( I'm using 560K on the Spinning Thing, 20uA ) but other people have in the past reported problems with laptop serial.
 
Dope slap

Are you absolutely sure you don't have the resistors forming a potential divider?
...
Try removing the 10k pull down. (it will be OK as long as the PC remains connected).
If it works without the 10k but not with it, then it looks like you still have a potential divider and not a current limit with pull-down.
Ding ding ding! We have a winner!

When you stare at these connections long enough the simplest mistakes can get past you. My 18X lives on a breadboard, with all of the input pins tied high through 10K resistors. So to make it into a serial input circuit, you just move it to ground, right?

You have to move it down the breadboard to where the 22K resistor is if you want the serial input to actually work.
 

BeanieBots

Moderator
Glad you found it and thanks for being honest.
IMHO, those who have reported the "fix" to be a reduction in the 22k, probably have made the same mistake.
A 22k/10k potential divider from 6v into a 5v PICAXE is borderline working. Hence reducing the 22k is likely to make it work.
Reducing the 22k when it is driving 100Mohm//10pF (PICAXE input load) is going to have almost no effect.
 
Top