DAC Test prog
Dependencies: mbed
Revision 0:9cf9c2bb9d64, committed 2018-01-26
- Comitter:
- AbermetAlexander
- Date:
- Fri Jan 26 12:57:44 2018 +0000
- Commit message:
- DAC;
Changed in this revision
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 |
diff -r 000000000000 -r 9cf9c2bb9d64 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jan 26 12:57:44 2018 +0000 @@ -0,0 +1,48 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); +AnalogOut aout(PA_4); //A3 Ersatz +AnalogOut aout2(PA_5); //A4 Motor 1 +AnalogOut aout3(PA_6); //A5 Motor 2 + +float aout_var = 0.0f; + +int main() +{ + pc.printf("Press '+' to increase DAC, '-' to decrease DAC\n"); + + while(1) { + + char input = pc.getc(); + + if((input == '+')&&(aout_var < 1.0f)) { + aout_var += 0.1f; //+0,33 Volt + + aout=aout_var; + printf("aout = %1.2f volt\n", aout.read() * 3.3f); + + aout2=aout_var; + printf("aout2 = %1.2f volt\n", aout2.read() * 3.3f); + + aout3=aout_var; + printf("aout3 = %1.2f volt\n", aout3.read() * 3.3f); + + wait (0.5); + } + if((input == '-')&&(aout_var > 0.0f)) { + aout_var -= 0.1f; //+0,33 Volt + + aout=aout_var; + printf("aout = %1.2f volt\n", aout.read() * 3.3f); + + aout2=aout_var; + printf("aout2 = %1.2f volt\n", aout2.read() * 3.3f); + + aout3=aout_var; + printf("aout3 = %1.2f volt\n", aout3.read() * 3.3f); + + wait (0.5); + } + pc.printf("Press '+' to increase DAC, '-' to decrease DAC\n"); + } +} \ No newline at end of file
diff -r 000000000000 -r 9cf9c2bb9d64 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jan 26 12:57:44 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/7130f322cb7e \ No newline at end of file