In a recent project, the use of Optocoupler as an ad sampling chip is isolated as an SPI.
As we all know, the speed must be reduced, so the SPI speed adjusted to 8Kbps, began to use.
Optocoupler Circuit is the most standard and the simplest circuit.
The board was painted by others, and they told me that the R258 here is 680 euros and R263 is 4.7k,u68 for TLP181
A simple test, basically no problem, the data can be obtained normally.
Ready to put on the product to use, the problem is: often read to the wrong data, in careful pondering, is not the front-end ad sampling is not allowed? As a result of filtering processing, the data collected by Kalman filter, thinking that the problem should be solved. The results show that there is still a great deviation.
So, do the processing, each time the data collected by the ad processing, every mining, record cnt++, each found with the previous data value difference >0.2v, record err_cnt++, long-term operation to see.
After running for a period of time, it was found that err_cnt accounted for nearly 4% of the total CNT, the problem is serious.
Tracking again, to see when the data error, and normal data, the difference between a very large, and then carefully study, found about 1/2 or 1/4 of the normal value, so guess, whether it is the SPI read, a bit lost, so, the Optocoupler is removed, direct connection to see if there is a mistake.
Removal of Optocoupler, data read, read 10,000 data, found that no such errors, firm confidence, optocoupler problems!.
Read the TLP181 data sheet carefully and discover that there is a passage of Y:
Well, there's a problem with the pull-up resistor, so the R263 is changed to 2K, the problem is significantly improved, and the test error rate is reduced to 1%. Yo, do, continue to change, change the resistance to 1.2K, ah, the error rate has not changed.
Strange, isn't the drive current enough? Change the R258 to 220 euro, eh, the error rate rose to 4%, can't think of.
What to do? Only in the detail of the data sheet again, looking, the opposite, looked at 10 times, suddenly see this paragraph
Yes, we need to consider CTR, the relationship between IC and if should be corresponding how many ICS and if do I have to first?
or read the manual.
Recommended if is 16-20ma, that according to the above description, the saturated Ctr is at least 30%, so the selected if is about 16mA, IC in 10mA, according to this specification selected R258 and R262
R258 = (5-0.7)/16ma = 268 Kohm
R263 = (3-0.2)/10ma = 300 Kohm
So choose r258=220 R260 = 300, replace the original resistor, test, read half an hour, 10,000 times, error rate is 0.
OK, Fix it.
The resistance problem of opto-coupler as Isolation