HM-SEC-RHS und AskSinPP 4.1.2 StepUp Batt-Messung

Entwicklung und Bau von Hardware aller Art, die im HM-Umfeld eingesetzt werden kann

Moderator: Co-Administratoren

mczeus
Beiträge: 41
Registriert: 14.01.2019, 20:56
Hat sich bedankt: 4 Mal
Danksagung erhalten: 1 Mal

Re: HM-SEC-RHS und AskSinPP 4.1.2 StepUp Batt-Messung

Beitrag von mczeus » 31.05.2022, 21:46

@der-pw

Würdest du bitte den Sketch mal posten den du bei dem Board im Einsatz hast. Mir geht es hauptsächlich um die Spanungsmessung von der Zelle!

der-pw
Beiträge: 435
Registriert: 26.01.2019, 13:39
Wohnort: Wolfenbüttel
Hat sich bedankt: 126 Mal
Danksagung erhalten: 100 Mal
Kontaktdaten:

Re: HM-SEC-RHS und AskSinPP 4.1.2 StepUp Batt-Messung

Beitrag von der-pw » 03.06.2022, 10:56

mczeus hat geschrieben:
31.05.2022, 21:46
Würdest du bitte den Sketch mal posten den du bei dem Board im Einsatz hast.
Ich verwende eigentlich den Standardsketch, außer dass ich unter
https://github.com/pa-pa/AskSinPP/blob/ ... HS.ino#L30

Code: Alles auswählen

#define DEVICE_CONFIG CFG_STEPUP_ON,11,10
gesetzt habe.

Möglicherweise hatte ich BATTERY_IRQ aber deaktiviert.
Irgendwas war da... schon wieder zu lange her. :roll:
Grüße,
Patrick

https://github.com/der-pw

mczeus
Beiträge: 41
Registriert: 14.01.2019, 20:56
Hat sich bedankt: 4 Mal
Danksagung erhalten: 1 Mal

Re: HM-SEC-RHS und AskSinPP 4.1.2 StepUp Batt-Messung

Beitrag von mczeus » 07.06.2022, 11:23

bin dabei das umzusetzen, aber hab da paar Probleme.
Komischer weise funktioniert das flashen nicht mehr ohne Fehlermeldung!

Code: Alles auswählen

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.16
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\user\AppData\Local\Temp\arduino_build_909774/HM-SEC-RHS.ino.hex"
avrdude: writing flash (19890 bytes):

Writing | ################################################## | 100% 5.46s

avrdude: 19890 bytes of flash written
avrdude: verifying flash memory against C:\Users\user\AppData\Local\Temp\arduino_build_909774/HM-SEC-RHS.ino.hex:
avrdude: load data flash data from input file C:\Users\user\AppData\Local\Temp\arduino_build_909774/HM-SEC-RHS.ino.hex:
avrdude: input file C:\Users\user\AppData\Local\Temp\arduino_build_909774/HM-SEC-RHS.ino.hex contains 19890 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 4.05s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x00 != 0x0c
avrdude: verification error; content mismatch

avrdude done.  Thank you.

Der ausgewählte serielle Port 
 ist nicht vorhanden oder das Board ist nicht angeschlossen
Sketch ist aber geflashed

Code: Alles auswählen

11:20:00.548 -> AskSin++ v5.0.0 (Jun  7 2022 11:19:44)
11:20:00.548 -> Address Space: 32 - 94
11:20:00.548 -> CC init1
11:20:00.548 -> CC Version: 14
11:20:00.586 ->  - ready
11:20:00.586 -> Config Freq: 0x2165D2
11:20:00.586 -> Activate Cycle Msg
11:20:00.586 -> Stepup - ExternalVCC
11:20:00.586 -> Stepup - ExternalVCC
11:20:00.833 -> eVcc: 300
Sketche:

Code: Alles auswählen

//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// ci-test=yes board=328p aes=no
//- -----------------------------------------------------------------------------------------------------------------------

// define this to implement new RHS3 device
#define RHS3

// define this to read the device id, serial and device type from bootloader section
// #define USE_OTA_BOOTLOADER

// use background internal VCC measure
//#define BATTERY_IRQ

#ifdef RHS3
  // send battery value
  #define CONTACT_STATE_WITH_BATTERY
#endif


