Customize 3-phase sketch

Hi there,

I'm completely new in the world of programming Arduino and Raspberry, so I have some struggles to get the 3-phase sketch working right.

I'd like to get al the available data of a 3-phase motor, so I want to read all the data and transmit it to my raspberry Pi. The clean sketch is working and the results are good. But when I add my parameters (see below), the TX don't send any data anymore. Something with the 60 bytes?

typedef struct { int power1, realPower1, apparentPower1, powerFactor1, Irms1, power2,
 realPower2, apparentPower2, powerFactor2, Irms2, power3, realPower3, apparentPower3,
 powerFactor3, Irms3, power4, realPower4, apparentPower4, powerFactor4, Irms4, Vrms; }
 PayloadTX; 

My second issue is about sending the data, when I lower the number of parameters in the typedef struct  (see below), the emonTX sends every 10 seconds the data package to my PI. So it is working well, but my Emonhub only reads 0 for realPower and apparentPower.

typedef struct { int power1, realPower1, apparentPower1, power2, realPower2,
 apparentPower2, power3, realPower3, apparentPower3,
 power4, realPower4, apparentPower4, Vrms; } PayloadTX;   

Do I have to specify these parameters for RF transmission?

Thanks in advance!

Robert Wall's picture

Re: Customize 3-phase sketch

The 60 bytes limit is a function of the JeeLib radio packet format. It is supposed to be 66 bytes, but there is a bug somewhere that I believe JeeLabs were looking at, but I know no more. Take a look at the Resources article about the RFM12B for details on how the radio packet is transmitted. It's a little out of date now as more data types are permitted and interpreted by emonHub, but the principle remains sound. What might be happening to produce the zero values (assuming you have picked up the correct values - do they appear in the IDE serial window?) is integer truncation - what's the difference between "power" and "realPower"/"apparentPower" (i.e. are you sending the same value twice?).

Bart's picture

Re: Customize 3-phase sketch

First, thanks for your reaction.

I have read the file, that's why I thought that it should had something to do with the bytes, but I wasn't sure about it.

After your answer, I have checked if values appeared in the serial window and it was. So after that I checked the sketch and founded out that I still had to define the other serial parameters.

You were right about Power and realPower, they are both the same but I was still testing with defining.

Final typedef struct:

typedef struct { int power1, apparentPower1, powerFactor1, Irms1, power2, apparentPower2,
powerFactor2, Irms2, power3, apparentPower3, powerFactor3, Irms3, power4, apparentPower4, 
powerFactor4,Irms4, Vrms; } PayloadTX;

Other definitions:

  emontx.power1 = realPower1;  // Copy the desired variables ready for transmission
  emontx.power2 = realPower2;
  emontx.power3 = realPower3;
  emontx.power4 = realPower4;
  emontx.apparentPower1 = apparentPower1;
  emontx.apparentPower2 = apparentPower2;
  emontx.apparentPower3 = apparentPower3;
  emontx.apparentPower4 = apparentPower4;
  emontx.Irms1 = Irms1;
  emontx.Irms2 = Irms2;
  emontx.Irms3 = Irms3;
  emontx.Irms4 = Irms4;
  emontx.powerFactor1 = powerFactor1;
  emontx.powerFactor2 = powerFactor2;
  emontx.powerFactor3 = powerFactor3;
  emontx.powerFactor4 = powerFactor4;
  emontx.Vrms   = Vrms;

 

Robert Wall's picture

Re: Customize 3-phase sketch

The calculations produce all the values. The limited number of values sent is only to make the 'payload' compatible with the standard emonTx demo sketches.

But a warning is needed: There have been problems with synchronisation between the two ends of the radio link, especially if there are long runs of zero values; the symptoms are that the emonHub rejects the data because the received byte string is the wrong length.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.