2 Replies Latest reply on Jun 16, 2015 12:29 PM by coherentkris

    Collecting data from the physical world.

    KylePutzier

      No questions. Just thought I would share what I've learned recently.

       

      I want to gather production information from my companies machines. Some of this data is a count of how much raw material go through the machines. In the past I have had the operator manually enter the counter information into FileMaker. Then I found a counter device that had a built-in telnet server, so I was able to write a shell script to communicate with the telnet server. I got close to full automation, but there were issues with the way the device operated and then the company quit making them. Killed that idea. Found quite a few other devices, but all were either cost prohibitive or to difficult for my brain to understand.


      I have now found an easy way to gather that info programmably by using a simple little microprocessor called Arduino.

      An Arduino is a very small device that has quite a few I/O connections that can be connected to many different types of sensors. I learned enough Arduino programming to build exactly what I need.

       

      Basically I just had to couple it with a ethernet board, add an inductive proximity sensor, add a counter and a web server program and read the values via FileMakers Insert URL script step. Total cost $50, or so, for each machine. Well within my budget.

      I can see a future where I can program an Arduino to control the machines from data obtained programmably from FileMaker.

      Arduino's have been around for quite awhile. I don't think they will become obsolete anytime soon.

       

      Below is the program I cobbled together from snippets I found. It's basically a very simple C++ program. The program waits for an incoming signal, debounces it, increments the counter variable, saves that number to permanent memory and checks/processes web requests . It can do all that in .012th of a second (12,000 microseconds). It idles (waits for an incoming signal) at 136 microseconds.

       

      #include <SPI.h>

      #include <Ethernet.h>

      #include <avr/eeprom.h>

       

      const int buttonPin = 2;

      const int PulsePin = 7;

      const int ReadyPin = 6;

      int buttonState;

      int lastButtonState = LOW;

      unsigned long CurrentCount = 0;

      long lastDebounceTime = 0;

      long debounceDelay = 10;

      EEMEM unsigned long Location;

       

      byte mac[] = {

        0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED  // The MAC address can be anything as long as it is unique

      };

      IPAddress ip(192, 168, 1, 177);

      EthernetServer server(80);

       

      void setup() {

        CurrentCount = eeprom_read_dword( &Location );

        pinMode(buttonPin, INPUT);

        pinMode(PulsePin, OUTPUT);

        pinMode(ReadyPin, OUTPUT);

        digitalWrite(PulsePin, LOW);  // set initial LED state

        Serial.begin(9600);

        Ethernet.begin(mac, ip);

        server.begin();

        digitalWrite(ReadyPin, HIGH);  // Program is running indicator

      }

       

      void loop() {

        //

        //  // Program run time seconds.

        //  unsigned int time = 0;

        //  time = micros();

        //  //

       

        int reading = digitalRead(buttonPin);  // read the state of the switch into a local variable:

        if (reading != lastButtonState) {

          lastDebounceTime = millis();     // reset the debouncing timer

        }

       

        if ((millis() - lastDebounceTime) > debounceDelay) {

          if (reading != buttonState) {

            buttonState = reading;

            if (buttonState == HIGH) {

              digitalWrite(PulsePin, HIGH); // Blink the LED to show a pulse has arrived

              delay (1);

              digitalWrite(PulsePin, LOW);

              CurrentCount = ++CurrentCount; // Increment the counter

      //        Serial.println(CurrentCount);

              eeprom_write_dword( &Location, CurrentCount );

            }

          }

        }

        lastButtonState = reading;

       

        Web(); // Check for a web request

       

        //  // Program run time seconds

        //  time = micros() - time;

        //  Serial.println(time, DEC);

        //  delay(100);

        //  //

      }

       

      void Web() {

        // listen for incoming web request (clients)

        EthernetClient client = server.available();

        if (client) {

          boolean currentLineIsBlank = true;

          while (client.connected()) {

            if (client.available()) {

              char c = client.read();

              // send a standard http response header

              client.println("HTTP/1.1 200 OK");

              client.println("Content-Type: text/html");

              client.println("Connection: close");

      //        client.println("Refresh: 1");  // Refresh used for debugging purposes. Comment out when not needed.

              client.println();

              client.println("<!DOCTYPE HTML>");

              client.println("<html>");

              client.print("The count is ");

              client.print(CurrentCount);

              client.println("<br />");

              client.println("</html>");

              break;

            }

          }

          delay(1);    // give the web browser time to receive the data

          client.stop();

        }

      }

        • 1. Re: Collecting data from the physical world.
          mikebeargie

          24U has a plugin for phidgets, which is similar to arduino but not quite the same. There are also a number of serial port plugins that could be used for "physical world" devices. I also think that applescript or using something like baseelements to run scripts would give you control over connected devices.

           

          An easier integration might be to have your arduino push it's relevant data to a server that you then grab.

           

          I actually did a basic proof of concept of this for a PHP site recording a simple temperature log following this guide:

          http://www.tweaking4all.com/hardware/arduino/arduino-ethernet-data-push/

           

          You could easily tie into this data from FileMaker via ESS or Insert From URL to pull an array.

           

          Luckily I have the biggest makerspace in the country in my backyard (columbus idea foundry), unluckily I haven't had time to really get involved in some of the groups there.

           

          There was also a devcon session a few years back run by some people from the Pittsburgh usergroup that showed filemaker driving physical objects.

          • 2. Re: Collecting data from the physical world.
            coherentkris

            Machine<>computer interfaces can also happen with National Instruments LabView.

            I wrote a program for a former employer that leveraged LabView and a database to accomplish full operational control over a CO2 laser via the CANBUS. It also facilitated capture, validation, error reporting, and charting of the operational state parameters every .5 seconds