Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ControlLoop.c@0:70e79ca6391c, 2011-03-16 (annotated)
- Committer:
- gvloch
- Date:
- Wed Mar 16 10:20:41 2011 +0000
- Revision:
- 0:70e79ca6391c
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| gvloch | 0:70e79ca6391c | 1 | |
| gvloch | 0:70e79ca6391c | 2 | #include "mbed.h" |
| gvloch | 0:70e79ca6391c | 3 | #include <string.h> |
| gvloch | 0:70e79ca6391c | 4 | #include "header.h" |
| gvloch | 0:70e79ca6391c | 5 | |
| gvloch | 0:70e79ca6391c | 6 | |
| gvloch | 0:70e79ca6391c | 7 | extern float InputLightLevel; // in dBm |
| gvloch | 0:70e79ca6391c | 8 | extern float OutputLightLevel; // in dBm |
| gvloch | 0:70e79ca6391c | 9 | extern float ReflectedLightLevel; // in dBm |
| gvloch | 0:70e79ca6391c | 10 | extern float PumpLightLevel1; // in dBm |
| gvloch | 0:70e79ca6391c | 11 | extern float PumpLightLevel2; // in dBm |
| gvloch | 0:70e79ca6391c | 12 | extern float InputLightLevelM; |
| gvloch | 0:70e79ca6391c | 13 | extern float OutputLightLevelM; |
| gvloch | 0:70e79ca6391c | 14 | extern float ReflectedLightLevelM; |
| gvloch | 0:70e79ca6391c | 15 | extern float PumpLightLevel1M; |
| gvloch | 0:70e79ca6391c | 16 | extern float PumpLightLevel2M; |
| gvloch | 0:70e79ca6391c | 17 | extern float AmplifierGain; //in dB |
| gvloch | 0:70e79ca6391c | 18 | extern float AmplifierPower; //in dBm |
| gvloch | 0:70e79ca6391c | 19 | extern char AmplifierMode; // CC = Constant Current, CG = Constant Gain, CP = constant output power |
| gvloch | 0:70e79ca6391c | 20 | extern float PumpCurrent1; // mA |
| gvloch | 0:70e79ca6391c | 21 | extern float PumpCurrent2; // mA |
| gvloch | 0:70e79ca6391c | 22 | extern int DebugLevel; |
| gvloch | 0:70e79ca6391c | 23 | |
| gvloch | 0:70e79ca6391c | 24 | void CheckLimits(void) |
| gvloch | 0:70e79ca6391c | 25 | { |
| gvloch | 0:70e79ca6391c | 26 | if (InputLightLevel<-30.0) InputLightLevel=-30.0; |
| gvloch | 0:70e79ca6391c | 27 | if (InputLightLevel>30.0) InputLightLevel=30.0; |
| gvloch | 0:70e79ca6391c | 28 | if (OutputLightLevel<-30.0) OutputLightLevel=-30.0; |
| gvloch | 0:70e79ca6391c | 29 | if (OutputLightLevel>30.0) OutputLightLevel=30.0; |
| gvloch | 0:70e79ca6391c | 30 | if (ReflectedLightLevel<-30.0) ReflectedLightLevel=-30.0; |
| gvloch | 0:70e79ca6391c | 31 | if (ReflectedLightLevel>30.0) ReflectedLightLevel=30.0; |
| gvloch | 0:70e79ca6391c | 32 | if (PumpLightLevel1<-30.0) PumpLightLevel1=-30.0; |
| gvloch | 0:70e79ca6391c | 33 | if (PumpLightLevel1>30.0) PumpLightLevel1=30.0; |
| gvloch | 0:70e79ca6391c | 34 | if (PumpLightLevel2<-30.0) PumpLightLevel2=-30.0; |
| gvloch | 0:70e79ca6391c | 35 | if (PumpLightLevel2>30.0) PumpLightLevel2=30.0; |
| gvloch | 0:70e79ca6391c | 36 | if (AmplifierGain<0.0) AmplifierGain=0.0; |
| gvloch | 0:70e79ca6391c | 37 | if (AmplifierGain>30.0) AmplifierGain=30.0; |
| gvloch | 0:70e79ca6391c | 38 | if (AmplifierPower<-30.0) AmplifierPower=-30.0; |
| gvloch | 0:70e79ca6391c | 39 | if (AmplifierPower>30.0) AmplifierPower=30.0; |
| gvloch | 0:70e79ca6391c | 40 | if (PumpCurrent1<0.0) PumpCurrent1=0.0; |
| gvloch | 0:70e79ca6391c | 41 | if (PumpCurrent1>600.0) PumpCurrent1=600.0; |
| gvloch | 0:70e79ca6391c | 42 | if (PumpCurrent2<0.0) PumpCurrent2=0.0; |
| gvloch | 0:70e79ca6391c | 43 | if (PumpCurrent2>600.0) PumpCurrent2=600.0; |
| gvloch | 0:70e79ca6391c | 44 | |
| gvloch | 0:70e79ca6391c | 45 | } |
| gvloch | 0:70e79ca6391c | 46 | void ControlLoop(void) |
| gvloch | 0:70e79ca6391c | 47 | { |
| gvloch | 0:70e79ca6391c | 48 | CheckLimits(); |
| gvloch | 0:70e79ca6391c | 49 | } |