+ Post New Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 30
  1. #1
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Arduino UNO unsure about coding for project, help appreciated!!

    Hello, I am doing a project of current measurement using the LEM LA 55-P transducer which senses the strength of magnetic field produced by a current carrying conductor traveling through the hole of the sensor and outputs a linear milliamp output. I want to interface this sensor with an Arduino UNO but am not to certain about the code required. A little bit about the sensor, it can measure a primary current up to 50 Amps which will output 50 milliamps; I am going to have the output going to a 100ohm precision resistor so that 50mA max output will equal 5 volts; 50mA x 100 ohms = 5 volts. I want to then send this output to the Arduinos analog to digital converter, and have an LCD display wired to the Arduino, with a code stating that 5 volts input will display 50 Amps to the LCD, 1 volt will display 10 amps etc. basically every 0.1 Volt = 1 Amp. if anyone has any insight on how to go about writing this code it would be much appreciated, I don’t think it will be an overly complicated code but I have next to no experience with C++, Thanks for your help.

  2. #2
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    122 / 122
    Points
    5,417
    Level
    17

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    Try this code which I wrote.

    Code:
    #define LEM_LA_55_P_Transducer A0
    double current = 0;
    
    
    void setup() {
      // put your setup code here, to run once:
      Serial.begin(9600);
      delay(100);
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      current = analogRead(LEM_LA_55_P_Transducer) * 50.0 / 1023.0;
      Serail.print(current);  
      Serial.println(" Amperes");
    }
    Input 0-5V from 100 Ohms resistor to A0 pin of Arduino Uno.

    You have to convert AC Current to DC using a diode and scale it to 0-5V range.



  3. #3
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    awesome, thanks for your help.. i will most definitely give this code a try and will get back to you with the results. As for converting AC to DC that is how i have it set up, i am using a unidirectional supply instead of a bidirectional supply in which it states in this link, http://www.lem.com/hq/en/content/view/208/157/ that you have to put a diode in series with the output.. this trick does indeed work but through playing around with this circuit i came to find out that, when measuring DC it works perfectly fine with the expected output extremely accurate, but when measuring AC through this circuit it only puts out half of the expected output. The diode cuts off the bottom half of the AC wave, which i assume because of this i only get half of my expected output. I supposed one way of getting around this would be to double the measuring resistor when using this circuit to measure AC? where as, say i am measuring a load that draws 10 amps AC, and get a 5 mA output, instead of the 100 ohm resistor to get .5V which would be half of the expected output, i could use a 200 ohm resistor to get the ranged voltage of 1V.. mind you the only thing with that is that 200 ohm resistor exceeds the range of the datasheet of the lem la 55-p http://www.lem.com/docs/products/la_55-p_e.pdf , although i dont think this will effect much other than maybe decreasing the capability of the upper measuring range of the sensor, which i am only using as a thesis project so i wont be measuring very large currents, more so just to prove the circuit works and do a detailed explanation on how it works.



  4. #4
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    122 / 122
    Points
    5,417
    Level
    17

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    0.7V drop across 1N4007 diode. Choose resistor such that for 50A (sec: 50mA) gets converted to 5.7V. This will give 5V after diode and then it will work with my code.

    Also read this.

    https://learn.openenergymonitor.org/...edirected=true

    50mA through 100 Ohms = 5V rms

    5Vrms through diode gives 5 * 1.4142 = 7.071V

    You can't feed 7.x V to ADC pin. You have to scale this value to 5V using voltage divider.



  5. #5
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    but where as the sensor is in the current domain, the output current shouldn't be effected by the diodes in series, since current in series is equal throughout and the resistor is after the diode shouldn't there be no voltage drop considered in the calculation?

    - - - Updated - - -

    Just checked out the link you posted, thats actually really helpful, although the LA 55-P isnt a current transformer it is still relatable, this sensor has 1000 loop, 1:1000 ratio

    - - - Updated - - -

    As i look further into your claim, would i have to adjust the 100ohm resistor when measuring DC? as DC has no rms and is just a steady value. When measuring AC i used the website you provided to figure a 70 ohm resistor would scale the AC mA value for the 0-5V range for the ADC where 50mA x sqrt 2 = 70.7mA x 70 ohms = 4.949 volts



    •   Alt19th March 2017, 21:32

      advertising

        
       

  6. #6
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    122 / 122
    Points
    5,417
    Level
    17

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    Provide link for the datasheet of your sensor. Is it hall effect based sensor ?



  7. #7
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    certainly, it was in one of the links above but here it is, http://www.lem.com/docs/products/la_55-p_e.pdf yes, the sensor is hall effect.



  8. #8
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    Was the datasheet of any use? your code uploaded properly, now to test it..



  9. #9
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    122 / 122
    Points
    5,417
    Level
    17

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    I am busy with some project. I will check the datasheet.

    After this line

    Code:
    Serial.println(" Amperes");
    Add line

    Code:
    delay(1000);
    and upload the sketch to Arduino. You will be able to see what it is printing on Serial Terminal.



  10. #10
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    Click image for larger version. 

Name:	20170322_072136.jpg 
Views:	8 
Size:	286.7 KB 
ID:	137221 here is a picture of my project so far, if the picture works..



    •   Alt22nd March 2017, 14:37

      advertising

        
       

  11. #11
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    122 / 122
    Points
    5,417
    Level
    17

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    Have you checked this link ?

    http://pautex.fr/domotique/index.php



  12. #12
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    i have now, interesting project.. it seems to be using the same sensor as i, although i believe it to be overly complicated for myself, i am just a student of electronic technologies and my project is for my thesis class. The documentation i have to do with the project is worth a lot more point wise then actually having the project working extremely accurately, i am just trying to get the Arduino to process the simple output from the sensor and send the signal to an LCD, nothing more but hey i do greatly appreciate your help.



  13. #13
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    So I tried your code to no avail, unless I have my lcd hooked up wrong, I used the pin layout a friend used for a timer hooked up to an ardunio to lcd as the pin diagram.. here is a picture of the test setup, I had roughly .60volts going into A0 but nothing at all displayed on the lcd

    - - - Updated - - -

    Click image for larger version. 

Name:	20170322_170110.jpg 
Views:	2 
Size:	263.9 KB 
ID:	137235Click image for larger version. 

Name:	20170322_170120.jpg 
Views:	1 
Size:	216.6 KB 
ID:	137236Click image for larger version. 

Name:	20170322_154644.jpg 
Views:	2 
Size:	289.0 KB 
ID:	137237

    - - - Updated - - -

    with the picture of the arduino i actually have the 5volt and ground wires removed, but i did have them there.. as you can see them in the total picutre.. the arduino ground went to pins 1 and 16 of the lcd and 5v pin of arduino went to pins 2 and 15

    - - - Updated - - -

    Pin 1 and pin 16 are connected to the terminal strip I have that goes to Arduino GND, I also have the 5v on the Arduino going to the terminal strip which pin2 and pin 15 are connected, Pin D7 is connected to pin 4 on the LCD, pin D8 is connected to pin 6 on the LCD, pin D9 is connected to pin 11 on the LCD, pin D10 is connected to pin 12 on the LCD, pin D11 is connected to pin 13 on the LCD, pin D12 is connected to pin 14 on the LCD.

    - - - Updated - - -

    im going to try wiring the lcd again with this instructable http://www.instructables.com/id/Conn...uino/?ALLSTEPS and see if that can get me some text on the display



  14. #14
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    122 / 122
    Points
    5,417
    Level
    17

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    The Code I gave prints Current Value on Serial Terminal that is UART (Tx Pin transmits the data) and not Lcd Code. If you want to use Lcd then I will make a new code.



  15. #15
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    Hello, i have spent hours on this problem over the past few days reading countless articles and came up with something, here is your original code that i altered...

    #define LEM_LA_55_P A0
    double current = 0;
    int voltageinput_pin=A0;
    int voltageinput;


    // include the library code:
    #include <LiquidCrystal.h>


    // initialize the library with the numbers of the interface pins
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

    void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
    delay(100);

    lcd.begin(16, 2);
    lcd.print(" Current =");
    }

    void loop() {
    voltageinput=analogRead(voltageinput_pin);
    lcd.setCursor(0, 1);
    // print the number of primary current going through);LEM_LA_55_P:
    lcd.print(voltageinput*0.0048828125/100);
    lcd.print(" Amperes");

    // put your main code here, to run repeatedly:
    current = analogRead(LEM_LA_55_P) * 10.0 / 1023.0;
    Serial.print(current);
    Serial.println(" Amperes");
    delay(1000);

    }

    - - - Updated - - -

    Click image for larger version. 

Name:	20170324_204631.jpg 
Views:	6 
Size:	354.4 KB 
ID:	137324 here is my display at the moment

    - - - Updated - - -

    i havent tried it out, although i can tell you on your original serial coding i was getting whacky numbers, it was reading like.. 17 amps constant without any input, i tried to come out with an equation, i have voltageinput as analog pin 0, and the .0048828125 number i got from dividing 5volts(max input) / 1024 (2^10) and that / 100 because of the 100 ohm resistor.. i feel like this isnt going to work out, say i have 10 amps primary = 10 mA out x 100 ohms = 1 volt into A0, so it would be.. 1 volt x .0048828125 / 100 = ~.0000488281 ..... where the LCD to display 10 Amps



  16. #16
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    122 / 122
    Points
    5,417
    Level
    17

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    I have not used that sensor. I can only help you with code.



  17. #17
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    im getting outputs from the sensor... thats the easy part.. and i have the lcd reading "current =" its the coding i am not sure about.. i just tested it out and that conversion is no good, i had .6 volts going into A0.. it seems like its not changing the reading value of the lcd.. heres the summary, the sensor measures 0-50A and outputs 0-50 mA (analog) x 100ohm ranging resistor = 0-5volts into A0.. i just cant seem to figure out how to convert this 0-5 volts into A0 to display 0-50 Amps on the lcd as i want the lcd to display the primary current not the secondary output.. i know its all done within the software but as i said before.. i am very novice with this



    •   Alt25th March 2017, 01:43

      advertising

        
       

  18. #18
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    122 / 122
    Points
    5,417
    Level
    17

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    You should not give more than 5V to adc pin. if you give then adc module gets damaged. If your sensor output voltage is greater then 5V then scale it to 0-5V range using two resistors (voltage divider) and feed it to adc.

    analogread() returns 0 to 1023 raw adc value

    so, if you need to convert it to 0 to 50 value then


    value = analogRead(A0) * 50 / 1023.0;

    if analogRead(A0) returned 1023 then

    1023 * 50 / 1023 = 50



  19. #19
    Junior Member level 3
    Points: 154, Level: 2

    Join Date
    Feb 2017
    Posts
    27
    Helped
    0 / 0
    Points
    154
    Level
    2

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    0 to 50 A = 0 to 1023 bits with 0=0 and 1023 = 5 volts in so maybe it would be (Vin*50)/1023 ?



  20. #20
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    122 / 122
    Points
    5,417
    Level
    17

    Re: Arduino UNO unsure about coding for project, help appreciated!!

    Vin is 0 to 5V

    for 0 to 5V you get 0 to 1023 raw adc value and so

    raw_adc_value * 50 / 1023

    why don't you feed 5V to A0 pin and see if it displays 50 on lcd ?



--[[ ]]--