Hardware components | ||||||
![]() |
| × | 8 | |||
| × | 2 | ||||
| × | 8 | ||||
| × | 5 | ||||
| × | 4 | ||||
| × | 4 | ||||
| × | 2 | ||||
| × | 4 | ||||
| × | 1 | ||||
![]() |
| × | 1 | |||
![]() |
| × | 2 | |||
Software apps and online services | ||||||
![]() |
| |||||
![]() |
| |||||
![]() |
|
https://mpq.u-paris.fr/?Projet-MONTANA-du-Pole-Technique
The only goal of my participation is to improve the hardware by replacing the microcontrollers and the computer with a XILINX FPGA platform.
Silk BOTTOM of the multiplexing and trigger generation automaton
It's the Silk BOTTOM of the control electronics of the opto-mechanical drivers, alignment cameras, power meter, generation of 8 TTL pulses and 16 USB 2.0 High Speed ports to 2 PC USB inputs.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
routing inner 1 of the multiplexing and trigger generation automaton
It's the routing inner 1 copper of the control electronics of the opto-mechanical drivers, alignment cameras, power meter, generation of 8 TTL pulses and 16 USB 2.0 High Speed ports to 2 PC USB inputs.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
routing inner 2 of the multiplexing and trigger generation automaton
It's the routing inner 1 copper of the control electronics of the opto-mechanical drivers, alignment cameras, power meter, generation of 8 TTL pulses and 16 USB 2.0 High Speed ports to 2 PC USB inputs.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
routing copper bottom of the multiplexing and trigger generation automaton
It's the copper bottom of the control electronics of the opto-mechanical drivers, alignment cameras, power meter, generation of 8 TTL pulses and 16 USB 2.0 High Speed ports to 2 PC USB inputs.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
Silk TOP of the multiplexing and trigger generation automaton
It's the Silk TOP of the control electronics of the opto-mechanical drivers, alignment cameras, power meter, generation of 8 TTL pulses and 16 USB 2.0 High Speed ports to 2 PC USB inputs.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
schematic of the multiplexing and trigger generation automaton
It's the diagram of the control electronics of the opto-mechanical drivers, alignment cameras, power meter, generation of 8 TTL pulses and 16 USB 2.0 High Speed ports to 2 PC USB inputs.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.
The MEGA 2560 card receives the parameters from the computer via LabVIEW and controls the analog multiplexers and communicates the parameters of the 8 TTL signals to the two PIC18F microcontrollers which take care of the generation, delay synchronization and pulse width.

