Project-CETI / whale-tag-embedded

Source code for the software that is used to build the image for the embedded computer inside the Whale Tags to be deployed onto sperm whales for project CETI
Apache License 2.0
13 stars 5 forks source link

Automatic shutdown is not working #21

Closed MattCummings0517 closed 2 years ago

MattCummings0517 commented 2 years ago

In the cetiTagSensors.c file (at or about line 483) the attempt to gracefully turn off the Pi when the battery goes below critical is not working as intended. A return value of -1 (error) comes back. The design idea is to just shutdown the Pi if the program arrives at this point, but something is blocking the attempt.

    CETI_LOG("updateState(): Battery critical, halting");
    system("halt");
    break;

The device just keeps going. Eventually the battery reaches 5.2 V at which point the hardware undervoltage protection engages. There is no evidence that the Pi tries to reboot on any residual charge or oscillation of the UV condition, however running the battery all the way down is not desirable in general.

MattCummings0517 commented 2 years ago

This bug manifested on V2.1 Tag 3 - the tag discharged all the way down to the hardware UV safety. The protection would not allow charging initially, but was able to recover by applying a voltage to VMID and got it to start taking charge. One of the cells had gone all the way to 1.9V. We were fortunate to revive this Tag.

MattCummings0517 commented 2 years ago

2.1-4 addresses this by using the FPGA and a new monitor program that samples the battery voltage once per minute. If the voltage drops below the critical threshold (currently 3V), the monitor sends a command to cetiTagApp via named pipe. This command arms the FPGA to shutoff if it detects a GPIO flag from the Pi going low. Then the script powers the Pi down with shutdown -P +1.