Searching \ for '[PIC] AC Detection' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/power.htm?key=ac
Search entire site for: 'AC Detection'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] AC Detection'
2007\04\05@203330 by Yigit Turgut

picon face
Hi all,

I have 50Hz input between 0 - 400mv amplitude.And I want to give
specific outputs for ranges.

For example ;

Input : 40mv - 111mv Output : 1V
Input : 112mv - 214mv Output : 1.5V
.
.
.
.
.
Input : 280mv - 400mv Output : 5.0V

Betwen 40mv - 112mv output will be 1V
    "      112mv - 214mv    "      "    "  1.5V and so on.

Maximun output will be 5V.Since I will be measuring the output with a
16F877 voltmeter,it would be nice to embed these operations in this
PIC.I have ;

from 3 to 10
15 and 16
from 18 to 30

numbered pins empty.

But, I am confused about seperating the ranges and giving the
output.Suggestions are welcomed.

Cheers

2007\04\05@205658 by Jinx

face picon face
> I am confused about seperating the ranges and giving the
> output.Suggestions are welcomed.

Hi Yigit. First of all it would probably help to get better resolution -
amplify the AC up to 5V pk-pk or use Vref+

To separate the ranges, 16-bit subtraction tests and gotos would be
fairly straightforward

And for the output, a resistive divider on each pin, multiplexed
to a common point with output resistors, perhaps to a buffer
amp. Only the active output is set as such and to '1', all others
would be hi-Z

The other option would be to use PWM into an RC filter and
monitor/adjust the voltage with the ADC

You don't give all the steps, perhaps there's a logic solution using
resistors and 4066 gates

2007\04\05@215028 by Sergey A.Dryga

face picon face
Jinx <joecolquitt <at> clear.net.nz> writes:

>
> > I am confused about seperating the ranges and giving the
> > output.Suggestions are welcomed.
>
> Hi Yigit. First of all it would probably help to get better resolution -
> amplify the AC up to 5V pk-pk or use Vref+
>


If number of steps allow, you can use LED bar=graph driver to convert input
voltage to output steps.  Each ouput can go to diode, followed by resistor to
make a divider where only output pin with "1" contributes to output voltage.  

You will need to amplify the signal and rectify it to convert 50Hz to DC.




2007\04\05@224611 by Jinx

face picon face


> If number of steps allow, you can use LED bar=graph driver

The LM391x or something like it did pop into my head but the full
relationship between Yigit's input and output wasn't spelled out

2007\04\06@031046 by Yigit Turgut

picon face
> > If number of steps allow, you can use LED bar=graph driver
>
> The LM391x or something like it did pop into my head but the full
> relationship between Yigit's input and output wasn't spelled out

Well,I am planning to get all the output from one pin.I actually
haven't heard of anything like this before since all things must be
handled by the software what is left is a bunch of "if's".As pseudo ;

if(input<=112mv){ output=1v; } and so on.At the top of all the if's is the

