0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

raspi can module 第参の挑戦

Posted at

1. canbus module

raspberry pi で can を接続するばあい、
canbus module は arduino shield を流用する方法があります。
aliexpress などで、 MCP2515 CAN Bus Module TJA1050 .. 検索できます。

2. 問題点

arduino shield は多くが信号レベル5Vで接続することになりますが、raspberry pi のP1端子の信号レベルは3.3Vでなければなりません。
raspberry pi と MCP2515 CAN Bus Moduleとの接続の記事をさがすと、
TJA1050 のVCC端子を持ち上げて、5Vを接続
MCP2515 のVCC端子には 3.3vを接続と苦労しています。

3. 正解なのか

今回は5Vのみで動作するTJA1050の代わりに、機能的に同等な3.3V動作可能なMAX3051を利用します。
phy.png
U1 TJA0150 を MAX3051 に半ゴテで交換します。
replace.png

4. 動作例

4.1接続表

P1-J4.png

4.2 /boot/config.txt を編集

以下を追加
dtparam=spi=on dtoverlay=spi-bcm2835-overlay dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
interrupt=12 はGPIO12 を利用する場合です。

4.3 接続

pi@pi-desktop:~$ dmesg|grep spi [ 4.334544] mcp251x spi0.0 can0: MCP2515 successfully initialized. pi@pi-desktop:~$ sudo ip link set can0 type can bitrate 500000 pi@pi-desktop:~$ sudo ifconfig can0 up pi@pi-desktop:~$ candump -cae -t z can0,0:0,#FFFFFFFF (000.000000) can0 7F0 [3] 12 03 04 '...' (015.631918) can0 7F0 [5] 12 34 56 78 90 '.4Vx.' pi@pi-desktop:~$

以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?