Sinapse-Energia / talking-fiber

Firmware for optic fiber activity detection. Based on M3 MCU
0 stars 1 forks source link

[Sampling][By Time] Develop sampling process by time #6

Closed ralcaide closed 5 years ago

ralcaide commented 5 years ago

All peripherals OFF

After M minutes:

M and TH should be configurable in parametrization. By default:

M = 10 minutes TH = 2,7 V

ralcaide commented 5 years ago

It is necessary to find the best option in order to decrease the consumption as much as possible:

Quectel always connected VS Quectel connecting each M minutes ?

ghost commented 5 years ago

There is an issue with connecting only when publishing. One connection takes about 30-40 sec. If you will set period to 2 or more minutes, you can notice that after disconnection, we have power consumption reduced from 70 to 10 mA. But when connection is performed after disconnection we have situation when board is reboot, but without any HF. This situation same for AP and M2M. There is 2 possibilities: bug in m95 driver (I remember that we had something similar in past with disconnection, but not resolved it. but in this case we should see HF, but now we don't see it. Instead we have situation when whole board reboots, so it is very possible problem with M95 power circuit. We will investigate more with the scope.

ralcaide commented 5 years ago

Thanks for the commits and the comment.

Regarding the comment, I understand more or less the problem but I have a question: with this bug is the here proposed feature working? or is blocking the feature?

We would like to test the with period 15 min but we need to be sure that the device will publish if the measured level is lower than the TH.

If the bug is blocking the feature, the status is not "To be tested". It is "In Progress".

In other hand, here is required to disconnect all the peripherals, is the consumption reduced if the Quectel is always online?

ghost commented 5 years ago

If using M95 always online - feature is working. If disabling M95 when not publishing - it will not work because MCU is reset when re-enabling M95. When M95 is enabled consumption is still 60-70 mA. We will investigate how to fix bug and allow M95 to be disabled/enabled in runtime.

ralcaide commented 5 years ago

I understand. One of the main goal of this task is to reduce the consumption thanks to the disconnection of peripherals. If the disconnection of the M95 is not working, then this feature is still in progress. Please focus on this M95 problem because I think now is our biggest problem in order to get more lifespan of the battery, isn't?

ralcaide commented 5 years ago

@fpgamcu, any news about the M95 problem?

ralcaide commented 5 years ago

Testing AP_Based:

The periodic measurements are not published if the alerts are disabled.

Next definitions publish each 15 minutes Periodic and Alerts:

`//#define CONNECT_ONLY_TO_SEND // Enable periodic TF measurement and set default publish period in minutes

define ENABLE_PERIODIC

define DEFAULT_PERIOD "15"

//#define USE_SD_CARD // Enable alarm TF and set default period (minutes) and TH (mV)

define ENABLE_ALERT

define DEFAULT_ALERT_M "15"

define DEFAULT_ALERT_TH "2700"`

Next Definitions publishes nothing

`//#define CONNECT_ONLY_TO_SEND // Enable periodic TF measurement and set default publish period in minutes

define ENABLE_PERIODIC

define DEFAULT_PERIOD "15"

//#define USE_SD_CARD // Enable alarm TF and set default period (minutes) and TH (mV) // #define ENABLE_ALERT

define DEFAULT_ALERT_M "15"

define DEFAULT_ALERT_TH "2700"`

Are you able to reproduce this behavior?

ghost commented 5 years ago

Tested with first defined - getting each 15 minutes periodic and alerts Tested with second defined - getting each 15 minutes only periodic We could not reproduce the problem About M95 problem - seems like it is power issue on board. We will gather more info and send you pictures from scope.

ralcaide commented 5 years ago

With ap_based branch?

ghost commented 5 years ago

yes

ralcaide commented 5 years ago

Strange, our devices are not working like that

ralcaide commented 5 years ago

Are you able please to test the attached .hex? Is the same that we are testing with not valid results because is publishing only the messages the first time but not anymore. It is to say, for example at 8:15 is publishing them but not at 8:30, neither at 8:45 and so on...

TF-TESTING_TFS-sinapse-matoomam2m-0-9-V230818-AP_based-P=15m-A=15m.hex.txt

It is an .hex but I've added the .txt in order to be acceptable by github

ralcaide commented 5 years ago

Sorry, the previous file is using another APN. Here the file with your APN and default topic

TF-TESTING_TF-sinapse-kyivstar-0-9-V230818-AP_based-P=15m-A=15m.hex.txt

ralcaide commented 5 years ago

We are testing also without SD

ralcaide commented 5 years ago

We are testing with the device connected to the network and the result is the same, publish only the first time the periodic & alert message. Then, not anymore. We have tested in two different devices that were working right with the previous version. Could you try to reproduce, please?

ghost commented 5 years ago

We found the bug. Was not reproducible on our side because we used another broker set up to different ping period (longer, about 30 min). Now we used default broker and the issue was that we are not sending ping (because disabled on demand) and with 15 min period broker stop listening to the device. With enabled ping all works ok, latest commit should allow long periods.

ralcaide commented 5 years ago

Great, we will test it. Two questions:

This publish increase the consumption? Can me test with "CONNECT_ONLY_TO_SEND" or is buggy?

ghost commented 5 years ago

It will not increase consumption significantly. Comparing to measurement (300mA) send data consumption is near M95 standby.

CONNECT_ONLY_TO_SEND now cause restarts at reconnect. We are working on workaround.

ralcaide commented 5 years ago

Ok, we wait to the workaround.

Related with the consumption of measurement, I've already set a question in other issue but a put here again:

ghost commented 5 years ago

It is on for the 100-150 msec when measurement executing (each 15 min in our case). For https://github.com/Sinapse-Energia/talking-fiber/issues/7 it will be on all the time in order to enable analog watchdog to work.

ralcaide commented 5 years ago

So, for #7 the consumption will be very high. This is not the goal. Is just the opposite. If #7 will consume more than #6 we need to think about another solution. Any idea? HW modification?

Regarding the ping problem: If the device is disconnected form the broker when trying to publish should try to reconnect automatically, is not done like that?

ghost commented 5 years ago

Yes, there is code to perform reconnect, but it is not working. We are checking why it is happening. About consumption - HW modification should help, usually such measurement should hot consume more that several uA.

ralcaide commented 5 years ago

Ok, we will try to improve the HW

ghost commented 5 years ago

Implemented workaround is not very good, but it is only thing we can do with current hardware. If you uncomment CONNECT_ONLY_TO_SEND_WORKAROUND Device will work in the next way: 1) Connect to MQTT 2) Publish periodic and if needed alert 3) Disconnect and disable M95 4) Wait for periodic period or alert period 5) If periodic enabled and periodic period reached - restart device (go to p.1) 6) If alert enabled and alert period reached and TH check passed - restart device (go to p.1)

TODO add going to sleep mode when waiting for period.

ralcaide commented 5 years ago

I understand the workaround but I'm also right is not very good. I have several questions:

ralcaide commented 5 years ago

Regarding M95 and after read the attached documentation, regarding pages 24 -> 34. It is necessary check / test the following:

Minimum functionality mode reduces the functionality of the module to a minimum level. The consumption of the current can be minimized when the slow clocking mode is activated at the same time. The mode is set with the “AT+CFUN” command which provides the choice of the functionality levels =0, 1, 4.

if the quectel goes fro FUN=0 to FUN=1 is restarted also?

ralcaide commented 5 years ago

Quectel_M95_Hardware_Design_V3.1.pdf

ralcaide commented 5 years ago

@fpgamcu , please take a look to this guide in order to understand how work with M95 for Low consumption. Maybe could Eugene also to take a look in order to verify our design

Quectel_Low_Power_Design_User_Guide_V1.3.pdf

TO BE DONE through other task because it is a transversal requirement: #9

ralcaide commented 5 years ago

After #9, we've performed testing and found a bug. The FW is set with periodic = 60m and alerts = 5m.

All the connections and publications are well done but seems that the reading of the sensor is only done at periodic level and not at alerts level. The value and the timestamp changes when a periodic frame is published, then the next alerts displays same values returned by last periodic frame until the next periodic frame is published and so on.

This is not a valid behaviour, the photo-diode should be read each T_sampling

vAnArhist commented 5 years ago

This bug appears because calling GetVariable("TFVOL") is not executing HOOK from wrsouth.cpp to measure voltage. Latest commit should fix the issue.

ralcaide commented 5 years ago

Thanks we will test it

ralcaide commented 5 years ago

Tested and working fine. The problem is still the high battery consumption. Publishing alerts each 15minutes, 1200mAh have a long life of less than 24 hours. We need to understand why is the consumption so high

ralcaide commented 5 years ago

To be tested with periods bigger than 60 min. Example = 720min