I discovered there was still some space left on my GTI-PWM board so I decided to include a 4-digit energy display. There were some nice dual 7-segment displays (no-name LB-5310) in my tray, I still had a PIC16F818 left so the space was quickly occupied with a straightforward display circuit (click to embiggen):
The PIC drives the common anode displays from 4 PNP transistors (BC857B). The common cathodes (the schematic lists the respective pin numbers) are driven directly from PORTB. The PIC also digitizes the measured current from my GTI and calculates the power from it. By summing the power samples you get energy. The code (assembly) was quickly kludged together with the help from piclist.com (see the code for the links). They have some really useful code snippets which I used and modified to get the BCD values for the 7-segment displays and the conversion from the session energy in Wmin to xxx.x Wh. The total is displayed in x.xxx kWh and stored in EEPROM when the cycling session on my homotrainer ends. I found that the conversion to 0.1 Wh increments is very encouraging when in a cycling session. It increases every 5-6 seconds so you have feedback often. With modest effort every minute a watt-hour of energy is generated and fed back into the grid.
It worked beautifully! The totals are duly remembered and the session display is working like it should:
You can see the two three-legged regulators above the zeroes. The left one a 7815 feeding the driver to the MOSFET and the right one the 7805 for the PIC. Both stay cool. The MODE switch is mounted more to the left below the big analog meter.
All in all a fun little and useful project!
Update: There is always that finishing touch. I got red transparent filter foil from my local model toy hardware store and used it to filter the displays. The red light emitted from the segments now really stands out! And yes, in the meantime I generated no less than 68 Wh. I'm an energy tycoon! Woohoo!
Update2: I discovered that the overflow of TOTLO was not handled correctly. The TOTALS display duly changed from 0.255 to 0.000 kWh. This was caused by the wrong test for INCF. I tested for STATUS,C (carry) but STATUS,Z gets set because the register becomes zero. The only thing I did not test during development using the simulator. Come to think of it, the overflow from 9.999 kWh to 0.000 also hasn't been tested. The overflow from x.999 kWh to (x+1).000 works.
Back to the projects page
Date: 26 March 2021, updated 24 April 2021
This software is licensed under the CC-GNU GPL.