Current sensor sampling

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
Hello,

I'm using this current sensor TLI4970 located at the emitter leg of a power IGBT, which is being switched at 10 kHz. I'm reading the sensor every 10 ms. However, sometimes I get expected values, and sometimes I get strange values. Does this have to do with the sampling frequency? Is this behavior normal? I know that I'm measuring current on a switching element, which is why I'm probably not getting a "constant current value". What are your thoughts?
 

kubeek

Joined Sep 20, 2005
5,795
What are you trying to measure? If the average current, then you have to use a low pass filter at less than 5KHz. If the peak current, RMS, or anything else that requires high frequency content, then you have to seriously rethink your strategy.
 

crutschow

Joined Mar 14, 2008
34,470
If it's being switched at 10 kHz and you are only sampling every 10ms, then the sample value depends upon where in the 10 kHz period the sample occurs.
What are the "expected values".
You may need to synchronize the samples with the desired portion of the 10kHz wave.
 

danadak

Joined Mar 10, 2018
4,057
Are you trying to get an instantaneous value or a profile of rise/fall ?

If former you need to over sample the sensor and pick max, typically SAR type A/D
would easily accomplish this. It would be easy to add internal digital comparator to
below schematic and make peak detection trivial off the DMA channel. If profile boost
the SAR rate to 1M SPS and trigger DMA to take synchronously one cycle of
samples and then do with the profile data set whatever you want, offload it over
COMM or display it or .......

Something like this -

upload_2018-9-28_16-32-13.png

The stuff internal to this processor familiy, attached is component list. A component
is an onchip resource.

Regards, Dana
 

Attachments

Last edited:

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
What are you trying to measure? If the average current, then you have to use a low pass filter at less than 5KHz. If the peak current, RMS, or anything else that requires high frequency content, then you have to seriously rethink your strategy.
I have a typical low side switching setup, so I have the load at the collector leg and I decided to place the sensor at the emitter leg of the Power IGBT. What I expect to measure is the DC average current through the load, which is a DC motor.
 

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
If it's being switched at 10 kHz and you are only sampling every 10ms, then the sample value depends upon where in the 10 kHz period the sample occurs.
What are the "expected values".
You may need to synchronize the samples with the desired portion of the 10kHz wave.
Let's say I'm getting 6A (what I expect), then in the next measurements I get values around 0A. Then I get 6A again and so on.
 

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
If it's being switched at 10 kHz and you are only sampling every 10ms, then the sample value depends upon where in the 10 kHz period the sample occurs.
What are the "expected values".
You may need to synchronize the samples with the desired portion of the 10kHz wave.
I had dropped this topic for a while. I'm getting back to it now.
At the end of the day, I'm switching the IGBT at 5 kHz. I'm thinking of triggering an interrupt every rising edge of the PWM signal, and sample the current at this point. Do you think it's a good idea?
 

kubeek

Joined Sep 20, 2005
5,795
If you want still to measure the average current, then use a low pass filter to get the average, and then sample that with ADC at whatever sample rate suits you. If you have any additional requirements, like controlling said current in a closed loop, then you will need to describe what you want in a much better way.
 

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
If you want still to measure the average current, then use a low pass filter to get the average, and then sample that with ADC at whatever sample rate suits you. If you have any additional requirements, like controlling said current in a closed loop, then you will need to describe what you want in a much better way.
Ok. It just seems weird to me that I have to use an ADC, when the sensor gives me a digital signal.
 

danadak

Joined Mar 10, 2018
4,057
Then average the data stream.

Attached some ap notes on the topic.

Synch sampling is good as long as your timing allows
for mux changes, settling time of switching events, etc..


Regards, Dana.
 

Attachments

ebeowulf17

Joined Aug 12, 2014
3,307
Ok. It just seems weird to me that I have to use an ADC, when the sensor gives me a digital signal.
If it's digital, maybe it has built in capabilities. Can you set/change parameters on it? Can you configure it for some sort of average/RMS output?

