Help with ADC conversion


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2008
    Posts
    52

    Default Help with ADC conversion

    I am wanting to monitor the voltage output of a full wave bridge rectifier and determine when the RMS voltage drops below a certain value. I don't want to filter the "humps" because I want to know almost instantly when the voltage drops and stays low for a certain period of time. I don't have any code yet as I am still just thinking about how it can be done. Does anyone have any ideas or point me toward a thread that has covered this?

    Thanks, Don

  2. #2
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    A possible starting point would be:

    1. Use peak values. Set your minimum (~1.42xRMS) in software, perhaps as a constant.

    2. Use a voltage divider to give you a sample output, calculated to give a maximum which does not exceed 5V. Total series resistance of the divider will depend on the output voltage of your bridge and the current through the divider, but it doesn't need to draw even as much as a milliamp--possibly even 100 microamps would do.

    3. With an ADC port, repeatedly sample the voltage from the divider for half the period of the bridge input. (How many times depends on the precision you require.) For instance, if the input is 60 Hz, the period is 16.7 ms, so an 8.4 ms sample would do it. Or, if your processor isn't doing much of anything else, just sample continuously.

    4. Continue to sample as needed, and compare the maximum value from any given sample to the minimum you have established as a limit. When it drops below the minimum you've set, record for how many consecutive sampling cycles the value stays below.

    One note: If the output from the bridge is filtered, you'll need to put a diode between the output of the bridge and any filtering (e.g., a capacitor) and place the voltage divider ahead of that diode.

    This is off the top of my head (or "shooting from the hip").

    I'm sure there will be other suggestions, better, simpler, or both.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    If the voltage threshold is a single fixed value, I would use an comparator interrupt with some basic filtering on the Voltage comparator input. This way you can do whatever you want during the time an Low-Voltage Alarm occur.

    Still possible to use a Timer Based ADC reading... but you need to consider the ADC sampling time + Timer interrupt time in your latency.. so maybe not as this "almost instantly"

    Another possible solution... use a zero-cross interrupt and read the voltage at ~0.707Vmax... not yet "almost instantly" either.
    Last edited by mister_e; - 31st January 2009 at 23:48.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I'll second the Comparator idea, but with a little difference. (Don't filter the signal)

    Set a timer to have a delay of 20ms or more.
    Using the comparator Interrupts, reload that timer every time you get a pulse.

    If the voltage drops below the comparator's trigger point, the timer will overflow.
    Use the timer interrupt/flag to determine when there's an error condition

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3162&stc=1&d=123345227 4" />
    Attached Images Attached Images  
    DT

  5. #5
    Join Date
    Oct 2008
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Darrel, Mister_E

    I am not very familiar with comparators and the use of timers. I have been trying to read more about how to implement them. But this is what I think I need to do. Feed signal into CCP1 pin (after setting up compare module) on say an 18F1320. Set timer1 to reset after every pulse (half cycle ~8ms) by using comparator interrupt flag. If interrupt flag is not set (voltage below threshhold), timer overflows and sets overflow flag. If this is correct, what I don't understand is where the reference voltage (comparator's trigger point)to determine a low voltage condition comes from. Its probably pretty simple but I haven't grasped it yet.

    Thanks for the help,

    Don

    Edit:
    After reading the datasheet again and again and again..... I think I may not have a clue what you guys are trying to tell me...
    Last edited by dbachman; - 1st February 2009 at 19:21.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    That will be hard to setup PIC18F1320 analog comparator, as he don't have any BUT... PIC18F2220 and lots other have some already built-in.

    Internal analog comparator works as regular voltage comparator (LM393 and so on), you set a voltage reference on one input pin (voltage divider, trim pot, whatever else fancy stuff), and you apply your signal on the other input pin, then you just monitor the voltage comparator output.

    In a PIC, when the output of the comparator change, it can trigger an interrupt event, so it's done in background. Once in the Interrupt handler, you do what you need to do.

    Have a look at Darrel's Instant interrupt, this will save you some headaches. There's also some code-example on how to use'em with Timer.
    http://www.pbpgroup.com/modules/wfse...p?articleid=19

    From there, you should be able to begin some experiments.
    Last edited by mister_e; - 1st February 2009 at 19:29.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Oct 2008
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hey Steve,

    I was just check'n to see if you would catch that............not.

    Anyway, I do have a couple of 18F2550 which look like they have the analog comparators. After looking at THAT datasheet, things are becoming a little more clear. I think I actually might be able to put something together. Thanks for the help and hopefully you can stand by as I try to get this to work.

    Thanks, Don

Similar Threads

  1. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  2. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 01:48
  3. ADC conversion trouble
    By PICante in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 30th April 2008, 20:42
  4. ADC problem with PIC16F917
    By eetech in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th March 2007, 21:22
  5. ADC problem
    By NacNud in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th December 2004, 02:27

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts