Go Down

Topic: Voltage read circuit with relay on/off (Read 5037 times) previous topic - next topic

Grumpy_Mike

Quote
You said "change". You mean "new wiring after relay is on"? Can you explain? Voltage reading program should consider the "change"?

I meant change in voltage reading. At first you thought there was something wrong as you got a change. Now you know there is something wrong because you are not measuring the change in voltage correctly. However your voltage is sagging under the load of your relay.

Your terms are all muddled up. You do not take voltage your relay takes current, yes it takes a lot of current, you tell me how much because you haven't told me the type.
It is the current your relay is taking that is causing the voltage to drop because of the high impedance or poor regulation of your solar cells. You are going to measure that correctly when you put the right resistors in your circuit. If your grounds are wired right.

hlai_arduino

Tom,

Solar part is pretty simple, no any drawing now. Sorry.

hlai_arduino

After more tests, I think it's design problem. After relay is on, the load is equivalent to a resistor "on top of resistor divider". Therefore, the code to calculate the voltage does not work anymore. You can change the code to "account" for the added resistor (it is load) to compensate it, but if it's unknown load (such as different pump), it's not a solution.

(See attached picture)

I tried on 5v input, and simply use a resistor added as a load (attached the relay, one end of resistor is attached to ground, another end attached to relay output). I noticed that it is off about 0.5v as well:

1) Measure output (the relay output when it is on) is, such as 5v.
2) But, the code read voltage is 5.5v. (Input is 5v. It can't be 5.5v).

3) When relay is off, the code voltage read is 5v.


So, can someone suggest a right circuit design?

Grumpy_Mike

Quote
After relay is on, the load is equivalent to a resistor "on top of resistor divider". Therefore, the code to calculate the voltage does not work anymore.

No that is wrong. That relay is a load in parallel with your potential divider and has no effect at all on the potential divider.

I have told you what is going on before. Your relay is drawing so much current that the voltage drops. The potential divider still works the same and still measures what you have.

Quote
can someone suggest a right circuit design?

There is nothing wrong with your circuit.

hlai_arduino

If removing relay,

1) Do you agree my hand drawing of 2nd part? Relay + pump = resistor?

2) If agree 1), can the code calculates same voltage results for 2 circuits (my latest hand drawings) ?  Your suggestions is that code will generate same voltage reading for 2nd part of drawing.  I hope so.  But, I really doubt about it, as it's obvious different circuit for calculating voltage (not simply 2 resistors divider any more).

3) If NOT agree 1), what equivalent circuit is after relay is on? What can I do to avoid it? Should I change code to calculating voltage after relay is on (2 sets of code to read voltage). I should choose "good" relay to avoid this issue.

I believe 1), so I will do a test according to 1). (very simple test.)

(Never done electrical since college. I am really confused. Sorry.)


Grumpy_Mike

Why bother posting questions if you are not going to believe the answer. I have been doing electronics for over 40 years so I must know a bit.
If you don't want to learn then stop asking the same question and concentrate on what you don't understand, which is basic current flow in seriese and parallel circuits.

TomGeorge

Hi
Can you please post a picture of your project in jpg, png or pdf format.
This so we can see what you are using.

Question.
1) Where is your battery?
2) Can you post a COMPLETE circuit diagram, including, solar panel, solar controller, battery, arduino, relay and pump.

Tom....  :)
Everything runs on smoke, let the smoke out, it stops running....

hlai_arduino

Hi Mike,

Thank you for your all replies.

I did that simple test, it won't affect the code to calculate the voltage (you are right).

But, with real relay (the circuit I am making), I still have not solved my problem.

Your suggestions of how to solve it are:

1) Check my circuit. I already checked. All seems fine. (I might need to rethink).
2) Relay problem? I need to use good relay?
3) Change my code to compensate "bad" relay?

I am still clueless.

(Relay: QIANJI 3v)

TomGeorge

Hi,
PLEASE, PLEASE, PLEASE, post us a copy of your code, PLEASE, PLEASE, PLEASE.
And use code # tags PLEASE.

When you get these discrepacies, can you measure the voltage at the analog input pin of the arduino as well, PLEASE.

Tom....... :smiley-roll-sweat:
Everything runs on smoke, let the smoke out, it stops running....

hlai_arduino

Hi Tom,

The code tries to smooth sudden voltage change (not in git). I am afraid it costs unnecessary time for you. If you want, you can focus on

With 2 resistors posted before, the following is piece of it. You can ignore the "averaging part" of it.

....

  if (current_voltage_read_count >= average_count) {
    current_voltage_read_count = 0;  //Reset
   
    //5/1023 = 0.0048875. 5v max of analog input.
    float Vout = voltage_ave_read_raw * 0.0048875 / average_count; 
    Vin = Vout * 5.26;
   
    // Reset
    voltage_ave_read_raw = 0;
  }

....

For my problem, you can think of it as Vout =  Vin * alpha. The details of the parameters is not important here.

My problem:

With same "alpha", relay on: hand measure voltage (not equal) code measured voltage.  Relay off: both same and accurate (ok for me). Hand measure is done on R7 (basically the Vin and Vout).


Based on what I heard so far, I don't exactly what's next step, besides making sure my circuit is wired according to drawing (correct).




Grumpy_Mike

Quote
Based on what I heard so far, I don't exactly what's next step, besides making sure my circuit is wired according to drawing (correct).

For god sake man, why will you not do the things that will allow us to help you!

TomGeorge

Hi,
Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Can you please post a COMPLETE copy of your sketch, using code tags.

When you get these discrepancies, can you measure the voltage at the analog input pin of the arduino as well, PLEASE.

1) Where is your battery?
2) Can you post a COMPLETE circuit diagram, including, solar panel, solar controller, battery, arduino, relay and pump.

Tom....... :smiley-eek:
Everything runs on smoke, let the smoke out, it stops running....

Go Up