ArduinoComm

Updated: 11 April 2010 - code significantly simplified. No need to have identifiers for each value any more.

ArduinoComm is used for all the basic sensor setups as the first step on the computer side to read the data coming in from the arduino and output it to terminal for viewing, The added advantage over using the arduino serial monitor is that you can output the data with ease to a file for logging or live graphing using kst.

How it works

ArduinoComm simply reads in data sent from the Arduino and prints it to the terminal window. 

The main thing to note is that it read's in lines and so say you want to print out realPower, ApparentPower and powerFactor typically the arduino code would look like this.

Serial.print(realPower);

Serial.print(' ');

Serial.print(apparentPower);

Serial.print(' ');

Serial .println(powerFactor);

Note that the last line is a Serial.println

Running ArduinoComm

  1. Install java and rxtx library (if not installed)
  2. Download the ArduinoComm java program here.
  3. Unzip ArduinoComm.tar.gz
  4. Compile the program by typing $ javac *.java
  5. Run the program with $ java Program

Note: you may need to change the serial port set in program.java to do this:

  1. open program.java in text editor
  2. edit the line that specifies port name/number
  3. save program.java
  4. compile 
    $ javac *.java
  5. Run the program with $ java Program

Java Installation, rxtx lib install + Compiling and Running java programs

You should now see lines of values appear in your terminal window, looking something like the screenshot above.

You can then write these values to a file by running the program with $ java Program >filename.dat

This file can then be opened in real time by KST for graphing which is detailed here.

Charles's picture

Hi Chaps, Have you given any

Hi Chaps,

Have you given any thought to using "zero-crossing-detection" to facilitate power-factor recording ?

I have been doing some work on just such a system, and have only recently come across the Arduino ( and your site )

Cheers, Charles

dubbleUJay's picture

Hi Charles, I'm busy with a

Hi Charles,
I'm busy with a similar project and "zero-crossing" was suggested by someone to measure frequency, but not power.
Do you have a cct diagram for such a circuit that will work with the Arduino's 0-5V input maybe?
Thanks,
dubbleUJay

TrystanLea's picture

Hello Charles and dubbleUJay,

Hello Charles and dubbleUJay, Thanks for the suggestion Charles. I have been using zero-crossing detection on the voltage signal to measure frequency but haven't tried to use it to measure power factor. I think it might be challenging however since the current signal is often much less sinusoidal and so the point at which it crosses zero isn't so "clear" as the voltage signal. I tried to measure the frequency from the current signal and found that that was a problem.

Ive been measuring the voltage signal with a step down AC to AC transformer recently and then calculating the power factor by dividing the real power by the apparent power, seems to be working nicely, need to document it next and put it up here :)

Trystan

Guest's picture

Power factor measurement

Hi

I am now on a project "Power factor Measurement and Improvement. I done googling a lot and got some idea about powerfactor. But still cant start with the project. Can you please share the idea of calculating Power factor?

TrystanLea's picture

Re: Power factor measurement

Have you read through this page: 
http://openenergymonitor.org/emon/node/61

It details the power factor and have a look here too http://openenergymonitor.org/emon/node/62

 

 

Guest's picture

Power Factor improvment

In my project I have to improve power factor using capacitor banks.But Ino idea about this cpacitor banks. Is it the simple AC capacitors?
Any idea?

Charles's picture

Hi Trystan, I was thinking of

Hi Trystan, I was thinking of using the zero-crossing of the current waveform and the voltage-waveform, then measuring the time diffrence - is fairly simple to then calculate the power-factor. On smaller loads, like switching power-supplies or "CFL" lights, the power factor is not nearly as important as with larger loads. I have some experience with power-factor-correction at installations like saw-mills and the like ( 500 KVa supply ). Charles

Hendrik van Eeden's picture

Measuring the power factor

Measuring the power factor with the Arduino is not that easy. The zero crossings must be measured with the current to the load as well as the voltage across the load. If the voltage is stepped down through a transformer, it will introduce a phase shift of unknown value. So you need to be able to measure and then correct for the introduced phase shift. Or use a resistive voltage divider which then introduce high (line) voltages into your project. For household purposes the power factor is near to 1 and I believe can be safely ignored.