This commit is contained in:
parent
e3abcb64f3
commit
c358675783
1 changed files with 78 additions and 15 deletions
|
|
@ -1,17 +1,23 @@
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
//this test works when testing with boards 1 and 2
|
//this code sets values in the MAX5387LAUD+ via I2C.
|
||||||
//set the threshold as a 1 time value, max is 3.3V (voltage reference removed from protos)
|
//it then reads back those values over A1 and A2 inputs
|
||||||
//crashes due to 50Hz noise
|
//The ADC is set to 12 bits for the DUE
|
||||||
//input thresholds not checked 100%
|
//Channels are scanned in parallel (0 to 255)
|
||||||
//minimum input signal duration 40ns for coincidence.
|
//then alternatively ascending and descending.
|
||||||
//at 40ns incident coincidence the output lasts for 150ns - plenty for the DUE to capture.
|
//Output is a CSV over serial at 9600bps.
|
||||||
//Hardware is more reliable than DUE's noise immunity.
|
|
||||||
|
//this test works when testing with board 2
|
||||||
//Note the MAX5387LAUD+ doesn't support I2C readback.
|
//Note the MAX5387LAUD+ doesn't support I2C readback.
|
||||||
|
|
||||||
//detailed threshold calibration could be done, but our signal generator doesn't plug in very well.
|
|
||||||
//using DAC would be a nice option for checking the thresholds.
|
|
||||||
byte ADCval;
|
byte ADCval;
|
||||||
|
byte ADCval1;
|
||||||
|
byte ADCval2;
|
||||||
|
byte ADCval3;
|
||||||
|
byte ADCval4;
|
||||||
|
byte ADCval5;
|
||||||
|
byte ADCval6;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
|
|
@ -28,25 +34,82 @@ void setup() {
|
||||||
//setup the serial for debug
|
//setup the serial for debug
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
//setup the MAX5387 pot
|
//setup the MAX5387 pot
|
||||||
ADCval = byte(0x00);
|
ADCval1 = byte(0x00);
|
||||||
|
ADCval2 = byte(0x00);
|
||||||
|
ADCval3 = byte(0xFF);
|
||||||
|
ADCval4 = byte(0x00);
|
||||||
|
ADCval5 = byte(0x00);
|
||||||
|
ADCval6 = byte(0xFF);
|
||||||
|
analogReadResolution(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
|
for (int i=0; i<=0xFF; i++){
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
//Serial.print("MAX5387 Address ");
|
//Serial.print("MAX5387 Address ");
|
||||||
//Serial.print(0x28, HEX);
|
//Serial.print(0x28, HEX);
|
||||||
Wire.beginTransmission(byte(0x28)); // transmit to device #112
|
Wire.beginTransmission(byte(0x28)); // transmit to device #112
|
||||||
Wire.write(byte(B00010011));
|
Wire.write(byte(B00010011));
|
||||||
Wire.write(ADCval);// sets register pointer to echo #1 register (0x02)
|
Wire.write(ADCval1);// sets register pointer to echo #1 register (0x02)
|
||||||
Wire.endTransmission(); // stop transmitting
|
Wire.endTransmission(); // stop transmitting
|
||||||
Serial.print("Setpoint:"); //note that this is manually updated by the human!
|
Serial.print("Both Channels ++ Setpoint 1:"); //note that this is manually updated by the human!
|
||||||
Serial.print(ADCval); //note that this is manually updated by the human!
|
Serial.print(ADCval1); //note that this is manually updated by the human!
|
||||||
|
Serial.print("; Setpoint 2:"); //note that this is manually updated by the human!
|
||||||
|
Serial.print(ADCval1); //note that this is manually updated by the human!
|
||||||
Serial.print("; A1:"); //note that this is manually updated by the human!
|
Serial.print("; A1:"); //note that this is manually updated by the human!
|
||||||
Serial.print(analogRead(A1));
|
Serial.print(analogRead(A1));
|
||||||
Serial.print("; A2:"); //note that this is manually updated by the human!
|
Serial.print("; A2:"); //note that this is manually updated by the human!
|
||||||
Serial.print(analogRead(A2));
|
Serial.print(analogRead(A2));
|
||||||
Serial.println(";"); //note that this is manually updated by the human!
|
Serial.println(";"); //note that this is manually updated by the human!
|
||||||
delay(1000);
|
ADCval1++;
|
||||||
ADCval++;
|
delay(10);
|
||||||
|
}
|
||||||
|
for (int i=0; i<=0xFF; i++){
|
||||||
|
|
||||||
|
Wire.beginTransmission(byte(0x28)); // transmit to device #112
|
||||||
|
Wire.write(byte(B00010001));
|
||||||
|
Wire.write(ADCval3);// sets register pointer to echo #1 register (0x02)
|
||||||
|
Wire.endTransmission(); // stop transmitting
|
||||||
|
Wire.beginTransmission(byte(0x28)); // transmit to device #112
|
||||||
|
Wire.write(byte(B00010010));
|
||||||
|
Wire.write(ADCval4);// sets register pointer to echo #1 register (0x02)
|
||||||
|
Wire.endTransmission(); // stop transmitting
|
||||||
|
Serial.print("Ch1-- Ch2++ Setpoint 1:"); //note that this is manually updated by the human!
|
||||||
|
Serial.print(ADCval3); //note that this is manually updated by the human!
|
||||||
|
Serial.print("; Setpoint 2:"); //note that this is manually updated by the human!
|
||||||
|
Serial.print(ADCval4); //note that this is manually updated by the human!
|
||||||
|
Serial.print("; A1:"); //note that this is manually updated by the human!
|
||||||
|
Serial.print(analogRead(A1));
|
||||||
|
Serial.print("; A2:"); //note that this is manually updated by the human!
|
||||||
|
Serial.print(analogRead(A2));
|
||||||
|
Serial.println(";"); //note that this is manually updated by the human!
|
||||||
|
ADCval3--;
|
||||||
|
ADCval4++;
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
for (int i=0; i<=0xFF; i++){
|
||||||
|
|
||||||
|
Wire.beginTransmission(byte(0x28)); // transmit to device #112
|
||||||
|
Wire.write(byte(B00010001));
|
||||||
|
Wire.write(ADCval5);// sets register pointer to echo #1 register (0x02)
|
||||||
|
Wire.endTransmission(); // stop transmitting
|
||||||
|
Wire.beginTransmission(byte(0x28)); // transmit to device #112
|
||||||
|
Wire.write(byte(B00010010));
|
||||||
|
Wire.write(ADCval6);// sets register pointer to echo #1 register (0x02)
|
||||||
|
Wire.endTransmission(); // stop transmitting
|
||||||
|
Serial.print("Ch1++ Ch2-- Setpoint 1:"); //note that this is manually updated by the human!
|
||||||
|
Serial.print(ADCval5); //note that this is manually updated by the human!
|
||||||
|
Serial.print("; Setpoint 2:"); //note that this is manually updated by the human!
|
||||||
|
Serial.print(ADCval6); //note that this is manually updated by the human!
|
||||||
|
Serial.print("; A1:"); //note that this is manually updated by the human!
|
||||||
|
Serial.print(analogRead(A1));
|
||||||
|
Serial.print("; A2:"); //note that this is manually updated by the human!
|
||||||
|
Serial.print(analogRead(A2));
|
||||||
|
Serial.println(";"); //note that this is manually updated by the human!
|
||||||
|
ADCval5++;
|
||||||
|
ADCval6--;
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue