Download - ePrints Soton

Transcript
142
Chapter 5 Case Study: Deployment in a Prototype System – Software
There are a number of intricacies associated with using these functions, that are considered at the end of this subsection.
Device management functions
These functions are provided for system initialisation and to enable the periodic refresh
of data in the microcontroller’s copy of the EEDS of the energy modules.
• eanInit is called on system start-up to initialise relevant EAN variables to zero,
and calls the pyeInit function.
• eanStartUp tests the supply voltage of the microcontroller; if it is below the threshold value it returns a ‘0’; otherwise, it reads the EEDS data from all modules
into the microcontroller memory and returns a ‘1’.
• eanRefresh checks the microcontroller supply voltage; if above the threshold value
it checks for changes using the pyeRefresh function. If no change is detected, the
function returns a ‘1’; if it was unable to complete due to low supply voltage it
returns a ‘0’, otherwise (if changes were found), it returns a ‘2’.
• eanRescan checks the microcontroller supply voltage; if above the threshold value
it checks for changes using the pyeRescan function. If no change is detected, the
function returns a ‘1’; if it was unable to complete due to low supply voltage it
returns a ‘0’, otherwise (if changes were found), it returns a ‘2’.
Together these functions enable the energy status to be updated periodically, and for
the addition or removal of energy modules to be detected and appropriate action taken.
Detail of capabilities
The limitations of a resource-constrained microcontroller mean that some mathematical
functions need to be performed with care in order to maintain the precision of results.
For example, the calculations carried out for estimating the power obtained from the
photovoltaic module involves the use of a Taylor expansion to implement Equation 4.7
mathematically. The Taylor expansion of the exponential function, ex , is shown in
Equation 5.1. The calculation involves a substantial amount of floating-point arithmetic, which is challenging for these resource-constrained microcontrollers. Indeed, the
limitations of the fixed-point numbers also mean that the precision of the Taylor expansion approximation is limited. As an example, Figure 5.8 shows the computation of e8 ,
using the expansion shown in Equation 5.1, to a varied amount of terms. Due to the
limits of the long variable which is used to hold the result of the factorial function, the
thirteenth term (13! = 6, 227, 020, 800) is the highest term that can be computed; as ex