This commit is contained in:
commit
e3abcb64f3
1 changed files with 52 additions and 0 deletions
52
CPiThreshold.ino
Normal file
52
CPiThreshold.ino
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#include <Wire.h>
|
||||
|
||||
//this test works when testing with boards 1 and 2
|
||||
//set the threshold as a 1 time value, max is 3.3V (voltage reference removed from protos)
|
||||
//crashes due to 50Hz noise
|
||||
//input thresholds not checked 100%
|
||||
//minimum input signal duration 40ns for coincidence.
|
||||
//at 40ns incident coincidence the output lasts for 150ns - plenty for the DUE to capture.
|
||||
//Hardware is more reliable than DUE's noise immunity.
|
||||
//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;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
pinMode(35, OUTPUT); //setup for the MAX5387 - later set to 0. signal PA0
|
||||
pinMode(36, OUTPUT);//setup for the MAX5387 - later set to 0. signal PA1
|
||||
pinMode(37, OUTPUT);//setup for the MAX5387 - later set to 0. signal PA2
|
||||
pinMode(A1, INPUT); //make sure the input pins are in high impedance mode
|
||||
pinMode(A2, INPUT);//make sure the input pins are in high impedance mode
|
||||
digitalWrite(35, LOW);//configure the address of the MAX5387 pot
|
||||
digitalWrite(36, LOW);//configure the address of the MAX5387 pot
|
||||
digitalWrite(37, LOW);//configure the address of the MAX5387 pot
|
||||
pinMode(5, INPUT); //set the interrupt pin for trigger as high impedance, probably not required
|
||||
|
||||
//setup the serial for debug
|
||||
Serial.begin(9600);
|
||||
//setup the MAX5387 pot
|
||||
ADCval = byte(0x00);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
Wire.begin();
|
||||
//Serial.print("MAX5387 Address ");
|
||||
//Serial.print(0x28, HEX);
|
||||
Wire.beginTransmission(byte(0x28)); // transmit to device #112
|
||||
Wire.write(byte(B00010011));
|
||||
Wire.write(ADCval);// sets register pointer to echo #1 register (0x02)
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
Serial.print("Setpoint:"); //note that this is manually updated by the human!
|
||||
Serial.print(ADCval); //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!
|
||||
delay(1000);
|
||||
ADCval++;
|
||||
}
|
||||
Loading…
Reference in a new issue