1 2 Previous Next 17 Replies Latest reply on Jun 26, 2019 3:03 AM by suto_2664507

    PSOC5LP : Regarding calibration and how to write to EEPROM

    suto_2664507

      For example, a calibration method in a system may take an offset depending on the pressure value condition.In the current program, the specification is 0 megapascal at 0.8V and 2.5 megapascal at 2.4V, but the EEPROM can not be written immediately after correction is completed.

      In the latter case, once calibrated, it is impossible to recalibrate next time.

      It is necessary to calibrate both of them many times, and I want to write it to EEPROM when I finish calibrating.

       

      /**
      * store_zero_calibration
      * store zero_offset
      */
      int store_zero_calibration(void)
      {
          int result ;
          result = store_float(zero_offset, ZERO_OFFSET_ADDRESS) ;
          return( result ) ;
      }

      /**
      * store_center_calibration(void)
      */
      int store_center_calibration(void)
      {
          int result ;
          result = store_float(center_offset, CENTER_OFFSET_ADDRESS) ;
          return( result ) ;
      }

      /**
      * store_calibration
      * store zero_offset, center_offset
      * this function will erase EEPROM
      */
      int store_calibration(void)
      {
          cystatus result ;   
         
          result = erase_EEPROM() ;
          if (result != CYRET_SUCCESS) {
              return( result ) ;
          }
         
          result = store_zero_calibration() ;
          if (result != CYRET_SUCCESS) {
              return( result ) ;
          }
         
          result = store_center_calibration() ;
          if (result != CYRET_SUCCESS) {
              return( result ) ;
          }
         
          return( result ) ;
      }

      /**
      * restore_calibration
      * restore zero_offset and center_offset
      */
      void restore_calibration(void)
      {
          zero_offset = restore_float(ZERO_OFFSET_ADDRESS) ;
          center_offset = restore_float(CENTER_OFFSET_ADDRESS) ;
          pres_bias = -zero_offset ;
          calc_ramp_and_bias() ;
      }

       

        • 1. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
          MoTa_728816

          Hi,

           

          So what is the question?

           

          > It is necessary to calibrate both of them many times, and I want to write it to EEPROM when I finish calibrating.

          As far as reading the code,

          you can store(write to EEPROM) both values by calling store_calibration()

          or you can just store the zero_offset value by calling store_zero_calibration()

          or you can just store the center_offset value by calling store_center_calibration()

           

          And calling restore_calibration() will restore both values.

           

          moto

          • 2. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
            suto_2664507

            Hi

             

            Currently, both offset and intermediate pressure correction
            The mode is 0 → 1 → 2 → 3 → 4 → off → 0 is to be written to the EEPROM, but I want to write to the EEPROM after each correction.
            After writing once, HOS_SW can not make corrections until the power is reset.

            I do not know well what description should be changed in subroutineization.

            • 3. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
              MoTa_728816

              Hi,

               

              > Currently, both offset and intermediate pressure correction

              I'd suggest to

              put store_zero_calibration() at the end of do_zero_calibration()

              replace store_calibration() with store_center_calibration() in the do_center_calibration()

              Then they will be written to the EEPROM each time their calibration is performed.

               

              > After writing once, HOS_SW can not make corrections until the power is reset.

              Odd, HOS_SW should work as far as you are in mode 0.

              At least, returning from 5 to 0, HOS_SW should be active.

               

              This is getting too detailed, please make the question more general.

               

              moto

              • 4. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                MoTa_728816

                OK, I found one reason.

                 

                My type of switch interrupt disables itself to prevent bouncing.

                 

                You have choice of

                (1) Make a round trip of mode for each HOS_SW

                or

                (2) Remove / comment out     HOS_SW_INT_Disable()  from hos_sw_isr()

                 

                There could be more approaches, but it's beyond the scope of community.

                 

                moto

                • 5. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                  BoTa_264741

                  t.suzuki,

                  There is a custom community component, which allows to save multiple data into EEPROM

                  myEEPROM: component to save/recall application settings in EEPROM between power offs

                   

                  It can save multiple data at the single location, or partial data at several locations, whatever suits best for you application.

                  /odissey1

                  • 6. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                    suto_2664507

                    OK.

                    Please fix it to other software programmers.

                    However, -Err is output each time the power is turned on, which is a problem that you are having trouble.
                    How not so?

                    • 7. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                      MoTa_728816

                      Dear Suzuki-san,

                       

                      This is a community and a public place.

                      So please make the question general and clear,

                      and try to describe the problem and its condition.

                       

                      If there is/are problem(s), that is "YOUR" problem unless the root cause was made by Cypress.

                       

                      Having said that, if you get "Error" Display at the beginning of a program,

                      there should be at least two methods, (there could be more though)

                       

                      (1) Assign "Non-Error" initial values to the variables involved.

                       

                      (2) Do not show display until program is ready or display that the program in "Preparing"

                       

                      Best Regards,

                      18-Jun-2019

                      Motoo Tanaka

                      • 8. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                        BoTa_264741

                        t.suzuki,

                        It seems that you are using automatic Google translation, which makes it hard to understand. Please try to post your question here using original language (Japanese?). That may be more productive.

                        • 9. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                          suto_2664507

                          Dear, user_342122993

                           

                          日本語で記述させていただきます。

                          先ず、私はハードウェア技術者です。C言語やPSoCでの関数の扱い方等は現在勉強中です。

                          またこのコミュニティでは様々な方と意見交換する場であることも理解はしております。

                          しかし、C言語での構築方法はは初心者の私には敷居が高く、皆さんにどのように意見を求めて良いのか

                          正直苦労しております。

                           

                          「圧力スイッチ」と呼ばれるシステムを開発いたしましたが、ソフトウェアは、ここでも御世話になっている方に大部分を作成していただきました。

                          現在このシステムを検証しておりますが、残念ながら仕様に沿った動作が出来ていないのが現実です。

                          プログラム製作者ではないと、どこの関数でどういった動きをさせているのか、変数の箇所であるとか私にはなかなか見つけ出して修正することが難しいのが現実です。

                          修正依頼すると、他の箇所で動きがおかしくなったりと、その繰り返しで困っております。

                          指示を受けるのですが、C言語初心者には、難しい問題です。

                             

                          コミュニティは離れて、外部のソフトウェア技術者に依頼しようと考えております。

                          user_342122993の方で有償請負出来る方を知っておられましたら、ご紹介下さい。

                          • 10. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                            TakashiM_61

                            >コミュニティは離れて、外部のソフトウェア技術者に依頼しようと考えております。

                            本件に付きましては、Cypress特約店もしくはCypress担当営業にお問合せください。

                            また、Cypress Design Partnerとして、下記をご用意しております。

                            https://www.cypress.com/design-partner-program/partners

                            一度、参考にしてください。

                             

                            以上です。

                            1 of 1 people found this helpful
                            • 11. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                              suto_2664507

                              TakashiM_61様

                               

                              初めまして、鈴木と申し上げます。
                              ご紹介いただき、感謝です。

                              早速連絡してみたいと思います。

                              有難う御座いました。

                              • 12. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                                suto_2664507

                                TakashiM_61様

                                 


                                お世話様です、デザイン・パートナーさんのほとんどは、いつの間にか登録された方が多くて、中には営業の方もおられました。ほとんどの人は、開発をしていない、売買をしている、コミュニティで積極的に活動していない、というのがほとんどでした。個人事業主様もいらっしゃいましたが、すでに案件で埋め尽くされて、アドバイスは不可能という事でした。
                                せっかく推奨して下さったのに残念でした。

                                 


                                またコミュニティで少しずつ問い合わせてみる方が良いのかも知れませんね。

                                • 13. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                                  suto_2664507

                                  in trouble!

                                  Get voltage from ADC. The voltage input 0.8 V to 4 V is linearly converted from 0.00 MPascal to 5.00 MPascal.
                                  Assign the result to PASCAL.

                                  In 7SEGMENT, the value changes in the range of 0.00 to 0.12 even in the absence of pressure.

                                  What kind of fix do you like?

                                   

                                   

                                   

                                  void measure_pressure(void)
                                  {
                                      static uint8_t initialFlag = 1;                            /*  */
                                      ADC_DelSig_1_StartConvert();
                                      ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_WAIT_FOR_RESULT) ;
                                      //       if (ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_RETURN_STATUS)) {
                                      // ADCから電圧を取得。単位がmVなので、Vに変換するため1000.0で割る。その結果を変数voltに代入。
                                      // volt = ADC_DelSig_1_CountsTo_mVolts(ADC_DelSig_1_GetResult16()) / 1000.0;
                                      volt = ADC_DelSig_1_CountsTo_mVolts(ADC_DelSig_1_GetResult16()) / 1000.0;
                                             
                                      // 0.8~4.0の値を、0.0~5.0の範囲に線形変換する。その結果を変数pascalに代入。
                                      pascal = lerp(0.8, 4.0, 0.0, 5.0, volt);

                                      if (initialFlag) {
                                      // 初回のみ、平均値(移動平均)を直接セットする。そうしないと、起動直後に0.0からゆっくり変化してしまってよくない。
                                          setAvg(pascal);
                                          initialFlag = 0;
                                      }
                                             
                                      // 平均値(移動平均)を更新。平均値は、上のほうで定義している変数avgとに代入される。
                                      updateAvg(pascal);
                                     
                                      pressure = pres_ramp * avg + pres_bias ;
                                  }

                                  void report_pressure(void)
                                  {
                                      // UARTへデバッグ出力
                                      sprintf(buf, "ADC=%5.3f[V]  Raw=%5.3f[MPa] Average=%5.3f[MPa]\r\n", volt, pascal,avg);
                                      print(buf) ;
                                  }

                                   

                                  • 14. Re: PSOC5LP : Regarding calibration and how to write to EEPROM
                                    MoTa_728816

                                    Hi

                                     

                                    > Get voltage from ADC. The voltage input 0.8 V to 4 V is linearly converted from 0.00 MPascal to 5.00 MPascal.

                                    > Assign the result to PASCAL.

                                    I'm glad hearing that.

                                     

                                    > In 7SEGMENT, the value changes in the range of 0.00 to 0.12 even in the absence of pressure.

                                    Does "in the absence of pressure" means that the analog input is floating?

                                    Does the value changes that match if you connect ADC input to the ground?

                                     

                                    If the analog input is floating, changing of the ADC read value seems to be reasonable.

                                     

                                    moto

                                    1 2 Previous Next