If you're just getting a stream of instantaneous digital samples from it, you're going to have a hard time getting useful averages from it unless your sample rate goes up dramatically. Sync'ing it with on-times will only ever get you the instantaneous current reading when it's on, not the average current of both on and off times (I think, unless I'm totally misunderstanding your control system.)
 

mcgyvr

Joined Oct 15, 2009
5,394
Let's say I'm getting 6A (what I expect), then in the next measurements I get values around 0A. Then I get 6A again and so on.
The sensor is a snapshot in time..
The 6A is the snapshot of when the IGBT is switched on.. The 0A is when the IGBT is switched off..
Its switching on and off at the 5kHz frequency.. Its all about the timing..
A multiple snapshot average is needed or a way to sync the timing..
 

cmartinez

Joined Jan 17, 2007
8,257
Ok. It just seems weird to me that I have to use an ADC, when the sensor gives me a digital signal.
I've used sensors like that before (though not the exact type you're using) and both crutschow and kubeek are right. Those sensors deliver the instantaneous reading from the current flowing through them in such a way that you could construct the current's waveform if you wanted to. The easiest path that I see for you to take is to sync your readings using a zero-crossing detector as a timing reference.
 

cmartinez

Joined Jan 17, 2007
8,257
Xavier, take a look at this thread. It deals, more or less, with the same problem you're facing, but using a different sensor with different characteristics. Your sensor is digital, while mine is analog. I found it far more convenient to use an analog sensor since (in my case in particular) what I needed to do was to trigger an MCU's input when a certain amount of current was detected. And I accomplished that by using a simple comparator.
 

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
At first glance, thanks you all for your comments. I want to point out that I'm dealing with this sensor for educational purposes. I'm not interested in replacing it with another one with different characteristics for now. Whether an analog sensor is better, it's alright. For a next application, I will thoroughly examine different options for current measurement.

Some caveats:
1- There's no way for me to reprogram the sensor, i.e, change bandwidth and OCD feature. I have to use it with default parameters.
2- The sensor is physically mounted on a PCB, that's why I can't change it.
3- The microcontroller for the application is an STM32 clocked at 32 MHz, SPI clock is 2 MHz.

As I'm aware I can't reprogram the sensor, I want to do as much as possible with its default parameters.
Because the sensor is located in a transistor switched at 5 kHz, I was thinking of connecting the 5 kHz signal to another pin and trigger an interrupt routine every rising edge of the PWM signal. This routine would only pull CS low, read SPI and pull CS high.That way I thought I would measure current only when the transistor is ON. I still don't know if this approach is convenient. I can also program an interrupt routine at a fix frequency, and sample the sensor at that frequency, but that would only give me a lot of random values, which I later need to average them somehow. What I actually want to accomplish is to read the current and give a warning if certain value is exceeded.
 

mcgyvr

Joined Oct 15, 2009
5,394
Sounds like averaging is the way to go and just requires a software adjustment..
Or comparison and drop out those that are far from your average "high" number or whatever depending on the accuracy you need and sample rate..
 

cmartinez

Joined Jan 17, 2007
8,257
At first glance, thanks you all for your comments. I want to point out that I'm dealing with this sensor for educational purposes. I'm not interested in replacing it with another one with different characteristics for now. Whether an analog sensor is better, it's alright. For a next application, I will thoroughly examine different options for current measurement.

Some caveats:
1- There's no way for me to reprogram the sensor, i.e, change bandwidth and OCD feature. I have to use it with default parameters.
2- The sensor is physically mounted on a PCB, that's why I can't change it.
3- The microcontroller for the application is an STM32 clocked at 32 MHz, SPI clock is 2 MHz.

As I'm aware I can't reprogram the sensor, I want to do as much as possible with its default parameters.
Because the sensor is located in a transistor switched at 5 kHz, I was thinking of connecting the 5 kHz signal to another pin and trigger an interrupt routine every rising edge of the PWM signal. This routine would only pull CS low, read SPI and pull CS high.That way I thought I would measure current only when the transistor is ON. I still don't know if this approach is convenient. I can also program an interrupt routine at a fix frequency, and sample the sensor at that frequency, but that would only give me a lot of random values, which I later need to average them somehow. What I actually want to accomplish is to read the current and give a warning if certain value is exceeded.
If the spi clock is running that fast, then you should be able to take many samples per second and average them using simple binary division.

The small challenge will be making measurements in sync with the waveform's frequency. This so you could calculate a reliable average value.
 
Top