Documentos de Académico
Documentos de Profesional
Documentos de Cultura
FromEmbeddedSystemsLearningAcademy
Contents
1ProjectTitle
2Abstract
3Objectives&Introduction
3.1TeamMembers&Responsibilities
4Schedule
5PartsList&Cost
6Design&Implementation
6.1HardwareDesignandImplementation
6.2Descriptionofparts
6.3HardwareImplementationateachNODE
6.4SoftwareDesignandImplementation
7Testing&TechnicalChallenges
8Conclusion
8.1ProjectVideo
8.2ProjectSourceCode
9References
9.1Acknowledgement
9.2ReferencesUsed
ProjectTitle
DataAcquisitionusingCANbus
Abstract
OurprojectistoimplementahighspeeddataacquisitionsystemusingCANandperformtasksaccordingtothedatareceived.
OursystemwillcollectdatafromsensorsovermultiplenodesandtransmitthedataovertheCANbus.TheCANpacketsare
receivedbyasinglenodewhichwilldotherequiredfunctionalityasdesiredbytheapplication.TheLEDsatthereceivernode
simulatethefunctionswhichcabedoneusingthedataacquiredovertheCANbus.Thepurposeistogatherallthedata
simultaneouslyovertheCANbusandimplementhardwarefilteringtomanagethedatapacketsontheCANbus
Figure1showsthesystemblockdiagram:
Objectives&Introduction
TheobjectiveofthisprojecttoimplementCANbusandestablishcommunicationbetweendevices.Ourideaistouseuse6degree
offreedomMPU6050sensorasmotion/gesture,ultrasonicrangefinderHCSR04asobstacledetectorfordataharvestingand
sendingthesedataovertheCANbus.Specificmovement/rangewilltriggerpredefinedtasksandtransmitthecontroltodifferent
LEDs.Accordingtothedirectionoftheaccelerometeranditstiltmovement,aswellasultrasonicsensordistance,specific
applicationatthethirdnodewouldbedone.
TeamMembers&Responsibilities
ShwetaBohare
CanbusInterface
MradulaNayak
CanbusInterface
HengZhang
6DOFandUltrasonicsensors
AllTeam
FreeRTOSSoftwareDesign
3Donthecomputer
Schedule
Task
Ordersensors
Systemdesign
Actual
2/25
3/18
Completed.Otherpartsareordered.
3/18
3/26
SelfLooptestingofCANBus
Completed.
3/27
4/13
WriteonmicroSDSPImicroSDI/O
InitialwriteonSDcardisdone.
4/6
4/12
Interfacingultrasonicsensorwiththeboard.
Done
4/13
4/27
Accelerometerdatatransmissionbetween2Boards. Done
4/22
4/27
Communicationbetween3CANNodes
Done
4/28
5/5
Testingandremovebugs,furtherenhancements
Done
5/22
5/22
Demo
PartsList&Cost
</tr>
Parts
Cost
Comment
SJOneBoard[1](http://www.socialledge.com/sjsu/index.php?title=SJ_One_Board)
Each
boarduses
$80.00
for
x3
different
functions
GY521board(MPU6050)
$5.90
x1
6DOF
motion
sensor
$0.00 highspeed
TJA1049TK[2]
x4free CAN
(http://www.nxp.com/products/interface_and_connectivity/transceivers/can_transceivers/TJA1049TK.html)
samples transceiver
HCSR04[3](http://www.micropik.com/PDF/HCSR04.pdf)
$3.00 Ultrasonic
x1free ranging
samples module
TotalCost
$249.00
Keepit
low
Design&Implementation
HardwareDesignandImplementation
InourprojectweareusingthreenodestocommunicateoveraCANbus.TheCANControllerisembeddedontheSJONEboard
whichtransmitsthemicrocontrollerlogicsignalstoCANtransceiver.TheCANtransceiverisavoltageconverterwhichtransmits
thedataonCANbusbyconvertingitintoelectricalsignalsrequiredforCAN.TheCANtranceiverrequiresa5Vsupplyforits
working.HencewehavedesignedaPowerCircuittoprovide5VdctotheCANtransceiver.Intheproject,dataisacquiredfrom
twosensors,eachconnectedtoseparatenodes.WeareusingMPU6050whichisinterfacedwithNode1viaI2Cprotocol.
UltrasonicsensorHCSR04isconnectedtoNode2whichdetectsthedistanceofanobjectfromthesensor.Thereceivernode
getsthedatafromNode1andNode2anditsimulatesthedataontheLEDsconnected.
Descriptionofparts
PowerSupply:LM7805
AnLM7805linearregulatorICisusedforthispurpose.ItconvertsaDCinput
voltageofrange725Vtoastable+5V.Itrequiresjusttwoexternalcapacitorsandis
veryeasytouseTheinputDCvoltageforLM7805couldbeobtainedfroma9VDC
walladapterthatcansupply1Ampofloadcurrent.Weneedthe5voltsupplyforall
theexternalICshavebeenusedinthisprojectlikeMCP2551andMPU6050.The
followingschematicisgeneratethe5Voltregulatedpower.
PowersupplyCircuit
CANtransceiver:MCP2551
TheMCP2551isahighspeedCAN,faulttolerantdevicethatservesastheinterfacebetween
aCANprotocolcontrollerandthephysicalbus.TheMCP2551deviceprovidesdifferential
transmitandreceivecapabilityfortheCANprotocolcontroller,andisfullycompatiblewith
theISO11898standard,including24Vrequirements.Itwilloperateatspeedsofupto1
Mb/s.Itisusedforfollowingfunctions:
1.AsaTransmitter:ItoperatesintwostatesDominantandRecessive.Whendifferential
voltagebetweenCANHandCANLislessthan102Vitoperatedindominantmode,and
whenthevoltagedifferenceislessthan1.2voltitoperatesinRecessivemode.Theseboth
MCP2551
modesarecorrespondstotheTXDpin.
2.Maximumnodes:allowingamaximumof112nodestobeconnected.
3.ReceiverFunction:TheRXDoutputpinreflectsthedifferentialbusvoltagebetweenCANHandCANL.TheLowandHigh
statesoftheRXDoutputpincorrespondtotheDominantandRecessivestatesoftheCANbus,respectively.
4.Operations.Highspeedflowcontrolandstandby.HighSpeedmodeisselectedbyconnectingtheRSpintoVSS.Inthismode,
thetransmitteroutputdrivershavefastoutputriseandfalltimestosupporthighspeedCANbusrates.Theslope,orslewrate
(SR),iscontrolledbyconnectinganexternalresistor(REXT)betweenRSandVOL(usuallyground).Thedevicemaybeplaced
inStandbyorSLEEPmodebyapplyingahighleveltotheRSpin.
MCP2551(http://www.sparkfun.com/datasheets/DevTools/Arduino/MCP2551.pdf)
MPU6050
MotionSensor:MPU6050
TheMPU6050isamotionsensorthatcombinestwochips:theMPU6050,whichcontainsa3axis
gyroscope,3axisaccelerometerandanonboardDigitalMotionProcessor.Althoughthebuiltinprocessoris
integratedwith6axisMotionFusionalgorithms,suchasKalmannfilter,itisnotopensource.Asaresult,we
simplyuseMPU6050asa6DOFmotionsensorandrendershighresolution6DOFinformationstotheSJ
Oneboardforfurtherusage.WhendevelopingtheMPUdriver,werefertothesparkfungithubsite:(1.
https://github.com/sparkfun/MPU6050_Breakout2.http://www.botched.co.uk/pictutorials/mpu6050setup
dataaquisition/)aswellasthegivendriversinSJSUDevbyProfessorPreetpalKang.Itiscommunicate
withSJOneboardviaI2Cports.
UltrasonicSensor:HCSR04
TheUltrasonicRangingModuleHCSR04isalowpowersimplemodule,with4ports:VCC(5V),GND,Trig(input),
Echo(output).ItisconnectedtotheSJOneboardthroughGPIOpins,sinceitdoesn'thaveprotocols.Wheneverweneedto
measuretherange,wesupplyashort10usPulsetothetriggerinputtoinvokethissensorthenitwillsendout8cycleburstof
ultrasoundat40kHzsoastoreceiveitsecho.Theformulatocalculatethedistanceisthroughthetimeintervalsfromtrigger
signalsandtheechosignalsby:us/58=centimeters.
HardwareImplementationateachNODE
HCSR04
PininterfaceoneachNode
Node1
Onnode1,wehave
connectedMPU6050on
I2C2ofSJONEBoard.
CANtransceiveris
connectedonCAN1of
SJONEboard.A
terminatingresistorisalso
connectedtotheCAN
transceiverofNode1.
Node2
Onnode2,wehave
connectedHCSR04on
GPIOpinsP1.6andP1.7.
Ittransmitsthedistanceof
Node1
theobjectovertheCANbus.CANtransceiverwith
terminatingresistorisalsoconnectedonthisnode.
Node3
Onnode3,wehaveconnectedtheCANtransceiveronCAN1
ofSJONEboard.Wehaveconnected5LEDs,onefor
distancefromultrasonicsensoronNode2andother4LEDs
determinethetiltoftheobjectonNode1.
Node2
Node3
SoftwareDesignandImplementation
Inourproject,everynodehastocomputethedataandtransmititovertheCANbus.Forpropersynchronizationofthe
transmission,wehavedividedeachfunctionintotaskswhichcommunicateviaQueues.WehaveutilizedFreeRTOSAPIfor
managingthetasksandqueues.
Softwareimplementationisdoneusing:
1.CANdriver2.I2CdriverforMPU60503.Ultrasonicsensortrigerring
1.CANdriver
CANisahighspeeddatabusfordeterministiccommunication.Ittransmitsat100k,250k,500kand1Mbitspeeds.CANnodes
communicatebytransferringCANframesandeachnodehasaIDassociatedwithit.TheIDforeachnodeisdevelopedinthe
program.CANbusworksinthefollowingmodes:1.OFFMODE:Itdoesnotacceptanymessagefromanynode.2.BYPASS
MODE:Itacceptsallthemessagesthatitreceives.3.AcceptanceFiltering:Itacceptsonlythespecificmessagesoftheidstored
initsRAM.
Inourdesign,wehave2transmitternodesandonereceivernode.HencewehaveimplementedAcceptancefilteringatthe
receivernodetoacknowledgethemessagesofthetransmitternodes.ThetransmittingnodesareinOFFmode,asitneednot
receiveanymessagesfromtheothertransmitternode.
FLOWDIAGRAMSEXPLAININGTRANSMITTERANDRECEIVERFLOWDIAGRAM
Cantransmitterdriver
Canreceiverdriver
2.I2CdriverforMPU6050
Atnode1,theI2CdriveriswrittentointerfacewithMPU6050.ThedeviceaddressofMPU6050is0x69.TheI2Cstatemachine
goesthroughdifferentdtagestoreadfromdatafromMPU6050.TheconfigurationresistorsofMPU6050isfirstset.Sincewe
areonlyreadingaccelerometervalues,weareonlyreadingthe16bitregistersofX,Y,Zaxis.
TheTasksatNode1areperformingthefunctionsinthefollowingmanner:
Node1
3.Ultrasonicsensortrigerring
Atnode2,wearegettingthedistanceoftheobjectfromthenodeusinganultrasonicsensor.Anultrasonicburstistriggeredusing
aTriggerpinonthesensormodule.Thereceiverpartofthesensorthenlistensfortheechoreturnpulse.AnEchopinonthe
sensorremainsatHIGHvoltagelevelduringthetimeandthedistanceoftheobjectcanbecalculatedfromthisduration.Distance
oftheobjectiscalculatedusingtheformula:Distance=((Timetaken)*340m/s)/
ThetasksatNode2areperformedasfollows:
Node2
Atnode3,thereareLEDswhichworkaccordingtothedatasentoverfromthetwonodes.Thetasksaredistributedasfollows:
Node3
Testing&TechnicalChallenges
Hardwareissues
1.Duringselfloop,werecognizedthattherehastobea1KresistorattheRspinoftransceiverwhichhastobeconnectedto
ground.
2.Designingofpowersupplytookalotoftime.Wedesignedaseparatepowersupplytoprovidecontinuous5Vsupply.
3.Duetoimproperconnectionsoftransceiverandpowersupply,theCANtransceiverICwasburntandwehadtoreplaceitmany
times.
Softwareissues
1.ThemoderegisterofCANwasnotgettingwrittenbecauseoferrorinclockset.Wesettheclocksourceto2insys_config.h.
2.TheCMRregisterwasnotsetduringselfloop,becauseofwhichtheCANtransmissionhadnotstarted.
3.ThedatasentfromthesensorshadtobesenttoCANcontrollerandatthereceivernodepropertimingdelayhadtobeputto
processthedatafromtwonodes.
4.Hardwarefilteringdidn'tworkforalotoftimeduetoaerrorintheCANdriver.Wehavewrittenaseparatepieceofcodetoset
thehardwarefiltering.
5.ReadingserialdatafromSJONEboardtoplotonMATLABorprocessingsoftwarewasnotsuccessfulsincetheboardwas
gettingresetoncetheportwasopened.
Conclusion
TheaimoftheprojectwasimplementationofCANcontrollerandwewereabletoachievethat.However,wecouldnotdothe
GUItoshowthedatareceivedonthereceivernode.ButwedefinitelylearntvariousplatformsonwhichGUIcanbedone.The
projecthashelpeduslearnaboutthedriverofCANbus.
ProjectVideo
https://www.youtube.com/watch?v=P1lKocL61o
ProjectSourceCode
Sourceforgesourcecodelink(https://sourceforge.net/projects/sjsu/files/CmpE244_SJSU_S2014/)
References
Acknowledgement
WewouldliketoexpressourheartfeltgratitudetoProf.PreetpalKangwhogaveusanopportunitytodothisprojectonthetopic
(DataAcquisitionusingCANbus)whichenhancedourunderstandingofCANbusanditsprotocolaswellasprovidedus
knowledgeaboutdifferentsensors.
Secondlywewouldalsoliketothankourclassmateswhohelpedusalotintheapplicationofthisprojectwithinthelimitedtime
frame.
ReferencesUsed
1.http://users.ece.utexas.edu/~valvano/Datasheets/MCP2551.pdf
2.http://www.micropik.com/PDF/HCSR04.pdf
3.http://www.invensense.com/mems/gyro/documents/PSMPU6000A00v3.4.pdf
4.http://www.socialledge.com/sjsu/index.php?title=SJ_One_Board
Retrievedfrom"http://www.socialledge.com/sjsu/index.php?title=S14:_Data_Acquisition_using_CAN_bus&oldid=9497"
Thispagewaslastmodifiedon6August2014,at16:40.
Thispagehasbeenaccessed1,532times.
ContentisavailableunderPublicDomain.