I'm building a small device that will read in numerical data from a Mitutoyo indicator, record and chart this data on the screen. These indicators use an "SPC" protocol that has a single input "request" pin that once set low will cause the device to start sending a clock and data signals for a total of 52 bits. Explanation of the data stream can be found here
I've got a simple python script written that "waits" for the next pulse using a while loop waiting for the clock pin to go low before reading the next bit; similar to this arduino project I found. this sort-of works, but on occasion it seems as those it either misses a bit or accidentally reads a bit twice and then it gets out of sync and the whole thing stops working.
There must be a better way to do this. Is there a way to instruct the Pi that "this pin is a clock, expect 52 bits on the data line" and have it read in more efficiently. I need to read in pulses from a cycle counter and there are other functions that this Pi will need to perform in concert with taking the occasional readings from the indicator, I fear that once it starts doing other things at the same time the bad reads/sync issues will get even worse.