dfawer

Dependencies:   FuncGen Serial_HL mbed

Fork of ProcVisDemo by michael hollegha

Committer:
ogris
Date:
Tue Apr 25 06:53:30 2017 +0000
Revision:
2:7884bf7a7dae
Parent:
1:e88b745f2ca2
asw

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hollegha2 0:9ac39e20730c 1 #include "mbed.h"
hollegha2 0:9ac39e20730c 2 #include "Serial_HL.h"
ogris 2:7884bf7a7dae 3 #include "FuncGenFSST3.h"
ogris 2:7884bf7a7dae 4
hollegha2 0:9ac39e20730c 5 SerialBLK pc(USBTX, USBRX);
hollegha2 0:9ac39e20730c 6 SvProtocol ua0(&pc);
hollegha2 0:9ac39e20730c 7
ogris 2:7884bf7a7dae 8 void CommandHandler();
hollegha2 1:e88b745f2ca2 9
ogris 2:7884bf7a7dae 10 SingnedRampGen fg1;
ogris 2:7884bf7a7dae 11 float ampl=1.0, v1=0.0;
hollegha2 0:9ac39e20730c 12
ogris 2:7884bf7a7dae 13 void ExecSignalChain();
hollegha2 0:9ac39e20730c 14
hollegha2 0:9ac39e20730c 15 int main(void)
hollegha2 0:9ac39e20730c 16 {
ogris 2:7884bf7a7dae 17 pc.format(8,SerialBLK::None,1); pc.baud(500000); // 115200
ogris 2:7884bf7a7dae 18
ogris 2:7884bf7a7dae 19
ogris 2:7884bf7a7dae 20 ua0.SvMessage("FuncGenMain2"); // Meldung zum PC senden
ogris 2:7884bf7a7dae 21
ogris 2:7884bf7a7dae 22 Timer stw; stw.start();
ogris 2:7884bf7a7dae 23 while(1) // while(1)-Loop der mit dem PC kommuniziert
ogris 2:7884bf7a7dae 24 {
ogris 2:7884bf7a7dae 25 CommandHandler();
ogris 2:7884bf7a7dae 26 if( (stw.read_ms()>10) ) // 100Hz
ogris 2:7884bf7a7dae 27 { // dieser Teil wird mit 100Hz aufgerufen
ogris 2:7884bf7a7dae 28 ExecSignalChain();
ogris 2:7884bf7a7dae 29 stw.reset();
ogris 2:7884bf7a7dae 30 if( ua0.acqON ) {
ogris 2:7884bf7a7dae 31 ua0.WriteSV(1, v1);
ogris 2:7884bf7a7dae 32 }
ogris 2:7884bf7a7dae 33 }
ogris 2:7884bf7a7dae 34 }
ogris 2:7884bf7a7dae 35 return 1;
ogris 2:7884bf7a7dae 36 }
hollegha2 0:9ac39e20730c 37
ogris 2:7884bf7a7dae 38 void ExecSignalChain()
ogris 2:7884bf7a7dae 39 {
ogris 2:7884bf7a7dae 40 fg1.CalcOneStep();
ogris 2:7884bf7a7dae 41 v1 = fg1.val*ampl;
hollegha2 0:9ac39e20730c 42 }
hollegha2 0:9ac39e20730c 43
hollegha2 0:9ac39e20730c 44 void CommandHandler()
hollegha2 0:9ac39e20730c 45 {
ogris 2:7884bf7a7dae 46 uint8_t cmd;
ogris 2:7884bf7a7dae 47 if( !pc.IsDataAvail() )
ogris 2:7884bf7a7dae 48 return;
ogris 2:7884bf7a7dae 49 cmd = ua0.GetCommand();
hollegha2 0:9ac39e20730c 50
ogris 2:7884bf7a7dae 51 if( cmd==2 ) { // set Frequ
ogris 2:7884bf7a7dae 52 fg1.SetFrequ(ua0.ReadF());
ogris 2:7884bf7a7dae 53 ua0.SvMessage("SetFrequ");
ogris 2:7884bf7a7dae 54 }
hollegha2 0:9ac39e20730c 55
ogris 2:7884bf7a7dae 56 if( cmd==3 ) { // set Ampl
ogris 2:7884bf7a7dae 57 ampl = ua0.ReadF();
ogris 2:7884bf7a7dae 58 ua0.SvMessage("Set Ampl");
ogris 2:7884bf7a7dae 59 }
hollegha2 0:9ac39e20730c 60 }
hollegha2 0:9ac39e20730c 61
hollegha2 0:9ac39e20730c 62