if{(input<=400mv) {output=5v; }

is this code embedable somehow ? I mean can't I sense the input "values" ?

2007\04\06@035650 by Robert Rolf

picon face

Yigit Turgut wrote:

>>>If number of steps allow, you can use LED bar=graph driver
>>
>>The LM391x or something like it did pop into my head but the full
>>relationship between Yigit's input and output wasn't spelled out
>
>
> Well,I am planning to get all the output from one pin.I actually
> haven't heard of anything like this before since all things must be
> handled by the software what is left is a bunch of "if's".As pseudo ;
>
> if(input<=112mv){ output=1v; } and so on.At the top of all the if's is the
>
> if{(input<=400mv) {output=5v; }
>
> is this code embedable somehow ? I mean can't I sense the input "values" ?

Seems to me that the simplest solution to what he seems to be describing
(variable voltage in converted to discrete steps of voltage out)
is to use an A/D with sufficient bits to get desired number output steps
tied to D/A with same number of bits.
Scale up the input value to have it cover the required number of steps,
and scale the D/A to get the output voltage range he requires for that number
of steps.

No PIC needed.

If he really wants to use a PIC, he needs one with on board A/D, and either
CCP/PWM output or software PWM to fake out a D/A (doesn't say how fast he
has to do this conversion so a simple R/C low pass filter may be sufficient).

I know of no PIC with on board D/A to give him "one pin" output.

Robert

2007\04\06@042052 by Jinx

face picon face
> Well,I am planning to get all the output from one pin

Hi Yigit. Don't quite understand that. You originally said you have

"from 3 to 10
15 and 16
from 18 to 30

numbered pins empty"

So all these pins are available for resistors ? Or do you really want
to have an analogue voltage generated by one pin ? I mean, could
be extravagant and use a frequency to voltage convertor. What sort
of settling time for this voltage are you looking at ?

> if{(input<=400mv) {output=5v; }
>
> is this code embedable somehow ? I mean can't I sense the
> input "values" ?

Sure - http://www.piclist.com/techref/microchip/codeflow.htm

2007\04\06@111546 by Yigit Turgut

picon face
> "from 3 to 10
> 15 and 16
> from 18 to 30
>
> numbered pins empty"
>
> So all these pins are available for resistors ? Or do you really want
> to have an analogue voltage generated by one pin ? I mean, could
> be extravagant and use a frequency to voltage convertor. What sort
> of settling time for this voltage are you looking at ?

yes those are empty but voltmeter (which is going to measure the
output) probes will be consant.This is why I said that the output must
be at one pin.

And Robert, can you extend your NON-PIC solution a little bit further,
it sounds matching my need.

2007\04\06@181025 by Jinx

face picon face

> yes those are empty but voltmeter (which is going to measure the
> output) probes will be consant.This is why I said that the output
> must be at one pin

One PIC pin is just one point in the circuit. Would the output of an
op-amp (buffering a DAC) also not count as 'one pin' ?

You'll have to excuse me - I don't see the importance of the voltage
being on a PIC pin specifically

2007\04\06@183927 by Jinx

face picon face
> > Input : 40mv - 111mv Output : 1V
> > Input : 112mv - 214mv Output : 1.5V
> > (unspecified)
> > Input : 280mv - 400mv Output : 5.0V

> use an A/D with sufficient bits to get desired number output steps
> tied to D/A with same number of bits

Hi Robert, the steps Yigit has indicated above don't suggest a linear
relationship. If it isn't log either, then something with smarts is going
to have to translate

Yigit, can you detail the input ranges and voltage out for each please

You haven't said what 'quality' of output voltage (eg PWM ripple,
precision) you want and how quickly

2007\04\07@011807 by Yigit Turgut

picon face
> > > Input : 40mv - 111mv Output : 1V
> > > Input : 112mv - 214mv Output : 1.5V
> > > (unspecified)
> > > Input : 280mv - 400mv Output : 5.0V
>
> > use an A/D with sufficient bits to get desired number output steps
> > tied to D/A with same number of bits
>
> Hi Robert, the steps Yigit has indicated above don't suggest a linear
> relationship. If it isn't log either, then something with smarts is going
> to have to translate
>
> Yigit, can you detail the input ranges and voltage out for each please
>
> You haven't said what 'quality' of output voltage (eg PWM ripple,
> precision) you want and how quickly

Well deadline is monday.

Exact values are like these ;

Input   : 30-57-130-202-270-330-380-422-460-492-520 (mV)

Output :  0 - 0.5 - 1 - 1.5 - 2 - 2.5 - 3 - 3.5 - 4 - 4.5 - 5 (V)

11 values for both.First I will put an offset with a SGA to get 0 for
that 30mv input.And then I am planning to use a non-inverting
(probably) LM358 gain amplifier.Since the graph is

http://img441.imageshack.us/my.php?image=graphprcjt01es8.jpg

seems like it can be operate -almost- linear.

But of course I do have time to adapt it to PIC and it would be really
good since I can get precise output with it.

2007\04\07@020857 by Robert Rolf

picon face
Yigit Turgut wrote:

>>>>Input : 40mv - 111mv Output : 1V
>>>>Input : 112mv - 214mv Output : 1.5V
>>>>(unspecified)
>>>>Input : 280mv - 400mv Output : 5.0V
>>
>>>use an A/D with sufficient bits to get desired number output steps
>>>tied to D/A with same number of bits
>>
>>Hi Robert, the steps Yigit has indicated above don't suggest a linear
>>relationship. If it isn't log either, then something with smarts is going
>>to have to translate

A programmed EPROM. A/D = address. D/A =data for D/A.
A PIC would be easier to 'tweak'.

>>Yigit, can you detail the input ranges and voltage out for each please
>>
>>You haven't said what 'quality' of output voltage (eg PWM ripple,
>>precision) you want and how quickly
>
>
> Well deadline is monday.

You're going to have fun meeting that.
School project/assignment?

{Quote hidden}

Quite an odd shape. Something like a brightness correction curve for a lamp dimmer.
Is the output really SUPPOSED to be step wise? That is NOT what your graph shows.
It shows a incremental output for every input value, not a fixed one.

> But of course I do have time to adapt it to PIC and it would be really
> good since I can get precise output with it.

PIC A/D. Use lookup table (or if-then-else tree) to create D/A value to
use in software or hardware PWM to get you a 1 pin output.

Lots of software PWM code out there.

Robert

2007\04\07@023633 by Yigit Turgut

picon face
> It shows a incremental output for every input value, not a fixed one.
>
> > But of course I do have time to adapt it to PIC and it would be really
> > good since I can get precise output with it.
>
> PIC A/D. Use lookup table (or if-then-else tree) to create D/A value to
> use in software or hardware PWM to get you a 1 pin output.
>
> Lots of software PWM code out there.

This graph is the graph of the measurements.Of course it supposed to be linear.

2007\04\07@040227 by Jinx

face picon face


> > You haven't said what 'quality' of output voltage (eg PWM ripple,
> > precision) you want and how quickly
>
> Well deadline is monday.

Haha, no what I meant was how quickly you need the voltage to
settle if you use PWM !! If you were attempting to follow the AC
that might get tricky because of the RC filter. It wouldn't be so
tricky with switched resistors though

I agree with Robert re PIC

Monday is a bit soon but it should be doable

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...