SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By palloquin
#198066
Hi,

I hope someone will be able to shed some light on my mystery...

I have a setup with a loadcell connected to an arduino via an HX711 breakout board.
The setup as been calibrated and works very well.

Step two in my master plan is to start measuring, switch on a relay, and keep it on until the weight measured exceeds a certain point.

The strange thing is that as soon as I switch on the relay, the loadcell measurement changes by 2 grams (without any actual weight having been added to the scale yet).

What is going on here? Things I can imagine:
- The relay clicking somehow throws things off (unlikely)
- The fact that I apply current to the relay circuit somehow interferes with my measurement


I've played with the moment and delays surrounding the tare() call I make to the scale.

It is clear that if I first tare() and then switch the relay I have issues, but if I first switch and then tare() the scale works fine.

Any thoughts?
#198072
This is a result of small changes in your supply voltage due to the load it is powering. Your relay is drawing enough current that your voltage reference is slightly shifting which in turn affects the measurements from your load cell. What you need to do is isolate the power to your relay from the reference for your cell. The HX711 has separate digital and analog supplies which allows you to do this. My assumption is that both the analog and digital sides of the HX711 along with the relay are all being powered from the Arduino.

-Bill
#198076
Hi Bill,

Thank you for you comment! I'm quite new to this, but it makes sense (somewhat ;) ).

I have several HX711 lying around, a few original sparkfuns with separate analog and digital pins and cheap aliexpress versions with just 1 pin. get what you pay for here I suppose.

The whole thing is powered through the USB port on the arduino (makes it easy to debug too). How whould you suggest I go about isolating? I'm not sure how I would do that...

This is my diagram:
Image

Thank you!!!
#198085
Sorry for the delay but I've been busy this weekend.

It's definitely the relay causing the regulated voltage to sag slightly. Fortunately there are a few ways you can attack the problem. The simplest would be to use a more powerful 5V supply since your current one doesn't seem to be quite up to the task.

The next option would be to use a different power supply for the coil of your relay. To make this work, you will have to make sure the grounds of your USB supply and the relay supply are connected together.

Third would be to use a different supply for the analog side of the HX711. If you take a look at the schematic for the HX711, you will see that it has a VCC and VDD connection. VCC powers the load cell and the analog front end of the chip. VDD powers the digital interface of the chip. You would leave VDD connected to the same supply as the Arduino but use a different supply on VCC, preferably something fairly precise and stable. Like the separate supply for the relay, you will have to connect the grounds together to make everything work properly.

I hope that gets you moving in the right direction!

-Bill
#198087
Hey Bill,

thank you for your support again!
I doubt it's the power supply, I'm using a Samsung 5v/2.0A USB power supply. I should hope 2 amps is enough... right?

Double power supply would be very cumbersome obviously. But, could I use the same USB based PSU but bypass the arduino?

Right now I feed in to the USB port of the arduino and I have the 5v of arduino connected to my 5v circuit. could it be that somehow the output of the 5v rail on the arduino is not sufficient and that splitting of the 5v of the PSU and directly supplying that to the 5v circuit on my pcb would do the trick? In such a case, could I still also leave all the pins connected to the arduino USB, basically supply the same 5v source through 2 separate channels?

roughly something like this:
Image
(I've removed the keypad connector from the drawing since it doesn't influence this issue and got in the way for a quick sketch...)|
#198090
While your USB phone charger has enough power to keep everything running, it was not designed with sensitive analog electronics in mind. The small shift in output voltage when you energize the relay has no effect on your digital electronics because everything is still in spec, but your analog electronics use that voltage as a reference and small changes in that voltage coupled with the large gain you are likely using with the HX711 changes your scaling enough that you're seeing changes in your output.

When using the USB port for power, the Vusb input is tied to the +5V rail on the Nano via a schottky diode (see the Nano's schematic here: https://www.arduino.cc/en/uploads/Main/ ... .2-SCH.pdf ) which will have a small voltage drop associated with it. If you connect Vusb to +5V, you are eliminating that drop but you are still fully relying on the stability of your USB power source for everything connected to your project. There is a chance that this will improve your operation but no guarantee. This is why it is critical to isolate the power going to your relay from the HX711. It's a good design practice to keep power electronics isolated from analog and lower power digital circuitry specifically for the problem you are encountering here.

-Bill
#198092
Hey Bill,

Thank you again for explaining... Being impatient I just went ahead and tried this afternoon. My original PCB design accounted for the possibility of powering through an external 5v source and has a 2 pin molex connector which linked to +5V and GND on the USB connector.

And.... this works! At least with my Samsung charger as source, I've not tried other options yet.

So, I'm mostly happy, because my electronics seem to be working as expected, thanks to the pointers you gave me. But, your further comments do make me wonder how stable this is. I'll have to keep an eye on things.

You state "... due to the large load of the energized relay...", could the fact that this is a relatively small relay help in limiting the negative effects you describe? (these are the relay's I'm using: link)

What kind of PSU would you suggest for small projects like this? I still don't completely understand how I isolate. I do hope that does not mean using dual PSU's..! is there some basic reading on this?
#198094
The relay you are using is a SRA-05VDC-CL which has a 5V 0.6 Watt coil, so it draws a nominal 120mA. In the grand scheme of things, that's not a lot of power, but relative to everything else in your project, it's huge.

Now that you are saying everything appears to be working properly when you jump the USB voltage directly to the +5V terminal, it would appear that the Schottky diode between Vusb and +5V on the Nano is probably causing the problem you're seeing. Diodes have voltage drops across them that are related to the current going through them. A 120mA change in current would be significant enough to see a small shift in the voltage drop which would have a direct impact on your load cell circuit. The datasheet for the SS1P3L diode has a graph for the current vs. forward voltage but it doesn't go low enough to show the exact values for when your relay would be off. Extrapolating, you can see that there would be a change in that range though. Bypassing the diode eliminates the current dependent voltage shift.

If I were making a project board like this from scratch, I would probably lay the power out as follows assuming I have a choice of my input power.

1. Input power supply would be 12V.
2. I would use a 12V relay controlled by a transistor from the microcontroller.
3. I would use a +5V regulator for all the 5V digital logic on the board and would consider a switching one if the load was large enough.
4. For the analog side, I would use a precision 5V regulator or reference separate from the one used for the digital side.

In this arrangement, there can be fluctuations in the 12V rail and the 5V regulators will have enough headroom to maintain a stable voltage level. Keeping the analog and digital regulators separate helps keep noise out of the analog side and can allow for much larger loads to be applied on the digital side (the arduino can source a lot of current from each I/O pin if you use a bunch) without having a direct impact on analog front end.

Every situation is different and there is no single correct way to implement this. As a designer/engineer, it's your responsibility to weigh the benefits and tradeoffs of any approach and pick the route that gets the job done adequately.

-Bill

P.S. Read up on flyback or snubber diodes for relay coils. You should be using one around the coil of your relay to protect the transistor from large voltage spikes that can be generated by turning the coil off in a very short period of time (short periods of time are what transistors excel at).
#198100
Hey Bill,

Thank you once more.. You left me with my head spinning. It's clear I have a lot to read up on, since I only half understand the things you are writing here ;) I'll schedule some time this weekend to study your advise.

I was advised to use a diode over the relay before, which resulted in the diode I put in my schematic... is that what you mean, or did I misunderstand the original advise I got, or do I need a second one?

Cheers!