Digimatic SPC Interface

Status
Not open for further replies.
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:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…