The experiment using this program is introduced on "Interface" No.11, CQ publishing Co.,Ltd, 2014. 本プログラムを使った実験は,CQ出版社のインターフェース 2014年11月号で紹介しています.
Dependencies: DSProcessingIO mbed
Fork of DAC_Test by
Revision 1:339c82434d38, committed 2014-07-15
- Comitter:
- CQpub0Mikami
- Date:
- Tue Jul 15 05:28:03 2014 +0000
- Parent:
- 0:f7880759a9d8
- Child:
- 2:4bd5fbc225c3
- Commit message:
- Test program of DSProcessing library
; Adc, Dac, and DacDual classes
Changed in this revision
--- a/DAC_Test.cpp Sun Jul 13 13:28:28 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -//-------------------------------------------------------------- -// Test of DacDual class -// -// Copyright (c) 2014 MIKAMI, Naoki, 2014/06/17 -//-------------------------------------------------------------- - -#include "mbed.h" -#include "MCP4922Single.hpp" -#include "MCP4922Dual.hpp" - -using namespace Mikami; - -// sampling frequency -const float FS_ = 40.0e3f; - -DacDual dacAB_; -Ticker timer_; // for timer interrupt - -float phi_; - -// Called every 0.025 ms -void TimerIsr() -{ - const float PI = 3.14159265f; - const float PI2 = 2*PI; - const float DPHI = PI2/10; - - float value = 0.8f*sinf(phi_); - - dacAB_.Write(value, value); - - phi_ += DPHI; - if (phi_ >= PI) phi_ -= PI2; -} - -int main() -{ - timer_.attach_us(&TimerIsr, 1.0e6f/FS_); - - phi_ = 0; - while (true) {} // infinite loop -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DSProcessingIO.lib Tue Jul 15 05:28:03 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/CQpub0Mikami/code/DSProcessingIO/#c3f647a89947
--- a/SignalProcessingIO.lib Sun Jul 13 13:28:28 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/CQpub0Mikami/code/SignalProcessingIO/#a2cdffe24b67
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main_ADDA.cpp Tue Jul 15 05:28:03 2014 +0000 @@ -0,0 +1,33 @@ +//-------------------------------------------------------------- +// Test program of DacDual class +// +// Copyright (c) 2014 MIKAMI, Naoki, 2014/07/14 +//-------------------------------------------------------------- + +#include "mbed.h" +#include "AdcInternal.hpp" +#include "MCP4922Dual.hpp" + +using namespace Mikami; + +const float FS_ = 10.0e3f; // sampling frequency: 10 kHz + +Adc adc_; // default, input: A0 +DacDual dacAB_; // object of DacDual class +Ticker timer_; // for timer interrupt + +// Called every 0.1 ms +void TimerIsr() +{ + float value = adc_.Read(); // AD + + // pin14 : Inphase + // pin10 : Out-of-phase + dacAB_.Write(value, -value); +} + +int main() +{ + timer_.attach_us(&TimerIsr, 1.0e6f/FS_); + while (true) {} // infinite loop +}