#define CFG_STEPUP_BYTE 0x00
#define CFG_STEPUP_OFF  0x00
#define CFG_STEPUP_ON   0x01

#define CFG_BAT_LOW_BYTE 0x01
#define CFG_BAT_CRITICAL_BYTE 0x02

// define device configuration bytes
#define DEVICE_CONFIG CFG_STEPUP_ON,11,10

// 24 0030 4D455130323134373633 80 910101

#define EI_NOTEXTERNAL
#include <EnableInterrupt.h>
#include <AskSinPP.h>
#include <LowPower.h>

#include <Register.h>
#include <ContactState.h>

// we use a Pro Mini
// Arduino pin for the LED
// D4 == PIN 4 on Pro Mini
#define LED1_PIN 4
#define LED2_PIN 5
// Arduino pin for the config button
// B0 == PIN 8 on Pro Mini
#define CONFIG_BUTTON_PIN 8

#define SENS1_PIN 14
#define SENS2_PIN 15
#define SABOTAGE_PIN 16

// activate additional open detection by using a third sensor pins
// #define SENS3_PIN 16
// #define SABOTAGE_PIN 0

// number of available peers per channel
#define PEERS_PER_CHANNEL 10

// all library classes are placed in the namespace 'as'
using namespace as;

// define all device properties
#ifdef RHS3
const struct DeviceInfo PROGMEM devinfo = {
    {0xa9,0xb8,0xc3},       // Device ID
    "fenstert80",           // Device Serial
    {0xF2,0x09},            // Device Model
    0x10,                   // Firmware Version
    as::DeviceType::ThreeStateSensor, // Device Type
    {0x01,0x00}             // Info Bytes
};
#else
const struct DeviceInfo PROGMEM devinfo = {
    {0x09,0x56,0x34},       // Device ID
    "papa222111",           // Device Serial
    {0x00,0xC3},            // Device Model
    0x22,                   // Firmware Version
    as::DeviceType::ThreeStateSensor, // Device Type
    {0x01,0x00}             // Info Bytes
};
#endif

class SwitchSensor {
  InternalVCC internal;
  ExternalVCC<17,7,LOW,3000> external;
  uint8_t mod;
public:
  typedef uint16_t ValueType;
  static const int DefaultDelay = 250;

  SwitchSensor() : mod(0) {}

  void mode (uint8_t m) {
    mod = m;
    init();
  }

  void init () {
    if( mod == 0 ) {
      internal.init();
      DPRINTLN("InternalVCC");
    }
    else {
      external.init();
      DPRINTLN("Stepup - ExternalVCC");
    }
  }

  void start () {
    if( mod == 0 ) internal.start();
    else external.start();
  }

  uint16_t finish () {
    return mod == 0 ? internal.finish() : external.finish();
  }
};

#ifdef BATTERY_IRQ
  typedef IrqInternalBatt BatSensor;
#else
  typedef BattSensor<AsyncMeter<SwitchSensor> > BatSensor;
#endif

/**
 * Configure the used hardware
 */
typedef AvrSPI<10,11,12,13> SPIType;
typedef Radio<SPIType,2> RadioType;
typedef DualStatusLed<LED2_PIN,LED1_PIN> LedType;
typedef AskSin<LedType,BatSensor,RadioType> BaseHal;
class Hal : public BaseHal {
public:
  void init (const HMID& id) {
    BaseHal::init(id);
  }
} hal;

#ifdef RHS3
  DEFREGISTER(Reg0,DREG_CYCLICINFOMSG,MASTERID_REGS,DREG_TRANSMITTRYMAX,DREG_SABOTAGEMSG,DREG_LOWBATLIMIT)
#else
  DEFREGISTER(Reg0,DREG_CYCLICINFOMSG,MASTERID_REGS,DREG_TRANSMITTRYMAX,DREG_SABOTAGEMSG)
#endif
class RHSList0 : public RegList0<Reg0> {
public:
  RHSList0(uint16_t addr) : RegList0<Reg0>(addr) {}
  void defaults () {
    clear();
    cycleInfoMsg(true);
    transmitDevTryMax(6);
    sabotageMsg(true);
#ifdef RHS3
    lowBatLimit(22); // default low bat 2.2V
#endif
  }
};

DEFREGISTER(Reg1,CREG_AES_ACTIVE,CREG_MSGFORPOS,CREG_EVENTDELAYTIME,CREG_LEDONTIME,CREG_TRANSMITTRYMAX)
class RHSList1 : public RegList1<Reg1> {
public:
  RHSList1 (uint16_t addr) : RegList1<Reg1>(addr) {}
  void defaults () {
    clear();
    msgForPosA(1); // CLOSED
    msgForPosB(2); // OPEN
    msgForPosC(3); // TILTED
    // aesActive(false);
    // eventDelaytime(0);
    ledOntime(100);
    transmitTryMax(6);
  }
};

#ifdef SENS3_PIN
class ThreePinPosition : public TwoPinPosition {
  uint8_t pin3;
public:
  ThreePinPosition () : pin3(0) {}
  void init (uint8_t p1,uint8_t p2,uint8_t p3,const uint8_t* pmap) {
    TwoPinPosition::init(p1,p2,pmap);
    pin3 = p3;
  }
  void measure (__attribute__((unused)) bool async=false) {
    TwoPinPosition::measure(async);
    if( _position == State::PosA && AskSinBase::readPin(pin3) == HIGH) {
      _position = State::PosB;
    }
  }
};

template <class HALTYPE,class List0Type,class List1Type,class List4Type,int PEERCOUNT>
class ThreePinChannel : public ThreeStateGenericChannel<ThreePinPosition,HALTYPE,List0Type,List1Type,List4Type,PEERCOUNT> {
public:
  typedef ThreeStateGenericChannel<ThreePinPosition,HALTYPE,List0Type,List1Type,List4Type,PEERCOUNT> BaseChannel;

  ThreePinChannel () : BaseChannel() {};
  ~ThreePinChannel () {}

  void init (uint8_t pin1,uint8_t pin2,uint8_t pin3,uint8_t sabpin,const uint8_t* pmap) {
    BaseChannel::init(sabpin);
    BaseChannel::possens.init(pin1,pin2,pin3,pmap);
  }

};

typedef ThreePinChannel<Hal,RHSList0,RHSList1,DefList4,PEERS_PER_CHANNEL> ChannelType;
#else
typedef ThreeStateChannel<Hal,RHSList0,RHSList1,DefList4,PEERS_PER_CHANNEL> ChannelType;
#endif

class RHSType : public ThreeStateDevice<Hal,ChannelType,1,RHSList0> {
public:
  typedef ThreeStateDevice<Hal,ChannelType,1,RHSList0> TSDevice;
  RHSType(const DeviceInfo& info,uint16_t addr) : TSDevice(info,addr) {}
  virtual ~RHSType () {}

  virtual void configChanged () {
    TSDevice::configChanged();
    // set battery low/critical values
    #ifdef RHS3
    battery().low(getList0().lowBatLimit());
    battery().critical(getList0().lowBatLimit()-3);
    #else
    battery().low(getConfigByte(CFG_BAT_LOW_BYTE));
    battery().critical(getConfigByte(CFG_BAT_CRITICAL_BYTE));
    #endif
    #ifndef BATTERY_IRQ
    // set the battery mode
    battery().meter().sensor().mode(getConfigByte(CFG_STEPUP_BYTE));
    #endif
  }
};

RHSType sdev(devinfo,0x20);
ConfigButton<RHSType> cfgBtn(sdev);

const uint8_t posmap[4] = {Position::State::PosB,Position::State::PosC,Position::State::PosA,Position::State::PosB};
void setup () {
  DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
  sdev.init(hal);
  buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
#ifdef SENS3_PIN
  sdev.channel(1).init(SENS1_PIN,SENS2_PIN,SENS3_PIN,SABOTAGE_PIN,posmap);
#else
  sdev.channel(1).init(SENS1_PIN,SENS2_PIN,SABOTAGE_PIN,posmap);
#endif
  sdev.initDone();
    
  // measure battery every 1h
  hal.battery.init(seconds2ticks(60UL*60),sysclock);
  // wait for valid battery value
  while( hal.battery.current() == 0 ) ;
}

void loop() {
  bool worked = hal.runready();
  bool poll = sdev.pollRadio();
  if( worked == false && poll == false ) {
    // deep discharge protection
    // if we drop below critical battery level - switch off all and sleep forever
    if( hal.battery.critical() ) {
      // this call will never return
      hal.sleepForever();
    }
    // if nothing to do - go sleep
    hal.sleep<>();
  }
}
wenn ich #define BATTERY_IRQ reinnehme funktioniert die Platine auch die reedkontakte, mach ich ihn raus um die externe Messung zu verwenden funktioniert nichts.

