- Timestamp:
- 08/14/09 14:29:20 (15 years ago)
- Files:
-
- webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs (modified) (4 diffs)
- webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c (modified) (1 diff)
- webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h (modified) (2 diffs)
- webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs
r28 r30 19 19 <ProjectSessionItem path="RTOSDemo" name="unnamed" /> 20 20 <ProjectSessionItem path="RTOSDemo;EnergyMetersEmbedded" name="unnamed" /> 21 <ProjectSessionItem path="RTOSDemo;EnergyMetersEmbedded;Demo Source" name="unnamed" /> 22 <ProjectSessionItem path="RTOSDemo;EnergyMetersEmbedded;EnergyMeters" name="unnamed" /> 21 23 <ProjectSessionItem path="RTOSDemo;EnergyMetersEmbedded;System Files" name="unnamed" /> 24 <ProjectSessionItem path="RTOSDemo;EnergyMetersEmbedded;uIP Source" name="unnamed" /> 22 25 </Project> 23 26 <Register1> … … 38 41 </TraceWindow> 39 42 <Watch1> 40 <Watches active="0" update="Never" /> 43 <Watches active="1" update="Never" > 44 <Watchpoint evalMode="2" linenumber="72" numelements="10" evalType="0" radix="-1" name="meterItems" expression="meterItems" filename="d:/energymetersproject/source/energymeters/meters_isrs.c" /> 45 <Watchpoint linenumber="64" radix="-1" name="currentTime" expression="currentTime" filename="d:/energymetersproject/source/energymeters/meters_isrs.c" /> 46 </Watches> 41 47 </Watch1> 42 48 <Watch2> … … 44 50 </Watch2> 45 51 <Watch3> 46 <Watches active=" 1" update="Never" >52 <Watches active="0" update="Never" > 47 53 <Watchpoint evalMode="2" linenumber="0" numelements="10" evalType="0" radix="-1" name="meterItems" expression="meterItems" filename="" /> 48 54 </Watches> … … 54 60 </Watch4> 55 61 <Files> 56 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\birdy\Lokale Einstellungen\Anwendungsdaten\Rowley Associates Limited\CrossWorks for ARM\packages\targets\Philips_LPC210X\Philips_LPC230X_Startup.s" y="276" path="C:\Dokumente und Einstellungen\birdy\Lokale Einstellungen\Anwendungsdaten\Rowley Associates Limited\CrossWorks for ARM\packages\targets\Philips_LPC210X\Philips_LPC230X_Startup.s" left="0" selected="1" name="unnamed" top="261" /> 62 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="84" debugPath="D:\EnergyMetersProject\Source\EnergyMeters\Meters.c" y="122" path="D:\EnergyMetersProject\Source\EnergyMeters\Meters.c" left="0" selected="0" name="unnamed" top="99" /> 63 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\EnergyMetersProject\EnergyMeters\ARM7_LPC2368_Rowley\main.c" y="113" path="D:\EnergyMetersProject\EnergyMeters\ARM7_LPC2368_Rowley\main.c" left="0" selected="0" name="unnamed" top="101" /> 64 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\EnergyMetersProject\Source\EnergyMeters\Meters_ISRs.c" y="89" path="D:\EnergyMetersProject\Source\EnergyMeters\Meters_ISRs.c" left="0" selected="1" name="unnamed" top="66" /> 65 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="19" debugPath="D:\energymetersproject\source\energymeters\timeConversion.c" y="18" path="D:\energymetersproject\source\energymeters\timeConversion.c" left="0" selected="0" name="unnamed" top="0" /> 66 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="37" debugPath="D:\energymetersproject\source\energymeters\MetersIncludes.h" y="8" path="D:\energymetersproject\source\energymeters\MetersIncludes.h" left="0" selected="0" name="unnamed" top="0" /> 67 <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="D:\EnergyMetersProject\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd-cgi.c" y="0" path="D:\EnergyMetersProject\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd-cgi.c" left="0" selected="0" name="unnamed" top="0" /> 57 68 </Files> 58 69 <ARMCrossStudioWindow activeProject="EnergyMetersEmbedded" autoConnectTarget="Macraigor Wiggler (20 Pin)" debugSearchFileMap="" fileDialogInitialDirectory="D:\freeRTOSexample\Source\EnergyMeters" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388479" debugSearchPath="" buildConfiguration="ARM Flash Debug" /> webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c
r22 r30 120 120 meterItems[METER_INDEX_GAS].timeLastTick = getEpochTimeWithMs(); /* when did the last tick occur? epoch (seconds) */ 121 121 meterItems[METER_INDEX_GAS].timeBeforeLastTick = getEpochTimeWithMs(); /* when did the tick before last tick occur? epoch (seconds) */ 122 meterItems[METER_INDEX_GAS].valueLastTick = 0; /* what value did we have at the last tick? */ 123 meterItems[METER_INDEX_GAS].valueBeforeLastTick = 1; /* what value did we have at the tick before the last tick? */ 122 meterItems[METER_INDEX_GAS].valueLastTick = 1; /* what value did we have at the last tick? */ 123 meterItems[METER_INDEX_GAS].currentValue = 1; /* same: start value of the meter */ 124 meterItems[METER_INDEX_GAS].valueBeforeLastTick = 0; /* what value did we have at the tick before the last tick? */ 124 125 125 126 } webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h
r22 r30 7 7 #define METER_INDEX_GAS 0 /* index of the gas meter data */ 8 8 9 #define DEBOUNCE_TICK_THRESHOLD_MS 50 /* when two ticks are less than this time period apart, the second tick is ignored (debouncing) */ 10 #define ACCUMULATE_TICK_THRESHOLD_SEC 30 /* how long (seconds) should the ticks be accumulated before a new data item is created? */ 9 11 10 12 typedef struct … … 15 17 portLONG valueLastTick; /* what value did we have at the last tick? */ 16 18 portLONG valueBeforeLastTick; /* what value did we have at the tick before the last tick? */ 19 portLONG currentValue; /* the value of the meter. gets incremented by the ISR */ 17 20 } meterItem; 18 21 webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c
r22 r30 61 61 void handleGasMeterTick(void) 62 62 { 63 meterItems[METER_INDEX_GAS].timeBeforeLastTick = meterItems[METER_INDEX_GAS].timeLastTick; /* when did the tick before the last tick occur? */ 64 meterItems[METER_INDEX_GAS].timeLastTick = getEpochTimeWithMs(); /* when did the last tick occur? epoch (seconds) */ 65 meterItems[METER_INDEX_GAS].valueLastTick = 0; /* what value did we have at the last tick? */ 66 meterItems[METER_INDEX_GAS].valueBeforeLastTick = 1; /* what value did we have at the tick before the last tick? */ 63 unsigned long long currentTime = getEpochTimeWithMs(); /* current epoch time with ms in ms */ 64 if ( currentTime > (meterItems[METER_INDEX_GAS].timeLastTick + DEBOUNCE_TICK_THRESHOLD_MS) ) 65 { 66 /* we have a tick that is not a bounce */ 67 meterItems[METER_INDEX_GAS].currentValue++; /* one more tick. always increase the counter */ 68 69 /* now check if we should accumulate the ticks for this time period so we leave the new data item available long 70 * enough on the web page to be read by the server 71 */ 72 if ( currentTime > ((unsigned long long)meterItems[METER_INDEX_GAS].timeLastTick + ((unsigned long long)ACCUMULATE_TICK_THRESHOLD_SEC * (unsigned long long)1000)) ) 73 { 74 /* if the last meter tick happened longer than DEBOUNCE_TICK_THRESHOLD_MS ago (i.e. the switch did not just bounce) */ 75 meterItems[METER_INDEX_GAS].timeBeforeLastTick = meterItems[METER_INDEX_GAS].timeLastTick; /* when did the tick before the last tick occur? (epoch in milliseconds) */ 76 meterItems[METER_INDEX_GAS].timeLastTick = currentTime; /* when did the last tick occur? (epoch in milliseconds) */ 77 meterItems[METER_INDEX_GAS].valueBeforeLastTick = meterItems[METER_INDEX_GAS].valueLastTick; /* what value did we have at the tick before the last tick? */ 78 meterItems[METER_INDEX_GAS].valueLastTick = meterItems[METER_INDEX_GAS].currentValue; /* what value did we have at the last tick? now one more! */ 79 /* at present, valueLastTick and currentValue are the same. This might be different for future versions. */ 80 } 81 else 82 { 83 ; /* nothing to do, curentValue was increased already above */ 84 } 85 } 86 else 87 { 88 ; /* we bounced, ignore this tick */ 89 } 67 90 } 68 91