Load Current Sensing with PIC

Discussion in 'The Projects Forum' started by jwilk13, Oct 24, 2011.

  1. jwilk13

    jwilk13 Thread Starter Member

    Joined:
    Jun 15, 2011
    Messages:
    228
    Location:
    California
    Hi all,

    I've recently started back up on a previous project, and I have a new feature that I would like to add. I'm trying to measure the current to the load with my PIC18F45K20; a schematic is given. The BSP762T is a high-side switch with its input coming from RC2 of the PIC (this is a PWM signal, ~100 Hz). The load is inductive, and is connected at H3. I'm trying to get the lowest cost solution, and I'm guessing this is going to be with a shunt resistor, I'm just not sure how to apply it to my particular application.

    If it makes any difference, the load is connected to ground at all times, so the high side switch is necessary. I'm not sure if this means I need a high-side current measurement technique or not, and I'm hoping you guys here can help me out. Also, the load current varies from 0-2A with the PWM signal at a peak of 24VDC when varied from 0-95%.

    I've done some reading on the subject, so any practical knowledge would be greatly appreciated. Thanks in advance.

    [​IMG]
  2. jwilk13

    jwilk13 Thread Starter Member

    Joined:
    Jun 15, 2011
    Messages:
    228
    Location:
    California
    I stumbled on a neat little current monitoring device from Diodes, Inc. and wanted to get everyone's thoughts. I did some more testing, and the maximum current draw is 1A, not 2. The attached image is what I came up with. Think this will work?

    [​IMG]
  3. SgtWookie

    SgtWookie Expert

    Joined:
    Jul 17, 2007
    Messages:
    22,080
    Location:
    In the vast midwest of the USA; CST
    Looks like it might, but you have the upper left labeled "RC2". You actually need to put this sensor AFTER the junction of D1 and the BSP 762 pin 3 (out). That way the current flowing through the diode when the high-side switch turns off will also be measured.

    You mention ~1A for the load current, but the high side switch is rated for 2A. That's sort of pushing it a bit close, don't you think? I like to have MOSFETs rated for 3x or more the current that will be flowing through them.
  4. jwilk13

    jwilk13 Thread Starter Member

    Joined:
    Jun 15, 2011
    Messages:
    228
    Location:
    California
    Silly mistake...I know better than that :p

    In reality, the load current will most likely never get to 1A, more like 0.75A for short periods of time (seconds). But you're right, it is a bit close. They also list a typical nominal current of 2.4A depending on mounting conditions, and I plan on mounting it with more than adequate active heatsink area. Hopefully that's enough, but if it's not, I'll give you the chance to say "I told you so" :p.

    I'll give the current sensor a try and see how it goes. Thanks for the input.
  5. jwilk13

    jwilk13 Thread Starter Member

    Joined:
    Jun 15, 2011
    Messages:
    228
    Location:
    California
    Here's what I came up with. I'm wondering if someone can verify my resistor values. As stated: max current is 1A (high side of load is connected at H3), R12 and R13 are 1k, R14 is 33k, R11 is the current sense resistor and its value is 0.1 ohms. My goal is to have Vout range from 0-3.3V because that's what my A/D on the PIC is using as reference. This is my first attempt at this, so thanks for the help.

    [​IMG]
  6. SgtWookie

    SgtWookie Expert

    Joined:
    Jul 17, 2007
    Messages:
    22,080
    Location:
    In the vast midwest of the USA; CST
    Why don't you upload your .sch (and .brd if you have one).

    You're starting to run power rails around everywhere; it would be so much cleaner if you simply used symbols (I like using the supply2.lbr symbols) to connect things to power and ground.
  7. jwilk13

    jwilk13 Thread Starter Member

    Joined:
    Jun 15, 2011
    Messages:
    228
    Location:
    California
    Here's something hopefully a bit cleaner. We've talked about this particular schematic before, so a couple of things I already think I know:

    1. The efficiency of the voltage regulators is going to be bad and the amount of power dissipated as heat is going to be relatively high due to this inefficiency. Going with a switching regulator would be a better choice, but I don't have that luxury right now.

    2. The high side current monitor uses an operational amplifier configuration, and because of this, extra care has to be taken in the PCB design to minimize EMI that could cause adverse measurements.

    As far as #2 is concerned, I'm still trying to read up on that subject, but it seems like some sort of guard ring should do the trick. I'm just still not sure how to do that with the package that the device is in. Because of this, I don't have a board layout yet, but suggestions as to some things to take into consideration might be helpful :). The big thing right now is making sure the circuit works as I think it should, in particular the high-side current monitor.

    [​IMG]
  8. jwilk13

    jwilk13 Thread Starter Member

    Joined:
    Jun 15, 2011
    Messages:
    228
    Location:
    California
    As per SgtWookie's request, here's a sample board design for the above schematic. I tried to place components such that analog and digital are somewhat separated, but I'm still unsure about U5. I know I want the component leads as short as possible, but I was under the assumption that I also want the device to be some distance away from the switching device (U4). Basically, my main concerns are with EMI/EMC and noise affects, especially on U5. I'm new to this process, and reading application notes on EMI/EMC reduction is only getting me so far. Nothing seems to give relevant examples, so any help on my design would be greatly appreciated.

    Also, a couple of questions:

    1) Should I include a bypass capacitor for U5?
    2) Would extending the top ground plane around the top power plane help? I attached a second image showing something like that. I read somewhere that this is a common practice, but I'm still unsure.
    3) Everything I've read says to separate analog and digital grounds. I'm limited to one common ground. Is this going to create problems?

    Thanks to all in advance.

    [​IMG]

    [​IMG]
Similar Threads
Forum Title Date
The Projects Forum Constant current dummy load. Please review & suggest. Aug 17, 2014
The Projects Forum CurrentLoad Question Nov 5, 2013
The Projects Forum Constant Current Dummy Load Sep 9, 2012
The Projects Forum who here wants a free 'intelligent' constant current load ?? Mar 28, 2012
The Projects Forum High current at medium speeds to inductive load Jan 13, 2011

Related Site Pages

Section Title

Share This Page