{"id":1496,"date":"2024-12-17T17:26:01","date_gmt":"2024-12-17T09:26:01","guid":{"rendered":"https:\/\/aoofoo.com\/?p=1496"},"modified":"2025-01-10T22:53:27","modified_gmt":"2025-01-10T14:53:27","slug":"%e7%bb%bc%e5%90%88usb%e6%b5%8b%e5%8a%9f%e7%8e%87%e4%bb%aa%e5%99%a8","status":"publish","type":"post","link":"https:\/\/aoofoo.com\/index.php\/2024\/12\/17\/%e7%bb%bc%e5%90%88usb%e6%b5%8b%e5%8a%9f%e7%8e%87%e4%bb%aa%e5%99%a8\/","title":{"rendered":"[\u7efc\u5408]USB\u6d4b\u529f\u7387\u4eea\u5668"},"content":{"rendered":"<h2>\u524d\u8a00<\/h2>\n<p>\u60f3\u8981\u5236\u4f5c\u4e00\u4e2aUSB\u6d4b\u529f\u7387\u7684\u4eea\u5668\uff0c\u9996\u5148\uff0c\u9700\u8981\u4e86\u89e3\u9700\u8981\u4ec0\u4e48\u4f20\u611f\u5668\uff0c\u7136\u540e\u6839\u636e\u81ea\u8eab\u7684\u9700\u6c42\uff0c\u6765\u5224\u65ad\u662f\u5426\u9700\u8981\u5236\u4f5cPCB\u677f\uff0c\u5728\u7f51\u7edc\u4e0a\u5bfb\u6c42\u76f8\u5173\u8d44\u6599\uff0c\u4ee5\u8fbe\u5230\u6700\u7ec8\u5b9e\u73b0\u7684\u76ee\u7684\uff0c\u672c\u6b21\u9879\u76ee\u7684\u96be\u70b9\u4e3b\u8981\u4e3aPCB\u7684\u8bbe\u8ba1\u548c\u4ee3\u7801\u7684\u7f16\u5199\uff0c\u9700\u8981\u4e86\u89e3\u76f8\u5173\u77e5\u8bc6\uff0c\u624d\u80fd\u987a\u5229\u7684\u5236\u4f5c\u51faUSB\u6d4b\u529f\u7387\u4eea\u5668\u3002<\/p>\n<p>\u5728\u8fd9\u91cc\u6211\u4eecMCU\u4f7f\u7528\u7684\u662fstm32g030f6p6\uff0c\u8be5\u82af\u7247\u53ea\u80fd\u4f7f\u7528HAL\u5e93\uff0c\u4e0d\u80fd\u4f7f\u7528\u6807\u51c6\u5e93\uff0c\u6240\u4ee5\u53ef\u4ee5\u76f4\u63a5\u4e0aSTM32CubeIDE\u6765\u751f\u6210\u63a5\u53e3\u4ee3\u7801\u5c31\u884c\u3002<\/p>\n<h2>\u786c\u4ef6<\/h2>\n<h3>\u8f93\u51fa\u7535\u6d41\/\u7535\u538b\/\u529f\u7387\u76d1\u63a7\u5668<\/h3>\n<p>\u60f3\u8981\u5236\u4f5c\u4e00\u4e2a\u6d4b\u529f\u7387\u76f8\u5173\u7684\u4eea\u5668\uff0c\u5fc5\u987b\u6709\u4e00\u4e2a\u82af\u7247\uff08\u4f20\u611f\u5668\uff09\uff0c\u80fd\u591f\u8ba9\u6211\u4eec\u7684MCU\u8bfb\u53d6\u8fd9\u4e2a\u4f20\u611f\u5668\u7684\u5185\u5bb9\uff0c\u90a3\u4e48\u73b0\u5728\u6211\u4eec\u5c31\u9700\u8981\u4ecb\u7ecd\u4e00\u4e0b\u8fd9\u4e2a\u4f20\u611f\u5668\uff1aINA220\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1497\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/12\/\u5c4f\u5e55\u622a\u56fe-2024-12-17-160703.png\" alt=\"\" width=\"1092\" height=\"622\" \/><\/p>\n<p>\u6211\u4eec\u9010\u4e00\u5bf9\u5b83\u7684\u5f15\u811a\u4f5c\u7528\u8fdb\u884c\u89e3\u6790\uff1a<\/p>\n<p>1.\u5730\u5740\u53ef\u4ee5\u901a\u8fc7<span style=\"color: #ff9900;\"><strong>A1\u3001A0<\/strong><\/span>\u8fdb\u884c\u914d\u7f6e\uff1a<\/p>\n<p>INA220 \u7684 I2C \u5730\u5740\u662f 7 \u4f4d\u683c\u5f0f\u3002<br \/>\n\u5730\u5740\u7684\u9ad8 5 \u4f4d\u662f\u56fa\u5b9a\u7684\uff1a1000 0\u3002<br \/>\n\u5730\u5740\u7684\u4f4e 2 \u4f4d\u7531\u5f15\u811a A0 \u548c A1 \u7684\u8fde\u63a5\u51b3\u5b9a\uff0c\u8fd9\u4e9b\u5f15\u811a\u53ef\u4ee5\u901a\u8fc7\u786c\u4ef6\u8fde\u63a5\u5230 GND \u6216 VCC \u6765\u914d\u7f6e\u3002<\/p>\n<p>\u6211\u5462\uff0c\u5c31\u5c06A0\u548cA1\u63a5\u5730\u5566\uff0c\u8282\u7701\u4e00\u4e24\u4e2a\u5f15\u811a\uff0c\u6240\u4ee5\u6211\u7684INA220\u7684\u5730\u5740\u5c31\u662f\uff1a<strong> 1000 000<\/strong>\u3002<\/p>\n<p>2.<span style=\"color: #ff9900;\">NC<\/span>\u662f\u4e00\u4e2a\u7a7a\u5185\u90e8\uff0c\u65e0\u9700\u8fde\u63a5\u5916\u90e8\u5668\u4ef6\u3002<\/p>\n<p>3.<span style=\"color: #ff9900;\">SDA\u3001SCL<\/span>\u662fI2C\u7684\u901a\u4fe1\u5f15\u811a\uff0c\u9700\u8981\u63a5\u5165\u5230STM32\u7684GPIO\u53e3\u4e0a\uff0c\u4f46\u8981\u6ce8\u610f\u522b\u5fd8\u4e86\u52a0\u4e0a\u62c9\u7535\u963b\u3002<\/p>\n<p>4.<span style=\"color: #ff9900;\">Vs<\/span>\u662fINA220\u7684\u4f9b\u7535\u5f15\u811a\uff0cINA220\u53ef\u4ee5\u75313V~5.5V\u7684\u7535\u6e90\u8fdb\u884c\u4f9b\u7535\u3002<\/p>\n<p>5.<span style=\"color: #ff9900;\">GND<\/span>\u662f\u63a5\u5730\u7684\u5f15\u811a\u3002<\/p>\n<p>6.<span style=\"color: #ff9900;\">VBUS<\/span>\u662f\u63a5\u5165\u9700\u8981\u6d4b\u91cf\u7684\u7535\u538b\u7684\u603b\u7ebf\u4e0a\u3002<\/p>\n<p>7.<span style=\"color: #ff9900;\">IN+<\/span> \u548c <span style=\"color: #ff9900;\">IN-<\/span> \u662f INA220 \u7684\u5dee\u5206\u8f93\u5165\u5f15\u811a\uff0c\u7528\u6765\u8fde\u63a5\u7535\u6d41\u68c0\u6d4b\u7535\u963b\uff08\u5373\u5206\u6d41\u7535\u963b\uff0c\u901a\u5e38\u79f0\u4e3a Shunt Resistor\uff09\u7684\u4e24\u7aef\u3002<\/p>\n<p><span style=\"color: #ff9900;\">IN-<\/span>:\u8d1f\u5dee\u5206\u5206\u6d41\u7535\u538b\u3002\u8fde\u63a5\u5230\u5206\u6d41\u7535\u963b\u5668\u7684\u8d1f\u4fa7\u3002<\/p>\n<p><span style=\"color: #ff9900;\">IN+<\/span>:\u6b63\u5dee\u5206\u5206\u6d41\u7535\u538b\u3002\u8fde\u63a5\u5230\u5206\u6d41\u7535\u963b\u5668\u7684\u6b63\u4fa7\u3002<\/p>\n<p>INA220 \u901a\u8fc7\u6d4b\u91cf IN+ \u548c IN- \u4e4b\u95f4\u7684\u7535\u538b\u5dee\uff08\u5373\u5206\u6d41\u7535\u963b\u4e0a\u7684\u7535\u538b\u964d\uff09\u6765\u8ba1\u7b97\u7535\u6d41\u3002<br \/>\n\u7535\u6d41\u516c\u5f0f\uff1a<br \/>\nI = V_shunt \/ R_shunt<br \/>\n\u5176\u4e2d\uff1a<br \/>\nI \u662f\u7ecf\u8fc7\u5206\u6d41\u7535\u963b\u7684\u7535\u6d41\u3002<br \/>\nV_shunt \u662f IN+ \u548c IN- \u4e4b\u95f4\u7684\u7535\u538b\u5dee\u3002<br \/>\nR_shunt \u662f\u5206\u6d41\u7535\u963b\u7684\u963b\u503c\uff0c\u8fd9\u91cc\u6211\u7684\u7535\u963b\u7684\u963b\u503c\u662f<strong>5m\u03a9<\/strong>\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1525\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/12\/\u5c4f\u5e55\u622a\u56fe-2025-01-10-150124.png\" alt=\"\" width=\"1212\" height=\"613\" \/><\/p>\n<p>\u6709\u4e86\u8fd9\u4e9b\u4fe1\u606f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8fdb\u884c\u4ee3\u7801\u7684\u7f16\u5199\u4e86\uff0cINA220 \u7684\u603b\u7ebf\u7535\u538b\uff08Bus Voltage\uff09\u5bc4\u5b58\u5668\uff0c\u662f\u5b58\u50a8\u7740\u603b\u7ebf\u7535\u538b\u7684\u6beb\u4f0f\u503c\uff0c\u6211\u4eec\u53ef\u4ee5\u8fdb\u884c\u8bfb\u53d6\u8ba1\u7b97\uff1a<\/p>\n<p><strong>\u8bfb\u53d6\u603b\u7ebf\u7535\u538b<\/strong><\/p>\n<pre class=\"corepress-code-pre\"><code>u16 INA220_GetVoltage(void)\r\n{\r\n\tu16 temp=0;\r\n\tu8 buffer[2] = {0,0};\r\n\r\n\tHAL_I2C_Mem_Read(&amp;hi2c1,INA220_ADDR,BV_REG,I2C_MEMADD_SIZE_8BIT,&amp;buffer[0],2,100);\r\n\ttemp = buffer[0]&lt;&lt;8|buffer[1];\/\/\u8bfb\u53d6\u5230\u7684\u4e24\u4e2a8\u4f4d\u4e8c\u8fdb\u5236\u6570\u5408\u6210\u4e00\u4e2a16\u4f4d\u4e8c\u8fdb\u5236\u6570\r\n\ttemp &gt;&gt;= 3;\t\t\t\t\t\/\/\u53f3\u79fb\u4e09\u4f4d\u5bf9\u9f50\u6570\u636e\r\n\ttemp  *= 4;\t\t\t\t\t\/\/\u8ba1\u7b97\u51fa\u6beb\u4f0f\u7535\u538b\r\n\r\n\treturn temp;\r\n}<\/code><\/pre>\n<p>\u8bfb\u53d6 INA220 \u7684\u603b\u7ebf\u7535\u538b\uff08Bus Voltage\uff09\u5bc4\u5b58\u5668\u662f16\u4f4d\uff0c\u6240\u4ee5temp\u7684\u7c7b\u578b\u662fu16.<\/p>\n<p>\u603b\u7ebf\u7535\u538b\u5bc4\u5b58\u5668\u7684\u6700\u4f4e 3 \u4f4d\uff08D2-D0\uff09\u672a\u4f7f\u7528\uff0c\u4e3a 0\uff0c\u6240\u4ee5temp\u8981\u53f3\u79fb 3 \u4f4d\uff0c\u5c06\u6709\u6548\u6570\u636e\u5bf9\u9f50\uff0c\u4f7f\u5f97 <code>temp<\/code> \u7684\u6700\u4f4e\u4f4d\u5bf9\u9f50\u3002<\/p>\n<p>\u603b\u7ebf\u7535\u538b\u5bc4\u5b58\u5668\u7684\u6bcf\u4f4d\u8868\u793a 4 mV\uff0c\u6240\u4ee5temp\u9700\u8981\u4e58\u4ee54\u3002<\/p>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u8ba1\u7b97\u51fa\u603b\u7ebf\u7535\u538b\u7684\u6beb\u4f0f\u503c\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>\u7535\u8def\u4fdd\u62a4\u4e8c\u6781\u7ba1<\/h3>\n<p>ESD\u4e8c\u6781\u7ba1\uff08Electrostatic Discharge Diode\uff09\uff0c\u4e5f\u79f0\u4e3a\u9759\u7535\u4fdd\u62a4\u4e8c\u6781\u7ba1\uff0c\u5176\u4e3b\u8981\u4f5c\u7528\u662f\uff1a<\/p>\n<p>\u4fdd\u62a4\u7535\u8def\u514d\u53d7\u9759\u7535\u653e\u7535\uff08ESD\uff09\u7684\u635f\u5bb3\u3002\u5728USB\u63a5\u53e3\u7684\u70ed\u63d2\u62d4\u8fc7\u7a0b\u4e2d\uff0c\u5bb9\u6613\u4ea7\u751f\u9ad8\u7535\u538b\u7684\u9759\u7535\u653e\u7535\uff0c\u8fd9\u53ef\u80fd\u4f1a\u635f\u574f\u654f\u611f\u7684\u7535\u5b50\u5143\u5668\u4ef6\uff0c\u5c24\u5176\u662fUSB\u6570\u636e\u7ebf\uff08D+\u3001D-\uff09\u548c\u4e32\u53e3\u82af\u7247\uff08\u5982CH340K\uff09\u7684\u8f93\u5165\/\u8f93\u51fa\u5f15\u811a\u3002<br \/>\n\u5438\u6536\u5e76\u6cc4\u653eESD\u7535\u6d41\u3002\u5f53\u7535\u8def\u53d7\u5230ESD\u51b2\u51fb\u65f6\uff0cESD\u4e8c\u6781\u7ba1\u80fd\u591f\u8fc5\u901f\u5bfc\u901a\uff0c\u5c06\u8fc7\u7535\u538b\u548c\u8fc7\u7535\u6d41\u5f15\u5bfc\u81f3\u5730\uff08GND\uff09\uff0c\u4ece\u800c\u4fdd\u62a4\u540e\u7ea7\u7535\u8def\u3002<\/p>\n<h2>QC\u8bf1\u9a97<\/h2>\n<p>USB\u529f\u7387\u6d4b\u8bd5\u8fd8\u6709\u4e00\u4e2a\u7ed5\u4e0d\u5f00\u7684\u8bdd\u9898\uff0c\u90a3\u5c31\u662fQC\u8bf1\u9a97\uff0c\u4ec0\u4e48\u662fQC\u8bf1\u9a97\uff1f<\/p>\n<p>QC\u8bf1\u9a97\uff0c\u5373Quick Charge\uff08\u5feb\u901f\u5145\u7535\uff09\u534f\u8bae\u8bf1\u9a97\uff0c\u662f\u6307\u5229\u7528\u7279\u5b9a\u7684\u7535\u8def\u6216\u4ee3\u7801\u6a21\u62df\u8bbe\u5907\u4e0e\u5145\u7535\u5668\u4e4b\u95f4\u7684\u901a\u4fe1\uff0c\u4f7f\u5145\u7535\u5668\u8f93\u51fa\u9ad8\u4e8e\u6807\u51c6USB\u7535\u538b\uff085V\uff09\u7684\u7535\u538b\uff0c\u59829V\u300112V\u7b49\u3002\u5176\u539f\u7406\u662f\u901a\u8fc7\u5728USB\u63a5\u53e3\u7684D+\u548cD-\u6570\u636e\u7ebf\u4e0a\u65bd\u52a0\u7279\u5b9a\u7684\u7535\u538b\u6c34\u5e73\uff0c\u8bf1\u5bfc\u652f\u6301QC\u534f\u8bae\u7684\u5145\u7535\u5668\u8c03\u6574\u8f93\u51fa\u7535\u538b\u3002<\/p>\n<p>\u5728\u5236\u4f5cUSB\u529f\u7387\u6d4b\u8bd5\u5668\u6216\u5176\u4ed6\u9700\u8981\u6a21\u62dfQC\u534f\u8bae\u7684\u8bbe\u5907\u65f6\uff0c\u901a\u8fc7\u8bf1\u9a97\u5145\u7535\u5668\u8f93\u51fa\u4e0d\u540c\u7684\u7535\u538b\uff0c\u6d4b\u8bd5\u8bbe\u5907\u5728\u4e0d\u540c\u7535\u538b\u4e0b\u7684\u6027\u80fd\u3002<\/p>\n<p>\u5229\u7528STM32\u7684GPIO\u5f15\u811a\uff0c\u8bbe\u7f6e\u7279\u5b9a\u7684\u7535\u538b\u6c34\u5e73\uff0c\u5b9e\u73b0\u4e0eQC2.0\u548cQC3.0\u534f\u8bae\u517c\u5bb9\u7684\u901a\u4fe1\uff0c\u63a7\u5236\u5145\u7535\u5668\u8f93\u51fa\u7535\u538b\u3002<br \/>\n\u5de5\u4f5c\u539f\u7406\uff1a<br \/>\nQC2.0\uff1a\u901a\u8fc7\u7279\u5b9a\u7684\u7535\u538b\u7ec4\u5408\uff0c\u4e00\u6b21\u6027\u8bf7\u6c42\u5145\u7535\u5668\u8f93\u51fa\u6307\u5b9a\u7684\u7535\u538b\u3002<br \/>\nQC3.0\uff1a\u901a\u8fc7\u5728D+\u6216D-\u7ebf\u4e0a\u53d1\u9001\u8109\u51b2\uff0c\u9010\u6b65\u589e\u52a0\u6216\u51cf\u5c11\u8f93\u51fa\u7535\u538b\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u60f3\u8981\u5236\u4f5c\u4e00\u4e2aUSB\u6d4b\u529f\u7387\u7684\u4eea\u5668\uff0c\u9996\u5148\uff0c\u9700\u8981\u4e86\u89e3\u9700\u8981\u4ec0\u4e48\u4f20\u611f\u5668\uff0c\u7136\u540e\u6839\u636e\u81ea\u8eab\u7684\u9700\u6c42\uff0c\u6765\u5224\u65ad\u662f\u5426\u9700\u8981\u5236\u4f5cPC [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-1496","post","type-post","status-publish","format-standard","hentry","category-issue"],"_links":{"self":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/1496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/comments?post=1496"}],"version-history":[{"count":4,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/1496\/revisions"}],"predecessor-version":[{"id":1526,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/1496\/revisions\/1526"}],"wp:attachment":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/media?parent=1496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/categories?post=1496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/tags?post=1496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}