Gerhard van Lochem / Mbed 2 deprecated AmpCon

Files at this revision

API Documentation at this revision

Comitter:
gvloch
Date:
Wed Mar 16 10:20:41 2011 +0000
Commit message:

Changed in this revision

CommandLine.c Show annotated file Show diff for this revision Revisions of this file
ConfigFile.lib Show annotated file Show diff for this revision Revisions of this file
ConfigManager.c Show annotated file Show diff for this revision Revisions of this file
ControlLoop.c Show annotated file Show diff for this revision Revisions of this file
GlobalVariables.c Show annotated file Show diff for this revision Revisions of this file
RPCInterface.lib Show annotated file Show diff for this revision Revisions of this file
SerialControl.c Show annotated file Show diff for this revision Revisions of this file
hardwareinterface.c Show annotated file Show diff for this revision Revisions of this file
header.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CommandLine.c	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,277 @@
+
+#include "mbed.h"
+#include <string.h>
+#include "header.h"
+#include "SerialRPCInterface.h"
+
+
+extern float InputLightLevel;  // in dBm
+extern float OutputLightLevel;  // in dBm
+extern float ReflectedLightLevel;  // in dBm
+extern float PumpLightLevel1;  // in dBm
+extern float PumpLightLevel2; // in dBm
+extern float InputLightLevelM;
+extern float OutputLightLevelM;
+extern float ReflectedLightLevelM;
+extern float PumpLightLevel1M;
+extern float PumpLightLevel2M;
+extern float AmplifierGain; //in dB
+extern float AmplifierPower; //in dBm
+extern char  AmplifierMode; // C = Constant Current, G = Constant Gain, P = constant output power
+extern float PumpCurrent1; // mA
+extern float PumpCurrent2; // mA
+extern char SerialControl;
+extern int DebugLevel;
+
+extern char commandstring[16];
+extern char commandstringlen;
+extern "C" void mbed_reset();
+
+
+
+
+void splashscreen();
+void commandline(void)
+{
+    long int templi=0;
+    
+   
+    //pc.scanf("%s",&commandstring);
+  
+    if (commandstring[0] == '*')
+    {
+         printf("Resetting...\n\r");
+         wait_ms(1000);
+         mbed_reset(); 
+    }
+    if (commandstring[0] == 's')
+    {
+         splashscreen();
+        statusscreen();
+    }
+    if (commandstring[0] == 'd')
+        {
+        if (commandstring[1]<97)
+        {
+            templi = (commandstring[1]-48)*0x10;
+        }else
+        {
+            templi = (commandstring[1]-97+10)*0x10;
+        }
+        if (commandstring[2]<97)
+        {
+            templi += (commandstring[2]-48);
+        }else
+        {
+            templi += (commandstring[2]-97+10);
+        }
+        printf ("\n\rDAC(%X)\n\r", templi);
+        
+    }
+ 
+    
+    if (commandstring[0] == '.')
+    {
+        switch (AmplifierMode)
+        {
+        case 'c':
+        case 'C':
+            PumpCurrent1+=1.0;
+            PumpCurrent2+=1.0;
+            printf ("\n\rPumpCurrent1 %3.1f mA\n\r", PumpCurrent1);
+            printf ("\n\rPumpCurrent2 %3.1f mA\n\r", PumpCurrent2);
+            break;
+        case 'g':
+        case 'G':
+            AmplifierGain+=0.1;
+            printf ("\n\rAmplifierGain %3.1f dBm\n\r", AmplifierGain);
+            break;
+        case 'p':
+        case 'P':
+            AmplifierPower+=0.1;
+            printf ("\n\rAmplifierPower %3.1f dBm\n\r", AmplifierPower);
+            break;        
+        }
+    }
+                            
+    if (commandstring[0] == ',')
+    {
+        switch (AmplifierMode)
+        {
+        case 'c':
+        case 'C':
+            PumpCurrent1-=1.0;
+            PumpCurrent2-=1.0;
+            printf ("\n\rPumpCurrent1 %3.1f mA\n\r", PumpCurrent1);
+            printf ("\n\rPumpCurrent2 %3.1f mA\n\r", PumpCurrent2);
+            break;
+        case 'g':
+        case 'G':
+            AmplifierGain-=0.1;
+            printf ("\n\rAmplifierGain %3.1f dB\n\r", AmplifierGain);
+            break;
+        case 'p':
+        case 'P':
+            AmplifierPower-=0.1;
+            printf ("\n\rAmplifierPower %3.1f dBm\n\r", AmplifierPower);
+            break;        
+        }
+    }
+    if (commandstring[0] == '<')
+    {
+        PumpCurrent1+=1.0;
+        PumpCurrent2-=1.0;
+        printf ("\n\rPumpCurrent1 %3.1f mA\n\r", PumpCurrent1);
+        printf ("\n\rPumpCurrent2 %3.1f mA\n\r", PumpCurrent2);
+    }
+    if (commandstring[0] == '>')
+    {
+        PumpCurrent1-=1.0;
+        PumpCurrent2+=1.0;
+        printf ("\n\rPumpCurrent1 %3.1f mA\n\r", PumpCurrent1);
+        printf ("\n\rPumpCurrent2 %3.1f mA\n\r", PumpCurrent2);
+    }
+    if ((commandstring[0] == 'c')||(commandstring[0] == 'C'))
+    {
+        if ((commandstring[1] == 'c')||(commandstring[1] == 'C')) {AmplifierMode='c'; printf("Amplifier Mode: CONST CURRENT");}
+        if ((commandstring[1] == 'g')||(commandstring[1] == 'G')) {AmplifierMode='g'; printf("Amplifier Mode: CONST GAIN");}
+        if ((commandstring[1] == 'p')||(commandstring[1] == 'P')) {AmplifierMode='p'; printf("Amplifier Mode: CONST POWER");}
+        
+  
+    }
+    if (commandstring[0] == 'r')
+    {
+        if (commandstring[1]<97)
+        {
+            templi = (commandstring[1]-48)*0x10;
+        }else
+        {
+            templi = (commandstring[1]-97+10)*0x10;
+        }
+        if (commandstring[2]<97)
+        {
+            templi += (commandstring[2]-48);
+        }else
+        {
+            templi += (commandstring[2]-97+10);
+        }
+
+         printf ("\n\r(%X) => \n\r", templi);
+    }
+    if ((commandstring[0] == 'w')&&(commandstringlen == 10))
+    {
+        if (commandstring[1]<97)
+        {
+            templi = long(commandstring[1]-48)*0x10000000;
+        }else
+        {
+            templi = long(commandstring[1]-97+10)*0x10000000;
+        }
+        if (commandstring[2]<97)
+        {
+            templi += long(commandstring[2]-48)*0x1000000;
+        }else
+        {
+            templi += long(commandstring[2]-97+10)*0x1000000;
+        }
+        if (commandstring[3]<97)
+        {
+            templi += long(commandstring[3]-48)*0x100000;
+        }else
+        {
+            templi += long(commandstring[3]-97+10)*0x100000;
+        }
+        if (commandstring[4]<97)
+        {
+            templi += long(commandstring[4]-48)*0x10000;
+        }else
+        {
+            templi += long(commandstring[4]-97+10)*0x10000;
+        }
+        if (commandstring[5]<97)
+        {
+            templi += long(commandstring[5]-48)*0x1000;
+        }else
+        {
+            templi += long(commandstring[5]-97+10)*0x1000;
+        }
+        if (commandstring[6]<97)
+        {
+            templi += long(commandstring[6]-48)*0x100;
+        }else
+        {
+            templi += long(commandstring[6]-97+10)*0x100;
+        }
+        if (commandstring[7]<97)
+        {
+            templi += long(commandstring[7]-48)*0x10;
+        }else
+        {
+            templi += long(commandstring[7]-97+10)*0x10;
+        }
+        if (commandstring[8]<97)
+        {
+            templi += long(commandstring[8]-48);
+        }else
+        {
+            templi += long(commandstring[8]-97+10);
+        }
+        printf ("\n\r(%X)\n\r", 0);
+    }
+    if (commandstring[0] == '?')
+    {
+        printf("\n\r");
+        printf("|----------------------------------------------------------------------|\n\r");
+        printf("|  Read command rxx<cr> => r-read xx-address                           |\n\r");
+        printf("|  Write command wxxyyyyyy<cr> => r-read xx-address yyy-data           |\n\r");
+        printf("|  Set DAC command dxx<cr> => d-write to DAC xxx-data                  |\n\r");
+        printf("|  Set Amplifier mode cx<cr> => x=c,g or p (Const current,gain,power)  |\n\r");  
+        printf("|                                                                      |\n\r");  
+        printf("|  Status  command:    s                                               |\n\r");
+        printf("|  Manual Contol:      ,  Negative step                                |\n\r");    
+        printf("|  Manual Contol:      .  Positive step                                |\n\r");          
+        printf("|  Pump Balance adjust:<  Negative step                                |\n\r");    
+        printf("|  Pump Balance adjust:>  Positive step                                |\n\r");    
+        printf("|  RESET Controller:   *                                               |\n\r");  
+        printf("|----------------------------------------------------------------------|\n\r");
+    }
+  printf("\r\n>");
+  
+}
+void statusscreen(void)
+{
+         printf ("\n\rStatus\n\r");
+         printf("SystemCoreClock      = %.3f MHz\n\r", (float)SystemCoreClock/1000000.0);
+         printf("InputLightLevel      = %3.1f dBm\n\r", InputLightLevel);
+         printf("OutputLightLevel     = %3.1f dBm\n\r", OutputLightLevel);
+         printf("ReflectedLightLevel  = %3.1f dBm\n\r", ReflectedLightLevel);
+         printf("PumpLightLevel1      = %3.1f dBm\n\r", PumpLightLevel1);
+         printf("PumpLightLevel2      = %3.1f dBm\n\r", PumpLightLevel2);
+        switch (AmplifierMode)
+        {
+        case 'c':
+        case 'C':
+         printf("Pump Mode            = CONSTANT CURRENT\n\r");
+            break;
+        case 'g':
+        case 'G':
+         printf("Pump Mode            = CONSTANT GAIN\n\r");
+            break;
+        case 'p':
+        case 'P':
+         printf("Pump Mode            = CONSTANT POWER\n\r");
+            break; 
+        }       
+         printf("AmplifierGain        = %3.1f dBm\n\r", AmplifierGain);
+         printf("PumpCurrent1         = %3.1f mA\n\r", PumpCurrent1);
+         printf("PumpCurrent2         = %3.1f mA\n\r", PumpCurrent2);
+         printf("\n\r>");   
+  
+}
+void splashscreen(void)
+{
+    printf("%c",0x0C);
+    printf("\r\nXtera Amplifier controller Debug Interface v0.01\n\n\r"); 
+    printf("Type ?<cr> for help\n\n\r");
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ConfigFile.lib	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/shintamainjp/code/ConfigFile/#f6ceafabe9f8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ConfigManager.c	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,110 @@
+#include "ConfigFile.h"
+#include "mbed.h"
+#include <string.h>
+#include "header.h"
+extern float InputLightLevelM;
+extern float OutputLightLevelM;
+extern float ReflectedLightLevelM;
+extern float PumpLightLevel1M;
+extern float PumpLightLevel2M;
+extern float AmplifierGain; //in dB
+extern float AmplifierPower; //in dBm
+extern char  AmplifierMode; // CC = Constant Current, CG = Constant Gain, CP = constant output power
+extern float PumpCurrent1; // mA
+extern float PumpCurrent2; // mA
+extern float CurrentSource1MAX; 
+extern float CurrentSource2MAX; 
+extern char SerialControl;
+extern int DebugLevel;
+LocalFileSystem local("local");
+ConfigFile cfg;
+
+void ReadConfigFile(void) {
+    char *cfg1 = "DebugLevel";
+    char *cfg2 = "InputLightLevelM";
+    char *cfg3 = "OutputLightLevelM";
+    char *cfg4 = "ReflectedLightLevelM";
+    char *cfg5 = "PumpLightLevel1M";
+    char *cfg6 = "PumpLightLevel2M";
+    char *cfg7 = "DefaultAmplifierGain";
+    char *cfg8 = "DefaultAmplifierPower";
+    char *cfg9 = "DefaultAmplifierMode";
+    char *cfg10 = "DefaultPumpCurrent1";
+    char *cfg11 = "DefaultPumpCurrent2";
+    char *cfg12 = "CurrentSource1MAX";
+    char *cfg13 = "CurrentSource2MAX";
+    char *cfg14 = "SerialControl";
+    char value[BUFSIZ];
+    /*
+     * Read a configuration file from a mbed.
+     */
+      printf("\n\rReading Config File:\n\r");
+    if (!cfg.read("/local/config.txt")) {
+        printf("Failure to read a configuration file.\n");
+    }
+
+    /*
+     * Get a configuration value.
+     */
+    if (cfg.getValue(cfg1, &value[0], sizeof(value))) {
+        printf("%s = %i\n\r", cfg1, atoi(value));
+        DebugLevel = atoi(value);
+    }
+    if (cfg.getValue(cfg2, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg2, atof(value));
+        InputLightLevelM = atof(value);
+    }
+  if (cfg.getValue(cfg3, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg3, atof(value));
+        OutputLightLevelM = atof(value);
+    }
+  if (cfg.getValue(cfg4, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg4, atof(value));
+        ReflectedLightLevelM = atof(value);
+    }
+  if (cfg.getValue(cfg5, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg5, atof(value));
+        PumpLightLevel1M = atof(value);
+    }
+  if (cfg.getValue(cfg6, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg6, atof(value));
+        PumpLightLevel2M = atof(value);
+    }
+  if (cfg.getValue(cfg7, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg7, atof(value));
+        AmplifierGain = atof(value);
+    }
+  if (cfg.getValue(cfg8, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg8, atof(value));
+        AmplifierPower = atof(value);
+    }
+  if (cfg.getValue(cfg9, &value[0], sizeof(value))) {
+        printf("%s = %s\n\r", cfg9, value);
+        AmplifierMode = value[1];
+    }
+  if (cfg.getValue(cfg10, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg10, atof(value));
+        PumpCurrent1 = atof(value);
+    }
+  if (cfg.getValue(cfg11, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg11, atof(value));
+        PumpCurrent2 = atof(value);
+    }     
+  if (cfg.getValue(cfg12, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg12, atof(value));
+        CurrentSource1MAX = atof(value);
+    }     
+  if (cfg.getValue(cfg13, &value[0], sizeof(value))) {
+        printf("%s = %3.4f\n\r", cfg13, atof(value));
+        CurrentSource2MAX = atof(value);
+    }     
+  if (cfg.getValue(cfg14, &value[0], sizeof(value))) {
+        printf("%s = %c\n\r", cfg14, value[0]);
+        SerialControl = value[0];
+    }     
+    
+    
+      printf("\n\r\n\r>");
+  
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ControlLoop.c	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,49 @@
+
+#include "mbed.h"
+#include <string.h>
+#include "header.h"
+
+
+extern float InputLightLevel;  // in dBm
+extern float OutputLightLevel;  // in dBm
+extern float ReflectedLightLevel;  // in dBm
+extern float PumpLightLevel1;  // in dBm
+extern float PumpLightLevel2; // in dBm
+extern float InputLightLevelM;
+extern float OutputLightLevelM;
+extern float ReflectedLightLevelM;
+extern float PumpLightLevel1M;
+extern float PumpLightLevel2M;
+extern float AmplifierGain; //in dB
+extern float AmplifierPower; //in dBm
+extern char  AmplifierMode; // CC = Constant Current, CG = Constant Gain, CP = constant output power
+extern float PumpCurrent1; // mA
+extern float PumpCurrent2; // mA
+extern int DebugLevel;
+
+void CheckLimits(void)
+{
+    if (InputLightLevel<-30.0) InputLightLevel=-30.0;
+    if (InputLightLevel>30.0) InputLightLevel=30.0;
+    if (OutputLightLevel<-30.0) OutputLightLevel=-30.0;
+    if (OutputLightLevel>30.0) OutputLightLevel=30.0;
+    if (ReflectedLightLevel<-30.0) ReflectedLightLevel=-30.0;
+    if (ReflectedLightLevel>30.0) ReflectedLightLevel=30.0;
+    if (PumpLightLevel1<-30.0) PumpLightLevel1=-30.0;
+    if (PumpLightLevel1>30.0) PumpLightLevel1=30.0;
+    if (PumpLightLevel2<-30.0) PumpLightLevel2=-30.0;
+    if (PumpLightLevel2>30.0) PumpLightLevel2=30.0;
+    if (AmplifierGain<0.0) AmplifierGain=0.0;
+    if (AmplifierGain>30.0) AmplifierGain=30.0;
+    if (AmplifierPower<-30.0) AmplifierPower=-30.0;
+    if (AmplifierPower>30.0) AmplifierPower=30.0;
+    if (PumpCurrent1<0.0) PumpCurrent1=0.0;
+    if (PumpCurrent1>600.0) PumpCurrent1=600.0;
+    if (PumpCurrent2<0.0) PumpCurrent2=0.0;
+    if (PumpCurrent2>600.0) PumpCurrent2=600.0;
+
+}
+void ControlLoop(void)
+{
+    CheckLimits();   
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GlobalVariables.c	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,34 @@
+#include "header.h"
+#include "mbed.h"
+
+
+int DebugLevel;
+
+float Laser1DriveCurrent; //in mA
+float Laser1PumpLightLevel; //in dBm
+float Laser2DriveCurrent; //in mA
+float Laser2PumpLightLevel; //in dBm
+
+
+
+float InputLightLevel; // in dBm
+float OutputLightLevel; // in dBm
+float ReflectedLightLevel; // in dBm
+float PumpLightLevel1; // in dBm
+float PumpLightLevel2; // in dBm
+float InputLightLevelM;  
+float OutputLightLevelM;
+float ReflectedLightLevelM;
+float PumpLightLevel1M;
+float PumpLightLevel2M;
+float AmplifierGain; //in dB
+float AmplifierPower; //in dBm
+char AmplifierMode; // C = Constant Current, G = Constant Gain, P = constant output power
+float PumpCurrent1; // mA
+float PumpCurrent2; // mA
+float CurrentSource1MAX; 
+float CurrentSource2MAX; 
+
+char SerialControl;
+char commandstring[16];
+char commandstringlen;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RPCInterface.lib	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/MichaelW/code/RPCInterface/#a9e2c45097c8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialControl.c	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,87 @@
+#include "mbed.h"
+#include "header.h"
+extern float InputLightLevel;  // in dBm
+extern float OutputLightLevel;  // in dBm
+extern float ReflectedLightLevel;  // in dBm
+extern float PumpLightLevel1;  // in dBm
+extern float PumpLightLevel2; // in dBm
+extern float InputLightLevelM;
+extern float OutputLightLevelM;
+extern float ReflectedLightLevelM;
+extern float PumpLightLevel1M;
+extern float PumpLightLevel2M;
+extern float AmplifierGain; //in dB
+extern float AmplifierPower; //in dBm
+extern char  AmplifierMode; // C = Constant Current, G = Constant Gain, P = constant output power
+extern float PumpCurrent1; // mA
+extern float PumpCurrent2; // mA
+extern char SerialControl;
+
+Serial disp(USBTX, USBRX); // usb for now
+void waitforcommand(void)
+{
+    char c;
+    int i;
+    float f;
+
+       disp.scanf("%c,%d,%f",&c,&i,&f);
+       disp.printf("<%c><%d><%f>\n\r",c,i,f);
+       if ((c == 'r') || (c == 'R'))
+       {
+            switch (i)
+            {
+                case 0:
+                disp.printf("%f",InputLightLevel);  
+                break;
+                case 1:
+                disp.printf("%f",OutputLightLevel);  
+                break;
+                case 2:
+                disp.printf("%f",ReflectedLightLevel);  
+                break;
+                case 3:
+                disp.printf("%f",PumpLightLevel1);  
+                break;
+                case 4:
+                disp.printf("%f",PumpLightLevel2);  
+                break;
+                case 5:
+                disp.printf("%f",AmplifierGain);  
+                break;
+                case 6:
+                disp.printf("%f",AmplifierPower);  
+                break;
+                case 7:
+                disp.printf("%c",AmplifierMode);  
+                break;
+                case 8:
+                disp.printf("%f",PumpCurrent1);  
+                break;
+                case 9:
+                disp.printf("%f",PumpCurrent2);
+                break;
+                       
+           }
+       }
+       if ((c == 'w') || (c == 'W'))
+       {
+         switch (i)
+            {
+                case 5:
+                AmplifierGain=f;  
+                break;
+                case 6:
+                AmplifierPower=f;  
+                break;
+                case 7:
+                //AmplifierMode);  
+                break;
+                case 8:
+                PumpCurrent1=f;  
+                break;
+                case 9:
+                PumpCurrent2=f;
+                break;
+            }
+       }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hardwareinterface.c	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+#include "header.h"
+
+AnalogIn RLL(p15);
+AnalogIn SLL(p16);
+AnalogIn ReflLL(p17);
+AnalogIn Pump1LL(p18);
+AnalogIn Pump2LL(p19);
+AnalogIn SupyLL(p20);
+
+PwmOut PUMP1_DRV(p24);
+PwmOut PUMP2_DRV(p23);
+
+
+extern float InputLightLevel;  // in dBm
+extern float OutputLightLevel;  // in dBm
+extern float ReflectedLightLevel;  // in dBm
+extern float PumpLightLevel1;  // in dBm
+extern float PumpLightLevel2; // in dBm
+extern float InputLightLevelM;
+extern float OutputLightLevelM;
+extern float ReflectedLightLevelM;
+extern float PumpLightLevel1M;
+extern float PumpLightLevel2M;
+extern float AmplifierGain; //in dB
+extern float AmplifierMode; // CC = Constant Current, CG = Constant Gain, CP = constant output power
+extern float PumpCurrent1; // mA
+extern float PumpCurrent2; // mA
+extern float CurrentSource1MAX; 
+extern float CurrentSource2MAX; 
+
+void ReadADCValues(void)
+{
+    InputLightLevel = 10.0*log10(RLL*InputLightLevelM);
+    OutputLightLevel = 10.0*log10(SLL*OutputLightLevelM);
+    ReflectedLightLevelM = 10.0*log10(ReflLL*ReflectedLightLevel);
+    PumpLightLevel1 = 10.0*log10(Pump1LL*PumpLightLevel1M);
+    PumpLightLevel2 = 10.0*log10(Pump2LL*PumpLightLevel2M);
+
+}
+void WritePWMValues(void)
+{
+   PUMP1_DRV = PumpCurrent1/CurrentSource1MAX;
+   PUMP2_DRV = PumpCurrent2/CurrentSource2MAX;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/header.h	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,13 @@
+#include "mbed.h"
+void splashscreen(void);
+void statusscreen(void);
+void commandline(void);
+
+void ReadConfigFile(void);
+
+void ReadADCValues(void);
+void WritePWMValues(void);
+void ControlLoop(void);
+
+void waitforcommand(void);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,97 @@
+//---------------------------------------------------------------------//
+//                             Defines                                 //
+//---------------------------------------------------------------------//
+#include "mbed.h"
+#include "header.h"
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+PwmOut PWMSetup(p24);
+
+//---------------------------------------------------------------------//
+//                             Variables                               //
+//---------------------------------------------------------------------//
+int i=0,ms_counter=0;
+char getkey;
+extern float InputLightLevel;  // in dBm
+extern float OutputLightLevel;  // in dBm
+extern float ReflectedLightLevel;  // in dBm
+extern float PumpLightLevel1;  // in dBm
+extern float PumpLightLevel2; // in dBm
+extern float InputLightLevelM;
+extern float OutputLightLevelM;
+extern float ReflectedLightLevelM;
+extern float PumpLightLevel1M;
+extern float PumpLightLevel2M;
+extern float AmplifierGain; //in dB
+extern float AmplifierPower; //in dBm
+extern char  AmplifierMode; // C = Constant Current, G = Constant Gain, P = constant output power
+extern float PumpCurrent1; // mA
+extern float PumpCurrent2; // mA
+extern char SerialControl;
+extern int DebugLevel;
+extern char commandstring[16];
+extern char commandstringlen;
+
+//---------------------------------------------------------------------//
+//                             Functions                               //
+//---------------------------------------------------------------------//
+
+Serial pc(USBTX, USBRX); // tx, rxSerial pc(USBTX, USBRX); // tx, rx
+Ticker timer;
+
+void SerialBuffer(void)
+{
+     if(pc.readable())
+     {
+        getkey=pc.getc();            
+        commandstring[i] = getkey;
+        i++;        
+     }
+     if ((i>=15)||(getkey==0x0d)||(getkey=='.')||(getkey=='>')||(getkey==',')||(getkey=='<')||(getkey=='p')||(getkey=='P')||(getkey=='[')||(getkey==']')||(getkey=='*')||(getkey=='s')||(getkey=='?'))         
+     {
+        getkey=0;
+        led2=1;
+        commandline();
+        led2=0;
+        i = 0;
+     }
+     
+}
+void Tick() {
+
+    ReadADCValues();
+    ControlLoop();
+    WritePWMValues();
+    //SerialBuffer();
+   
+     ms_counter++;
+     if (ms_counter>=1000) ms_counter=0;
+     if (ms_counter>500) led1 = 1; else led1 = 0; // show we are still alive
+}
+void Initialise(void)
+{
+     ReadConfigFile();
+     timer.attach_us(&Tick, 1000);
+     PWMSetup.period_us(1000);
+}
+//---------------------------------------------------------------------//
+//                             Main                                    //
+//---------------------------------------------------------------------//
+
+
+int main() {
+
+    pc.baud(57600);
+    splashscreen(); 
+    wait_ms(200);
+    Initialise();
+
+
+    while(1)
+    {
+    waitforcommand();
+
+    }
+    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Mar 16 10:20:41 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e