Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775
{"id":1094,"date":"2021-06-11T23:41:31","date_gmt":"2021-06-11T14:41:31","guid":{"rendered":"https:\/\/craft-gogo.com\/?p=1094"},"modified":"2024-03-17T12:53:55","modified_gmt":"2024-03-17T03:53:55","slug":"raspberrypi-adconverter","status":"publish","type":"post","link":"https:\/\/craft-gogo.com\/raspberrypi-adconverter\/","title":{"rendered":"\u3010Raspberry Pi\u3011A\/D\u30b3\u30f3\u30d0\u30fc\u30bf MCP3208\u3092\u4f7f\u3063\u3066\u30a2\u30ca\u30ed\u30b0\u8a08\u6e2c"},"content":{"rendered":"\n

Raspberry Pi\u3092\u7528\u3044\u305f\u30c7\u30d0\u30a4\u30b9\u5236\u5fa1\u306b\u306f\u3001\u6e29\u5ea6\u30bb\u30f3\u30b5\u30fc\u3084\u8ddd\u96e2\u30bb\u30f3\u30b5\u30fc\u306a\u3069\u3067\u5468\u8fba\u74b0\u5883\u3092\u691c\u77e5\u3059\u308b\u3053\u3068\u304c\u5fc5\u9808\u3067\u3059\u3002\u3067\u3082\u3001Raspberry Pi\u306b\u306fA\/D\u30b3\u30f3\u30d0\u30fc\u30bf\u304c\u5099\u308f\u3063\u3066\u3044\u306a\u3044\u3093\u3067\u3059…\u3002<\/p>\n\n\n\n

\u672c\u8a18\u4e8b\u3067\u306f\u3001Raspberry Pi\u3068A\/D\u30b3\u30f3\u30d0\u30fc\u30bfMCP3208\u3092\u63a5\u7d9a\u3057\u3066\u3001\u30bb\u30f3\u30b5\u5024\u3092\u8aad\u307f\u53d6\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\t\t

\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\"\"\t\t\t\t\t<\/a>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\u30e9\u30ba\u30d1\u30a44\u5bfe\u5fdc\u3000\u30ab\u30e9\u30fc\u56f3\u89e3\u3000\u6700\u65b0\u3000Raspberry\u3000Pi\u3067\u5b66\u3076\u96fb\u5b50\u5de5\u4f5c\u3000\u4f5c\u308b\u3001\u52d5\u304b\u3059\u3001\u3057\u304f\u307f\u304c\u308f\u304b\u308b\uff01 \uff08\u30d6\u30eb\u30fc\u30d0\u30c3\u30af\u30b9\uff09 [ \u91d1\u4e38 \u9686\u5fd7 ]\t\t\t\t\t<\/a>\n\t\t\t\t<\/div>\n\n\t\t\t\t\t\t\t\t\t
\u697d\u5929\u30d6\u30c3\u30af\u30b9<\/div>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\u00a51,650\t\t\t\t\t\t\uff082024\/12\/18 10:46\u6642\u70b9 | \u697d\u5929\u5e02\u5834\u8abf\u3079\uff09<\/span>\n\t\t\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\tAmazon\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t<\/div>\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\u697d\u5929\u5e02\u5834\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\"\"\n\t\t\t\t\t\u30dd\u30c1\u30c3\u30d7<\/span>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\n\n\n

Raspberry Pi\u3067\u30a2\u30ca\u30ed\u30b0\u8a08\u6e2c\u3059\u308b\u306b\u306fA\/D\u30b3\u30f3\u30d0\u30fc\u30bf\u304c\u5fc5\u8981<\/h2>\n\n\n\n

Raspberry Pi\u306fArduino\u3068\u306f\u7570\u306a\u308a\u3001A\/D\u30b3\u30f3\u30d0\u30fc\u30bf\u304c\u642d\u8f09\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u305d\u306e\u305f\u3081\u3001Raspberry Pi\u3067\u30a2\u30ca\u30ed\u30b0\u8a08\u6e2c\u3059\u308b\u306b\u306f\u3001A\/D\u30b3\u30f3\u30d0\u30fc\u30bf\u3092\u5225\u9014\u7528\u610f\u3057\u306a\u304f\u3066\u306f\u306a\u308a\u307e\u305b\u3093\u3002<\/span><\/strong><\/p>\n\n\n\n

\u672c\u8a18\u4e8b\u3067\u306f\u3001Microchip Technology\u793e\u306eMCP3208\u3068\u3044\u3046A\/D\u30b3\u30f3\u30d0\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

MCP3208\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306fSPI<\/span><\/strong>\u3068\u3044\u3046\u898f\u683c\u304c\u63a1\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001Raspberry Pi\u3068MCP3208\u306fSPI\u63a5\u7d9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

A\/D\u30b3\u30f3\u30d0\u30fc\u30bf MCP3208\u306e\u4ed5\u69d8<\/h3>\n\n\n\n

MCP3208\u306f12bit\u306eA\/D\u30b3\u30f3\u30d0\u30fc\u30bf<\/span><\/strong>\u3067\u3059\u3002<\/p>\n\n\n\n

12bit = 4096\u523b\u307f\u3067\u30a2\u30ca\u30ed\u30b0\u5024\u3092\u691c\u51fa\u51fa\u6765\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n\n\n\n

\u307e\u305f\u3001MCP3208\u306f8\u3064\u306e\u30a2\u30ca\u30ed\u30b0\u5165\u529b\u4fe1\u53f7\u3092\u8aad\u307f\u53d6\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002\u59c9\u59b9\u54c1\u3068\u3057\u3066MCP3204\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u3061\u3089\u306f\u30a2\u30ca\u30ed\u30b0\u5165\u529b\u4fe1\u53f7\u304c4\u3064\u307e\u3067\u306b\u9650\u3089\u308c\u308b\u3053\u3068\u4ee5\u5916\u3001\u4ed5\u69d8\u306f\u540c\u3058\u3067\u3059\u3002<\/p>\n\n\n\n

Raspberry Pi\u3068A\/D\u30b3\u30f3\u30d0\u30fc\u30bf\u3092SPI\u901a\u4fe1\u3059\u308b<\/h3>\n\n\n\n

SPI\u306fSerial Peripheral Interface<\/span><\/strong>\u306e\u7565\u3067\u30de\u30a4\u30b3\u30f3\u3068\u5468\u8fbaIC\u9593\u3092\u63a5\u7d9a\u3059\u308b\u30d0\u30b9\u3067\u3059\u3002<\/p>\n\n\n\n

Raspberry Pi\u3068MCP3208\u306b\u306fSPI\u304c\u5099\u308f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n

\u4e21\u8005SPI\u3092\u63a5\u7d9a\u3057\u901a\u4fe1\u3059\u308b\u3053\u3068\u3067\u3001MCP3208\u3067\u8aad\u307f\u53d6\u3063\u305f\u5024\u3092Raspberry Pi\u304c\u8a8d\u8b58\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n\n\n\n

SPI\u901a\u4fe1\u3059\u308b\u305f\u3081\u306espidev\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u4f7f\u3044\u65b9<\/h2>\n\n\n\n

MCP3208\u304c\u8a08\u6e2c\u3057\u305f\u30a2\u30ca\u30ed\u30b0\u5024\u3092Raspberry Pi\u3078\u9001\u4fe1\u3057\u3066\u3082\u3089\u3046\u306e\u306b\u3001\u6c7a\u307e\u3063\u305f\u901a\u4fe1\u3084\u308a\u3068\u308a\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n

\u30c7\u30fc\u30bf\u30b7\u30fc\u30c8\u3092\u898b\u306a\u304c\u3089\u3001\u81ea\u5206\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u304c\u3001\u7d50\u69cb\u5927\u5909\u3067\u3059\u3002<\/p>\n\n\n\n

spidev\u3068\u3044\u3046API<\/span><\/strong>\u304c\u3042\u308b\u306e\u3067\u3001\u4eca\u56de\u306fspidev\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n

SpiDev\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u751f\u6210<\/h3>\n\n\n\n
spi = spidev.SpiDev()<\/code><\/pre><\/div>\n\n\n\n

\u30af\u30e9\u30b9\u5185\u306e\u95a2\u6570\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306bSpiDev\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

MCP3208\u3068\u306e\u63a5\u7d9a<\/h3>\n\n\n\n
spi.open(port,cs)<\/code><\/pre><\/div>\n\n\n\n

spi.open()\u3067MCP3208\u3068\u306e\u901a\u4fe1\u3092\u958b\u59cb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

\u7b2c1\u5f15\u6570\u306eport\u306f\u30012\u7cfb\u7d71\u3042\u308bSPI\u306e\u5185\u3069\u3061\u3089\u3092\u4f7f\u7528\u3059\u308b\u304b\u9078\u629e\u3057\u307e\u3059\u3002SPI0\u306a\u30890\u3001SPI1\u306a\u30891\u306e\u6570\u5024\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

\u7b2c2\u5f15\u6570\u306ecs\u306f\u3001\u3069\u306e\u30c7\u30d0\u30a4\u30b9\u3068\u901a\u4fe1\u3059\u308b\u304b\u3067\u3059\u3002MCP3208\u304cCE0\u3068\u63a5\u7d9a\u3055\u308c\u3066\u3044\u308b\u306a\u30890\u3001CE\u306a\u30891\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

\u901a\u4fe1\u5468\u671f\u306e\u8a2d\u5b9a<\/h3>\n\n\n\n
spi.max_speed_hz = 1000000 # 1MHz<\/code><\/pre><\/div>\n\n\n\n

spi.max_speed_hz\u306b\u901a\u4fe1\u5468\u6ce2\u6570\u3092\u4ee3\u5165\u3059\u308b\u3068\u3001\u305d\u306e\u5468\u6ce2\u6570\u3067\u901a\u4fe1\u3057\u307e\u3059\u3002\u901a\u4fe1\u5468\u6ce2\u6570\u306e\u9006\u6570\u304c\u901a\u4fe1\u5468\u671f\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n

\u30c7\u30fc\u30bf\u8ee2\u9001<\/h3>\n\n\n\n
xfer2(list of values)<\/code><\/pre><\/div>\n\n\n\n

\u95a2\u6570xfer2\u3067\u5f15\u6570\u306e\u5024\u3092MCP3208\u3078\u8ee2\u9001\u3057\u307e\u3059\u3002<\/p>\n\n\n

\n
\n
\"\"<\/figure>\n<\/div>\n
\n

MCP3208\u304c\u30a2\u30ca\u30ed\u30b0\u8a08\u6e2c\u3057\u305f\u5024\u3092Raspberry Pi\u306b\u8ee2\u9001\u3057\u3066\u3082\u3089\u3046\u306b\u306f\u3001Raspberry Pi\u304b\u3089\u3069\u3093\u306a\u30c7\u30fc\u30bf\u3092\u8ee2\u9001\u3059\u308c\u3070\u3088\u3044\u306e\uff1f<\/p>\n<\/div>\n<\/div>\n\n\n

MCP3208\u306e\u30c7\u30fc\u30bf\u30b7\u30fc\u30c8<\/a>\u306b\u3088\u308b\u3068\u30011\u56de\u306e\u901a\u4fe1\u30678bit(1byte)\u00d73\u306e\u30c7\u30fc\u30bf\u8ee2\u9001\u304c\u5fc5\u8981\u3067\u3059<\/span><\/strong>\u3002Raspberry Pi\u304b\u3089\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8ee2\u9001\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

1byte\u76ee<\/p>\n\n\n\n

0<\/td>0<\/td>0<\/td>0<\/td>0<\/td>1
(start bit)<\/td>
SGL\/
DIFF<\/td>
D2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

2byte\u76ee<\/p>\n\n\n\n

D1<\/td>D0<\/td>X<\/td>X<\/td>X<\/td>X<\/td>X<\/td>X<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

3byte\u76ee<\/p>\n\n\n\n

X<\/td>X<\/td>X<\/td>X<\/td>X<\/td>X<\/td>X<\/td>X<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u8aac\u660e\u306b\u3042\u305f\u308a\u3001\u30c1\u30e3\u30f3\u30cd\u30eb0\u3067\u30a2\u30ca\u30ed\u30b0\u8a08\u6e2c\u3059\u308b\u3053\u3068\u3068\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

\u300cSGL\/DIFF\u300d\u306f\u30011(SGL): \u7d76\u5bfe\u5024\u8a08\u6e2c\u304b\u30010(DIFF): \u30c1\u30e3\u30f3\u30cd\u30eb\u9593\u306e\u5dee\u5206\u5024\u8a08\u6e2c\u304b\u306e\u9078\u629e\u3067\u3059\u3002\u7d76\u5bfe\u5024\u3067\u8a08\u6e2c\u3057\u305f\u3044\u306e\u30671\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

\u7d76\u5bfe\u5024\u8a08\u6e2c\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u30013bit\u30c7\u30fc\u30bf \u300cD2\/D1\/D0\u300d\u306f\u30c1\u30e3\u30f3\u30cd\u30ebNo.\u306e\u6307\u5b9a\u3067\u3059\u3002 \u30c1\u30e3\u30f3\u30cd\u30ebNo.\u6307\u5b9a\u65b9\u6cd5\u306f\u3001\u30c1\u30e3\u30f3\u30cd\u30ebNo. = 4\u00d7D2 + 2\u00d7D1 + D0 \u3068\u306a\u308a\u307e\u3059\u3002\u30a2\u30ca\u30ed\u30b0\u8a08\u6e2c\u3059\u308b\u30c1\u30e3\u30f3\u30cd\u30ebNo.\u306f0\u3067\u3059\u306e\u3067\u3001D2=0\u3001D1=0\u3001D0=0\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

\u300cX\u300d\u306e\u5024\u306f\u554f\u308f\u308c\u307e\u305b\u3093\u306e\u3067\u30010\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

\u4ee5\u4e0a\u307e\u3068\u3081\u308b\u3068\u3001Raspberry Pi\u304b\u3089MCP3208\u3078\u306e\u8ee2\u9001\u30c7\u30fc\u30bf\u306f\u30012\u9032\u6570\u8868\u8a18\u30670b00000110\u30010b00000000\u30010b00000000\u300116\u9032\u6570\u8868\u8a18\u30670x06\u30010x00\u30010x00\u3068\u306a\u308a\u307e\u3059\u3002<\/span><\/strong><\/p>\n\n\n\n

Raspberry Pi\u3067\u30a2\u30ca\u30ed\u30b0\u8a08\u6e2c\u3057\u3066\u307f\u308b<\/h2>\n\n\n\n

\u6e96\u5099\u3057\u305f\u3082\u306e<\/h3>\n\n\n\n