Technical Query....

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Technical Query....

Post by Sparkoids »

Hi guys,

Trawling around the internet I have discovered that a lot of sites with electronic designs, particularly those involving switching to microcontrollers, have extra components fitted.

So for example a switch that is "Active Low" in Flowcode has a 10k pull up resistor (which I understand ok) but some sites have the input, despite being on the same power rail as the PIC, going to the micro with the pull up as described but also with a 22pF capacitor to ground.

I get the reasons for that being the case but is it necessary to do that?

I even know someone who said not to fit any pull ups or caps because the PIC has them fitted internally.

All three methods work OK with Flowcode generated software so are all these extra components necessary for long term reliability or not (and why please)...

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Technical Query....

Post by medelec35 »

Sparkoids wrote: I even know someone who said not to fit any pull ups or caps because the PIC has them fitted internally.
Not true in the case of inputs in my experence.

Here are my thoughts
Since an input to a microcontroller has a very high input resistance, a pull-up or pull down resistor is 100% essential In the case of single throw switches that are either closed or open circuit.
Without a pull-up or pull-down resistor, then with switch open circuit the input to a microcontroller will be floating. So a finger or electrical noise near the i/p would be enough to cause the i/p to change from logic 0 to logic1. This is undesirable.
The cap is probably there to decouple any interference, and perhaps acts to stop switch de-bouncing (when switch is first closed the contacts briefly open and close (bounce) very quickly)
If a microcontroller is reading an input very quickly and increments a count variable by 1 when switch is first closed, then after switch has close, counter will read a random value depending on how many times switch has bounced before resting in the closed position.
If a suitable capacitor is found, then the bouncing will be more rapid than the time cap takes to charge and discharge, so the voltage i/p to microcontroller will be steady.
Switch de-bouncing can achieve in the software. E.g if i/p has change state, wait 5ms, then recheck i/p voltage.

People also use cap if they want the i/p to be at 0V when power is first applied (even if switch is o/c) and a pull up resistor is used.

Martin
Martin

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Re: Technical Query....

Post by Sparkoids »

Hi Martin,

I am using pull up resistors just because it's what I've always done but thanks for the description of the caps.

I will lose them, clear the ports and keep the debounce in software.

Thanks fella - just wanted to make sure the long term reliability of the circuit wouldn't be affected...


James :-}

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Technical Query....

Post by medelec35 »

Sparkoids wrote: I even know someone who said not to fit any pull ups or caps because the PIC has them fitted internally.
Actually I just had a thought of what this person is talking about.

Microcontrollers have weak internal pull-up resistors, that you have to enable. They are not active as a default
The most common way of activating them is using a C code block with clear_bit(option_reg , 7); But best to check with data sheet for correct commands .

So they are correct, you don't always need a pull-up resistor. But you only get weak pull-ups not weak pull downs,


Martin
Martin

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Re: Technical Query....

Post by Sparkoids »

Hi Martin,

The pull ups and pull downs are staying fitted but I didn't know if he was right about his internal resistors assertion and fortunately didn't have a couple of beers and hit the email as I would often have done!

Thanks for that...

James :-}

Post Reply