XPS/Auger / Mbed 2 deprecated AD5761_working_voltage_code

Dependencies:   mbed RPCInterface

Files at this revision

API Documentation at this revision

Comitter:
csoulen
Date:
Fri Aug 02 18:27:16 2019 +0000
Parent:
0:9c752239b87d
Commit message:
2.0;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Aug 02 18:23:22 2019 +0000
+++ b/main.cpp	Fri Aug 02 18:27:16 2019 +0000
@@ -7,11 +7,13 @@
 SPI spi(p11, p12, p13); // mosi, miso, sclk
 DigitalOut cs(p14); // Chip select, active low
 
+//Set up variables
 float voltage = 5;
 int voltage_byte[2],new_voltage;
 int max_voltage = 20;
 int data_iterations = 10;
 
+// Define the RPCs
 RPCVariable<float> rpcvoltage(&voltage, "voltage");
 
 // Define a function to address via Serial
@@ -24,49 +26,24 @@
 RPCFunction rpcvoltage_test(&voltage_test, "voltage_test");
 
 void New_Voltage(Arguments *in, Reply *out) {
-    
-    // Start with a software full reset
-   /* cs = 0;
-    spi.write(0x0F);
-    spi.write(0);
-    spi.write(0);
-    cs = 1;
-    wait(0.5);
-    */
+    // Function used to check if the DAC is working. prints out the voltage defined by the vaiable "voltage"
     //prep voltage values
     new_voltage = 65535*(voltage+10)/max_voltage;
     voltage_byte[0] = (new_voltage & 0xFF00) >> 8;
     voltage_byte[1] = (new_voltage & 0x00FF);
     
+    //Print voltage values to the DAC
     cs = 0;
     spi.write(DAC_WRITE_UPDATE_REG);
     spi.write(voltage_byte[0]);
     spi.write(voltage_byte[1]);
     cs = 1;
+    
     pc.printf("Begin AD5761_OS %i",new_voltage);
         
 
 }
 
-void voltage_test(Arguments *in, Reply *out) {
-    
-    int voltage_vector[data_iterations];
-    float voltage_step = 1;
-    float x_scan_DAC_range = 20;
-    float scan_low_v = 0;
-    for(int data_point_count =0; data_point_count<=data_iterations; data_point_count++)
-    {
-            voltage_vector[data_point_count] = 65535*(scan_low_v+(data_point_count)*voltage_step)/x_scan_DAC_range;
-            voltage_vector[2*data_iterations - data_point_count] = voltage_vector[data_point_count];
-    }
-    for(int data_point_count =0; data_point_count<=2*data_iterations; data_point_count++)
-    {
-        pc.printf("   %i \n\r",voltage_vector[data_point_count]);
-       
-    }
-        
-
-}
 
 int main() {