void getOptBuffering(int *k , double *h , double Length) { if (PARM(buffering_scheme) == MIN_DELAY) { if (PARM(shielding)) { double r = computeResistance(Length); double c_g = 2*computeGroundCapacitance(Length); double c_c = 2*computeCouplingCapacitance(Length); *k = (int) sqrt(((0.4*r*c_g)+(0.57*r*c_c))/ (0.7*BufferDriveResistance*BufferInputCapacitance)); //k is the number of buffers to be inserted *h = sqrt(((0.7*BufferDriveResistance*c_g)+ (1.4*1.5*BufferDriveResistance*c_c))/(0.7*r*BufferInputCapacitance)); //the size of the buffers to be inserted } else { double r = computeResistance(Length); double c_g = 2*computeGroundCapacitance(Length); double c_c = 2*computeCouplingCapacitance(Length); *k = (int) sqrt(((0.4*r*c_g)+(1.51*r*c_c))/ (0.7*BufferDriveResistance*BufferInputCapacitance)); *h = sqrt(((0.7*BufferDriveResistance*c_g)+ (1.4*2.2*BufferDriveResistance*c_c))/(0.7*r*BufferInputCapacitance)); } } else if (PARM(buffering_scheme)== STAGGERED) { double r = computeResistance(Length); double c_g = 2*computeGroundCapacitance(Length); double c_c = 2*computeCouplingCapacitance(Length); *k = (int) sqrt(((0.4*r*c_g)+(0.57*r*c_c))/ (0.7*BufferDriveResistance*BufferInputCapacitance)); *h = sqrt(((0.7*BufferDriveResistance*c_g)+ (1.4*1.5*BufferDriveResistance*c_c))/(0.7*r*BufferInputCapacitance)); } else { fprintf(stderr, "ERROR, Specified buffering scheme is not supported.\n"); exit(1); } }
int main(void) { bool bcm2835init = 0; bool SPIinit = 0; bcm2835_init(); AD5235_init(); int valueADCint = 0; int valueDACint = 0; double valueADC = 0; double valueDAC = 0; std::string input_K; std::string input_T; double K = 0.3; double T = 2E-5; //while (1) //{ //std::cout << "K = "; //std::cin >> K; //computeResistance(1E-4, K); //setRC(); //} std::cout << "parameters for RC circuit:\n"; std::cout << "enter time constant (default: 2E-5): "; std::getline(std::cin, input_T); if (!input_T.empty()) { T = std::stod(input_T, NULL); std::cout << "T = " << T << "\n"; } std::cout << "enter gain (default: 0.3): "; std::getline(std::cin, input_K); if (!input_K.empty()) { K = std::stod(input_K, NULL); } std::cout << "\n"; computeResistance(T, K); setRC(); //setR12(1023, 1023); AD7840_init(); AD7484_init(); writeToDAC(0); std::cout << "press enter to start simulation of PMDCM..."; std::cin.ignore(); //while (1) //{ //writeToDAC(readADC()); //} PMDCmotorIO(); //while (1) //{ //std::cout << "set Vout: "; //std::cin >> Vout; //writeToDAC(Vout); //} std::cout << "done" << std::endl; std::cin.ignore(); return 0; }