Breaking

Wednesday, January 8, 2020

Tesla CAN bus data logging-----make money online

Tesla CAN bus data logging-----make money online
today on Applied Science I thought we'd
talk about extracting information from a
modern cars data bus so we are sitting
in a new Tesla Model S on this rainy day
and I thought I'd talk about what I've
learned and how I plan to build a system
that will show the data on the cars
existing console it's pretty normal of
course for a car to show you the speed
it's going on the dashboard speedometer
but there's actually hundreds of other
variables that are commonly sent through
a car's data bus and some of them can be
pretty interesting so for example motor
torque in this car since it's electric
you can see the number of amps being
pulled out of the battery pack and
literally on and on so here if you know
something about car buses you may have
heard this term ODB 2 and this is a
somewhat standardized port that was
created mostly for emissions control
hardware and the Tesla has an ODB 2 port
in the drivers footwell but since this
car doesn't have an internal combustion
engine
there's no emissions equipment and so
there's really not much on that bus so
avoid that what you really want to do is
check out these two connectors that are
beneath the center console here there's
a little cubby hole that you can just
pull off there's two clips that just
snap down and it Tibbets in the back
just pull that off and then the smaller
connector is a four pin connector and
this is actually Ethernet so a couple
years ago when the Model S first came
out someone connected to this and
realized it was Ethernet and started
poking around in the cars private
network and then a couple months later
Tesla issued a firmware update and shut
this port off so what they did was they
disabled this at the cars Ethernet
switch so if you still want to get on
the card's Ethernet what you can do is
find the wires the Ethernet wire is
going to this center console computer
and input your own switch in there
basically tap into it and you can still
smooth the ethernet if you want but
we're not going to talk about that in
today's video what I'm most interested
in is this other connector which is a
can bus connector Tesla calls this a
diagnostic connector and there's
actually several can bus buses on here
if you haven't heard the term before
CANbus is used in the automotive
industry and it's more real time so
Ethernet might be good at sending
something like a an audio stream that
you're going to play on the the cars
sound system whereas the can bus is
actually carrying the low-level signals
that are connected to things like the
accelerator pedal the motor controller
indicating how much current it's using
and that sort of thing I spend quite a
bit of time piecing together all the
information needed to get this going and
I'll put all of it in the description of
this video feel free to ask me any
questions that there's actually not that
much information out there like for
example this connector is not a very
standard connector in fact if you can't
get this a digit key or mouser or
anything like that but after hunting
around on the Tesla Motor Club forum for
many many hours I found a seller who
actually has these connectors but thank
you very much for finding these and
making them available to hobbyists as I
mentioned this car has several different
can buses and currently we're going to
talk about canvas 3 which is the one
that carries drivetrain information so
motor power battery power accelerator
pedal position all that sort of stuff
and you can see currently the scope is
looking at what's going on on this
canvas canvas 3 and you can see a very
high rate of data going even though
we're just sitting here two cars
basically idling okay here's a closer
look at the scope and as you can see
there's a lot of data going by on the
bus here and this scope can decode all
the can bus information so if I turn bus
one on we set that up as a can bus and
the bitrate is 500k per second and it
can bus is in fact a differential
protocol it's two wires plus and minus
and normally the wire 0 is driven
differentially but interestingly on this
scope you only need to the sample one
half of the Lion
I guess it's good enough and so we can
do a single acquisition and you can see
there's data going by and so to make
this a little more interesting what we
can also do is set up the scope
that it triggers only on a specific
packet type so we'll go to the trigger
menu and instead of just triggering on
the edge of the waveform will trigger on
the bus and if this is b1 the can bus
and we're going to trigger on the
identifier so the identifier in a can
bus packet describes sort of which part
of the car it pertains to so I've
already set it up so that it's going to
trigger on a densifier hex 1:06 and this
is one of the drivetrain components I
think it might actually be the rear
motor controller what I'm going to do is
step on the gas that are the accelerator
pedal of the car and what you can see is
that this value changes well as I step
on the Tuttle the car is beeping because
it tells me I have to put it in Drive if
I want to go somewhere these other ones
are zero because we're not moving this
would be describing a motor torque I
think as you can see if I floor it this
goes to si so that's a maximum pedal
position and it's zero of course when my
foot is not on it another really useful
thing we can do with this scope is
capture a large quantity of data so if
we put the trigger type back to just
edge and I'm going to stop the
acquisition here and I'm going to change
the record length to a really high value
so when the scope was running really
quickly like that we're restoring a
hundred thousand data points and having
it just show this little section but
let's say we wanted to capture like 10
seconds worth of canned data to do
further analysis we can do that too and
it's all set
the Scopes memory to be 20 million
points and then I'm going to change the
time per division to be a much higher
value like 1 second so this should be 10
seconds worth of data so I'm going to
press the single button and this scope
doesn't show you in real time but
actually it is computing there it is
recording right now and so it's probably
it's been about 5 seconds since I
pressed it there's all the data and
what's happening is it says B 1 not yet
computed so in another few seconds it's
going to go through and figure out
all of the canvas messages for the
stream and there they are so if we
wanted to see them what we can do is go
to b1 this bus that we're decoding and
then go to the event table and this is a
list of all the messages that came in
during that 10-second acquisition and
hopefully it even shows what time the
message came in so minus 5 seconds I
have the trigger point set here and the
whole acquisition was 10 seconds so
minus 5 would be you know the first
thing that it saw and here's that
identifier column that I was mentioning
so if we scroll down through this list
of data there's the 106 and you can see
it was 0-0 if I have my foot on the
pedal this would be a different value
here so it's neat is that I can say I
can save this event table and it's not
highlighted right now because they don't
have a USB key plugged in but what I was
doing was collecting lots of data while
driving with a USB key in here I could
hit single really quickly and then go
collect some data and then after he
decoded all the canvas stuff I could say
a save table and it would save a CSV
file to the USB key then it can take the
USB key back to my computer and plot it
in Excel and I ended up with something
like this okay I know it's dark but
that's a quite a bit longer than I
expected I'll do another video in the
future with better lighting let me tell
you what's going on here I've got a
Raspberry Pi 3 and this I bought this
from copper Hill technologies and it
comes with a canvas shield so this is
connected directly to the car and it
even has a 12-volt decidable buck
converter so it's literally just four
wires connected to the car and
originally I was thinking well you know
I'll make another screen or something in
here kind of like this an extra LCD to
show the data that I've been vlogging
but really it's kind of annoying to
mount another screen and I've got this
huge 17 inch touchscreen built into the
cars - already so I started thinking
about ways that I could get the data
from the canvas onto the screen here now
Tesla house is pretty well locked down
however there is a web browser built
into it
and I started looking at ways that I
could get the canvas data from the
Raspberry Pi into the web browser and
this browser is WebSockets compatible
which means that I have a pretty low
latency pipeline between the browser and
the server so what I'm doing is I'm
running at node AF server
on the Raspberry Pi it's pulling data in
through the canvas shield in real time
and then this node j/s script is running
a server and the browser here is sucking
in the data so you can see it's actually
really responsive it's updating ten
times per second and I'm pretty sure it
can go much faster than that so I'm
doing is just stepping on the
accelerator pedal and you can see it's
updating nice and quickly there was a
couple of interesting gotchas along the
way that you might find interesting so
the way that I'm connecting the car to
the Raspberry Pi is through the wireless
network like I say I didn't want to hack
into the car I haven't touched that four
pin Ethernet connector and so the first
trick is that the car will not connect
to a wireless network that doesn't have
internet available or at least it seems
that way so to fix that problem I got my
Android phone and connected it via USB
to the Raspberry Pi and use USB
tethering from the phone so the
Raspberry Pi actually has internet now
through the wireless network on the
phone okay so now with routing and
everything the car will eventually get
to the Raspberry Pi through Wireless and
then from here to the phone and then out
to the Internet so that's all fine the
next interesting problem is that the
tesla browser doesn't allow you to
connect to local IP addresses so 192.168
whatever and they did that purposefully
I guess to keep you from you from doing
exactly what we're doing now I guess but
anyway since we have full control over
the router obviously this Raspberry Pi
is routing all the packets we can just
set up a static route so I've gone to
the address 42 42 42 42 and that just
reroutes all the packets to the local
host here and we can serve those packets
and the browser in the car has no idea
that it's talking to the Raspberry Pi I
think
talking to a public web server but this
seems to be a pretty good solution it's
very responsive and it just keeps
running it's not like I have to keep
reloading the page or anything like that
and so with a little magic you can
imagine what this is going to look like
you know the I'll have a graphing in
real time in the client-side and I'll be
able to do something like select
different things like you know if I
wanted to see acceleration over time
with motor torque and all that stuff I
could construct a graph in the browser
and that's that's what we hopefully
looking at next time
you
so in the next video we'll be talking
about the physics of the car a little
bit more the whole purpose of making
this data collection systems so that I
can record all the data from doing you
know kind of extreme things with the car
and then we can you know see what's
interesting with that okay I hope you

enjoyed that see you next time byeTop Paid Keyword :  earn cash online, google make money from home, earn money online without investment by clicking ads, free earn money website, online money making jobs, earn money online without investment by typing, online work for money, best online earning sites, make money online with google, online earning websites, money making websites, online earning websites for students, invest online and earn money, best online money making, online money income, view ads and earn money without investment

No comments: