[Outils/Fab/Comp] Reprogrammer un danfoss ekc 102/202 [moding]
Répondre à la discussion
Affichage des résultats 1 à 13 sur 13

Reprogrammer un danfoss ekc 102/202 [moding]



  1. #1
    Piefra

    Reprogrammer un danfoss ekc 102/202 [moding]


    ------

    bonjour

    il y a quelque mois j'ai recuperer dans du D3E d'un figorifiste des module danfoss EKC 102 / EKC 202

    apres demontage et analyse , il s'avere qu'ils contiennent un atmega32 et un connecteur spi ( sck / mosi /miso /ss /reset / vcc / gnd ) facielement accessible

    Nom : 20210404_113745.jpg
Affichages : 224
Taille : 58,2 Ko

    le port en haut a gauche :

    sck / miso / mosi / ss
    5V / GND / / reset

    on peut y voir aussi 4 relais et l'alim secteur integree 12V

    a suivre...

    -----
    Cordialement Piefra

  2. #2
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    la suite ..

    ca se programme facilement avec un arduino as isp ( https://www.arduino.cc/en/Tutorial/B...arduino-as-isp )

    avec une resitance de 1 a 10KO entre le 5V et le reset sur le cable / connecteur vers l'ekc

    une vue sous l'afficheur : l'uc

    Nom : 20210404_113338.jpg
Affichages : 194
Taille : 52,7 Ko


    la suite ...

  3. #3
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    re,

    la suite

    le relevee des ports de l'afficheur , des inputs et des output

    Nom : 20210404_114420.jpg
Affichages : 191
Taille : 90,2 Ko

  4. #4
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    le code :

    fait a partir de la librairie sevseg , adaptee a l'EKC : connectique commune aux claver et segment melange


    cpp et h a placer dans un dossier dans librairie de l'IDE par ex :

    [quote="sevseg_ekc.h"]
    Code:
    /* SevSeg Library
     *
     * Copyright 2017 Dean Reading
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     *
     *
     * This library allows an Arduino to easily display numbers and letters on a
     * 7-segment display without a separate 7-segment display controller.
     *
     * Direct any questions or suggestions to deanreading@hotmail.com
     * See the included readme for instructions.
     * https://github.com/DeanIsMe/SevSeg
     */
    
    #ifndef SevSeg_ekc_h
    #define SevSeg_ekc_h
    
    #if defined(ARDUINO) && ARDUINO >= 100
    #include "Arduino.h"
    #else
    #include "WProgram.h"
    #endif
    
    #define MAXNUMDIGITS  3
    #define MAXNUMSEGMENTS  9
    
    
    class SevSeg
    {
    public:
      SevSeg();
    
      byte digitButs[MAXNUMDIGITS];
    
      void refreshDisplay();
      void begin(bool leadingZerosIn);
      void setBrightness(int brightnessIn); // A number from 0..100
    
      void setNumber(long numToShow, char decPlaces=-1, bool hex=0);
      void setNumber(unsigned long numToShow, char decPlaces=-1, bool hex=0);
      void setNumber(int numToShow, char decPlaces=-1, bool hex=0);
      void setNumber(unsigned int numToShow, char decPlaces=-1, bool hex=0);
      void setNumber(char numToShow, char decPlaces=-1, bool hex=0);
      void setNumber(byte numToShow, char decPlaces=-1, bool hex=0);
      void setNumber(float numToShow, char decPlaces=-1, bool hex=0);
    
      void setSegments(byte segs[]);
      void setChars(char str[]);
      void blank(void);
      void Toogle(char ch);
    
    private:
      void setNewNum(long numToShow, char decPlaces, bool hex=0);
      void findDigits(long numToShow, char decPlaces, bool hex, byte digits[]);
      void setDigitCodes(byte nums[], char decPlaces);
      void segmentOn(byte segmentNum);
      void segmentOff(byte segmentNum);
      void digitOn(byte digitNum);
      void digitOff(byte digitNum);
    
      bool digitOnVal,digitOffVal,segmentOnVal,segmentOffVal;
      bool resOnSegments, updateWithDelays, leadingZeros;
      byte digitPins[MAXNUMDIGITS]={  PIN_PB2,PIN_PB1,PIN_PB0 };
      byte segmentPins[MAXNUMSEGMENTS]={  PIN_PC6 ,PIN_PC5 ,PIN_PC2,PIN_PC0,PIN_PD7,PIN_PC7,PIN_PC3,PIN_PC4,PIN_PC1 };
      byte prevUpdateIdx; // The previously updated segment or digit
      byte digitCodes[MAXNUMDIGITS]; // The active setting of each segment of each digit
      byte digitECodes[MAXNUMDIGITS]; // The active setting of each extras segment of each digit
      unsigned long prevUpdateTime; // The time (millis()) when the display was last updated
      int ledOnTime; // The time (us) to wait with LEDs on
      int waitOffTime; // The time (us) to wait with LEDs off
      bool waitOffActive; // Whether  the program is waiting with LEDs off
    };
    
    #endif //SevSeg_h
    /// END ///
    Dernière modification par Antoane ; 24/04/2021 à 13h03. Motif: quote -» code

  5. A voir en vidéo sur Futura
  6. #5
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    le code cpp correspondnat

    [sevseg_ekc.cpp]
    Code:
    /* SevSeg Library
     *
     * Copyright 2017 Dean Reading
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     ...coupe pour que ca rentre dans un msg...
     *
     * This library allows an Arduino to easily display numbers and letters on a
     * 7-segment display without a separate 7-segment display controller.
     *
     * Direct any questions or suggestions to deanreading@hotmail.com
     * See the included readme for instructions.
     * https://github.com/DeanIsMe/SevSeg
     */
    
    #include "SevSeg_ekc.h"
    
    #define BLANK_IDX 36 // Must match with 'digitCodeMap'
    #define DASH_IDX 37
    #define PERIOD_IDX 38
    #define ASTERISK_IDX 39
    
    static const long powersOf10[] = {
      1, // 10^0
      10,
      100,
      1000,
      10000,
      100000,
      1000000,
      10000000,
      100000000,
      1000000000
    }; // 10^9
    
    static const long powersOf16[] = {
      0x1, // 16^0
      0x10,
      0x100,
      0x1000,
      0x10000,
      0x100000,
      0x1000000,
      0x10000000
    }; // 16^7
    
    // digitCodeMap indicate which segments must be illuminated to display
    // each number.
    static const byte digitCodeMap[] = {
      //     GFEDCBA  Segments      7-segment map:
      B00111111, // 0   "0"          AAA
      B00000110, // 1   "1"         F   B
      B01011011, // 2   "2"         F   B
      B01001111, // 3   "3"          GGG
      B01100110, // 4   "4"         E   C
      B01101101, // 5   "5"         E   C
      B01111101, // 6   "6"          DDD
      B00000111, // 7   "7"
      B01111111, // 8   "8"
      B01101111, // 9   "9"
      B01110111, // 65  'A'
      B01111100, // 66  'b'
      B00111001, // 67  'C'
      B01011110, // 68  'd'
      B01111001, // 69  'E'
      B01110001, // 70  'F'
      B00111101, // 71  'G'
      B01110110, // 72  'H'
      B00000110, // 73  'I'
      B00001110, // 74  'J'
      B01110110, // 75  'K'  Same as 'H'
      B00111000, // 76  'L'
      B00000000, // 77  'M'  NO DISPLAY
      B01010100, // 78  'n'
      B00111111, // 79  'O'
      B01110011, // 80  'P'
      B01100111, // 81  'q'
      B01010000, // 82  'r'
      B01101101, // 83  'S'
      B01111000, // 84  't'
      B00111110, // 85  'U'
      B00111110, // 86  'V'  Same as 'U'
      B00000000, // 87  'W'  NO DISPLAY
      B01110110, // 88  'X'  Same as 'H'
      B01101110, // 89  'y'
      B01011011, // 90  'Z'  Same as '2'
      B00000000, // 32  ' '  BLANK
      B01000000, // 45  '-'  DASH
      B10000000, // 46  '.'  PERIOD
      B01100011, // 42 '*'  DEGREE ..
    };
    
    // Constant pointers to constant data
    const byte * const numeralCodes = digitCodeMap;
    const byte * const alphaCodes = digitCodeMap + 10;
    
    // SevSeg Constructor
    /******************************************************************************/
    SevSeg::SevSeg() {
      // Initial value
      ledOnTime = 2000; // Corresponds to a brightness of 100
      waitOffTime = 0;
      waitOffActive = false;
      prevUpdateIdx = 0;
      prevUpdateTime = 0;
      resOnSegments = 0;
      updateWithDelays = 0;
    }
    
    /******************************************************************************/
    void SevSeg::begin(bool leadingZerosIn) {
    
      leadingZeros = leadingZerosIn;
      digitOnVal = HIGH;
      segmentOnVal = LOW;
      digitOffVal = !digitOnVal;
      segmentOffVal = !segmentOnVal;
    
      // Set the pins as outputs, and turn them off
      for (byte digit = 0 ; digit < MAXNUMDIGITS ; digit++) {
        pinMode(digitPins[digit], OUTPUT);
        digitalWrite(digitPins[digit], digitOffVal);
      }
    
      for (byte segmentNum = 0 ; segmentNum < MAXNUMSEGMENTS ; segmentNum++) {
        pinMode(segmentPins[segmentNum], OUTPUT);
        digitalWrite(segmentPins[segmentNum], segmentOffVal);
      }
    
      blank(); // Initialise the display
    }
    
    void SevSeg::refreshDisplay() {
    
        unsigned long us = micros();
    
        // Exit if it's not time for the next display change
        if (waitOffActive) {
          if (us - prevUpdateTime < waitOffTime) return;
        }
        else {
          if (us - prevUpdateTime < ledOnTime) return;
        }
        prevUpdateTime = us;
    
        if (waitOffActive) {
            waitOffActive = false;
        }
        else {
            // Turn all lights off for the previous digit
            digitOff(prevUpdateIdx);
    
            if (waitOffTime) {
              // Wait a delay with all lights off
              waitOffActive = true;
              return;
            }
          }
    
        prevUpdateIdx++;
        if (prevUpdateIdx >= MAXNUMDIGITS) prevUpdateIdx = 0;
    
        // Illuminate the required segments for the new digit
        digitOn(prevUpdateIdx);
      
    
     }
    
    // segmentOn
    /******************************************************************************/
    // Turns a segment on, as well as all corresponding digit pins
    // (according to digitCodes[])
    void SevSeg::segmentOn(byte segmentNum) {
      digitalWrite(segmentPins[segmentNum], segmentOnVal);
      for (byte digitNum = 0 ; digitNum < MAXNUMDIGITS ; digitNum++) {
        if (digitCodes[digitNum] & (1 << segmentNum)) { // Check a single bit
          digitalWrite(digitPins[digitNum], digitOnVal);
        }
      }
    }
    
    // segmentOff
    /******************************************************************************/
    // Turns a segment off, as well as all digit pins
    void SevSeg::segmentOff(byte segmentNum) {
      for (byte digitNum = 0 ; digitNum < MAXNUMDIGITS ; digitNum++) {
        digitalWrite(digitPins[digitNum], digitOffVal);
      }
      digitalWrite(segmentPins[segmentNum], segmentOffVal);
    }
    
    // digitOn
    /******************************************************************************/
    // Turns a digit on, as well as all corresponding segment pins
    // (according to digitCodes[])
    void SevSeg::digitOn(byte digitNum) {
      digitalWrite(digitPins[digitNum], digitOnVal);
      for (byte segmentNum = 0 ; segmentNum < 7 ; segmentNum++) {
        if (digitCodes[digitNum] & (1 << segmentNum)) { // Check a single bit
          digitalWrite(segmentPins[segmentNum], segmentOnVal);
        }
      }
      for (byte segmentNum = 7 ; segmentNum < MAXNUMSEGMENTS ; segmentNum++) {
        if (digitECodes[digitNum] & (1 << segmentNum-7)) { // Check a single bit
          digitalWrite(segmentPins[segmentNum], segmentOnVal);
        }
      }
    }
    
    // digitOff
    /******************************************************************************/
    // Turns a digit off, as well as all segment pins
    void SevSeg::digitOff(byte digitNum) {
      for (byte segmentNum = 0 ; segmentNum < 7 ; segmentNum++) {
        digitalWrite(segmentPins[segmentNum], segmentOffVal);
      }
      for (byte segmentNum = 7 ; segmentNum < MAXNUMSEGMENTS ; segmentNum++) {
        digitalWrite(segmentPins[segmentNum], segmentOffVal);
      }
      digitalWrite(digitPins[digitNum], digitOffVal);
    
    // on profite de ce qu'il est eteint pour lire le button associe'
        pinMode(digitPins[digitNum], INPUT);
        digitButs[digitNum]=!digitalRead(digitPins[digitNum]); // est en pull up
        pinMode(digitPins[digitNum], OUTPUT);
    
    }
    
    // setBrightness
    /******************************************************************************/
    // Sets ledOnTime according to the brightness given. Standard brightness range
    // is 0 to 100. Flickering is more likely at brightness > 100, and < -100.
    // A positive brightness introduces a delay while the LEDs are on, and a
    // negative brightness introduces a delay while the LEDs are off.
    void SevSeg::setBrightness(int brightness) {
      brightness = constrain(brightness, -200, 200);
      if (brightness > 0) {
        ledOnTime = map(brightness, 0, 100, 1, 2000);
        waitOffTime = 0;
        waitOffActive = false;
      }
      else {
        ledOnTime = 0;
        waitOffTime = map(brightness, 0, -100, 1, 2000);
      }
    }
    
    
    // setNumber
    /******************************************************************************/
    // This function only receives the input and passes it to 'setNewNum'.
    // It is overloaded for all number data types, so that floats can be handled
    // correctly.
    void SevSeg::setNumber(long numToShow, char decPlaces, bool hex) { //long
      setNewNum(numToShow, decPlaces, hex);
    }
    
    void SevSeg::setNumber(unsigned long numToShow, char decPlaces, bool hex) { //unsigned long
      setNewNum(numToShow, decPlaces, hex);
    }
    
    void SevSeg::setNumber(int numToShow, char decPlaces, bool hex) { //int
      setNewNum(numToShow, decPlaces, hex);
    }
    
    void SevSeg::setNumber(unsigned int numToShow, char decPlaces, bool hex) { //unsigned int
      setNewNum(numToShow, decPlaces, hex);
    }
    
    void SevSeg::setNumber(char numToShow, char decPlaces, bool hex) { //char
      setNewNum(numToShow, decPlaces, hex);
    }
    
    void SevSeg::setNumber(byte numToShow, char decPlaces, bool hex) { //byte
      setNewNum(numToShow, decPlaces, hex);
    }
    
    void SevSeg::setNumber(float numToShow, char decPlaces, bool hex) { //float
      char decPlacesPos = constrain(decPlaces, 0, 1);
      if (hex) {
        numToShow = numToShow * powersOf16[decPlacesPos];
      }
      else {
        numToShow = numToShow * powersOf10[decPlacesPos];
      }
      // Modify the number so that it is rounded to an integer correctly
      numToShow += (numToShow >= 0) ? 0.5f : -0.5f;
      setNewNum(numToShow, decPlaces, hex);
    }
    
    
    // setNewNum
    /******************************************************************************/
    // Changes the number that will be displayed.
    void SevSeg::setNewNum(long numToShow, char decPlaces, bool hex) {
      byte digits[MAXNUMDIGITS];
      findDigits(numToShow, decPlaces, hex, digits);
      setDigitCodes(digits, decPlaces);
    }
    
    
    // setSegments
    /******************************************************************************/
    // Sets the 'digitCodes' that are required to display the desired segments.
    // Using this function, one can display any arbitrary set of segments (like
    // letters, symbols or animated cursors). See setDigitCodes() for common
    // numeric examples.
    //
    // Bit-segment mapping:  0bHGFEDCBA
    //      Visual mapping:
    //                        AAAA          0000
    //                       F    B        5    1
    //                       F    B        5    1
    //                        GGGG          6666
    //                       E    C        4    2
    //                       E    C        4    2        (Segment H is often called
    //                        DDDD  H       3333  7      DP, for Decimal Point)
    void SevSeg::setSegments(byte segs[]) {
      for (byte digit = 0; digit < MAXNUMDIGITS; digit++) {
        digitCodes[digit] = segs[digit];
      }
    }
    
    // setChars
    /******************************************************************************/
    // Displays the string on the display, as best as possible.
    // Only alphanumeric characters plus '-' and ' ' are supported
    void SevSeg::setChars(char str[]) {
      for (byte digit = 0; digit < MAXNUMDIGITS; digit++) {
        digitCodes[digit] = 0;
      }
      byte strIdx = 0; // Current position within str[]
      for (byte digitNum = 0; digitNum < MAXNUMDIGITS; digitNum++) {
        char ch = str[strIdx];
        if (ch == '\0') break; // NULL string terminator
        if (ch >= '0' && ch <= '9') { // Numerical
          digitCodes[digitNum] = numeralCodes[ch - '0'];
        }
        else if (ch >= 'A' && ch <= 'Z') {
          digitCodes[digitNum] = alphaCodes[ch - 'A'];
        }
        else if (ch >= 'a' && ch <= 'z') {
          digitCodes[digitNum] = alphaCodes[ch - 'a'];
        }
        else if (ch == ' ') {
          digitCodes[digitNum] = digitCodeMap[BLANK_IDX];
        }
        else if (ch == '.') {
          digitCodes[digitNum] = digitCodeMap[PERIOD_IDX];
        }
        else if (ch == '*') {
          digitCodes[digitNum] = digitCodeMap[ASTERISK_IDX];
        }
        else {
          // Every unknown character is shown as a dash
          digitCodes[digitNum] = digitCodeMap[DASH_IDX];
        }
        strIdx++;
      }
    }
    
    
    void SevSeg::Toogle(char ch) {
        byte digitNum=MAXNUMDIGITS;
        byte segment=0;   
        switch (ch) {
            case '*':digitNum=2;segment=0;break;
            case 'x':digitNum=2;segment=1;break;
    
    // gere par setnum
    //        case '.':digitNum=1;segment=0;break;
            case ';':digitNum=1;segment=1;break;
    
    // gere par setnum
    //        case '-':digitNum=0;segment=0;break;
            case 'H':digitNum=0;segment=1;break;
        }
        if (digitNum<MAXNUMDIGITS){digitECodes[digitNum] ^= 1<<segment;}   
    }
    
    
    // blank
    /******************************************************************************/
    void SevSeg::blank(void) {
      for (byte digitNum = 0 ; digitNum < MAXNUMDIGITS ; digitNum++) {
        digitCodes[digitNum] = digitCodeMap[BLANK_IDX];
      }
      segmentOff(0);
      digitOff(0);
    }
    
    // findDigits
    /******************************************************************************/
    // Decides what each digit will display.
    // Enforces the upper and lower limits on the number to be displayed.
    
    void SevSeg::findDigits(long numToShow, char decPlaces, bool hex, byte digits[]) {
      const long * powersOfBase = hex ? powersOf16 : powersOf10;
      const long maxNum = powersOfBase[MAXNUMDIGITS] - 1;
      const long minNum = -(powersOfBase[MAXNUMDIGITS] - 1);
    
      // If the number is out of range, just display dashes
      if (numToShow > maxNum || numToShow < minNum) {
        for (byte digitNum = 0 ; digitNum < MAXNUMDIGITS ; digitNum++) {
          digits[digitNum] = DASH_IDX;
        }
      }
      else {
        byte digitNum = 0;
    
        // Convert all number to positive values
        if (numToShow < 0) {
    //      digits[0] = DASH_IDX;
    //      digitNum = 1; // Skip the first iteration
          digitECodes[0] |= 1;
          numToShow = -numToShow;
        }else{
          digitECodes[0] &= 2;
        }        
    
        // Find all digits for base's representation, starting with the most
        // significant digit
        for ( ; digitNum < MAXNUMDIGITS ; digitNum++) {
          long factor = powersOfBase[MAXNUMDIGITS - 1 - digitNum];
          digits[digitNum] = numToShow / factor;
          numToShow -= digits[digitNum] * factor;
        }
        // Find unnnecessary leading zeros and set them to BLANK
        if (decPlaces < 0) decPlaces = 0;
        if (!leadingZeros) {
          for (digitNum = 0 ; digitNum < (MAXNUMDIGITS - 1 - decPlaces) ; digitNum++) {
            if (digits[digitNum] == 0) {
              digits[digitNum] = BLANK_IDX;
            }
            // Exit once the first non-zero number is encountered
            else if (digits[digitNum] <= 9) {
              break;
            }
          }
        }
    
      }
    }
    
    
    // setDigitCodes
    /******************************************************************************/
    // Sets the 'digitCodes' that are required to display the input numbers
    
    void SevSeg::setDigitCodes(byte digits[], char decPlaces) {
    
      // Set the digitCode for each digit in the display
      for (byte digitNum = 0 ; digitNum < MAXNUMDIGITS ; digitNum++) {
        digitCodes[digitNum] = digitCodeMap[digits[digitNum]];
        // Set the decimal point segment
        if (decPlaces == 1) {
                digitECodes[1] |= 1;
        }else{
                digitECodes[1] &= 2;
        }        
      }
    }
    
    /// END ///
    Dernière modification par Antoane ; 24/04/2021 à 13h04. Motif: quote -» code

  7. #6
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    pas facile de publier du code sur ce forum ( entre la limite de taille / le nombre d'image .... )

    [testekc_atemega32.ino]
    Code:
    /*
     * pour carte test ekc 200 ( danfoss ) 
     * atmega32 / 8Mhz ext (ou int selon modele ) / no bod / no lto / no eeprom / pinout standard  / no bootloader
     * via arduino as isp 
     */
    
    
    #include "SevSeg_ekc.h"
    SevSeg sevseg; //Instantiate a seven segment controller object
    
    #define MAX_NUMBER_STRINGS 10
    #define MAX_STRING_SIZE 7
    
    char testStrings[MAX_NUMBER_STRINGS][MAX_STRING_SIZE];
    int PATTERN_CHANGE_TIME=500;
    unsigned long timer = millis() - PATTERN_CHANGE_TIME;
    float testnum = -1300;
    byte testStringsPos = 0;
    byte timer2=0;
    byte testp = 0;
    //------------------------input----------------------------
    byte IPins[] = {PIN_PA0,PIN_PA2,PIN_PA3,PIN_PA4,PIN_PA5,PIN_PA6};
    char Ilibs[][4] = {"RD1","D2","D1","S5","S4","S3"};  // etiquette ekc 202 ( rd1 et retour etat relais D01 )
    byte ICount = 6;
    //------------------------comm EKA display--EKA modulke----------------------
    //byte RS485[] = {PIN_PD0,PIN_PD1,PIN_PD2};   // RX TX Transmit  ->  6lb184 --> sortie eka display A/B
    //byte SPI[]= {PIN_PB7,PIN_PB6,PIN_PB5,PIN_PB4,PIN_PB3};  // sck/miso/mosi/ss out/ss in
    //------------------------ouput----------------------------
    byte OPins[] = { PIN_PD3,PIN_PD4,PIN_PD5,PIN_PD6};  
    char Olibs[][4] = { "D01","D02","D03","D04"};  // relais selon etiquette ekc 202
    byte OCount = 4;
    //----------------------------------------------------
    void setup() {
      for( int P=0;P<OCount;P++) {pinMode(OPins[P], OUTPUT);}
      for( int P=0;P<ICount;P++) {pinMode(IPins[P], INPUT);}
    //------------------------7 segments----------------------------
      sevseg.begin(false);
      sevseg.setBrightness(0);
      // Adds set of test strings with periods in various places
      strcpy(testStrings[ 0], "---");
      strcpy(testStrings[ 1], "A ");
      strcpy(testStrings[ 2], " A");
      strcpy(testStrings[ 3], "  A");
      strcpy(testStrings[ 4], "888");
      strcpy(testStrings[ 5], "123");
      strcpy(testStrings[ 6], " 23");
      strcpy(testStrings[ 7], "  3");
      strcpy(testStrings[ 8], " 4");
      strcpy(testStrings[ 9], "5");
    }
    
    // the loop function runs over and over again forever
    bool decplace = 0;
    byte test=1;
    
    void loop() {
       
    // Cycle 
      if (millis() > (timer + PATTERN_CHANGE_TIME)) {
          timer2++;
          if (timer2==2){
              sevseg.Toogle('x');
              timer2=0;
          }
      // check buttons 
        if (millis() > (timer + 30)) {
          if (sevseg.digitButs[0]){
                sevseg.Toogle('H');
                test++;
                sevseg.setChars(testStrings[0]);
                my_delay(500);
          }
          if (sevseg.digitButs[1]){sevseg.Toogle('*');testnum=-1300;testStringsPos=0;testp=0;}
          if (sevseg.digitButs[2]){
                sevseg.Toogle(';');
                switch (test) {
                     case 2:{
                              decplace=!decplace;   
                      }break;
                      case 3:{
                          testp++;
                          sevseg.setChars(testStrings[0]);
                          my_delay(500);
                      }break;
                      case 4:{
                          testp++;
                          sevseg.setChars(testStrings[0]);
                          my_delay(500);
                      }break;
                }
                
          }
        }  
    
    //  tests choice 
        switch (test) {
            case 1:{
    // text aff
                PATTERN_CHANGE_TIME=500;
                sevseg.setChars(testStrings[testStringsPos]);
                testStringsPos++;
                if (testStringsPos >= MAX_NUMBER_STRINGS) testStringsPos = 5;
            }break;
            case 2:{
    // num aff 
                PATTERN_CHANGE_TIME=50;
                sevseg.setNumber(testnum/10,decplace);
                testnum++;
                if (testnum >= 1099) testnum =-1300;
            }break;
            case 3:{
    // testout pins
                PATTERN_CHANGE_TIME=100;
                if (testp >= OCount) testp = 0;
                sevseg.setChars(Olibs[testp]);
                digitalWrite(OPins[testp], !digitalRead(OPins[testp]));
                my_delay(200);
            }break;
            case 4:{
    // testin pins
                PATTERN_CHANGE_TIME=100;
                if (testp >= ICount) testp = 0;
                sevseg.setChars(Ilibs[testp]);
                my_delay(500);
                int val=0;
                val = digitalRead(IPins[testp]); 
                sevseg.setNumber(val);
                my_delay(200);
                val = analogRead(IPins[testp]); 
                sevseg.setNumber(val);
                my_delay(200);
            }break;
            default:{
                test=1;
            }break;
        }
        timer = millis();
      }
      sevseg.refreshDisplay(); // Must run repeatedly
    }
    
    void my_delay(int D){
          unsigned long T = millis()+ D ;
          while (millis()<T) {sevseg.refreshDisplay();}
    }
    Dernière modification par Antoane ; 24/04/2021 à 13h05. Motif: quote -» code

  8. #7
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    voici en annexes des images du module demonte

    en l'air les ports inputs
    en bas l'alim secteur et les sortie relais

    Nom : 20210404_113820.jpg
Affichages : 182
Taille : 51,0 Ko

  9. #8
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    copie du schema de cablage ( autocollant du module )

    Nom : 20210404_114613.jpg
Affichages : 177
Taille : 57,6 Ko

  10. #9
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    les autres photo en vrac

    20210404_113918.jpg
    20210404_113854.jpg
    20210404_113840.jpg
    20210404_113831.jpg

    idees de reutilisation d'un tel module

    avec juste le board cpu donc sans alim ni relais :
    par ex , un volmetre numerique -999V a 999V ou -99.0V a 99.0V avec la precision de l'adc atmega32

    avec le module complet :
    un thermostat mais c'est prevu pour sans mod !!
    un sequenceur secteur temporel ou selon des etats d'input ( D1 d2 sont prevu pour du tor et S1 a 3 pour des R variables mais ca focntionne aussi avec une tension 0/5V )
    vu qu'iul y a un port rs485 et SPI , ca peux etre piloter en serial selon un protocole a faire ou utiliser

    bref un truc industriel qui peux etre facilement reprogramme pour les amateurs

    je peux apporter toutes les precisions que je connais sur le sujet

    a venir : un module "carel" du meme acabi en cours d'analyse

    merci de votre attention
    cdlt

  11. #10
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    Re,

    Apres relecture de l'ensemble je viens de me rendre compte que les espaces ont ete compactes dans le code
    Gare aucopier coller

    Cdlt

  12. #11
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    Bjr,

    Je rajoute un schema sommaire du cablage des afficheurs , boutons et quartz rtc qui partagent les meme pins

    Nom : 20210422_192200.jpg
Affichages : 151
Taille : 62,2 Ko

    Une question sur le code modofie arrive

    Cdlt

  13. #12
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    la problematique :

    sur cette carte , il y a un second quartz non marque , et connecte en direct sur PC6 et PC7 ( TOSC1 / TOSC2 )
    ces pins sont aussi utilise par l'afficheur 7segments en partage via des diodes sur les sorties de l'afficheur avant les r de segments

    d'apres la doc c'est pour faire une RTC plus precise et calibre par un quartz alors que l'uc est gere par un oscilatateur interne rc
    apres la lecture de l'utilisation du timer2 de l' atmega et des test , le partage n'est pas possible et donc utilisable seulement en alternat
    je me suis dit que je pourrais faire une procedure d'autocalibration de l'horloge interne

    voila les 3 procedures que j'utilise initrtc() et stoprtc() et une ISR pour chronometrer a la seconde

    Code:
    int8_t chrono=0;
    unsigned long chronomillis=0;
    bool chrono1=0;
    
    void initRTC(){
      sevseg.blank();   // pour limiter les interaction avec le quartz
      digitalWrite(PIN_PC1,0);   // pour le toggle H
      TCNT2 = 0;
      ASSR |= (1 << AS2);   // quartz 16Khz
      TCCR2 |= (1 << CS22);  // prescale 1s
      TIMSK |= (1 << TOIE2);  // interup on overflow prescale
      while (ASSR & (1 << OCR2UB));
      sei();   // interupt on
      sevseg.RTC=1;  // global sevseg Off
    }
    
    void stopRTC(){
      ASSR &= !(1 << AS2);   // decouplage quartz car shared on pc6 et pc7
    //  TIMSK=0;
      sevseg.RTC=0;  // sevseg on
    }
    
    ISR(TIMER2_OVF_vect)
    {
        if(sevseg.RTC){
    // toogle "H" direct pour monter que le prog tourne sans gener le quartz
              digitalWrite(PIN_PB2,1);
              delay(500);
              digitalWrite(PIN_PB2,0);
    // gestion du chrono en seconde
              if (!chrono1){chronomillis=millis();chrono1=true;chrono=0;}
              else {chrono++;}
              if (chrono>20){stopRTC();chronomillis-=millis();chronomillis/=10000000;chrono1=false;}
        }
    }

    le prgramme main , ne fait que lancer initrtc , attend que le stoprtc soit fait et affiche chronomillis
    ca fonctionne parfaitement au resultat pres
    quelques soit le choix de test chrono>=X dans ISR ( qui fixe la tempo de calibration )
    le chronomillis me retrourne le nombre 429 (????)
    tout comme la division de chronomillis par 10000000 , trouver par test car je ne dispose que de 3 segments pour le retour

    d'apres ma conception du prog je devrait avoir la duree du calibrage en secondes comme retour

    qu'est mal fait ?

    merci de votre attention
    cdlt
    Dernière modification par Antoane ; 24/04/2021 à 13h06. Motif: remplacement des balises quote par code

  14. #13
    Piefra

    Re : reprogrammer un danfoss ekc 102 / 202 [moding]

    Re,

    Trop con !
    Je viens de me relire et viens de voir que je debordes avec chronomillis-=millis()
    Il faudrait plustot mettre chronomillis=millis()-chronomillis et une div par 1000 devrait suffire

    ...
    Testerai demain soir

    Cdlt

Discussions similaires

  1. Reprogrammer contrôleur LCD
    Par Max_Pof dans le forum Électronique
    Réponses: 0
    Dernier message: 10/02/2013, 21h57
  2. Impossible de reprogrammer un PIC
    Par GearsGL dans le forum Électronique
    Réponses: 9
    Dernier message: 03/05/2010, 19h21
  3. Reprogrammer lecteur mp3
    Par sephi25 dans le forum Électronique
    Réponses: 1
    Dernier message: 03/12/2009, 10h38
  4. reprogrammer l'icd2
    Par inviteff7a2099 dans le forum Électronique
    Réponses: 1
    Dernier message: 18/07/2008, 10h15
Découvrez nos comparatifs produits sur l'informatique et les technologies.