Tracking Production on a Biglia B301SM CNC Lathe (anno 2001) with integration of Arduino-Filemaker

In this project, we are integrating a Biglia B301SM CNC lathe, built in 2001, with our production monitoring system. The goal is to collect real-time data about production cycles and piece counts. This data will then be sent to our management software, developed with FileMaker, to improve efficiency and provide clear insights into production activity.

How It Works

To achieve this integration, we decided to use an Arduino board to detect signals from the lathe. Specifically, the Arduino monitors two key signals:

  1. Piece Count: Detected through the relay controlling the unloading arm’s solenoid valve.
  2. Production Time: Monitored via the relay that powers the green working-cycle lamp.

The Arduino inputs are connected directly to these relay contacts. When a signal is detected, the Arduino software processes the data and sends it to a web server.

Sending Data to FileMaker

The Arduino communicates with our FileMaker management system using the following steps:

  1. Monitoring Inputs: The Arduino continuously checks the status of the connected relays.
  2. Triggering Events: When a relay changes state (e.g., the arm moves or the green light switches on/off), the Arduino triggers an action.
  3. PHP File Execution: The Arduino opens a PHP file hosted on a web server.
  4. REST API Integration: The PHP script uses a cURL function to make a REST API call to FileMaker. This call writes data into a table.

Data Logged in FileMaker

Two types of data are logged in the FileMaker table:

  • Piece Production: Each piece produced creates a new record in the table, making it easy to count the total pieces.
  • State Changes: A record is added whenever the lathe’s state changes (e.g., working, stopped). By calculating the time difference between “working” and “stopped” records, the total production time is determined.

The Results

This system provides accurate and detailed information about the lathe’s activity. It logs:

  • The number of pieces produced.
  • The total working time of the lathe.

By automating data collection with Arduino and integrating it with FileMaker, this project transforms a 2001 CNC lathe into a modern, data-driven machine. This approach improves production monitoring without requiring expensive upgrades to the lathe itself.

Arduino code

// Configurazione Wi-Fi
const char* ssid = “CNC_2”; // Sostituisci con il tuo SSID Wi-Fi
const char* password = “*********************”; // Sostituisci con la tua password Wi-Fi

// Imposta i pin degli interruttori (D2 e D4)
const int interruttorePin1 = 2;
const int interruttorePin2 = 4;

// Variabili per memorizzare lo stato precedente degli interruttori
int statoPrecedente1 = HIGH;
int statoPrecedente2 = HIGH;

// URL del server PHP che riceve i dati
const char* server = “192.168.1.61”;

// Setup
void setup() {
// Inizializza i pin degli interruttori come input
pinMode(interruttorePin1, INPUT_PULLUP);
pinMode(interruttorePin2, INPUT_PULLUP);
Serial.begin(115200);

// Connessione alla rete Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println(“Connessione WiFi in corso…”);
}
Serial.println(“Connesso al WiFi”);
}

// Loop
void loop() {
// Leggi lo stato del primo interruttore
int statoAttuale1 = digitalRead(interruttorePin1);

// Se lo stato del primo interruttore è cambiato
if (statoAttuale1 != statoPrecedente1) {
statoPrecedente1 = statoAttuale1;

// Crea una connessione al server
WiFiClient client;

// Connetti al server
if (client.connect(server, 80)) { 
  // Invia la richiesta HTTP GET al file PHP corretto
  if (statoAttuale1 == LOW) {
    client.print(String("GET /filemaker_start.php HTTP/1.1\r\n") +
                 "Host: " + server + "\r\n" + 
                 "Connection: close\r\n\r\n");
  } else {
    client.print(String("GET /filemaker_stop.php HTTP/1.1\r\n") +
                 "Host: " + server + "\r\n" + 
                 "Connection: close\r\n\r\n");
  }

  Serial.println(statoAttuale1 == LOW ? "Richiesta start inviata" : "Richiesta stop inviata");

  // Chiudi la connessione
  client.stop();
} else {
  Serial.println("Errore nella connessione al server");
}

}

// Leggi lo stato del secondo interruttore
int statoAttuale2 = digitalRead(interruttorePin2);

// Se lo stato del secondo interruttore è cambiato
if (statoAttuale2 != statoPrecedente2) {
statoPrecedente2 = statoAttuale2;

// Crea una connessione al server solo se il pin è LOW
if (statoAttuale2 == LOW) {
  WiFiClient client;

  // Connetti al server
  if (client.connect(server, 80)) { 
    // Invia la richiesta HTTP GET al file PHP 
    client.print(String("GET /filemaker_conteggio_on.php HTTP/1.1\r\n") +
                 "Host: " + server + "\r\n" + 
                 "Connection: close\r\n\r\n");

    Serial.println("Richiesta conteggio_on inviata");

    // Chiudi la connessione
    client.stop();
  } else {
    Serial.println("Errore nella connessione al server");
  }
}

}

// Aspetta 500 millisecondi prima di verificare nuovamente
delay(500);
}

Screenshot

Categories:

Tags:


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *