• 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.

Digimatic SPC Interface

sspence65

New Member
Here is the code sample I'm working with:

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:

Latest threads

EE World Online Articles

Loading

 
Top