From 6a9c5c6eb1b86cc883c454bea7ba47f80294f01c Mon Sep 17 00:00:00 2001 From: James Devine Date: Tue, 6 Aug 2019 02:18:39 +0200 Subject: [PATCH] Delete detector_setting.ino --- detector_setting.ino | 211 ------------------------------------------- 1 file changed, 211 deletions(-) delete mode 100644 detector_setting.ino diff --git a/detector_setting.ino b/detector_setting.ino deleted file mode 100644 index 39561e8..0000000 --- a/detector_setting.ino +++ /dev/null @@ -1,211 +0,0 @@ -#include - -// configure these to configure the detector -static const int HV_DEFAULT = 0xAC; -static const int DEFAULT_DAC_THRESH = 559; //modification for V1.5 production batch, this is a generic setting to be tuned by users - -// other constants -static const int HV_MAX = 89; -static const int HV_MIN = 255; -static const int DEFAULT_THRESH = 559; -static const bool USE_DAC = true; - -//set up the pins to remap SPI by hand -//static const int num_devices = 2; -//static const int SS_pin[num_devices] = {14, 15}; -//static const int SCK_pin = 17; -//static const int MISO_pin = 22; -//static const int MOSI_pin = 16; - -// I2C adress pins -//#define MAX5387_PA0_pin A9 -//#define MAX5387_PA1_pin A10 -//#define MAX5387_PA2_pin A11 - -byte thresh1; -byte thresh2; -int bigpart; -int smallpart; - -// initilizes the detector with default values -void setupDetector(){ - // setup pins - detecSetPinModes(); - detcSetConstantPins(); - // set defaults - if (USE_DAC){ - // analogWrite(DAC0, DEFAULT_DAC_THRESH); - // analogWrite(DAC1, DEFAULT_DAC_THRESH); - }else{ - setThreshold(3, DEFAULT_THRESH); - } - setHV(HV_DEFAULT); - sprintf(txt,"Detector threshold: %d\n", DEFAULT_DAC_THRESH); - aSer->print(txt); - sprintf(txt,"Detector setup finished\n"); - aSer->print(txt); -} - - -// sets pin modes needed for the detector -void detecSetPinModes(){ - //setup analog writemode -// analogWriteResolution(12); - // I2C adress pins for the MAX5387 -// pinMode(MAX5387_PA0_pin, OUTPUT); -// pinMode(MAX5387_PA1_pin, OUTPUT); -// pinMode(MAX5387_PA2_pin, OUTPUT); - // HV pins -// digitalWrite(SS, HIGH); // Start with SS high -// for (int i=0; i>8); - - - switch(pot_channel){ - case 1: -sprintf(txt,"Setting threshold on channel 1 to: %d\n", value); - aSer->print(txt); - - Wire.beginTransmission(address); - Wire.write(B00001000); // sends five bytes - Wire.write(bigpart); // sends one byte - Wire.write(smallpart); - Wire.endTransmission(); - break; - case 2: -sprintf(txt,"Setting threshold on channel 2 to: %d\n", value); - aSer->print(txt); - - Wire.beginTransmission(address); - Wire.write(B00000000); // sends five bytes - Wire.write(bigpart); // sends one byte - Wire.write(smallpart); - Wire.endTransmission(); - break; - case 3: - sprintf(txt,"Setting threshold on both channels to: %d\n", value); - aSer->print(txt); - - Wire.beginTransmission(address); - Wire.write(B00001000); // sends five bytes - Wire.write(bigpart); // sends one byte - Wire.write(smallpart); - Wire.endTransmission(); - - Wire.beginTransmission(address); - Wire.write(B00000000); // sends five bytes - Wire.write(bigpart); // sends one byte - Wire.write(smallpart); - Wire.endTransmission(); - break; - } - /* - // do a value check - if (value > 255 || value < 1){ - return; - } else { - value = byte(value); - } - - Wire.begin(); - Wire.beginTransmission(byte(0x28)); // transmit to device #112 - switch(pot_channel){ - case 1: - sprintf(txt,"Setting threshold on channel 1 to: %d\n", value); - aSer->print(txt); - Wire.write(byte(B00010001)); //sets value to the first channel - Wire.write(value); - thresh1 = value; - break; - case 2: - sprintf(txt,"Setting threshold on channel 2 to: %d\n", value); - aSer->print(txt); - Wire.write(byte(B00010010)); //sets value to the second channel - Wire.write(value); - thresh2 = value; - break; - case 3: - sprintf(txt,"Setting threshold on channel 1&2 to: %d\n", value); - aSer->print(txt); - Wire.write(byte(B00010011)); //sets value to both channels - Wire.write(value); - thresh1 = value; - thresh2 = value; - break; - } - - - - Wire.endTransmission(); -*/ -} - - -// set the two HV supplies -byte setHV(byte _send) // This function is what bitbangs the data -{ - if (_send > 0x5A){ //hardlimit values - - sprintf(txt,"INFO: Setting HV 1&2 to: %d\n", _send); - aSer->print(txt); - //reception isn't implemented in this version. - //byte _receive = 0; - - digitalWrite(PC7, LOW); - - for(int i=0; i<8; i++) // There are 8 bits in a byte - { - digitalWrite(PC3, bitRead(_send, 7-i)); // Set MOSI - //delay(1); - digitalWrite(PB13, HIGH); // SCK high - //bitWrite(_receive, i, digitalRead(MISO_pin)); // Capture MISO - digitalWrite(PB13, LOW); // SCK low - //digitalWrite(MOSI_pin, LOW); // Set MOSI - - } - - digitalWrite(PC7, HIGH); - - - digitalWrite(PC8, LOW); - - for(int i=0; i<8; i++) // There are 8 bits in a byte - { - digitalWrite(PC3, bitRead(_send, 7-i)); // Set MOSI - //delay(1); - digitalWrite(PB13, HIGH); // SCK high - //bitWrite(_receive, i, digitalRead(MISO_pin)); // Capture MISO - digitalWrite(PB13, LOW); // SCK low - //digitalWrite(MOSI_pin, LOW); // Set MOSI - - } - - digitalWrite(PC8, HIGH); - //return _receive; // Return the received data - } -}