Advertisement
Atdiy

Untitled

Aug 24th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. /*
  2. Set and Measure Volts.c
  3.  
  4. Set D/A0 to 2.5 V and D/A1 to 1 V, and measure with A/D0 and A/D1.
  5. */
  6.  
  7. #include "simpletools.h" // Include simpletools
  8. #include "adcDCpropab.h" // Include adcDCpropab
  9.  
  10. int main() // main function
  11. {
  12. adc_init(21, 20, 19, 18); // CS=21, SCL=20, DO=19, DI=18
  13.  
  14. dac_ctr(26, 0, 194); // D/A ch 0 -> 2.5 V to D/A 0
  15. dac_ctr(27, 1, 78); // D/A ch 1 -> 1 V to D/A 1
  16.  
  17. printf("A/D0 = %f\n", adc_volts(0)); // Display A/D0 volts
  18. printf("A/D1 = %f\n", adc_volts(1)); // Display A/D1 volts
  19. pause(2000);
  20.  
  21. dac_ctr(26, 0, 78);
  22. dac_ctr(27, 0, 194);
  23.  
  24. printf("A/D0 = %f\n", adc_volts(0));
  25. printf("A/D1 = %f\n", adc_volts(1));
  26.  
  27. pause(2000);
  28. while(1)
  29. {
  30. for(int v = 0; v < 256; v++)S
  31. {
  32. dac_ctr(26, 0, v);
  33. dac_ctr(27, 1, 255-v);
  34. pause(4);
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement