1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Digimatic SPC Interface

Discussion in 'Arduino' started by sspence65, Oct 12, 2011.

  1. sspence65

    sspence65 New Member

    Joined:
    Oct 12, 2011
    Messages:
    3
    Likes:
    0
    Location:
    Andrews, SC

    Attached Files:

    Last edited: Oct 13, 2011
  2. sspence65

    sspence65 New Member

    Joined:
    Oct 12, 2011
    Messages:
    3
    Likes:
    0
    Location:
    Andrews, SC
    Here is the code sample I'm working with:

    Code (c):
    int req = 5; //caliper REQ line goes to pin 5
    int dat = 2; //caliper Data line goes to pin 2
    int clk = 3; //caliper Clock line goes to pin 3
    int iclk = 1; //pin 3 corresponds to interrupt number 1
    int i = 0; int j = 0; int k = 0; int n = 0;

    int mydata[52];

    void setup()
    {
      Serial.begin(19200);
      pinMode(req, OUTPUT);
      pinMode(clk, INPUT);
      pinMode(dat, INPUT);
    }

    void loop()
    {
      if (n == 0) attachInterrupt(iclk, myisr, RISING);
        PORTD |= (1<<5); // digitalWrite(req, HIGH);
        delay(10);
        PORTD &= ~(1<<5); // digitalWrite(req, LOW);
        if (i > 51)
        {
          for (j = 0; j < 13; j++)
          {
            Serial.print("--");
            for (k = 0; k < 4; k++)
            {
              Serial.print(mydata[(j*4)+k]);
            }
          }
        i = 0;
        }
    }

    void myisr()
    {
      if (i == 0) PORTD |= (1<<5); //digitalWrite(req, HIGH);
      if(i < 52)
      {
        mydata[j] = digitalRead(dat);
        i++;
      }
    }
     
    Last edited by a moderator: Jan 8, 2012
  3. sspence65

    sspence65 New Member

    Joined:
    Oct 12, 2011
    Messages:
    3
    Likes:
    0
    Location:
    Andrews, SC

Share This Page