SOS Programming Problem in Arduino Mega

Discussion in 'Programmer's Corner' started by Voidman, Nov 2, 2013.

  1. Voidman

    Thread Starter New Member

    Oct 8, 2013
    1
    0
    Hi, nice to meet you all here. :)

    Working on a smart energy meter project using the Arduino Mega 2560. Currently able to sense the input current from a normal wall socket outlet using ACS712 current sensor.

    I was scratching my head through the calculation of the I_rms from each cycle of a input power supply. Problems come in when:

    1. As far as I concerned, calculation of I_rms= (I_peak)/(sqrt2) for half a cycle but I noticed that the result I am getting are discrete signals. Is the formula appropriate for this situation?

    2. .txt file attached bellow is the source code use in Arduino IDE to read the current and calculate the I_rms. I am pretty sure there are errors in writing the code between the "if (amps > 0).....till... Serial.print(I_rms);" Feel free to point out my error and correct my mistakes.

    TQ.
     
  2. Danm1

    Member

    Jul 19, 2010
    55
    7
    It's not the best way to fix code, that is to post it on a forum, since people tend to fix their own bugs before they can get someone to look at it, but I did look.

    I suppose you know you don't have an exit condition in the for loop.
     
Loading...