Go Down

Topic: ACS 712 sensor error in measuring current (Read 3419 times) previous topic - next topic

knightridar

#15
Sep 20, 2017, 07:55 pm Last Edit: Sep 20, 2017, 08:00 pm by knightridar Reason: added pics
Hi powering it via:

Whole system:
24V, 21A, 500 Watt DC power supply

Arduino powered by:
12V, 5A, 24V DC to 12V DC converter hooked up to the power supply .


Relays and Current sensors powered by:
5V, 5A, 12/24V DC to  5V DC converter hooked up to the power supply.

The relays are on an 8 relay module (SONGLE brand).

You can download CAD models of the parts here:
https://grabcad.com/has-2/projects


For the 8 relay module, there are a few options but here is one link:
https://grabcad.com/library/8-12







Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

TomGeorge

Hi,
Thanks for the pics, now for the circuit diagram, even a picture of a hand drawn schematic will do.
Make sure you show how your gnds are connected.

Keep your input wiring well way from your output wiring, in particular the relay board.

It looks like your relays are directly under your current sense boards.

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

knightridar

#17
Sep 20, 2017, 09:14 pm Last Edit: Sep 20, 2017, 09:20 pm by knightridar
I am wondering if I should move this post over to the general electronics section.
Although I may still have some programming questions.

The reason why I have my ACS712 sensors right above the relays is because the wires were longer before but the wires were really becoming a hassle to organize and troubleshoot.
Also I am going to 3D print an enclosure and my print size is limited.
I am trying to keep things as close together as possible.

Are you telling me to keep input wiring far from output wiring for safety reasons?
I just realized that the relays have electromagnets. Could they have an effect on the ACS 712 sensors being mounted right above them since they are using hall sensors?

I am unsure of the schematic because I'm not sure if I wired the circuit in series with respect to the terminal blocks (although there are no resistors hooked up to the terminal blocks so is it a node???), but I will draw one out soon.

Just to give you an idea of the setup from the pictures:

I am using two separate terminal blocks to supply Vin and Gnd to supply power to the ACS 712 current sensor modules from the 5V DC converter.
(I used a multimeter and the voltage is at 5 volts but varies slightly sometimes as high as 5.5 volts when the relays turn on/off).

The 8 relay module was easy to supply power to. I am taking Vin and Gnd connections from the 5V power terminal blocks and hooking it up to the JD-VCC and Gnd connections on the module.

I am using another two separate terminal blocks to supply Vin and Gnd from the power supply to the relay module/current sensor and the ground connection gets connected to the white quick disconnect pieces in the previous post.
( Vin -->Goes from DC power supply to-->terminal blocks -->common port of relay
-->ACS 712 sensor--> ACS 712 sensor to NO port of relay--->quick disconnects)

(Gnd -->From DC power supply to -->terminal block -->to quick disconnects)
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

knightridar

#18
Sep 20, 2017, 11:24 pm Last Edit: Sep 20, 2017, 11:50 pm by knightridar Reason: added pic
The schematic is attached.






















Welcome.
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

knightridar

#19
Sep 21, 2017, 12:17 am Last Edit: Sep 21, 2017, 01:24 am by knightridar Reason: modded code
Here is an update....

At first I thought the ACS712 sensors were too close to the relays or the wiring itself was too close together or it could be both things.

I moved the ACS712 sensors away from the relays and moved wiring away from the relays and  the screen was displaying characters just right.

However, this didn't solve the problem.
I've noticed when the solenoid is not working or activating the cycle count is fine, but when the solenoid is working that is connected to relay #8,
I get a messed up cycle count on the LCD screen.

Weird.
I don't see how a rise in possible current for the solenoid could cause the screen to print out weird characters. The solenoid is 24V. The lcd screen has it's own separate power supply that is being fed by the 24V power supply.


Code: [Select]

#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to

const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

/****************************************************************************/

int TOn = 1000; // Adjust delay time in milliseconds to turn relay on/off
int TOff = 200;

/* Measuring DC Current Using ACS712 */

double mVperAmp = 66; // use 185 for 5A Module, 100 for 20A Module, and 66 for 30A Module
float ACSoffset = 2448.455;

double RawValue1 = 0;
double RawValue2 = 0;
double RawValue3 = 0;
double RawValue4 = 0;
double RawValue5 = 0;
double RawValue6 = 0;
double RawValue7 = 0;
double RawValue8 = 0;

double V1 = 0;
double V2 = 0;
double V3 = 0;
double V4 = 0;
double V5 = 0;
double V6 = 0;
double V7 = 0;
double V8 = 0;

