Testing and calibration
Now that we have our circuit built, it is time to test and calibrate it. In order to do that, I have provided you with simple JavaScript that you can use to read the input from AN0 on the BeagleBone:
var b = require('bonescript'); var inputPin = "P9_39"; loop(); function loop() { var value = b.analogRead(inputPin); var diff = value-0.667; //0dBm input console.log ("Value"); console.log(value); //DAC Reading console.log("Difference"); console.log(diff); //Difference between //current reading and 0dBm console.log ("Power"); console.log((diff/0.007)); // ~ 7% change per dBm setTimeout(loop, 1); }
The preceding script outputs various calculations for calibration and debugging purposes. The first variable value
is the raw input from the DAC. This value is a number between 0 and 1 that represents the percentage of the full-scale reading. So a reading of 0.667 means that the voltage in is 66.7 percent of 1.8 volts, or full scale. This can be confusing...