Using the Non-Invasive Current Sensor - 30A (SEN-11005)

It should, but considering that the last test didn’t work then that would be the first thing to confirm.

You haven’t indicated what you mean by “didn’t work”. Note that half-wave rectification won’t give you a useable analog voltage: you would need full-wave rectification and plenty of capacitor smoothing to get that. Half wave rectification can be used if you are reading the signal as digital and using triggering, or counting pulses over a period that would cover multiple cycles. That’s why the whole setup needs to be considered - the type of input to the Pi and the way you are reading it needs to match the output you are creating. The isolating capacitor can be small - tens of nF would work - while the smoothing capacitor would higher, in the uF range. None of the values is critical.

OK… some progress… some failure.

Got things looking good with my bench setup… using a blow heater to simulate pump motor. (I changed diode, amongst other issues)

Time for the real test… take it all outside and connect to my pressure pump. Dang… Seems to be on the edge of working. The simewave on the pump motor is less than perfect, after rectification, there just isn’t enough grunt to charge the cap, I’m seeing a trace on the CRO that sort of bounces between the OFF state (about 20mV mean) and ON… which SOMETIMES reads about 40mV.

I’m wondering if going full bridge might be the answer. I’ll get two diodes worth of voltage drop… but double the time charging the cap. Hoping that will bump up the mean measured voltage enough to be distinct from the OFF state.

PS My bench setup works great if I turn the heater on High… ie double the current. It works more or less on Low… but my pump draws even less current, hence my belief that I am on the edge of viability.

Tomorrow… need to buy more bits to test a full bridge rectifier.

Another PS… Counting the pulses interests me - as I have another pump to monitor also. Can you point me in the direction of how to code that on my Pico? I am not that experienced in microcontroller stuff… you may have noticed :wink:

1 Like

Hi Trevor,

Progress is still progress. It sounds like you’re nearly there and you have ideas on how to get yourself over the finish line.

As for the Pico, we have a wonderful free course put together that you may want to look at. It goes over the basics onwards to program a Pico. Chapters 2, 3, and 4 will show you how to read, interpret, and save data. Have a look and see what you think.

Looking forward to some more updates soon.