kann mir jemand bitte behilflich sein? oder ist die Baustelle zu gross :)

Benutzeravatar
stan23
Beiträge: 2038
Registriert: 13.12.2016, 21:14
System: Alternative CCU (auf Basis OCCU)
Wohnort: Altmühltal
Hat sich bedankt: 582 Mal
Danksagung erhalten: 336 Mal
Kontaktdaten:

Re: HM-SEC-RHS und AskSinPP 4.1.2 StepUp Batt-Messung

Beitrag von stan23 » 07.06.2022, 11:37

Um eine falsche Unterspannungserkennung auszuschließen würde ich die Zeile 266 auskommentieren:

Code: Alles auswählen

//      hal.sleepForever();
und das hier einfügen:

Code: Alles auswählen

//      hal.sleepForever();
      DPRINTLN("Undervoltage shutdown");
Viele Grüße
Marco

RaspberryMatic als VM auf einem NUC mit Proxmox und USB-Funkmodul
~80 Geräte (HM, HmIP, HMW, HBW, AskSin)

mczeus
Beiträge: 41
Registriert: 14.01.2019, 20:56
Hat sich bedankt: 4 Mal
Danksagung erhalten: 1 Mal

Re: HM-SEC-RHS und AskSinPP 4.1.2 StepUp Batt-Messung

Beitrag von mczeus » 07.06.2022, 12:07

vielen Dank!
so läuft er mal, die Spannung von 1,5v stimmt auch nur bekomme ich jetzt eine Statusmeldung

Code: Alles auswählen

12:03:29	Batterieladezustand gering
dauert das jetzt einfach?

Benutzeravatar
stan23
Beiträge: 2038
Registriert: 13.12.2016, 21:14
System: Alternative CCU (auf Basis OCCU)
Wohnort: Altmühltal
Hat sich bedankt: 582 Mal
Danksagung erhalten: 336 Mal
Kontaktdaten:

Re: HM-SEC-RHS und AskSinPP 4.1.2 StepUp Batt-Messung

Beitrag von stan23 » 07.06.2022, 13:05

Ehrlich gesagt blicke ich nicht durch welches Gerät mit Step-Up ist und welche Messung braucht.

Aktuell ist bei dir die Schwelle für eine leere Batterie zu hoch im Vergleich zur gemessenen Spannung, deswegen würde er abschalten (wenn die Zeile nicht auskommentiert ist) und schickt die Servicemeldung.
Viele Grüße
Marco

RaspberryMatic als VM auf einem NUC mit Proxmox und USB-Funkmodul
~80 Geräte (HM, HmIP, HMW, HBW, AskSin)

mczeus
Beiträge: 41
Registriert: 14.01.2019, 20:56
Hat sich bedankt: 4 Mal
Danksagung erhalten: 1 Mal

Re: HM-SEC-RHS und AskSinPP 4.1.2 StepUp Batt-Messung

Beitrag von mczeus » 07.06.2022, 14:24

gebe ich die Schwelle nicht hier

Code: Alles auswählen

#define DEVICE_CONFIG CFG_STEPUP_ON,11,10
mit?

papa
Beiträge: 705
Registriert: 22.05.2018, 10:23
Hat sich bedankt: 24 Mal
Danksagung erhalten: 120 Mal

Re: HM-SEC-RHS und AskSinPP 4.1.2 StepUp Batt-Messung

Beitrag von papa » 07.06.2022, 14:34

Aber nur wenn RHS3 nicht definiert ist.
https://github.com/pa-pa/AskSinPP/blob/ ... S.ino#L223
Anfragen zur AskSin++ werden nur im Forum beantwortet

mczeus
Beiträge: 41
Registriert: 14.01.2019, 20:56
Hat sich bedankt: 4 Mal
Danksagung erhalten: 1 Mal

Re: HM-SEC-RHS und AskSinPP 4.1.2 StepUp Batt-Messung

Beitrag von mczeus » 07.06.2022, 16:32

Ok, angepasst jetzt läuft er... Mal gespannt ob er tut was er soll auf Dauer :)

Antworten

Zurück zu „Hardwareentwicklung und Selbstbau von Aktoren und Sensoren“