L298 current sensor pin, convert pulsed current signal to consumption flag - Page 1
Forum section: electronics / projects

author: John Anderson
author_rank: Contributor
timestamp: February 27, 2015, 08:17:10 pm
content: Hi,I am designing a small, simple 12V motor controller fed by a L298 H-bridge driver. The H-bridge input pins are supplied by means of PWM at 40 Hz. The motor can be connected or disconnected from the output even with the input and enable on. For this reason, I am interested in adding additional circuitry in order to obtain a binary signal of consumption using the current sensor pins; that is obtain a permanent high level while some current is detected and a permanent low level when no current is detected (after at least 1 period, but this is flexible).The idea is to use a 0.5 ohm resistor to connect the sense pin to ground, and then use the voltage across the resistor to obtain the signal. I consider that the voltage measured will be from 5 mV to 1V and the Duty Cycle can be down to 1%. Because the sensor signal is also pulsed, I need somehow to filter it and obtain an stable output while consumption is 'on'. The problem is that I had not success to set properly a low-pass filter plus op-amp buffer configuration from this signal working reliably with all the mentioned conditions. I also tried to pre-amplify the sensor signal with another op-amp, then output that into the low-pass filter plus buffer, but had no success too.Any idea is appreciated. Thank you very much!

author: Zero999
author_rank: Super Contributor
timestamp: February 27, 2015, 08:50:10 pm
content: What are you interfacing with?If it's a microcontroller just use software.This can be done in hardware using the 555 timer as a missing pulse detector.http://www.ti.com/lit/ds/symlink/ne555.pdf

author: voja
author_rank: Contributor
timestamp: February 27, 2015, 11:35:31 pm
content: Put some capacitor to isolate AC component, and then amplify it with LM358 or so. Then you can do anything with the saturated signal, for instance detect it by software as Hero999 said. If there is no MCU in the circuit and you need the clean binary signal, you can make some kind of diode+capacitor combination to detect pulsed state. It is simple if you use another half of LM358 for detection, or even better LM392, it has opamp + comparator with open collector output, for good logic level.

author: John Anderson
author_rank: Contributor
timestamp: February 28, 2015, 09:23:44 am
content: Hi,Here's the circuit which I'm currently simulating. The op-amps are LM324. Maybe there's something related with common mode input range in the first op-amp?Even before the PWM input sends the first pulse, the output of it is in high state. Then, when simulating a certain Duty Cycle, for instance 50%, the filter doesn't hold the value properly, causing output CONSUMTION_FLAG to switch at the PWM frequency. Maybe the design of the filter itself is wrong too.The consumption flag is not intended to be connected to a MCU. In fact, what I'm looking for is the simpliest way to obtain the binary flag with the minimum, cheapest components.Any further comment is appreciated. Thank you!

author: voja
author_rank: Contributor
timestamp: February 28, 2015, 10:58:42 am
content: Try this circuit.If you want to amplify DC component, then Vthr=1.5mV might be too low, if there is some unstability, you should make it at least 3-5 mV, that's why AC amplification is better.In your circuit, it is better to use comparators instead of opamps. Note that I switshed + and - inputs on the first one. Resistors marked as "=" are "don't care" (a few Kohm), they have to be equal.It's hardly that 47 ohm and 100 nF give 34 Hz. I used 100 K instead of 47 ohm, so you shall have more than 10 ms pulse end delay.

author: John Anderson
author_rank: Contributor
timestamp: February 28, 2015, 04:51:47 pm
content: Thank you very much voja. I'll try your proposal.

author: Zero999
author_rank: Super Contributor
timestamp: February 28, 2015, 06:51:10 pm
content: If you're only using one channel then D5 to D8 aren't needed. You're better off connecting the two channels in parallel, even if you don't need the extra current. It will reduce the voltage drop and power dissipation.A transistor can be used to sense the voltage drop across the sense resistor. The Schottky diode connected between the base and collector protects the base-emitter junction from carrying too much current by diverting the excess current through the collector when the transistor turns on.The 555 timer based missing pulse detector will go high when its input is high for longer than RA*C = 330*103*100*10-9= 33ms.

author: John Anderson
author_rank: Contributor
timestamp: February 28, 2015, 07:18:34 pm
content: Hi, thank you again Hero999. I will take it into account your suggestion to use the 555 timer, it seems exactly what the application needs. Actually I use the 2 channels of the LM298, although the schematic was simplified for presentation clarity.However, I just tried the circuit proposed by voja and it worked! Thanks a lot! From it, I only changed a few resistor values to fine tuning the behavior. I changed the threshold voltage to 5mV (above max 2 mV in Datasheet), also changed the charging resistor to 1M instead of 100k, because at low Duty Cycles (below 10%) the capacitor voltage raised pretty close to 5v. Finally, to completely separate the reference voltage in the 2nd comparator, I also set the resistors divider to 32% (4k7/10k) to feed a threshold of 3,4v, slightly closer to 5v than 2,5v. By doing this, it guarantees that, starting from 0,4% Duty Cycle, the consumption flag remains in low state during the input PWM action. After the PWM signal stops, it takes about 110 ms to change to high state, which is 'fast' enough for my application.Attached is the waveform with the mentioned conditions. PWM starts at 50ms, the flag goes low, and stops at 250ms. Then the flag goes high at 360 ms.Now I will test in the protoboard.Thank you again to all for your ideas!

author: Zero999
author_rank: Super Contributor
timestamp: February 28, 2015, 08:36:11 pm
content: The comparator circuit should work quite well.How much current does the motor use?What's the maximum voltage drop across the current sense resistor?If it's above 0.5V, you could do to reduce the voltage drop and thus the power dissipation by adding Schottky diode in parallel with the sense resistor.

author: John Anderson
author_rank: Contributor
timestamp: March 01, 2015, 08:25:18 am
content: The max current is expected to be around 1A continuous, max 2A non-repetitive, so the voltage drop will be around 1V in the worst case.