double Amps1 = 0;
double Amps2 = 0;
double Amps3 = 0;
double Amps4 = 0;
double Amps5 = 0;
double Amps6 = 0;
double Amps7 = 0;
double Amps8 = 0;

const int S1 = A0; // Analog input pin that sensor is attached to
const int S2 = A1;
const int S3 = A2;
const int S4 = A3;
const int S5 = A4;
const int S6 = A5;
const int S7 = A6;
const int S8 = A7;

void setup () {
  lcd.begin(16, 2);   // set up the LCD's number of columns and rows:
  lcd.setCursor(0, 0); // set printing position on lcd screen, currently that is row 0, column 0)
  Serial.begin(9600);

  DDRA = B11111111; // set PORTA (digital 22-29) to outputs

  int maxnumber = 4; // set cycle count

  for (int count = 0; count < maxnumber;) //Counter will stop counting after certain amount of cycles
  {
    PORTA = B11111111;
    delay(TOn); //delay between turning on each relay
    PORTA = B00000000;
    delay(TOff); //delay between turning off each relay

    RawValue1 = analogRead(S1);
    RawValue2 = analogRead(S2);
    RawValue3 = analogRead(S3);
    RawValue4 = analogRead(S4);
    RawValue5 = analogRead(S5);
    RawValue6 = analogRead(S6);
    RawValue7 = analogRead(S7);
    RawValue8 = analogRead(S8);

    V1 = (RawValue1 / 1023.0) * 5000; // Gets you mV
    V2 = (RawValue2 / 1023.0) * 5000;
    V3 = (RawValue3 / 1023.0) * 5000;
    V4 = (RawValue4 / 1023.0) * 5000;
    V5 = (RawValue5 / 1023.0) * 5000;
    V6 = (RawValue6 / 1023.0) * 5000;
    V7 = (RawValue7 / 1023.0) * 5000;
    V8 = (RawValue8 / 1023.0) * 5000;

    Amps1 = ((V1 - ACSoffset) / mVperAmp);
    Amps2 = ((V2 - ACSoffset) / mVperAmp);
    Amps3 = ((V3 - ACSoffset) / mVperAmp);
    Amps4 = ((V4 - ACSoffset) / mVperAmp);
    Amps5 = ((V5 - ACSoffset) / mVperAmp);
    Amps6 = ((V6 - ACSoffset) / mVperAmp);
    Amps7 = ((V7 - ACSoffset) / mVperAmp);
    Amps8 = ((V8 - ACSoffset) / mVperAmp);

    Serial.print("Amps1 = "); // shows the voltage measured
    Serial.println(Amps1, 3); // the '3' after voltage allows you to display 3 digits after decimal point

    Serial.print("Amps2 = ");
    Serial.println(Amps2, 3);

    Serial.print("Amps3 = ");
    Serial.println(Amps3, 3);

    Serial.print("Amps4 = ");
    Serial.println(Amps4, 3);

    Serial.print("Amps5 = ");
    Serial.println(Amps5, 3);

    Serial.print("Amps6 = ");
    Serial.println(Amps6, 3);

    Serial.print("Amps7 = ");
    Serial.println(Amps7, 3);

    Serial.print("Amps8 = ");
    Serial.println(Amps8, 3);

    Serial.println("");

    lcd.clear(); //clears lcd before incrementing to next number
    count++;
    lcd.print(count);
  }
  DDRA = B00000000;
}

void loop() {
}
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

Wawa

The INA219 can only be used up to a maximum of 4 sensors because of the way it's setup and it uses the SDA and SCL ports on the arduino.
Not true.
You can use as many of these as you need on the same bus, if you solder a wire to one address field.
You can then use that wire as chip select.

A 30A sensor (30A bidirectional = 60Amp) has a resolution of ~13.5 steps per Amp, or one step per 75mA.
Just enough for one decimal place.
Leo..

knightridar

Sorry lost you there...

https://learn.adafruit.com/adafruit-ina219-current-sensor-breakout/assembly

Quote
Up to 4 boards may be connected. Addressing is as follows:
Board 0: Address = 0x40 Offset = binary 00000 (no jumpers required)
Board 1: Address = 0x41 Offset = binary 00001 (bridge A0 as in the photo above)
Board 2: Address = 0x44 Offset = binary 00100 (bridge A1)
Board 3: Address = 0x45 Offset = binary 00101 (bridge A0 & A1)
What do you mean by bus?
What is chip select?

Thanks.
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

Wawa

What do you mean by bus?

What is chip select?
1) I2C is a bus. Many devices can connect to the same two wires, as long as they have a unique address.

2) Selecting one chip, and ignoring others.


The INA219 has four user selectable addresses (the solder links).
So normally up to four of these modules can be connected to the same bus.

