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.
FuncGenMain3.cpp
00001 00002 #include "mbed.h" 00003 #include "Serial_HL.h" 00004 #include "FuncGenFSST.h" 00005 00006 SerialBLK pc(USBTX, USBRX); 00007 SvProtocol ua0(&pc); 00008 00009 SignedRampGen fg1; 00010 RectGen rg1; 00011 00012 00013 00014 float ampl1 = 1.0; 00015 float ampl2 = 0.5; 00016 float v1 = 0; // signal nach dem Verstellen der Amplidute 00017 float v2 = 0; 00018 00019 00020 void CommandHandler(); 00021 00022 void ExecSignalChain(); // Signalverarbeitungskette 1x durchrechen 00023 00024 int main(void) 00025 { 00026 pc.format(8,SerialBLK::None,1); pc.baud(115200); // 115200 00027 ua0.SvMessage("FuncGen"); // Meldung zum PC senden 00028 00029 Timer stw; stw.start(); 00030 while(1) 00031 { 00032 CommandHandler(); 00033 00034 if( (stw.read_ms()>10) ) // 100Hz 00035 { // dieser Teil wird mit 100Hz aufgerufen 00036 ExecSignalChain(); 00037 stw.reset(); 00038 if( ua0.acqON ) 00039 { 00040 ua0.WriteSV(1, v1); // v1 anzeigen 00041 ua0.WriteSV(2, v2); // v1 anzeigen 00042 } 00043 } 00044 } 00045 return 1; 00046 } 00047 00048 // wird mit 100Hz (Analyse) oder 44kHz (Echtzeit) aufgerufen 00049 void ExecSignalChain() 00050 { 00051 fg1.CalcOneStep(); 00052 v1 = fg1.val*ampl1; 00053 00054 rg1.CalcOneStep(); 00055 v2 = rg1.val*ampl2; 00056 //v1 = rg1.val_orginal*ampl2; 00057 } 00058 00059 void CommandHandler() 00060 { 00061 uint8_t cmd; 00062 if( !pc.IsDataAvail() ) 00063 return; 00064 00065 cmd = ua0.GetCommand(); 00066 00067 if( cmd==2 ) // Set Frequ. 00068 { 00069 fg1.SetFrequ(ua0.ReadF()); 00070 ua0.SvMessage("Set Frequ1"); 00071 } 00072 00073 if( cmd==3 ) // Set ampl 00074 { 00075 ampl1 = ua0.ReadF(); 00076 ua0.SvMessage("Set Ampl1"); 00077 } 00078 00079 if( cmd==4 ) // Set Frequ2 00080 { 00081 rg1.SetFrequ(ua0.ReadF()); 00082 ua0.SvMessage("Set Frequ2"); 00083 } 00084 00085 if( cmd==5 ) // Set ampl2 00086 { 00087 ampl2 = ua0.ReadF(); 00088 ua0.SvMessage("Set Ampl2"); 00089 } 00090 } 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107
Generated on Thu Jul 21 2022 09:23:03 by
1.7.2