Project

General

Profile

Pulse Counting Ferraris JNu

Added by alx37 about 5 years ago

I like to count pulses on an ferraris electrical meter
[[[http://de.wikipedia.org/wiki/Ferraris-Z%C3%A4hler]]]

The reel has a very short red mark I can successfully detect. I use an EE-SY310 which is working ok.

The problem I run into is that I get false positive readings meaning that there is no reflection or too little to reed for the EE-SY310.

I already changed the resistor responsible for the IR-led of the EE-SY310 from 1k(works perfetly with my gas meter) to 330 Ohm making it far brighter.
I spent “hours” for proper adjustment of the sensor.

I take about 4 readings a second which resembles in 240 per minute. To couterfeit false readings - if there is no reflection(“0”) - I take another reading 50ms after the first and again 150ms later and only if all three are “0” I deem it to be “0”.

However - out of the 240 readings per minute I get 1-2 false ones which is not a lot but renders readings useless (meter gives 75 rounds per kWh).
The problem seems to be the range in my eyes, electric consumption at my home ranges from 50W(3.xx rounds per hour) minimum up to 5000W(1 round in under 10sec) as a guessed maximum.

I think I should go to bed and continue tomorrow…

ALexander


Replies (10)

RE: Pulse Counting Ferraris JNu - Added by JohnO about 5 years ago

Hi Alexander,

I and others have tried to count the rotations on a similar meter using a TCRT5000, TCRT5000L and other devices and you have done a lot better than I managed.
http://forum.jeelabs.net/node/1463.html

Accuracy with less than 1% error isn’t too bad although I share your frustration. I abandoned my project for the meter. As I recall someone on here was considering using a laser and a sensor to see the slot in the wheel as it passes. I want a low power battery solution.

I am very interested if you make further progress.

RE: Pulse Counting Ferraris JNu - Added by alx37 about 5 years ago

Thank you
Clearer mind in the morning.

The bad thing is, these errors are completely random, it is not the wheel having some differences somewhere.

I’m going to add more brightness and use a 220Ohm resistor as a try or go even lower.
Next I’ll change sensor placement by 90°, at the moment it is perfectly inline with the reel with the detector right in the middle and the IR-led before in terms of rotating direction (FYI: other way round does not work at all)

I’d really like to have a meter with bright red lighting diode - life could be so easy. My gas meter has a reflecting spot in the wheel which works perfectly well - it’s easier to have like 3% hit in contrast to 97% hit in terms of reflection. Gas meter is currently in long term review for proper readings - there is no software debounce included, yet and i like to see rising temps of my heating with gas pulse counts combined (1 per 10 liters of gas).

I’ll post the sketch in the evening, I’m pretty sure you will find some powersavings and I’d like to change towards pinchanges away from digitalwrite.

RE: Pulse Counting Ferraris JNu - Added by martynj about 5 years ago

@alex37,

For your gas meter, did you see this old forum thread about using a Hall effect detector to sense the movement of the internal gas compartment(s)?

RE: Pulse Counting Ferraris JNu - Added by alx37 about 5 years ago

Yes, i did. I also tried successfully via reed contact switch which is working ok but precision is 100 litres per pulse whereas optical I get 10 litres per pulse.

RE: Pulse Counting Ferraris JNu - Added by JohnO about 5 years ago

I think I finally settled on a very low power Honeywell device as my magnetic swing interrupter. I am still using the same Eneloop batteries, fifteen months so far. There will be an updated thread somewhere.

RE: Pulse Counting Ferraris JNu - Added by alx37 about 5 years ago

#define RF69_COMPAT 1
#include 
#include 

#define BOOST     1   // measure battery on analog pin if 1, else vcc after

#define BLIP_NODE 23  // wireless node ID to use for sending blips
#define BLIP_GRP  210   // wireless net group to use for sending blips
#define BLIP_ID   1   // set this to a unique ID to disambiguate multiple nodes
#define SEND_MODE 3   // set to 3 if fuses are e=06/h=DE/l=CE, else set to 2

int IRpower = 10;
int inPin = 9;
int Status = 0;

int oldStatus = 0;
int Pulse = 0;
int Pulsesum = 0;
int loopcount = 0;

struct {
  int pls1;      
  int pls2;      
  } payload;


ISR(WDT_vect) { Sleepy::watchdogEvent(); }

void setup() {
  // get the pre-scaler into a known state
  cli();
  CLKPR = bit(CLKPCE);
#if defined(__AVR_ATtiny84__)
  CLKPR = 0; // div 1, i.e. speed up to 8 MHz
#else
  CLKPR = 1; // div 2, i.e. slow down to 8 MHz
#endif
  sei();

    bitSet(DDRB, 0); // rf on
    bitClear(PORTB, 0);


pinMode(IRpower, OUTPUT);
pinMode(8, OUTPUT);
  pinMode(inPin, INPUT);
  //Serial.begin(38400);

  rf12_initialize(BLIP_NODE, RF12_868MHZ, BLIP_GRP);
  // see http://tools.jeelabs.org/rfm12b
//  rf12_control(0xC040); // set low-battery level to 2.2V i.s.o. 3.1V
  rf12_sleep(RF12_SLEEP);

  //payload.id = BLIP_ID;
  //payload.boost = BOOST;
}

static byte sendPayload () {
  //++payload.ping;

  rf12_sleep(RF12_WAKEUP);
  rf12_sendNow(0, &payload, sizeof payload);

  //digitalWrite(10, HIGH);   // turn the LED on (HIGH is the voltage level)
  //Serial.println("ein");
  Sleepy::loseSomeTime(20);               // wait for a second
  //digitalWrite(10, LOW);
  rf12_sendWait(SEND_MODE);
  rf12_sleep(RF12_SLEEP);
}

void loop() {

loopcount++;
  //Serial.println("ein");
  digitalWrite(IRpower, HIGH);   // turn IR on 
  delay(6);               // wait for IR led
  oldStatus = Status;
  Status = digitalRead(inPin);
  //Serial.println(Status);
  //Serial.println("read");
if (Status == 0) {
  digitalWrite(IRpower, LOW);
  Sleepy::loseSomeTime(30); 
  digitalWrite(IRpower, HIGH);   // turn IR on 
  delay(6); 
  //Serial.println("nullcheck");
  Status +=digitalRead(inPin);
  digitalWrite(IRpower, LOW);
  //Serial.println(Status);
  Sleepy::loseSomeTime(225);
  digitalWrite(IRpower, HIGH);   // turn IR on 
  delay(6);
  Status +=digitalRead(inPin);
  //Serial.println(Status);
  //Serial.println("------------");
  if (Status > 1){Status = 1;};
  }
  digitalWrite(IRpower, LOW);    // turn IR off
  if (Status == 0 && oldStatus == 1) {Pulse++;};  
  //delay(500);               // wait for a second
  //Serial.println(Status);
  //Serial.println(Pulse);
  //Serial.println(Pulsesum);
  if (loopcount == 240) {
    Pulsesum=Pulsesum+Pulse;
    //Serial.println("Sending");
    payload.pls1 = Pulse;
    payload.pls2 = Pulsesum;
    sendPayload();
    //Serial.println("Sending done");
    loopcount=0;
    Pulse=0;
    Sleepy::loseSomeTime(225);
    }
    else
    {
    Sleepy::loseSomeTime(250);  
    }
}

RE: Pulse Counting Ferraris JNu - Added by alx37 about 5 years ago

I just changed to 220 Ohm resistor and I’m waiting for results.

Sketch above, your feedback welcome…

ALexander

RE: Pulse Counting Ferraris JNu - Added by alx37 about 5 years ago

void loop() {  
loopcount++;
  //Serial.println("ein");
  digitalWrite(IRpower, HIGH);   // turn IR on 
  delay(4);               // wait for IR led
  oldStatus = Status;
  Status = digitalRead(inPin);
  //Serial.println(Status);
  //Serial.println("read");
if (Status == 0) {
  digitalWrite(IRpower, LOW);
  Sleepy::loseSomeTime(30); 
  digitalWrite(IRpower, HIGH);   // turn IR on 
  delay(4); 
  //Serial.println("nullcheck");
  Status +=digitalRead(inPin);
  digitalWrite(IRpower, LOW);
  //Serial.println(Status);
  Sleepy::loseSomeTime(125);
  digitalWrite(IRpower, HIGH);   // turn IR on 
  delay(4);
  Status +=digitalRead(inPin);
  digitalWrite(IRpower, LOW);
  Sleepy::loseSomeTime(70);
  digitalWrite(IRpower, HIGH);   // turn IR on 
  delay(4);
  Status +=digitalRead(inPin);
  digitalWrite(IRpower, LOW);  
  Sleepy::loseSomeTime(16);
  digitalWrite(IRpower, HIGH);   // turn IR on 
  delay(4);
  Status +=digitalRead(inPin);  
  //Serial.println(Status);
  //Serial.println("------------");
  if (Status > 1){Status = 1;};
  }
  digitalWrite(IRpower, LOW);    // turn IR off
einscount +=Status;  
if (Status == 0 && oldStatus == 1 && einscount > 20) {
Pulse++;
//Serial.print("einscount-> ");
//Serial.println(einscount);
einscount = 0;
};  
  //delay(500);               // wait for a second
  //Serial.println(Status);
  //Serial.println(Pulse);
  //Serial.println(Pulsesum);
  if (loopcount == 240) {
    Pulsesum=Pulsesum+Pulse;
    //Serial.println("Sending");
    payload.pls1 = Pulse;
    payload.pls2 = Pulsesum;
    sendPayload();
    //Serial.println("Sending done");
    loopcount=0;
    Pulse=0;
    Sleepy::loseSomeTime(225);
    }
    else
    {
    Sleepy::loseSomeTime(250);  
    }
}

RE: Pulse Counting Ferraris JNu - Added by alx37 about 5 years ago

loop part improved.
another test run now error seems further lowered.

RE: Pulse Counting Ferraris JNu - Added by alx37 almost 5 years ago

I had a lockup on both my gas and electricity meter.
I suspected it to be batteries empty but it wasn’t.
Only thing I can say no rf after 4 days as there were no more receivings…

ALexander

    (1-10/10)