Advertisement
Guest User

Railroad Track

a guest
Aug 24th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 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()
  11. { // main function
  12. while(1)
  13. {
  14. adc_init(21, 20, 19, 18); // CS=21, SCL=20, DO=19, DI=18
  15.  
  16. dac_ctr(26, 0, 194); // D/A ch 0 -> 2.5 V to D/A 0
  17. dac_ctr(27, 1, 100); // D/A ch 1 -> 1 V to D/A 1
  18.  
  19. printf("A/D0 = %f\n", adc_volts(0)); // Display A/D0 volts
  20. printf("A/D1 = %f\n", adc_volts(1)); // Display A/D1 volts
  21. pause(2000);
  22.  
  23. dac_ctr(26, 0, 100);
  24. dac_ctr(27, 0, 194);
  25.  
  26. printf("A/D0 = %f\n", adc_volts(0));
  27. printf("A/D1 = %f\n", adc_volts(1));
  28.  
  29. pause(2000);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement