I'm trying to use an Arduino to receive commands sent by PIC (18F524). The signal consists of a CLOCK pin at ~ 48Khz and a SIGNAL pin. Every 'command' consist of 18 * 4, 72 'bits' and is sent 6 times for redundancy.
Datasheet: Clock / Data

Datasheet: commands

One command, 72 bits.
On every rising edge of the clock, the data signal is read. So my first attempt to receive commands is by using the source clock as interrupt and do a digitalRead of the data pin on RISING.
Add all 72 reads in an array and compare this array to known commands.
A known command looks like "101000001100000000000000110001000100000000110001001000001001000010101100". It always start with '1010' and ends with '1100'.
Last received command looked = "000000100100000101000000000000000010000000000000000010000000000000000001" which doesn't come close to the sent signal.
I'm guessing the Arduino is too slow to do the digitalRead on time.. For testing i'm setting a test pin to high during the digitalRead and measuring this with a logic analyzer.
const int clockPin = 0; // digital pin 2
const int ledPin = 13;
const int dataPin = 8;
const int testPin = 11;
int BjCmnd[72];
int i = 0;
int j = 0;
int q = 0;
int volX[72] = { 1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,1,0,0,
0,0,0,0,0,0,1,1,0,0,0,1,0,0,1,0,0,0,
0,0,1,0,0,1,0,0,0,0,1,0,1,0,1,1,0,0 };
void setup() {
Serial.begin(9600);
pinMode(clockPin, INPUT);
pinMode(dataPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(testPin, OUTPUT);
attachInterrupt(clockPin, pin2Interrupt, RISING);
}
void pin2Interrupt(void)
{
digitalWrite(testPin, HIGH);
int dataState = digitalRead(dataPin);
digitalWrite(testPin, LOW);
if (i == 72)
{
j++;
i=0;
}
BjCmnd[i] = dataState;
i++;
}
void loop() {
Serial.println(j);
delay(5000);
Serial.print("VJ VolX = \"");
for (q=0; q<=71; q++)
{
Serial.print(volX[q]);
}
Serial.println("\"");
Serial.print("BJ Cmnd = \"");
for (q=0; q<=71; q++)
{
Serial.print(BjCmnd[q]);
}
Serial.println("\"");
}
result:
Depending on the 'delay' for setting a pin HIGH, it seems the delay is too much to read the signalpin on the clock rising.
I've tried using a second arduino to delay the clock, but so far no luck.