But... if you control one of those solder links with an Arduino pin, you can change the address with software.
Talk to one module two modules, and ignore the others (that have been set to a different address).
Leo..

knightridar

Thanks I was reading up on it here:

http://tronixstuff.com/2010/10/20/tutorial-arduino-and-the-i2c-bus/

If I am not mistaken, only 1 device at a time can talk to the I2C bus?
Want to know because I need to turn the relays on/off simultaneously.

Also even if i can change the address,
I need to measure the current going out to 8 solenoids simultaneously.

So are you saying I can connect 8 modules and give them all different addresses?
I was confused with the 2 modules comment.
If I use two and assign different addresses via the pin, then I can get 8 different addresses?
Will they be unique?

Only issue is if I change them via the pin on an Arduino I won't be able to detect current simultaneously for 8 relays. That connection is a fixed hardware interface on the INA219 is it not?

https://learn.adafruit.com/adafruit-ina219-current-sensor-breakout/assembly
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

TomGeorge

#24
Sep 21, 2017, 04:39 am Last Edit: Sep 21, 2017, 04:46 am by TomGeorge
Hi,

Quote
Want to know because I need to turn the relays on/off simultaneously.

I need to measure the current going out to 8 solenoids simultaneously.
Input simultaneously is not possible, only very fast scanning of the inputs on the I2C bus.

Output yes, you can turn all outputs off simultaneously with direct port addressing.

How quick do you need the response to be?


Code: [Select]
int TOn = 1000; //Adjust delay time in milliseconds to turn relay on/off[color=#222222][/color]
int TOff = 200;


I don't think your relays are going to last long being operated at 1/(1 + 0.2) = 0.83Hz
With a duty cycle of  1000/(1000+200) = 83%

What is the application?

Tom... :)

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

Wawa

I need to measure the current going out to 8 solenoids simultaneously.

So are you saying I can connect 8 modules and give them all different addresses?
I was confused with the 2 modules comment.
Everything in a single core processor happens after each other.
Don't know what you are going to measure,
but the INA219 can only measure loads <26volt and grounded to the Arduino.
Be careful with PWM-ed loads. They will give false readings, since current will be 0% or 100% at different times.

Since you have four addresses available, you can connect modules in pairs.
e.g. address 0x40 and 0x41 active, and the other sets on 0x44 and 0x45.
Leo..

knightridar

#26
Sep 21, 2017, 06:55 pm Last Edit: Sep 21, 2017, 07:19 pm by knightridar Reason: URL LINKS ADDED
@Tom,

I don't need to make the cycle times that fast.
I was just trying to make them fast to speed up my testing process and times.

Goal is to do cyclic testing of solenoids.

I was thinking of using solid state relays. I did find one:
https://www.sainsmart.com/products/2-4-8-ch-5v-solid-state-relay
Problem was I wasn't sure about what I kind of DC loads it's capable of taking.

With the current relays it's written on top of them with respect to what amperage and dc/ac voltage they can take in.
Current relay part no. Songle SRD-05VDC-SL-C

http://pub.ucpros.com/download/27115-Songle-Relay-Datasheet.pdf?osCsid=t5nucvvbbtp4q2keq2qj15bqd6

My solenoids' voltage range is 12-24V, and a few at run at 115V AC..

@Wawa,

If I end up using that sensor then I will pair the modules,
but I would have preferred to measure 8 separate currents.

Thanks.
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

Wawa

Goal is to do cyclic testing of solenoids.

Problem was I wasn't sure about what I kind of DC loads it's capable of taking.

With the current relays it's written on top of them with respect to what amperage and dc/ac voltage they can take in.

My solenoids' voltage range is 12-24V, and a few at run at 115V AC..

If I end up using that sensor then I will pair the modules,
but I would have preferred to measure 8 separate currents.
The current of the actual coil?

Those relays are AC only. This is in the specs list:
"Load voltage range: 75 to 264VAC (50/60Hz)"

Just measure coil resistance. With ohms law you can calculate DC coil current.
Tricky with AC, because of coil inductance. Need to measure AC voltage too.

The INA219 can't do mains connected 115volt AC, and 24volt is borderline.
Seems you need to go back to the ACS712 (5A version).

measure 1, measure 2, switch to the next set, measure 3, measure 4, switch to the next set, etc..
Leo..


knightridar

#28
Oct 06, 2017, 02:47 am Last Edit: Oct 06, 2017, 02:59 am by knightridar
What does the picture below mean in terms of the DC voltage it can support?
These relays are pretty common in a lot of the modules being sold (i.e. single relay, 2,4,6,8)

I am supplying load to 24V solenoids right now.

Perhaps the documentation I provided is inaccurate?

Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

Go Up