code for MEGA250
C/C++This piece of code makes it possible to receive orders from a master unit in order to control all the opto-mechanical and optical peripherals and which takes care of the generation of the trigger outputs.
/************************************************************************************************************\
* PROGRAMME MEGA2560 *
* *
* PROJET MONTANA *
* *
* Batiste JANVIER *
*************************************************************************************************************/
#include <SPI.h> // needed for Arduino versions later than 018
#define TEMPK A0
// constants won't change. Used here to set a pin number :
const int ledPin = 13; // the number of the LED pin
// Variables will change :
int ledState = LOW; // ledState used to set the LED
unsigned int conv_tk; //Valeur de temperature retournee par la mesure du thermocouple type K
unsigned int TEMP = 0;
unsigned int etat = 0;
unsigned int FREQ1 = 0x0000, D1 = 0x0000, D2 = 0x0000, D3 = 0x0000, D4 = 0x0000, D5 = 0x0000, D6 = 0x0000, D7 = 0x0000, D8 = 0x0000, W1 = 0x0000, W2 = 0x0000, W3 = 0x0000, W4 = 0x0000, W5 = 0x0000, W6 = 0x0000, W7 = 0x0000, W8 = 0x0000;
float temperature; //Valeur de temperature retournee par la mesure du thermocouple type K
float debain = 0.0, debain_1 = 0.0, debain_2 = 0.0, debain_3 = 0.0, debain_4 = 0.0, debain1 = 0.0, debain2 = 0.0, debain3 = 0.0, debain4 = 0.0, debain5 = 0.0, debain6 = 0.0, ABSvalue = 0.0;
unsigned long i, j, indexCR;
String inputString = "", comstring = ""; // a string to hold incoming data
static char tab_val[51];
char cpt_tab = 0;
char outputString[50] = "";
char result[64];
char LSB = 0, MSB = 0;
unsigned char data_array[51], data_array1[51];
unsigned char string[64]; //tableau de 15 caractéres
unsigned char FPX[4], consfreq_array[4], WID1[4], WID2[4], WID3[4], WID4[4], WID5[4], WID6[4], WID7[4], WID8[4], DEL1[4], DEL2[4], DEL3[4], DEL4[4], DEL5[4], DEL6[4], DEL7[4], DEL8[4];
unsigned char var = 0;
boolean CaractNull = false;
boolean stringComplete = false; // whether the string is complete
int LED = 13;
int TRIG = 46; //active communication avec les esclaves
int EN12V1 = 44; //fournit l'alimentation de 4 caméras si besoin
int EN12V2 = 45; //fournit l'alimentation de 3 autres caméras si besoin
int SS1 = 49; // Slave Select slave1
int SS2 = 48; // Slave Select slave2
int CLK = 52; // the number of the CLK1 pin
int MISO_1 = 50;
void setup()
{
Serial.begin(9600);
inputString.reserve(200);
comstring.reserve(200);
pinMode(TRIG, OUTPUT);
pinMode(SS1, OUTPUT);
pinMode(SS2, OUTPUT);
pinMode(CLK, OUTPUT);
pinMode(MISO_1, INPUT);
digitalWrite(SS1, HIGH);
digitalWrite(SS2, HIGH);
digitalWrite(TRIG,LOW);
// set A0 as input for Temperature measurement Tk
pinMode(TEMPK,INPUT);
// trigger caméras EN12V1 (44) pour l'alim de 4 caméras, EN12V2 (45) pour l'alims des 3 autres caméras
pinMode(EN12V1, OUTPUT);
pinMode(EN12V2, OUTPUT);
pinMode(26, OUTPUT); //A0_1 multiplexeur A0
pinMode(27, OUTPUT); //A1_1 multiplexeur A1
pinMode(28, OUTPUT); //A2_1 multiplexeur A2
pinMode(29, OUTPUT); //EN1_1 multiplexeur EN
// set the digital pin as output: => relais actuateur piezo
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(40, OUTPUT);
pinMode(41, OUTPUT);
pinMode(42, OUTPUT);
pinMode(43, OUTPUT);
// commande multiplexeur USB
pinMode(36, OUTPUT); // USB
pinMode(37, OUTPUT);
pinMode(38, OUTPUT);
pinMode(39, OUTPUT);
pinMode(22, OUTPUT); //CAM
pinMode(23, OUTPUT);
pinMode(24, OUTPUT);
pinMode(25, OUTPUT);
// platines translation => platine N°1 (A02_1=0, A12_1=0, EN3_1=1 et A11=1); platine N°2 (A02_1=1, A12_1=0, EN3_1=1 et A10=1); platine N°3 (A02_1=0, A12_1=1, EN3_1=1 et A11=1); platine N°4 (A02_1=1, A12_1=1, EN3_1=1 et A10=1)
// activation en parallèle des relais moteurs respectifs des platines => platine N°1 (MM1=1 et MP1=1); platine N°2 (MM2=1 et MP2=1); platine N°3 (MM3=1 et MP3=1); platine N°4 (MM4=1 et MP4=1)
pinMode(33, OUTPUT); //AO2_1
pinMode(34, OUTPUT); //A12_1
pinMode(35, OUTPUT); //EN3_1
pinMode(14, OUTPUT); //MM1 platine1
pinMode(15, OUTPUT); //MP1 platine1
pinMode(16, OUTPUT); //MM2 platine2
pinMode(17, OUTPUT); //MP2 platine2
pinMode(18, OUTPUT); //MM3 platine3
pinMode(19, OUTPUT); //MP3 platine3
pinMode(20, OUTPUT); //MM4 platine4
pinMode(21, OUTPUT); //MP4 platine4
pinMode(A8, OUTPUT); //REL 5Vencod4
pinMode(A9, OUTPUT); //REL 5Vencod3
pinMode(A10, OUTPUT); //REL 5Vencod2
pinMode(A11, OUTPUT); //REL 5Vencod1
//RELAIS 5V 8 USB
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
pinMode(A6, OUTPUT);
pinMode(A7, OUTPUT);
//RELAIS 5V 8 USB
pinMode(A12, OUTPUT);
pinMode(A13, OUTPUT);
pinMode(A14, OUTPUT);
pinMode(A15, OUTPUT);
// MULTIPLEXAGE DES 4 S120C AVEC A01_1 = 30, A11_1 = 31 ET EN2_1 = 32
pinMode(30, OUTPUT);
pinMode(31, OUTPUT);
pinMode(32, OUTPUT);
//SPI
SPI.begin();
SPI.setBitOrder(MSBFIRST);
digitalWrite(TRIG,LOW);
digitalWrite(EN12V1,LOW);
digitalWrite(EN12V2,LOW);
// mise à 0 des relais actuateurs
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(40, LOW);
digitalWrite(41, LOW);
digitalWrite(42, LOW);
digitalWrite(43, LOW);
// mise à 0V des commandes multiplexeur USB
digitalWrite(36, LOW); // USB
digitalWrite(37, LOW);
digitalWrite(38, LOW);
digitalWrite(39, LOW);
digitalWrite(22, LOW); //CAM
digitalWrite(23, LOW);
digitalWrite(24, LOW);
digitalWrite(25, LOW);
for (i = 0; i < 50; i++)
{
data_array[i] = 0x00;
data_array1[i] = 0x00;
tab_val[i] = 0x00;
}
}
void loop()
{
// here is where you'd put code that needs to be running all the time.
serialEvent();
if (stringComplete)
{
comstring = "";
inputString = "";
cpt_tab = 0;
stringComplete = false;
}
}
////////////////////////////// fonction de gestion buffer RS232////////////////////////////////////
void serialEvent()
{
while (Serial.available())
{
// get the new byte:
char inChar = (char)Serial.read();//lecture du port COM
// add it to the inputString:
if (inChar != NULL && inChar != 13) //S'il n'y a pas de caractère null
{
stringComplete = false;
inputString += inChar;
comstring = inputString;
}
if (inChar == NULL) //Si le caractère est null
{
CaractNull = true;
inChar = 0x30;
inputString += inChar;
comstring = inputString;
tab_val[cpt_tab] = 1;
}
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\r')
{
stringComplete = true;
inputString += " OK";
if(etat != 2)Serial.println(inputString);
}
cpt_tab++;
decodDAC();
}
}/////////////////////////////////fin de fonction/////////////////////////////
void THERMK(void)
{
conv_tk = analogRead(TEMPK);
temperature = ((float)((conv_tk * (5./1023.) - 0.001866028708133974)/0.004832535885167464));
Serial.println(temperature);
}
/**************************************************************************************************************************************************************************************************************
* *
* *
* FONCTION DECODAC() *
* *
* *
**************************************************************************************************************************************************************************************************************/
void decodDAC()
{
char string[50];
if ( comstring[0] == '*' && comstring[1] == 'i' && comstring[2] == 'd' && comstring[3] == 'n' && comstring[4] == '?' && stringComplete == true) //Equations DACX
{
Serial.println("idn = Automate MONTANA");
}
if ( comstring[0] == 'C' && comstring[1] == 'A' && comstring[2] == 'M' && comstring[3] == '1' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //CAM1
{
//STOPCAM();
CAM1();
}
if ( comstring[0] == 'C' && comstring[1] == 'A' && comstring[2] == 'M' && comstring[3] == '2' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //CAM2
{
//STOPCAM();
CAM2();
}
if ( comstring[0] == 'C' && comstring[1] == 'A' && comstring[2] == 'M' && comstring[3] == '3' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //CAM3
{
//STOPCAM();
CAM3();
}
if ( comstring[0] == 'C' && comstring[1] == 'A' && comstring[2] == 'M' && comstring[3] == '4' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //CAM4
{
//STOPCAM();
CAM4();
}
if ( comstring[0] == 'C' && comstring[1] == 'A' && comstring[2] == 'M' && comstring[3] == '5' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //CAM5
{
//STOPCAM();
CAM5();
}
if ( comstring[0] == 'C' && comstring[1] == 'A' && comstring[2] == 'M' && comstring[3] == '6' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //CAM6
{
//STOPCAM();
CAM6();
}
if ( comstring[0] == 'C' && comstring[1] == 'A' && comstring[2] == 'M' && comstring[3] == '7' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //CAM7
{
//STOPCAM();
CAM7();
}
if ( comstring[0] == 'C' && comstring[1] == 'A' && comstring[2] == 'M' && comstring[3] == '8' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //CAM8
{
//STOPCAM();
CAM8();
}
if ( comstring[0] == 'U' && comstring[1] == 'S' && comstring[2] == 'B' && comstring[3] == '1' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //USB1
{
//STOPUSB();
USB1();
}
if ( comstring[0] == 'U' && comstring[1] == 'S' && comstring[2] == 'B' && comstring[3] == '2' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //USB2
{
//STOPUSB();
USB2();
}
if ( comstring[0] == 'U' && comstring[1] == 'S' && comstring[2] == 'B' && comstring[3] == '3' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //USB3
{
//STOPUSB();
USB3();
}
if ( comstring[0] == 'U' && comstring[1] == 'S' && comstring[2] == 'B' && comstring[3] == '4' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //USB4
{
//STOPUSB();
USB4();
}
if ( comstring[0] == 'U' && comstring[1] == 'S' && comstring[2] == 'B' && comstring[3] == '5' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //USB5
{
//STOPUSB();
USB5();
}
if ( comstring[0] == 'U' && comstring[1] == 'S' && comstring[2] == 'B' && comstring[3] == '6' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //USB6
{
//STOPUSB();
USB6();
}
if ( comstring[0] == 'U' && comstring[1] == 'S' && comstring[2] == 'B' && comstring[3] == '7' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //USB7
{
//STOPUSB();
USB7();
}
if ( comstring[0] == 'U' && comstring[1] == 'S' && comstring[2] == 'B' && comstring[3] == '8' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //USB8
{
//STOPUSB();
USB8();
}
if ( comstring[0] == 'U' && comstring[1] == 'S' && comstring[2] == 'B' && comstring[3] == 'S' && comstring[4] == 'T' && comstring[5] == 'O' && comstring[6] == 'P' && stringComplete == true) //STOP USB INSTRUMENTATION
{
STOPUSB();
}
if ( comstring[0] == 'C' && comstring[1] == 'A' && comstring[2] == 'M' && comstring[3] == 'S' && comstring[4] == 'T' && comstring[5] == 'O' && comstring[6] == 'P' && stringComplete == true) //STOP CAMERAS
{
STOPCAM();
}
if ( comstring[0] == 'T' && comstring[1] == 'E' && comstring[2] == 'M' && comstring[3] == 'P' && comstring[4] == '?' && stringComplete == true) //Lecture température thermocouple type K A0
{
THERMK();
}
if ( comstring[0] == 'P' && comstring[1] == 'L' && comstring[2] == 'A' && comstring[3] == '1' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //PLATINE N°1
{
STOPPLATINE();
PLATINE1();
}
if ( comstring[0] == 'P' && comstring[1] == 'L' && comstring[2] == 'A' && comstring[3] == '2' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //PLATINE N°2
{
STOPPLATINE();
PLATINE2();
}
if ( comstring[0] == 'P' && comstring[1] == 'L' && comstring[2] == 'A' && comstring[3] == '3' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //PLATINE N°3
{
STOPPLATINE();
PLATINE3();
}
if ( comstring[0] == 'P' && comstring[1] == 'L' && comstring[2] == 'A' && comstring[3] == '4' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //PLATINE N°4
{
STOPPLATINE();
PLATINE4();
}
if ( comstring[0] == 'P' && comstring[1] == 'L' && comstring[2] == 'A' && comstring[3] == 'S' && comstring[4] == 'T' && comstring[5] == 'O' && comstring[6] == 'P' && stringComplete == true) //STOP PLATINES
{
STOPPLATINE();
}
if ( comstring[0] == 'S' && comstring[1] == '1' && comstring[2] == '2' && comstring[3] == '1' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //S120 N°1
{
STOPS120C();
S120C1();
}
if ( comstring[0] == 'S' && comstring[1] == '1' && comstring[2] == '2' && comstring[3] == '2' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //S120 N°2
{
STOPS120C();
S120C2();
}
if ( comstring[0] == 'S' && comstring[1] == '1' && comstring[2] == '2' && comstring[3] == '3' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //S120 N°3
{
digitalWrite(LED,HIGH);
STOPS120C();
S120C3();
digitalWrite(LED,LOW);
}
if ( comstring[0] == 'S' && comstring[1] == '1' && comstring[2] == '2' && comstring[3] == '4' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //S120 N°4
{
STOPS120C();
S120C4();
}
if ( comstring[0] == 'S' && comstring[1] == '1' && comstring[2] == '2' && comstring[3] == 'S' && comstring[4] == 'T' && comstring[5] == 'O' && comstring[6] == 'P' && stringComplete == true) //STOP S120
{
STOPS120C();
}
if (comstring[0] == 'A' && comstring[1] == 'C' && comstring[2] == 'T' && comstring[3] == '1' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //actuateurs couple de miroir N°1
{
STOPACTUATEUR();
routCS();
}
if (comstring[0] == 'A' && comstring[1] == 'C' && comstring[2] == 'T' && comstring[3] == '2' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //actuateurs couple de miroir N°2
{
STOPACTUATEUR();
routCO();
}
if (comstring[0] == 'A' && comstring[1] == 'C' && comstring[2] == 'T' && comstring[3] == '3' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && comstring[7] == '1' && stringComplete == true) //actuateurs couple de miroir N°3
{
STOPACTUATEUR();
routCE();
}
if ( comstring[0] == 'A' && comstring[1] == 'C' && comstring[2] == 'T' && comstring[3] == 'S' && comstring[4] == 'T' && comstring[5] == 'O' && comstring[6] == 'P' && stringComplete == true) //Désactive le lien physique entre les actuateurs et le driver KIM101
{
STOPACTUATEUR();
}
if ( comstring[0] == 'T' && comstring[1] == 'R' && comstring[2] == 'I' && comstring[3] == 'G' && comstring[4] == '0' && stringComplete == true) // Arrêt des synchros sur TR1 à TR8
{
data_array[0] = 0x00;
data_array1[0] = 0x00;
digitalWrite(TRIG,LOW);
delay(1200);
transferslaves();
delay(10);
digitalWrite(TRIG,LOW);
}
if ( comstring[0] == 'T' && comstring[1] == 'R' && comstring[2] == 'I' && comstring[3] == 'G' && comstring[4] == '1' && stringComplete == true) // Génération d’un pulse unique sur TR1 à TR8
{
digitalWrite(LED,HIGH);
data_array[0] = 0x01;
data_array1[0] = 0x01;
digitalWrite(TRIG,LOW);
delay(1000);
transferslaves();
digitalWrite(TRIG,HIGH);
delay(1200);
digitalWrite(TRIG,LOW);
}
if ( comstring[0] == 'T' && comstring[1] == 'R' && comstring[2] == 'I' && comstring[3] == 'G' && comstring[4] == '2' && stringComplete == true) // Génération continue des synchros sur TR1 à TR8
{
digitalWrite(LED,HIGH);
data_array[0] = 0x02;
data_array1[0] = 0x02;
digitalWrite(TRIG,LOW);
delay(1200);
transferslaves();
digitalWrite(TRIG,HIGH);
}
if ( comstring[0] == 'F' && comstring[1] == 'R' && comstring[2] == 'E' && comstring[3] == 'Q' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION de la consigne fréquence (Hz)
{
for(i=0;i<4;i++)
{
FPX[i] = comstring[i+7]-0x30;
}
decompositionF();
}
if ( comstring[0] == 'D' && comstring[1] == 'E' && comstring[2] == 'L' && comstring[3] == '1' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION du délai de génération de TR1 (centaines de µs)
{
for(i=0;i<4;i++)
{
DEL1[i] = comstring[i+7]-0x30;
}
decompositionD1();
}
if ( comstring[0] == 'D' && comstring[1] == 'E' && comstring[2] == 'L' && comstring[3] == '2' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION du délai de génération de TR2 (centaines de µs)
{
for(i=0;i<4;i++)
{
DEL2[i] = comstring[i+7]-0x30;
}
decompositionD2();
}
if ( comstring[0] == 'D' && comstring[1] == 'E' && comstring[2] == 'L' && comstring[3] == '3' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION du délai de génération de TR3 (centaines de µs)
{
for(i=0;i<4;i++)
{
DEL3[i] = comstring[i+7]-0x30;
}
decompositionD3();
}
if ( comstring[0] == 'D' && comstring[1] == 'E' && comstring[2] == 'L' && comstring[3] == '4' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION du délai de génération de TR4 (centaines de µs)
{
for(i=0;i<4;i++)
{
DEL4[i] = comstring[i+7]-0x30;
}
decompositionD4();
}
if ( comstring[0] == 'D' && comstring[1] == 'E' && comstring[2] == 'L' && comstring[3] == '5' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION du délai de génération de TR5 (centaines de µs)
{
for(i=0;i<4;i++)
{
DEL5[i] = comstring[i+7]-0x30;
}
decompositionD5();
}
if ( comstring[0] == 'D' && comstring[1] == 'E' && comstring[2] == 'L' && comstring[3] == '6' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION du délai de génération de TR6 (centaines de µs)
{
for(i=0;i<4;i++)
{
DEL6[i] = comstring[i+7]-0x30;
}
decompositionD6();
}
if ( comstring[0] == 'D' && comstring[1] == 'E' && comstring[2] == 'L' && comstring[3] == '7' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION du délai de génération de TR7 (centaines de µs)
{
for(i=0;i<4;i++)
{
DEL7[i] = comstring[i+7]-0x30;
}
decompositionD7();
}
if ( comstring[0] == 'D' && comstring[1] == 'E' && comstring[2] == 'L' && comstring[3] == '8' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION du délai de génération de TR8 (centaines de µs)
{
for(i=0;i<4;i++)
{
DEL8[i] = comstring[i+7]-0x30;
}
decompositionD8();
}
if ( comstring[0] == 'W' && comstring[1] == 'I' && comstring[2] == 'D' && comstring[3] == '1' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION Consigne largeur de pulse TR1 (de 3 à 97 ms – C = 1µF)
{
for(i=0;i<3;i++)
{
WID1[i] = comstring[i+7]-0x30;
}
decompositionW1();
}
if ( comstring[0] == 'W' && comstring[1] == 'I' && comstring[2] == 'D' && comstring[3] == '2' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION Consigne largeur de pulse TR2 (de 3 à 97 ms – C = 1µF)
{
for(i=0;i<3;i++)
{
WID2[i] = comstring[i+7]-0x30;
}
decompositionW2();
}
if ( comstring[0] == 'W' && comstring[1] == 'I' && comstring[2] == 'D' && comstring[3] == '3' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION Consigne largeur de pulse TR3 (de 3 à 97 ms – C = 1µF)
{
for(i=0;i<3;i++)
{
WID3[i] = comstring[i+7]-0x30;
}
decompositionW3();
}
if ( comstring[0] == 'W' && comstring[1] == 'I' && comstring[2] == 'D' && comstring[3] == '4' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION Consigne largeur de pulse TR4 (de 3 à 97 ms – C = 1µF)
{
for(i=0;i<3;i++)
{
WID4[i] = comstring[i+7]-0x30;
}
decompositionW4();
}
if ( comstring[0] == 'W' && comstring[1] == 'I' && comstring[2] == 'D' && comstring[3] == '5' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION Consigne largeur de pulse TR5 (de 30 à 970 ms – C = 10µF))
{
for(i=0;i<3;i++)
{
WID5[i] = comstring[i+7]-0x30;
}
decompositionW5();
}
if ( comstring[0] == 'W' && comstring[1] == 'I' && comstring[2] == 'D' && comstring[3] == '6' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION Consigne largeur de pulse TR6 (de 30 à 970 ms – C = 10µF))
{
for(i=0;i<3;i++)
{
WID6[i] = comstring[i+7]-0x30;
}
decompositionW6();
}
if ( comstring[0] == 'W' && comstring[1] == 'I' && comstring[2] == 'D' && comstring[3] == '7' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION Consigne largeur de pulse TR7 (de 3 à 112 centaines de µs – C = 0.1µF)
{
for(i=0;i<3;i++)
{
WID7[i] = comstring[i+7]-0x30;
}
decompositionW7();
}
if ( comstring[0] == 'W' && comstring[1] == 'I' && comstring[2] == 'D' && comstring[3] == '8' && comstring[4] == ' ' && comstring[5] == '=' && comstring[6] == ' ' && stringComplete == true) // RECEPTION Consigne largeur de pulse TR8 (de 3 à 112 centaines de µs – C = 0.1µF)
{
for(i=0;i<3;i++)
{
WID8[i] = comstring[i+7]-0x30;
}
decompositionW8();
}
}
//****************************************************************************** DEC FREQ *******************************************************************************
void decompositionF (void)
{
FREQ1 = ((unsigned int)((FPX[0])*1000));
FREQ1 = FREQ1 + ((unsigned int)((FPX[1])*100));
FREQ1 = FREQ1 + ((unsigned int)((FPX[2])*10));
FREQ1 = FREQ1 + ((unsigned int)((FPX[3])*1));
var = (unsigned char)(FREQ1>>8); //prise MSB
data_array[1] = var;
data_array[2] = (unsigned char) (FREQ1);
data_array1[1] = data_array[1];
data_array1[2] = data_array[2];
}
//****************************************************************************** DEC DEL1 *******************************************************************************
void decompositionD1 (void)
{
D1 = ((unsigned int)((DEL1[0])*1000));
D1 = D1 + ((unsigned int)((DEL1[1])*100));
D1 = D1 + ((unsigned int)((DEL1[2])*10));
D1 = D1 + ((unsigned int)((DEL1[3])*1));
var = (unsigned char)(D1>>8); //prise MSB
data_array[3] = var;
data_array[4] = (unsigned char) (D1);
}
//****************************************************************************** DEC DEL2 *******************************************************************************
void decompositionD2 (void)
{
D2 = ((unsigned int)((DEL2[0])*1000));
D2 = D2 + ((unsigned int)((DEL2[1])*100));
D2 = D2 + ((unsigned int)((DEL2[2])*10));
D2 = D2 + ((unsigned int)((DEL2[3])*1));
var = (unsigned char)(D2>>8); //prise MSB
data_array[5] = var;
data_array[6] = (unsigned char) (D2);
}
//****************************************************************************** DEC DEL3 *******************************************************************************
void decompositionD3 (void)
{
D3 = ((unsigned int)((DEL3[0])*1000));
D3 = D3 + ((unsigned int)((DEL3[1])*100));
D3 = D3 + ((unsigned int)((DEL3[2])*10));
D3 = D3 + ((unsigned int)((DEL3[3])*1));
var = (unsigned char)(D3>>8); //prise MSB
data_array[7] = var;
data_array[8] = (unsigned char) (D3);
}
//****************************************************************************** DEC DEL4 *******************************************************************************
void decompositionD4 (void)
{
D4 = ((unsigned int)((DEL4[0])*1000));
D4 = D4 + ((unsigned int)((DEL4[1])*100));
D4 = D4 + ((unsigned int)((DEL4[2])*10));
D4 = D4 + ((unsigned int)((DEL4[3])*1));
var = (unsigned char)(D4>>8); //prise MSB
data_array[9] = var;
data_array[10] = (unsigned char) (D4);
}
//****************************************************************************** DEC DEL5 *******************************************************************************
void decompositionD5 (void)
{
D5 = ((unsigned int)((DEL5[0])*1000));
D5 = D5 + ((unsigned int)((DEL5[1])*100));
D5 = D5 + ((unsigned int)((DEL5[2])*10));
D5 = D5 + ((unsigned int)((DEL5[3])*1));
var = (unsigned char)(D5>>8); //prise MSB
data_array1[3] = var;
data_array1[4] = (unsigned char) (D5);
}
//****************************************************************************** DEC DEL6 *******************************************************************************
void decompositionD6 (void)
{
D6 = ((unsigned int)((DEL6[0])*1000));
D6 = D6 + ((unsigned int)((DEL6[1])*100));
D6 = D6 + ((unsigned int)((DEL6[2])*10));
D6 = D6 + ((unsigned int)((DEL6[3])*1));
var = (unsigned char)(D6>>8); //prise MSB
data_array1[5] = var;
data_array1[6] = (unsigned char) (D6);
}
//****************************************************************************** DEC DEL7 *******************************************************************************
void decompositionD7 (void)
{
D7 = ((unsigned int)((DEL7[0])*1000));
D7 = D7 + ((unsigned int)((DEL7[1])*100));
D7 = D7 + ((unsigned int)((DEL7[2])*10));
D7 = D7 + ((unsigned int)((DEL7[3])*1));
var = (unsigned char)(D7>>8); //prise MSB
data_array1[7] = var;
data_array1[8] = (unsigned char) (D7);
}
//****************************************************************************** DEC DEL8 *******************************************************************************
void decompositionD8 (void)
{
D8 = ((unsigned int)((DEL8[0])*1000));
D8 = D8 + ((unsigned int)((DEL8[1])*100));
D8 = D8 + ((unsigned int)((DEL8[2])*10));
D8 = D8 + ((unsigned int)((DEL8[3])*1));
var = (unsigned char)(D8>>8); //prise MSB
data_array1[9] = var;
data_array1[10] = (unsigned char) (D8);
}
//****************************************************************************** DEC WID1 *******************************************************************************
void decompositionW1 (void)
{
W1 = ((unsigned int)((WID1[0])*100));
W1 = W1 + ((unsigned int)((WID1[1])*10));
W1 = W1 + ((unsigned int)((WID1[2])*1));
data_array[11] = (unsigned char) (W1);
}
//****************************************************************************** DEC WID2 *******************************************************************************
void decompositionW2 (void)
{
W2 = ((unsigned int)((WID2[0])*100));
W2 = W2 + ((unsigned int)((WID2[1])*10));
W2 = W2 + ((unsigned int)((WID2[2])*1));
data_array[12] = (unsigned char) (W2);
}
//****************************************************************************** DEC WID3 *******************************************************************************
void decompositionW3 (void)
{
W3 = ((unsigned int)((WID3[0])*100));
W3 = W3 + ((unsigned int)((WID3[1])*10));
W3 = W3 + ((unsigned int)((WID3[2])*1));
data_array[13] = (unsigned char) (W3);
}
//****************************************************************************** DEC WID4 *******************************************************************************
void decompositionW4 (void)
{
W4 = ((unsigned int)((WID4[0])*100));
W4 = W4 + ((unsigned int)((WID4[1])*10));
W4 = W4 + ((unsigned int)((WID4[2])*1));
data_array[14] = (unsigned char) (W4);
}
//****************************************************************************** DEC WID5 *******************************************************************************
void decompositionW5 (void)
{
W5 = ((unsigned int)((WID5[0])*100));
W5 = W5 + ((unsigned int)((WID5[1])*10));
W5 = W5 + ((unsigned int)((WID5[2])*1));
data_array1[11] = (unsigned char) (W5);
}
//****************************************************************************** DEC WID6 *******************************************************************************
void decompositionW6 (void)
{
W6 = ((unsigned int)((WID6[0])*100));
W6 = W6 + ((unsigned int)((WID6[1])*10));
W6 = W6 + ((unsigned int)((WID6[2])*1));
data_array1[12] = (unsigned char) (W6);
}
//****************************************************************************** DEC WID7 *******************************************************************************
void decompositionW7 (void)
{
W7 = ((unsigned int)((WID7[0])*100));
W7 = W7 + ((unsigned int)((WID7[1])*10));
W7 = W7 + ((unsigned int)((WID7[2])*1));
data_array1[13] = (unsigned char) (W7);
}
//****************************************************************************** DEC WID8 *******************************************************************************
void decompositionW8 (void)
{
W8 = ((unsigned int)((WID8[0])*100));
W8 = W8 + ((unsigned int)((WID8[1])*10));
W8 = W8 + ((unsigned int)((WID8[2])*1));
data_array1[14] = (unsigned char) (W8);
}
//****************************************************************************** transfert SPI slaves N°1 et N°2 *******************************************************************************
void transferslaves (void)
{
//Slave1
//digitalWrite(PIEZZOOK,HIGH);
//CRC_slaves(data_array);
SPI.setClockDivider(SPI_CLOCK_DIV128);
SPI.begin();
SPI.setDataMode(SPI_MODE0);
digitalWrite(SS1,LOW);
delayMicroseconds(100);
//delay(5);
for(i=0;i<15;i++)
{
SPI.transfer(data_array[i]); //Envoi spi de tout le tableau S1
delayMicroseconds(1);
//SPI.transfer(0x00);
}
delay(100);
/*SPI.transfer(0);
SPI.transfer(0);
SPI.transfer(0);*/
digitalWrite(SS1,HIGH);
SPI.end();
//digitalWrite(PIEZZOOK,LOW);
delay(100);
//Slaves2
//digitalWrite(PIEZZOOK,HIGH);
//CRC_slaves(data_array1);
SPI.setClockDivider(SPI_CLOCK_DIV128);
SPI.begin();
SPI.setDataMode(SPI_MODE0);
digitalWrite(SS2,LOW);
//delay(5);
delayMicroseconds(100);
for(i=0;i<15;i++)
{
SPI.transfer(data_array1[i]);//Envoi spi de tout le tableau S2
delayMicroseconds(1);
//SPI.transfer(0x00);
}
delay(100);
/*SPI.transfer(0);
SPI.transfer(0);
SPI.transfer(0);*/
digitalWrite(SS2,HIGH);
SPI.end();
//digitalWrite(PIEZZOOK,LOW);
}
void S120C1 (void)
{
digitalWrite(32, HIGH); // EN
delay(1);
digitalWrite(30, LOW); // A0
digitalWrite(31, LOW); // A1
delayMicroseconds(20); // pauses for 20 microsecond
}
void S120C2 (void)
{
digitalWrite(32, HIGH); // EN
delay(1);
digitalWrite(30, HIGH); // A0
digitalWrite(31, LOW); // A1
delayMicroseconds(20); // pauses for 20 microsecond
}
void S120C3 (void)
{
digitalWrite(32, HIGH); // EN
delay(1);
digitalWrite(30, LOW); // A0
digitalWrite(31, HIGH); // A1
delayMicroseconds(20); // pauses for 20 microsecond
}
void S120C4 (void)
{
digitalWrite(32, HIGH); // EN
delay(1);
digitalWrite(30, HIGH); // A0
digitalWrite(31, HIGH); // A1
delayMicroseconds(20); // pauses for 20 microsecond
}
void STOPS120C (void)
{
digitalWrite(32, LOW); // EN
delay(1);
digitalWrite(30, LOW); // A0
digitalWrite(31, LOW); // A1
delayMicroseconds(20); // pauses for 20 microsecond
}
void CAM1 (void)
{
digitalWrite(A12, HIGH);
delay(100);
digitalWrite(22, HIGH); // EN
digitalWrite(23, LOW); // C0
digitalWrite(24, LOW); // C1
digitalWrite(25, LOW); // C2
delayMicroseconds(20); // pauses for 20 microsecond
//digitalWrite(EN12V1, HIGH); //alim 12V caméra
//delay(100);
digitalWrite(29, HIGH); // EN multiplexage trigger caméra N°1
digitalWrite(26, LOW); // A0
digitalWrite(27, LOW); // A1
digitalWrite(28, LOW); // A2
}
void CAM2 (void)
{
digitalWrite(A12, HIGH);
delay(100);
digitalWrite(22, HIGH); // EN
digitalWrite(23, HIGH); // C0
digitalWrite(24, LOW); // C1
digitalWrite(25, LOW); // C2
delayMicroseconds(20); // pauses for 20 microseconds
digitalWrite(29, HIGH); // EN multiplexage trigger caméra N°1
digitalWrite(26, HIGH); // A0
digitalWrite(27, LOW); // A1
digitalWrite(28, LOW); // A2
}
void CAM3 (void)
{
digitalWrite(A13, HIGH);
delay(100);
digitalWrite(22, HIGH); // EN
digitalWrite(23, LOW); // C0
digitalWrite(24, HIGH); // C1
digitalWrite(25, LOW); // C2
delayMicroseconds(20); // pauses for 20 microseconds
digitalWrite(29, HIGH); // EN multiplexage trigger caméra N°1
digitalWrite(26, LOW); // A0
digitalWrite(27, HIGH); // A1
digitalWrite(28, LOW); // A2
}
void CAM4 (void)
{
digitalWrite(A13, HIGH);
delay(100);
digitalWrite(22, HIGH); // EN
digitalWrite(23, HIGH); // C0
digitalWrite(24, HIGH); // C1
digitalWrite(25, LOW); // C2
delayMicroseconds(20); // pauses for 20 microseconds
digitalWrite(29, HIGH); // EN multiplexage trigger caméra N°1
digitalWrite(26, HIGH); // A0
digitalWrite(27, HIGH); // A1
digitalWrite(28, LOW); // A2
}
void CAM5 (void)
{
digitalWrite(A14, HIGH);
delay(100);
digitalWrite(22, HIGH); // EN
digitalWrite(23, LOW); // C0
digitalWrite(24, LOW); // C1
digitalWrite(25, HIGH); // C2
delayMicroseconds(20); // pauses for 20 microseconds
digitalWrite(29, HIGH); // EN multiplexage trigger caméra N°1
digitalWrite(26, LOW); // A0
digitalWrite(27, LOW); // A1
digitalWrite(28, HIGH); // A2
}
void CAM6 (void)
{
digitalWrite(A14, HIGH);
delay(100);
digitalWrite(22, HIGH); // EN
digitalWrite(23, HIGH); // C0
digitalWrite(24, LOW); // C1
digitalWrite(25, HIGH); // C2
delayMicroseconds(20); // pauses for 20 microseconds
digitalWrite(29, HIGH); // EN multiplexage trigger caméra N°1
digitalWrite(26, HIGH); // A0
digitalWrite(27, LOW); // A1
digitalWrite(28, HIGH); // A2
}
void CAM7 (void)
{
digitalWrite(A15, HIGH);
delay(100);
digitalWrite(22, HIGH); // EN
digitalWrite(23, LOW); // C0
digitalWrite(24, HIGH); // C1
digitalWrite(25, HIGH); // C2
delayMicroseconds(20); // pauses for 20 microseconds
digitalWrite(29, HIGH); // EN multiplexage trigger caméra N°1
digitalWrite(26, LOW); // A0
digitalWrite(27, HIGH); // A1
digitalWrite(28, HIGH); // A2
}
...
This file has been truncated, please download it to see its full contents.
Comments
Please log in or sign up to comment.