![]() ![]() _delay_us(600) // datasheet: at least 500us Set_low(pin) // set low before going output (open collector line safety) the line should be high (open collector with pullup) It might be overkill but no time for more tests now…) The test code is not presentable yet (ugly), but tested 100% ok with very long cables.Īlso please note that with very long cables the line will need a strong pull-up (at least 4k7 or less) and a local capacitor on the sensor side of the cable (I used an 1uF mlcc and seems to do the job. it does not care if the pulse edges are clean) Instead, after an edge detection it uses some fixed delays (following the datasheet) and checks the pin state once, in the middle of the expected pulse. I was getting checksum errors (and even bad values with falsely “correct†checksum) with a long but quiet cable, while the oscilloscope showed clean but not vertical pulse edges (due to capacitance).Īfter I realized what the problem was (skipping bits and losing the sequence), I wrote a reading sequence that does not try to detect one edge right after the other. The reason is that it depends only on transition detection which makes it very sensitive to anything but very clean and fast pulse edges. The way it moves through the reading sequence using the do-while loops, makes it extremely sensitive to any noise and also to any capacitance due to a long cable. ![]() I see this is an old thread, but please note that this code has serious problems. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |