Author Topic: PIC inputs and diode clamps and switching regulators, oh my.  (Read 4741 times)

0 Members and 1 Guest are viewing this topic.

Offline asgard

  • Regular Contributor
  • *
  • Posts: 119
  • Country: us
PIC inputs and diode clamps and switching regulators, oh my.
« on: November 23, 2010, 10:47:51 pm »
Greetings, Brue Telievers...

I have a project that requires me to present sensor data to a digital input pin.  The problem with that is the sensor presents a 5V signal, yet the input pin is only rated to 3.3 volts (Really 3.6v, but I don't want to push my luck).
Two methods of fixing this was presented by way of a Xilinx app note.  A FET with the gate to the 5v signal, source to the 3.3v supply, and the drain to the input pin is one method.  The other is a diode clamp with a resistor in series tied ot the 3.3v rail with the diode tied to the 5v signal and the 3.3v input pin.  That seemed like the best low-cost way
to get the circuit working.  I have been down the mill with level-shifters, so that is not the right way for me.
I was warned by somebody with way more brainpower than myself, that a diode clamp would cause the switching regulator (an LM3940) to shut down, since the load current would exceed the source.  I "think" I can put a parallel resister across the source on the regulator to increase the quiescent current across the source so that the regulator will continue to switch, but I only have a tenuous grasp of the math here.  Any tips?

J.R.


Klaatu Barada Nikto!

J.R. Stoner Bifrost Development Group asgard@jeffnet.org
 

alm

  • Guest
Re: PIC inputs and diode clamps and switching regulators, oh my.
« Reply #1 on: November 23, 2010, 11:08:45 pm »
Clamping diodes can work if you include a series resistor to limit current. You need to make sure that your diodes conduct before the internal diodes, which are often not rated for any current (hence the absolute max. input voltage of Vcc+1 diode drop or so).

One solution that I like is to make it an open collector output with pull-up. Put a diode in series with the output, with the cathode facing the output. Put a pull-up resistor (few kohm or so) to 3.3V on the anode side, and connect the anode to your input. The diode will conduct if pulled low, and the output voltage will be one diode drop (use Schottky diode to limit this to 0.3V or so). If the output is high, the diode will be reverse biased, and the pull-up resistor will pull it to 3.3V. Disadvantage is that low is slightly above 0V (should be well within VIL of your input), and the rise time is limited by the RC time of the pull-up resistor plus the (parasitic) capacitance of the input. I've used this successfully for 115200 baud async serial (UART), if your sensors are much faster than that, you may need an active solution.

I think Sparkfun has a page with various options, and this is number three or so. The other options are either more complex or use undocumented specs of the part (eg. ESD clamping diodes, datasheets often state that they should not conduct any current, and rarely give safe limits).
 

Offline TechGuy

  • Regular Contributor
  • *
  • Posts: 79
Re: PIC inputs and diode clamps and switching regulators, oh my.
« Reply #2 on: November 24, 2010, 07:11:29 pm »
Greetings, Brue Telievers...

I have a project that requires me to present sensor data to a digital input pin.  The problem with that is the sensor presents a 5V signal, yet the input pin is only rated to 3.3 volts (Really 3.6v, but I don't want to push my luck).
Two methods of fixing this was presented by way of a Xilinx app note.  A FET with the gate to the 5v signal, source to the 3.3v supply, and the drain to the input pin is one method.  The other is a diode clamp with a resistor in series tied ot the 3.3v rail with the diode tied to the 5v signal and the 3.3v input pin.  That seemed like the best low-cost way
to get the circuit working.  I have been down the mill with level-shifters, so that is not the right way for me.
I was warned by somebody with way more brainpower than myself, that a diode clamp would cause the switching regulator (an LM3940) to shut down, since the load current would exceed the source.  I "think" I can put a parallel resister across the source on the regulator to increase the quiescent current across the source so that the regulator will continue to switch, but I only have a tenuous grasp of the math here.  Any tips?

J.R.





You use a 1K to 10K resistor so that the zener diode doesn't draw a lot of current.

Input ---> 1K Res -+---> MCU Pin (3.3)
                           |
                         Zener
                           |
                         GND

That said you should be able to use a 10K resistor without the zener since the resistor would limit the current to about 500 uA @5V. Which would prevent damage to the MCU pin. You can use an even larger Resistor if your sensor data output speed is low.
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1378
  • Country: us
  • Very dangerous - may attack at any time
Re: PIC inputs and diode clamps and switching regulators, oh my.
« Reply #3 on: November 24, 2010, 07:53:08 pm »
Many 74AHCxxx parts can accept inputs up to 5 volts while powered from a lower voltage (typ 2.5 to 3.3).
The 74AHC244 octal buffer is one such part.

http://www.nxp.com/documents/data_sheet/74AHC_AHCT244.pdf
« Last Edit: November 24, 2010, 11:22:28 pm by oPossum »
 

Offline asgard

  • Regular Contributor
  • *
  • Posts: 119
  • Country: us
Re: PIC inputs and diode clamps and switching regulators, oh my.
« Reply #4 on: November 24, 2010, 10:57:10 pm »
So you are saying a diode clamp, such as this, would not work for me?  Can a normal diode, such as a 1N4148, work?
I also am trying to figure out what the resistor values, especially R1, should be to ensure the regulator turns on.

J.R.
Klaatu Barada Nikto!

J.R. Stoner Bifrost Development Group asgard@jeffnet.org
 

alm

  • Guest
Re: PIC inputs and diode clamps and switching regulators, oh my.
« Reply #5 on: November 24, 2010, 11:12:15 pm »
So you are saying a diode clamp, such as this, would not work for me?  Can a normal diode, such as a 1N4148, work?
The absolute max input voltage is Vcc+0.3V according to your requirements. The forward drop of a silicon diode like the 1N4148 is something like 0.4-0.6V, so the input will be clamped to something like 3.7-3.9V. Outside the PIC's specs. The disadvantage of this method is that you're putting two diodes in parallel, and you don't know much about the internal diodes. You could risk and it will likely work (at least for a while), but I dislike exceeding specs unlike I know what will happen. I don't usually consider myself better able to judge device capabilities than the manufacturer, so I design for worst case specs (i.e. it will blow up if I exceed the absolute max by 1mV).

I also am trying to figure out what the resistor values, especially R1, should be to ensure the regulator turns on.
5V/R1 >= minimum regulator output current
 

Offline asgard

  • Regular Contributor
  • *
  • Posts: 119
  • Country: us
Re: PIC inputs and diode clamps and switching regulators, oh my.
« Reply #6 on: November 24, 2010, 11:38:41 pm »
O.K.  If I blow off the discretes and use 74AHC244 buffers it simplifies everything logically, but introduces prop delay,
That might be the bitter pill I must swallow for this project.  But one other complication could result from the nature
of the input source.  This will be a rotary encoder which, being a mechanical device, could have transient surges or foreshortened pulse widths due reverse rotations.  That being the case I wonder if there is a risk of getting metastabile lockups in the buffer.

J.R.
Klaatu Barada Nikto!

J.R. Stoner Bifrost Development Group asgard@jeffnet.org
 

Offline tyblu

  • Frequent Contributor
  • **
  • Posts: 287
  • Country: 00
    • blog.tyblu.ca
Re: PIC inputs and diode clamps and switching regulators, oh my.
« Reply #7 on: November 25, 2010, 12:40:04 am »
This is definitely a digital input, not analog (ADC)? The methods here are for digital'ish signals (ie: non-linear responses).
Tyler Lucas, electronics hobbyist
 

Offline asgard

  • Regular Contributor
  • *
  • Posts: 119
  • Country: us
Re: PIC inputs and diode clamps and switching regulators, oh my.
« Reply #8 on: November 25, 2010, 05:44:55 am »
The input is bitonal, but the source (the sensor) is (probably) not.  It is going to be a simple phototransistor or photodiode.  Since the sensor is as cheap as I could budget I don't think the maker would spec a photo-Darlington device or somesuch.  Therefore, I expect to see a considerably lower-magnitude slope than is typical for TTL-level signals.  In addtion, the pulse width of the signals are by necessity random in duty cycle due to the direct mechanical linkage with the sensor.  It could be all worry over nothing, since the speed of the signal is going to be low, but randomness means the possibility must be designed against since the buffer would not be able to recover from a metastable lockup and so the MCU could get spurious transitions.

J.R.
Klaatu Barada Nikto!

J.R. Stoner Bifrost Development Group asgard@jeffnet.org
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1378
  • Country: us
  • Very dangerous - may attack at any time
Re: PIC inputs and diode clamps and switching regulators, oh my.
« Reply #9 on: November 25, 2010, 05:49:57 am »
74AHC14 hex Schmitt trigger inverter may work well with an encoder.

http://www.nxp.com/documents/data_sheet/74AHC_AHCT14.pdf
 

Offline dfnr2

  • Regular Contributor
  • *
  • Posts: 238
  • Country: us
Re: PIC inputs and diode clamps and switching regulators, oh my.
« Reply #10 on: November 26, 2010, 08:58:40 am »
I agree, you need a schmitt trigger on each channel to ensure a reliable response.  However, before designing in the 'HC14, you will need to check out the waveform and make sure that the dead zone of the 74hc14 is well within the detector output range under all conditions.  Otherwise you will get valid TTL signals that don't accurately reflect the quadrature behavior.  In that case, you would be better off using a dual op-amp configured as two schmitt triggers (one per detector).  You can then set the trigger points to whatever voltage you want.  Tie the open-collector outputs up to 3.3V with a resistor much smaller than the feedback divider network.  This will stabilize and square up the quadrature signals.  Any workaday comparator such as an LM2903 will work fine.  You can do the detection in software if you hook the conditioned detector signals to some "change on interrupt" pins, or if your software has other stuff to do, you can use one of the great encoder chips from usdigital (http://usdigital.com/products/interfaces/ics/) with up/down outputs hooked up to counter increment inputs on the uc.

These encoders actually incorporate schmitt triggers, but unless the dead zone is perfect for your application, you're better off making your own schmitt trigger anyway.

By the way, if your quadrature detector is a couple of phototransistors or whatever, what's to keep you from just powering them (and the LED's) with the 3.3V?  Then you could avoid having two supplies.  You'd still want a schmitt trigger, though.

Dave
« Last Edit: November 26, 2010, 09:02:49 am by dfnr2 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf