Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Converting 28v signal to logic levels for MCU.

Status
Not open for further replies.

ItsMike

New Member
Hey everyone,

I'm wondering what would be the easiest way of converting a 28v signal to 'high' logic level for mcu.

I've read somewhere that pics have an internal diode clamp or something so I would only need a series resistor to read the 28v as '1'.

Would these diodes tolerate 28v ?

Is there a better way to convert the 28v to '1' for the pic ?

Thanks in advance, Mike.
 
A resistor divider is probably the easiest

Not a good idea
Would these diodes tolerate 28v ?

Can cause a lot of bad things to happen.
 

Attachments

  • Divider.jpg
    Divider.jpg
    36.2 KB · Views: 582
Last edited:
What is this 28V coming from? Can you explain exactly what you're trying to do?
 
Last edited:
I have a system which I want to test.
Basically it should output 28v or 0v depending on it's input condition.
I thought of using a digital input pin instead of an ADC since I only care about the logic level.

Anyways, I'll just use a resistor divider.

Thanks.
 
Hey everyone,

I'm wondering what would be the easiest way of converting a 28v signal to 'high' logic level for mcu.

I've read somewhere that pics have an internal diode clamp or something so I would only need a series resistor to read the 28v as '1'.

Would these diodes tolerate 28v ?

Is there a better way to convert the 28v to '1' for the pic ?

A simple series resistor is perfectly fine, and is used in endless MicroChip application notes - including direct from the mains to a PIC pin.

But if you don't mind using two resistors instead of one, then a simple potential divider is fine as well - and has the advantage that it reduces the LOW voltage as well, as a 28V logic signal may not go low enough for a 5V logic input (and the diode only clamps the HIGH, and not the LOW).
 
Rather than attempting to reduce the voltage at the source and have the source directly drive the logic circuitry, you can use something like a relay or even an optoisolator to do the trick for "indirect" drive of the logic circuitry if the 28V source is capable of driving a 10-15mA load. This, I think, would be a "cleaner" way of doing things as the uC circuitry will not affect the loading or operation of the 28V circuit that you're monitoring.

If you decide to go the optoisolator route I recommend the 6N138 or similar. The 6N138 will accept a relatively low input current, the emitting LED only requires a forward voltage drop of around 1.3V and is a fast switching device (rise time = <2uS).

Here's a schematic using a 6N138 optoisolator to do the job you're asking. The 4K7 resistor is sized for a forward current of roughly 5-6mA with a 1.3V drop across the emitter LED on a 28V source voltage -

opto1-jpeg.53693


And here's a way to do it with a small signal relay. The 1K resistor is sized assuming a coil rating of 12V @ 15mA on a 28V source. The Omron G5V-2-H1-DC12 is a perfect match for this. Even though it's a DPDT relay, you would just use one of the internal switches in it -

relay1-jpeg.53695
 

Attachments

  • OPTO1.jpeg
    OPTO1.jpeg
    31.6 KB · Views: 3,562
  • RELAY1.jpeg
    RELAY1.jpeg
    40.4 KB · Views: 1,936
Last edited:
I'm with Nigel on this. I've seen Atmel appnote for mains zero cross detectors that utilize nothing more than a series resistor from isolated mains the same as the PIC ones, it's common practice. Simply limit the current through the clamp diode to perhaps half it's rated value and you should still get more than enough voltage to read a logic high.
 
You can use A TLL input with a series resistor and most times it will work like a charm. But it can cause problems.

The potential divider will work with any problems so would Jon Wilder optoisolator.

I have used the clamping diodes with 120 volt Ac worked fine, But after testing some small signal diodes used as clamping diodes there is a chance that they could blow and send the high voltage where you don't want it.

So i ask microchip Engineer got a nice reply, any thing was ok as long as you say in spec. So i did some more testing and I would say that any of these ways work but I will not be poking a pic with 120 ac any more with a resistor it could hurt you or kill you.

My reason is this I post a lot of stuff that a person that has little electronic training would try to build on a solderless bread board with out any isolation very bad idea. And if they ask can i do this I don't want to be the one that tells them yes and they get hurt.

28 volts not going to hurt you but the pic may not like it .
 
Last edited:
The beauty of the optoisolator is that the driving circuit doesn't need to be referenced to the same reference as the uC circuit. It's basically current loop technology if you think about it.
 
I will not be poking a pic with 120 ac any more with a resistor it could hurt you or kill you, only if you have no idea how to chose the correct resistor for that situation.
 
28 volts not going to hurt you but the pic may not like it .

You seem to be missing the point?, the PIC doesn't see 28 V - only 5.?V - and is 100% perfectly OK and within spec.

Jon Wilders suggestions are perfectly fine, if incredibly expensive (comparatively), but you wouldn't even consider using them for such a trivial task - you use them when isolation is required, not a simple (and small) logic level shift.
 
Just FYI for the OP...my suggestions were by no means a "you must do it this way or else" suggestion. They were meant as a "here's another way you can do things" suggestion. Granted the relay method would be the most expensive of the two, although perhaps the simplest, while the optoisolator can be had for around USD0.80 vs a USD0.10 resistor and a USD0.05 zener diode. I was more concerned with circuit loading myself as the inputs will draw SOME small amount of current through the dropping resistor, which will further enhance the voltage drop and cause the loading issue. Although perhaps "trivial" or "miniscule", the suggestions I offered would have zero loading from the uC inputs provided the 28V source was capable of driving 5-15mA loads.
 
Last edited:
I was more concerned with circuit loading myself as the inputs will draw SOME small amount of current through the dropping resistor, which will further enhance the voltage drop and cause the loading issue. Although perhaps "trivial" or "miniscule", the suggestions I offered would have zero loading from the uC inputs provided the 28V source was capable of driving 5-15mA loads.

You've got things the wrong way round :D

Both of your methods would INCREASE loading on the source massively, PIC's are CMOS devices and require next to no current for their input switching. If you're using the protection diodes for clipping, then the current is purely based on the value of resistor you use - and there's nothing to stop you using megaohm values.
 
As resistors are cheap I would prefer to use a voltage divider. And also a filter cap across the bottom resistor, as caps are cheap too. ;)

If your input signal changes slowly (like a button or mechanical switch) a large filter cap will give huge rejection of noise and also a huge reduction in voltage spikes that might hurt your PIC.

There should be a forum sticky for good simple input/output connecting to microcontrollers, things like voltage dividers, debounce RC filters, output driving one transistor, driving LED, driving relay etc as these simple things get asked constantly.
 
You've got things the wrong way round :D

Both of your methods would INCREASE loading on the source massively, PIC's are CMOS devices and require next to no current for their input switching. If you're using the protection diodes for clipping, then the current is purely based on the value of resistor you use - and there's nothing to stop you using megaohm values.

I wasn't speaking of loading the main 28V source. I was speaking of the potential of loading the newly created 5V source via either a purely resistive divider or a resistor/zener arrangement.
 
Out of the horses mouth
Many manufacturers protect their I/O pins from
exceeding the maximum allowable voltage
specification by using clamping diodes. These
clamping diodes keep the pin from going more
than a diode drop below VSS and a diode drop
above VDD. To use the clamping diode to protect
the input, you still need to look at the current
through the clamping diode. The current through
the clamp diodes should be kept small (in the
micro amp range). If the current through the
clamping diodes gets too large, then you risk
the part latching up. Since the source resistance
of a 5V output is typically around 10Ω, an
additional series resistor is still needed to limit
the current through the clamping diode as

With a voltage divider no chance of latching up, And there are chances of using a part that doesn't have clamping diodes there are pins
that don't have them.
 
Last edited:
Just wondering guys:

I played in the falstad circuit simulator to see how I'd go about converting 28VAC to something the PIC could work with. I used an astable 555 in place of the PIC because that circuit sim doesn't have a PIC. Can someone look at this schematic and tell me if it's looks like it would do the job of taking the 28 VAC signal and converting it into a stable 5ish DC volts for the PIC to work from?

I know the guys was talking DC in the original post, but I've got something that has 28V AC that I'd like to monitor. Please see picture, attached.

The 555 resistors values were mostly just random.

Long story short I'd like to monitor an old thermostat for duty cycle of different components in the system (heat, a/c, etc). These things can be monitored by testing the voltage of the different terminals on the thermostat. I'd like to use a setup like this to create a stable power supply, and then several other setups to to the AC to DC conversion and then the DC level shifting so I can test the state of each pin on the thermostat and use that to increment counters and what not.

Will this type of hardware setup work?
 

Attachments

  • 28V AC to power DC IC.png
    28V AC to power DC IC.png
    30.5 KB · Views: 471
Last edited:
I wasn't speaking of loading the main 28V source. I was speaking of the potential of loading the newly created 5V source via either a purely resistive divider or a resistor/zener arrangement.

Sorry, but that still doesn't seem to make any sense? - and no one has even suggested a zener here so far?, which is yet another possibility, but even more pointless.

There's no load from a PIC pin, it's a CMOS input, and as for the protection diode, the idea of that is to cause a 'load' and reduce the voltage to 5V actually on the PIC pin.
 
That will work just find wannaBinventor

It 'may' work (I haven't bothered working out the current in the potential divider and that required by the 555), but it's a VERY, VERY poor way of doing it, and VERY, VERY inefficient as well. If I was an examiner marking a design like that, the student wouldn't get a pass :D

If he really wants to lower the supply to the 555, then use a regulator (a simple transistor, zener and resistor would be enough).

But a simple 47K resistor (as an example value), direct to the PIC pin from the 28V is all that's required.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top