Thanks Jack. I am indeed getting closer to the finish line (it would help if I didn’t keep changing things… like adding in radio TX/RX… but that should be straightforward.

I just discovered I’ve made a basic mistake… somehow I moved the attenuation slider on my CRO probe to 1X not 10X… so all my measurements (and the trace above) are 10 times their actual value. I started out with it on 10X… so was OK. Now.. not! So this means I really only have a 300 mV signal to work with… and that isn’t going to get rectified with a common diode, is it!

That means, I believe (tell me if I’m wrong) I really need to either:

  1. get the Pico to read 0.3 V P-P AC input
  2. massage the signal before it hits the Pico (eg put it through an op amp)

Having only just started this journey, I’m not too sure if putting an AC voltage onto a GPIO pin is kosher… the basic guides about reading analogue inputs usually don’t talk about that… they assume a positive voltage.

I did read (and watch) a bit on using the PIO system, but that seems overkill. Something that counts zero crossings could work, but again, my naivity means slow progress! Can I set up an interupt handler that triggers on a pin going positive? If so, I reckon I could do it. Will I blow up my Pico if I put an AC signal on a pin? Dunno. Maybe I missed that bit in the documentation!!

An op amp could both shift and amplify my signal… so another option might to amplify, then rectify and smooth, get a simple positive DC voltage. I’ll try this too.. when my next package of goodies from Core arrives

Anyway, that’s the direction I think I need to go… unless you advise me otherwise!

Thankyou for your patiebce with a new guy, who is no doubt making all the newbie mistakes possible ;-(

1 Like

I’d do a mix of both. Use a summing op amp to bump the voltage out of the negatives and feed it into the analogue pins on a Pico. I’d also clamp the voltage with a Zener diode to be extra safe.

Hi Trevor
Firstly you mentioned earlier about some sort of residual signal present with the pump OFF.
Question: Are you switching the pump with a SSR (Solis State Relay)? If so this would be normal. A SSR has a “Snubber” circuit built in which is a capacitor and resistor connected in series ACROSS what would be called the relay “Contacts”. There will always be some leakage via this path and if you try to switch a very light load (in the mA range) with these they will appear to never switch off. This leakage is enough th keep a light load running. The best way to make sure everything is OFF is with unencumbered mechanical relay contacts.

I don’t quite know if this is even possible

I think this is what you will need to do. But to amplify AC you need a split supply. You can use a single supply if you level shift the AC zero up to half Vcc. The 3 links I suggested in an earlier reply on the Core web site will help here. The middle one on interfacing to Arduino goes into level shifting in detail. Please read.

You might have to consider rectifying to get a DC signal. If so you will have to amplify as a diode will need about 700mV just to turn on. If you use a bridge as you mentioned this means about 1.4V as you are aware. You can only use a bridge with isolated AC like a transformer secondary or similar. That is the voltage swings + and - WRT Ground. Once you level shift the AC voltage becomes a varying DC voltage WRT ground and a bridge will have ground conflicts. Not a good thing.

Rectification will require a capacitor being charged to peak value via a diode. Be it full or half wave this will involve charging current which has to be supplied by the source, in this case your sensor. As the capacitor is a short to ground at start up this inrush could be significant. A series resistor before the cap is used as a filter and will limit this current but I am not sure if the sensor is capable of supplying this. In this case an op amp will be needed with a high input Z and low output Z to isolate the sensor and supply this charging current.

Whatever you choose to do you will need significantly more that your measured 400mV peak (corrected to allow for probe setting mistake) which will mean amplification of some description.
Cheers Bob

Hey Bob… thanks for this.

I’ve made progress… but my kit is now someone disassembled…i am desperately trying to lock things down, but am spread a bit thin. Not enough hours in a day (and night)

The significant change since my last post: I have indeed massaged the signal from the 5A CT sensor using 1/4 of a quad op amp (HC17902… simply because thats all I had lying around). Put a trimpot in-circuit so I can tweak the gain… and after putting an electrolytic across the output, I indeed have a DC signal that clearly transitions between two different positive voltages, depending on pump on/off state. Woohoo. Should be trivial from here on. That said, I will go back and review the links you sent. I have so many tabs open its not funny…over 60! Sheesh…

In my “ïdle” time, I’ve been teaching myself how to use fritzing, and am well advanced in documenting the circuits, breadboard etc. Planning on replacing the breadboard with a Makers project board, as the breadboard connections are just too flakey. Who knows … might even go PCB once everything settles down!

Next challenge is to read input from my main pump… which I am switching on/off via an opto-isolated mains relay, driven from a GPIO pin. All works just fine, my remainng challenge is reading the opto-isolated relay-is-activated detect signal. I think I am almost there… probably just need to use a pull-up on the input pin. Am trying to master the technique of detecting zero crossings on a pin… and use interrupts, but I suspect I won’t need such fancy stuff when I hook it all up again.. with a pull-up. Once again… all I want is pump ON/OFF status confirmation… nothing more. This relay unit is currently connected via wires - it’s several meters from my Pico… I have a couple RF boards on order to go wireless… maybe next week.

This project has been a real learning exercise, forcing me to dust off my 55+ years electronics skills (or… lack of!), learn about Pico, Python, microcontrollers generally, fritzing (I did wonder about using LTSpice… but fritzing seems OK for what I need).

Along the way, I made some huge improvements in the ability of the laser distance sensor (VL53L1X) to detect water levels.. I plan to write it all up when I’m done, maybe it will help someone else.

Many thanks for your ongoing advice!

T.

Hi Trevor
No problem
Just interested. What is a “HC17902”. I have tries all sorts of combinations but can’t find anything. The 74HC series seem to be flip flops, Schmidt Trigger buffers and most other things digital, no mention of op amps. Tried juggling the rest around in case of a typo but no results.
Cheers Bob

Its a quad op amp… except I screwed up the prefix. It should have read HA 17902P… sorry about that.

I’m using it with a single supply voltage… thought I was going to need +ve and -ve, but with just a single supply, it appears to be doing just what I need. Not sure what the correct protocol is for posting curcuits is… I’ve drawn this as best I can in fritzing. Attached is screengrab of it…

The 3.5mm jack at bottom left is the input from the current sensor - YHDC. The Control and Detect optos are from my main bore pump… which fills my tank. I have NOT SHOWN the VL53L1X distance sensor (on I2C bus)… simply because I haven’t figured out how to do that in fritzing yet :wink: but, that is actually the main reason for this project! More on this later…

Cheers,
T.

Hi Trevor.
Well that is a nice change. Someone providing a decent Vcc (12V) instead of trying to make do with 3.3V or whatever is popular at the moment.

The circuit looks like it is will be a half wave rectifier with some gain (R6 and R7) which should be OK. Apparently it does what you want which at the end of the day is all that matters.

One thing though. The data sheet says (for single supply operation) the input should be from -0.3V to Vcc. The -0.3V is the worry. There does not seem to be any internal protection for the inputs so in your case I would recommend a Schottky diode with a foreword voltage drop of 300mV or less connected from non inverting input to ground with the cathode to the IC input (+).
This will clamp negative going signal to ground minus the diode voltage drop thus providing protection for the IC input. The negative going signal might seem small (400mV on your scope screen shot) but there is no guarantee it will stay that way. A Schottky diode is affordable insurance.
Cheers Bob

PS: It would not hurt to put another diode (same type) from + input to Vcc with Anode to + input. This will do the same for excessive positive going signal by clamping to Vcc plus the diode voltage drop. I know the sensor output is only supposed to be 1V but I tend to be a bit over cautious. Don’t like failures at the most inopportune times.

Hi Trevor
What is the actual value of c3. You have shown a polarised electrolytic cap but I would not think 0.1µF would be this type. I would have expected more like 100µF here with about 1k or so in series to limit charging current to a safe value
Cheers Bob

Thanks again Bob… and you addressed a concern I had about putting the negative voltage input on the op amp. I’ll heed your advice!

The smoothing cap is not 0.1 uF.. it is 0.1 mF, 100uF. Actually, I put a couple in parallel (I have limited options immediately at hand) Fritzing did not give me the option of labelling it as 100uF… that is why it is rendered as it is. I think R7 is also different - again, limited by the values fritzing gave me. No matter just tweak the pot. The variable resistor value of around 90 k gave me a gain of about 19. Bottom line: measured the voltage presented to GPIO15, it is just fine.

This was all done on my bench, using the 1kW heater as test load. Tomorrow, I hope to be able to test it in the field as it were, connected to my pressure pump, Output from the pump should be lower… but dirtier, than using my 1kW heater. Might be wise to install the Schottky BEFORE I do that, as I guess inrush might cause a significantly higher spike on pump startup.

I so appreciate your help… really great!
Thanks,
T.

Hi Trevor

The data sheet specifically says -0.3V absolute maximum negative.

You might destry the Op Amp if you don’t.

I certainly would. The inrush current of a motor (AC or DC) could be something like 8 or 10 times the operating current. If you have a figure for the “stall” current that will be close.

That will be 100k. I don’t think 90k is available.

Surely Fritzing gives you the option of changing component properties. If it doesn’t, give up on it. I tried it not long after it first appeared and in about half an hour had it uninstalled and removed from my computer. Have not looked at it since. To draw circuits I use KiCad in my mac and Abacom’s SPlan on a Windows laptop.

It certainly DOES MATTER. When trying to help, ACCURACY is paramount. There is no use publishing any sort of circuit if it is wrong. And when it is KNOWN to be wrong that is inexcusable. That is when I get a bit angry as I don’t like chasing my tail.

C1 (now 100µF) will not do much smoothing. When the op amp output goes positive it will charge up and when the op amp output goes to zero it will discharge back through the op amp. R8 is really doing nothing.
If you are measuring the DC with a DMM at the GPIO input you will be measuring the AVERAGE DC voltage of the rectified sine wave. Measurement with a scope at this input will check this.

A word of warning here. when discharged C1 will be a short circuit to ground and in the initial moment of charging will require quite a large current from the op amp. probably exceeding absolute maximum. The same goes for discharge. This will probably stress the op amp to the point of eventual failure.

If you want a DC voltage to the GPIO input I think you need something like this.

The extra resistor (1k to 10k) will limit the charging current to a safe value and the diode will prevent discharging back via the op amp.and allow the cap C1 to charge to the op amp peak value. This will then discharge via R8 when the motor stops and pulses from the op amp cease.

If you are a bit low on op amp level use a Schotttky diode but if you have some voltage in hand (due to op amp gain) a 1N4148 will be OK.
Cheers Bob

Hey there!

Great to see some discussion/circuit design going on here! Don’t have too much to add in the design aspect, just wanted to give my 2 cents regarding Fritzing.

Haven’t ever used it, so I can’t properly comment on its effectiveness. Personally, I primarily use LTSpice for super quick simulations, and Altium Designer (don’t recommend paying for this, I am a student and get a free student license) when I need some heavy lifting/PCB design. I know KiCad is a fantastic free alternative for PCB design and spice simulation, and have also used EasyEDA for spice sim (supplier component lookup is useful).

Good luck with the project @Trevor277988!

Thanks .. @Robert93820 I will check out SPlan, and when I catch my breath, other alternatives. I doubt I really need LTSpice…

I think you misunderstood my comment re resistor values… sure it “matters”. I was only saying that a small change in R7 can be compensated for by a corrsponding tweak of the R6 pot… which I have currently got at 90K of the 100K trimpot to give the desired output. If there are other implications, I’m unaware, but my guess is the important bit is the ratio of R6/R7… not so much the absolute values. Happy to be corrected!

Of course fritzing allows you to specify component values, but does not include a full set of resistor values to select in its dropdown to create the designated value text. My actual resistor is 5.1K… fritzing offers 4.7k or 6.8k.. There is no 5.6… Yep… weird.

@Zach - thanks for the comments. as a newbie I am still figuring out what tools to use. fritzing seemed to have the advantage of showing both schematic and also breadboard layouts, which seems pretty nice, but happy to explore better alternatives.

Now… I just need my remaining bits on order to arrive (RF transceivers), and I might actually get this project completed!

Thanks for the input,
T.

1 Like

Hi Trevor

That is a big jump. I can see your problem if Fritzing only offers a drop down list of values. KiCad lets you completely edit component properties by typing in the value you want. Very flexible.

Yes that ratio sets the gain. With a non inverting situation such as this the gain can never be less than 1. With R6 being 5k1 the theoretical gain (R7 = 100k) would be 20.6.

I have a sneaky feeling that R6 should be equal to R5 for best results. I think this has something to do with minimising any offset currents in the IC itself. Keeping any funnies equal for both inputs. If i get some time I will try to find the info and refresh the old grey matter.

If you increase R6 to 10k to match the gain will reduce to 11. If this is not enough and you need R6 to be 5k1 then reduce R5 to 5k1 to match.
Cheers Bob

2 Likes

Hi Trevor
Add on to above:
I think you can ignore the paragraph above regarding R5 and R6 being equal. I can find no reference to it. The output voltage will always be a value which will keep the + and - inputs equal. So having effectively infinite input Z.

I must have been getting mixed up with the inverting amplifier where a resistor from + input to ground (or reference) could be required under some circumstances.
Cheers Bob

2 Likes

Cool - thanks. Meanwhile, I got some BAT85 Schottky’s this AM, put one across the CT device with NOTHNG else, and set my CRO to capture the startup waveform of my pump (not my blow heater… this is the real deal). See below. It is doing it’s rectifying thing fine… but I am still left with a inrush spike of around 2V. Given my op amp datasheet says +ve input is fine up to Vcc - I believe this is NOT an issue… right?

As a follow-up question… I did wonder if, with the BAT85 in place if I even need the op amp. I’d be putting AC swinging between -0.3 and +2V at startup, and about -0.26 to +0.4V after it settles down, on the Pico GPIO pin, and would then need to detect the pulse (which I can do now :wink:
I’m still unsure of how terrible a neg voltage - even a small one - on a GPIO pin is. If its absolutely a no-no, I’ll just keep the op amp!

Your thoughts?


Cheers,
T.

1 Like

Negative voltages are considered a no-no in most case but you may get away with it this time. The Pico’s GPIO pins are rated for -0.3V to 3.3V so with the values you are detecting you should be fine considering this range especially if it settles down after startup.

Still, something to be careful of though!

I should have done this earlier… ie, reviewing the notes provided for interfacing the SEN-1105 to an Arduino. Shows a simple method to bias the voltage to the positive. That said… I am not using the SEN-1105 (a current device?), but a similar thing I got from YHDC, a voltage device. I think they have an internal burden resister and a couple diodes built-in.

Probably safest to just use the output from my op amp… I know it will always be positive, and makes reading the on/off status real easy. Which is all I require.

Hopefully, tomorrow I will have it all sorted.
Thanks,

PS… Samuel… where do I find the specs for the GPIO pins , ie the rating from -0.3 to +3.3V?
T.