PiCAN2 DUO SMPS USER GUIDE - copperhilltech.com
Transcript of PiCAN2 DUO SMPS USER GUIDE - copperhilltech.com
PiCAN2 DUO SMPS Rev D V1.4
SK Pang Electronics Ltd Ó 2021 www.skpang.co.uk
1
Product name PiCAN2 DUO 3A SMPS CAN-Bus Board for Raspberry Pi
Model number RSP-PICAN2DUOSMPS
Manufacturer SK Pang Electronics Ltd
PiCAN2 DUO SMPS USER GUIDE
V1.4
PiCAN2 DUO SMPS Rev D V1.4
SK Pang Electronics Ltd Ó 2021 www.skpang.co.uk
2
Contents
Table of Contents
1. Introduction ........................................................................................................... 31.1. Features.............................................................................................................................................................31.2. HardwareInstallation.................................................................................................................................31.3. ScrewTerminal..............................................................................................................................................41.4. 120WTerminator..........................................................................................................................................41.5. LED.......................................................................................................................................................................41.6. NotFittedItems.............................................................................................................................................42. Software Installation .............................................................................................. 41.7. BringUptheInterface.................................................................................................................................61.8. InstallingCANUtils.......................................................................................................................................63. Writing Your Own Software .................................................................................... 71.9. ApplicationinPython..................................................................................................................................71.10. ApplicationinC..............................................................................................................................................8
PiCAN2 DUO SMPS Rev D V1.4
SK Pang Electronics Ltd Ó 2021 www.skpang.co.uk
3
1. Introduction ThisPiCAN2DUOboardprovidetwoindependentCAN-BuschannelsfortheRaspberryPi4.ItusestheMicrochipMCP2515CANcontrollerwithMCP2551CANtransceiver.Connectionsaremadeviaplugin4wayscrewterminal.Thisboardhasa5v3ASMPSthatcanpowerthePiiswellviathescrewterminal.
EasytoinstallSocketCANdriver.ProgrammingcanbedoneinCorPython.
1.1. Features • CANv2.0Bat1Mb/s• HighspeedSPIInterface(10MHz)• Standardandextendeddataandremoteframes• CANconnectionviascrewterminal• 120Ωterminatorready• SerialLCDready• LEDindicator• Fourfixingholes,complywithPiHatstandard• SocketCANdriver,appearsascan0andcan1toapplication• InterruptRXonGPIO25andGPIO24• 5v3ASMPStopowerRaspberryPiandaccessoriesfromscrewterminal
o Reversepolarityprotectiono Highefficiencyswitchmodedesigno 7vto24vinputrange
1.2. Hardware Installation BeforeinstallingtheboardmakesuretheRaspberryisswitchedoff.Carefullyalignthe40wayconnectorontopofthePi.Usespacerandscrew(optionalitems)tosecuretheboard.
PiCAN2 DUO SMPS Rev D V1.4
SK Pang Electronics Ltd Ó 2021 www.skpang.co.uk
4
1.3. Screw Terminal TheCANconnectioncanalsobemadeviathe4wayscrewterminal.
ConnectorJ3pin4istheinputfortheSMPS,ithasaninputvoltagerangeof6vto20vthatisusedtopowertheRaspberryPi.
1.4. 120W Terminator Thereisa120Wfittedtotheboard.Tousetheterminatorsoldera2wayheaderpintoJP1andJP2theninsertajumper.
1.5. LED TherearetworedLEDsfittedtotheboard.ThisisconnectedtoGPIO04andGPIO26.
1.6. Not Fitted Items JP5canbeusetopoweraserialLCDwithdataonTXDlinefromthePi.Thereisalso5vsupplyonJP5.
2. Software Installation ItisbesttostartwithabrandnewRaspbianimage.Downloadthelatestfrom:
https://www.raspberrypi.org/downloads/raspbian/
CANA(J3)Pinnumber Function1 CAN_L2 CAN_H3 GND4 +12vIn
CANB(J4)Pinnumber Function1 CAN_L2 CAN_H3 GND4 n/c
PiCAN2 DUO SMPS Rev D V1.4
SK Pang Electronics Ltd Ó 2021 www.skpang.co.uk
5
Afterfirsttimebootup,doanupdateandupgradefirst.
sudo apt-get update
sudo apt-get upgrade
sudo reboot
Addtheoverlaysby:
sudo nano /boot/config.txt
Addthese4linestotheendoffile:
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=24
dtoverlay=spi-bcm2835-overlay
RebootPi:
sudo reboot
PiCAN2 DUO SMPS Rev D V1.4
SK Pang Electronics Ltd Ó 2021 www.skpang.co.uk
6
1.7. Bring Up the Interface YoucannowbringtheCANinterfacesup:
sudo /sbin/ip link set can0 up type can bitrate 500000
sudo /sbin/ip link set can1 up type can bitrate 500000
1.8. Installing CAN Utils InstalltheCANutilsby:
sudo apt-get install can-utils
ConnectthePiCAN2DuotoyourCANnetworkviascrewterminal.
TosendaCANmessageoncan0(CANBJ4)use:
cansend can0 7DF#0201050000000000
ThiswillsendaCANIDof7DF.Data020105–coolanttemperaturerequest.
TosendaCANmessageoncan1(CANAJ3)use:
cansend can1 7DF#0201050000000000
ConnectthePiCANDuotoaCAN-busnetworkandmonitortrafficbyusingcommand:
candump can0
Youshouldseesomethinglikethis:
PiCAN2 DUO SMPS Rev D V1.4
SK Pang Electronics Ltd Ó 2021 www.skpang.co.uk
7
3. Writing Your Own Software YoucanwriteyourownapplicationsoftwareineitherCorPython.
1.9. Application in Python DownloadthePython-CANfilesfrom:
https://github.com/hardbyte/python-can/releases/tag/3.2.0
UnzipandcopyovertothePi.
sudo python3 setup.py install
BringtheCANinterfaceupifitisnotalreadydone:
sudo /sbin/ip link set can0 up type can bitrate 500000
Nowstartpython3
python3
Tosentamessageouttypethefollowinglines:
import can
bus = can.interface.Bus(channel='can0', bustype='socketcan_native')
msg = can.Message(arbitration_id=0x7de,
data=[0, 25, 0, 1, 3, 1, 4, 1],
extended_id=False)
bus.send(msg)
PiCAN2 DUO SMPS Rev D V1.4
SK Pang Electronics Ltd Ó 2021 www.skpang.co.uk
8
Toreceivedmessagesanddisplayonscreentype:
notifier = can.Notifier(bus, [can.Printer()])
1.10. Application in C BringtheCANinterfaceupifitisnotalreadydone:
sudo /sbin/ip link set can0 up type can bitrate 500000
Downloadthesourcecodeandexamplefilesbytypingthefollowinginthecommandprompt:
wget http://skpang.co.uk/dl/cantest.tar
Unpackthetarfileandchangeintodirectoryby:
tar xf cantest.tar cd linux-can-utils
Theexamplefileiscalledcantest.ctoeditthisfile,typethefollowinginthecommandprompt:
nano cantest.c
Line77istheCANmessagetobesentout.
unsigned char buff[] = "7DF#0201050000000000";
7DFisthemessageIDand0201050000000000isthedata.Changethedatatosuit.PressCTRL-Xtoexit.Tocompiletheprogramtype:
make
Checktherearenoerrors.Toruntheprogramtype:
./cantest