3 ms·
Hardware noob question: How do you figure out when a packet of 24 bits starts? From the diagram in the post, the clock signal seems to just be identical blocks
by scribu 7y ago
Hardware noob question: How do you figure out when a packet of 24 bits starts?
From the diagram in the post, the clock signal seems to just be identical blocks of 4 bits.
Edit: Found the answer in one of the linked articles:
> Between each series of 24 bits there is a longer period during which CLK remains HIGH
- abetusk 7y agoFor others who are to lazy to link follow the linked article from the original article, there is a section of code in the function "loop" (modified for readability): void loop () { // if clock is LOW wait until it turns to HIGH // while (digitalRead(clockpin)==HIGH) {} tempmicros=micros(); // wait for the end of the HIGH pulse // while (digitalRead(clockpin)==LOW) {} // if the HIGH pulse was longer than 500 micros // we are at the start of a new bit sequence // if ((micros()-tempmicros)>500) { decode(); //decode the bit sequence } } so it looks like the 24 bit sequence is indicated by a 500 us pause between a falling edge and a rising edge of the data stream. [1] https://sites.google.com/site/marthalprojects/home/arduino/arduino-reads-digital-caliper https://sites.google.com/site/marthalprojects/home/arduino/a...
- unwind 7y agoI love that the input is using inverted logic due to the voltage translation needed, but the code and comments don't mention this. To me it looks like an obvious bug and first glance, since the CAPITALIZED sigal states don't match between code and comments. Glad I read the article first. :)