CAN Interface


102 posts   Page 2 of 5   1, 2, 3, 4, 5
by FlappySocks » Wed Mar 07, 2012 10:04 am
Thanks gja.
Posts: 7
Joined: Tue Mar 06, 2012 8:15 pm
by FlappySocks » Wed Mar 07, 2012 10:06 am
Thanks gja.
Posts: 7
Joined: Tue Mar 06, 2012 8:15 pm
by gja » Wed Mar 07, 2012 4:07 pm
Another schematic can be found here:

http://www.sparkfun.com/datash.....ld-v12.pdf

http://www.sparkfun.com/products/10039

An Arduino CANbus shield with GPS support and some whistles and bells we don't need schematic.

A few remarks:

- Ideally the power supply should not just be 12 to 5 volts, an input range from 9-30 or so would be better.

- what's the temp range of the Raspberry Pi? For automotive you normally need -40 to 125°, but I guess you can't expect that for 35$.

For educational purposes compromises can be made.
Posts: 22
Joined: Sat Mar 03, 2012 9:24 pm
by dega » Wed Mar 07, 2012 5:07 pm
Hi everyone,

I'm thinking to develop a CAN interface too, and I've been looking for CAN controllers and drivers.

I don't see the problem of the voltages that someone was mentioning though:

the MCP2515 is 3.3V compatible,

there are CAN transceivers that work at 3.3V, like the SN65HVD230D for example.

Won't this be enough to interface the RPi with a CAN bus?

Or am I missing something important?
Posts: 3
Joined: Wed Mar 07, 2012 4:44 pm
by Donald Becker » Thu Mar 08, 2012 8:18 pm
dega said:


I don't see the problem of the voltages that someone was mentioning though:

the MCP2515 is 3.3V compatible,

there are CAN transceivers that work at 3.3V, like the SN65HVD230D for example.

Won't this be enough to interface the RPi with a CAN bus?

Or am I missing something important?



Most "3.3V" CAN transceivers actually require a 5V supply for the transmitter.  The "3.3V" refers to the I/O voltages.

The '230 is one of the few transceivers that does actually use only a 3.3V supply, but it doesn't fully meet the transmit specs at that voltage.  It will likely work in an automotive environment, but may not in an industrial installation.

Most 5V CAN transceivers work fine with a MCP2515 running at lower voltage.  The only circuit change is putting a resistor divider on the CANRX since the MCP2515 doesn't have 5V tolerant inputs.

We often use a Si8421 isolator before the CAN transceiver, and power the transceiver with an independent 5V supply referenced to the CAN bus.  The Si8421 does level shifting and provides protection plus galvanic isolation. CAN transceiver are pretty tough, but that only means they'll survive as coupled power damages components behind them.
Posts: 3
Joined: Thu Dec 01, 2011 2:40 am
by CliffC » Mon Mar 12, 2012 2:40 am
@ Donald,

I'm new to CAN but I heard many people design automotive MCUs that needs a 5V CMOS device. As a know, CAN bus voltage level only up to 3.5V. Do you know why the MCU designers need a 5V CMOS device since 3.3V IO is ok to handle 3.5V range?

Appreciate for the advice.

Cliff
Posts: 1
Joined: Mon Mar 12, 2012 2:32 am
by abrugsch » Mon Mar 12, 2012 12:05 pm
Amigo said:


the overriding concern was that there are not enough embedded systems engineers around. Working with low-level hardware, needing to understand a bit more than just the programming language, seem to be in short supply.


Hi Amigo

I'd like to just say, this is an area I'd love to get into, but have no idea where to start...

I'm a C++ developer for windows desktop applications (well that's how i've been pigeon-holed anyway) but have flirted with embedded systems in several of my roles. If I'd been able to keep either of my first 2 jobs (redundancy :( ) I'd probably be a lot closer to this as they involved embedded systems and automotive applications.

the desktop market is rapidly heading towards C# and web apps with little demand for C++ devs except in legacy maintenance situations. (ick)

any nudges in the right direction for learning the skills you mention would be a great bonus :)

Thanks

ABrugsch
Posts: 6
Joined: Mon Mar 12, 2012 11:33 am
by gja » Fri Mar 16, 2012 11:20 am
An attempt to make a requirements list. Please shoot at it.

Raspberry CAN add-on board specs:

Need to have
mechanical:
- plug on gpio header, stay within pcb boundaries of Raspberry
- CAN connection on edge of PCB

electrical:
- mcp2515  SPI-CAN interface
- level converter (as per Donald Becker's post)
- CAN transceiver (preferences)

Nice to have:
electrical
- 9-40V input tolerant power supply for Raspberry and CAN board, galvanically isolated added on the board.
- galvanic isolation on CANbus
I think we need one out of these two galvanic separations for logging in a car. Also when connecting a Raspberry to a micro usb power supply, do we need to worry about possible ground loops without at least one form of galvanic separation?

Dream to have:
- GPS IC + antenna connector for logging location together with CANdata.
- RTC IC + backup battery for accurate timed logging
Posts: 22
Joined: Sat Mar 03, 2012 9:24 pm
by hzrnbgy » Fri Mar 16, 2012 11:53 am
If you have GPS, you already have extremely accurate timing source
Posts: 106
Joined: Mon Dec 26, 2011 10:55 pm
by FlappySocks » Fri Mar 16, 2012 11:57 am
I agree.  Not worth adding RTC.  I found a low cost GPS receiver that would be perfect for the PI. Just needs a MAX232 ic to convert the signals.
Posts: 7
Joined: Tue Mar 06, 2012 8:15 pm
by gja » Sat Mar 17, 2012 12:10 pm
hzrnbgy said:


If you have GPS, you already have extremely accurate timing source



IF you have a GPS connection, that is.  :-)

If not, (at boot time, in tunnels, in the garage) you need to work around it.
Posts: 22
Joined: Sat Mar 03, 2012 9:24 pm
by hzrnbgy » Sat Mar 17, 2012 1:27 pm
Most GPS receivers have built in RTC backup that requires a standard coin cell battery to work.
Posts: 106
Joined: Mon Dec 26, 2011 10:55 pm
by vlick » Wed Apr 04, 2012 10:44 am
Hi at all, I'm a newbie in this forum and I'd like to share some comments about the very interesting Topic.

To provide CAN interface to PI I'd also propose  the MCP2515 since:

- I'ts cheap

- Quite good performance, considering that is has two RX buffers (and related mask/filters) and three TX buffers.

- Using the SPI at "high" speed (having good PCB design...) we can reach good performance

- We can use the SocketCan layer (with the required adaptions if necessary) which is present in kernel 2.6

In my opinion this controller is a good compromise, and it fits with the educational purpose of the project.

In addition to the CAN controller (and transceiver) I'd agree to add on the "inCar" expansion board also :

- GPS receiver, connected via UART, with external antenna

-   ADC converter, connected via I2C.

The open points I see are at least:

- Which transceiver to use (High Speed, Low Speed, voltage ranges).

- Power supply management, and eventually to adopt the 5V tollerant buffers/shifter

- Components selections/Footprint of every chip

From my side, I can supply a basic diagram about the connections to the Can Controller, just to start the discussion.
Posts: 12
Joined: Wed Apr 04, 2012 8:35 am
by my_space » Thu Apr 05, 2012 11:01 am
Hey guys, I'm pretty new to programming but I can offer my suggestions (I'm still at university studying nothing relating to computing/hardware)

I became interested in building some sort of racing simulator and I currently have a instrument cluster hooked up to an arduino/can shield. I do believe a raspberrypi would offer much better performance as I can therefore ask it to do more operations than the arduino.

This is what I have so far::



The CAN shield I am using is provided by these guys :: http://secuduino.blogspot.com/

Their shield is a great starting point (schematic wise) in order to develop further and add more components. They are pretty helpful and their resources are viewable here::

https://github.com/IgorReal/SECUduino

Hopefully this can help. I would love to be apart of this project in some way.
Posts: 1
Joined: Thu Apr 05, 2012 9:43 am
by mpsteffen » Thu Apr 05, 2012 10:10 pm
Is there a SPI Driver yet ?

From what I read, eather SocketCan or CAN4Linux both support the mcp2515, but

as far as I know, there is no SPI Driver support for the RPi yet.

( definately none which works with the CAN4Linux driver )

Is anyone working on that ?

What would one need to be able to modify the kernel ?

( apart from a RPi, which I'm waiting for :-( )

I could provide electronics, embedded system & programing know-how.

so long

Matthias
Posts: 6
Joined: Thu Apr 05, 2012 8:45 pm
by vlick » Fri Apr 06, 2012 12:38 pm
I agree with Mathias: the first point to analize is the SPI side.

The driver for MCP2515 will be based on SPI communication, I figure out that the top half of the driver (the interrupt handler, which has to be lightweight and very fast) will give the acknowledge and will read the buffer using such communication protocol.

If the SPI driver isn't available right now, the only way I see is to implement it (maybe exploiting already available code), but this requires full access to the uC specifications: I hope that this will not be a problem, and eventually we have to face it.

I'll try to have a look to the SocketCan driver with MCP2515 support, and any help is very appreciated also in finding the usefull documentation needed.

regards

vlick
Posts: 12
Joined: Wed Apr 04, 2012 8:35 am
by mpsteffen » Sat Apr 07, 2012 11:45 pm
Hi vlick,

the available datasheet includes quite some details about the SPI Interface.

That should be O.K. for a start.

so long

Matthias
Posts: 6
Joined: Thu Apr 05, 2012 8:45 pm
by vlick » Fri Apr 13, 2012 11:31 pm
Hi Matthias,

could yuo kindly post the link to the datasheet?

I'm new about rapsberry (I just eard about it last week...) and I wasn't able to find it..!!

I had a look to the 2.6.26 kernel sources and the MCP2515, as aspected, is supported.

I need to figure out what is missing in the HW dependent code(Low Level SPI, Interrupt handler/GPIO settings)  but with some time and a lot patience it should not be a problem.

Any suggestion in adding a GPS receiver ?

Where is possible to see the board layout, just for starting to see the pinout and the available resources?

Final question: is there anyone who already has a unit? I'm still waiting an answer from rs about when will be possible to buy one sample.

thanks

vlick
Posts: 12
Joined: Wed Apr 04, 2012 8:35 am
by mole125 » Sat Apr 14, 2012 7:14 am
The wiki page has information about the GPIO pin out here http://elinux.org/Rpi_Low-leve.....eripherals, it also links to the datasheet (ref 5), if you look round the wiki you'll find lots of other information about the board as well.

Units started shipping yesterday but in very limited numbers, and the production line is only just starting to ramp up production - I think there will be a post next week which may give more guidelines as to how long it will take for them to clear the backlog. The best you can do is register now and hope it isn't too long.
Posts: 230
Joined: Tue Jan 10, 2012 2:01 pm
by mpsteffen » Sun Apr 15, 2012 9:00 am
Hi Vlick,

a somewhat shortended datasheet is available on the web.

just look for BCM2835-ARM-Peripherals.pdf

that should give you a very good impression on register layout and features of the SPI block.

By the way, has anyone tried to use python for driver development so far ?

No joke, because looking at the GPIO example, all required systemcall should be available in python.

And additionaly ctypes allows to "model" the register layout & bits as a CStruct, which could be instanciated at the according memory location.

Interactive playing around with the bit's and bytes could significantly speed up the whole process.

A "working" solution must be tranfered to C to enter kernel space obviously.

Drawback:

IRQ's probably  don't work in userspace.

So long

Matthias
Posts: 6
Joined: Thu Apr 05, 2012 8:45 pm
by gja » Sun Apr 15, 2012 11:35 am
mpsteffen said:

Is there a SPI Driver yet ?

From what I read, eather SocketCan or CAN4Linux both support the mcp2515, but

as far as I know, there is no SPI Driver support for the RPi yet.

( definately none which works with the CAN4Linux driver

The MCP2515 driver is  already included in the kernel for ARM?
https://github.com/raspberrypi/linux/tree/rpi-patches/drivers/net/can

We just need hardware to test it?
Posts: 22
Joined: Sat Mar 03, 2012 9:24 pm
by dhackney » Tue Apr 17, 2012 9:42 pm
gja said:

- what's the temp range of the Raspberry Pi? For automotive you normally need -40 to 125°, but I guess you can't expect that for 35$.
For educational purposes compromises can be made.



From the FAQ:

What is the usable temperature range?

The Raspberry Pi is built from commercial chips which are qualified to different temperature ranges; the LAN9512 is specified by the manufacturers being qualified from 0°C to 70°C, while the AP is qualified from -40°C to 85°C. You may well find that the board will work outside those temperatures, but we’re not qualifying the board itself to these extremes.
Posts: 11
Joined: Tue Apr 17, 2012 8:32 pm
Location: USA
by dhackney » Tue Apr 17, 2012 11:14 pm
I'm interested in RasPi CAN support for ISOBUS / ISO 11783 data.

Goal:

Provide an open source hardware & software solution to produce and wirelessly transmit near-real-time ISOBUS data.

Problem Solved:

Currently, growers do not own and have limited access to the precision agriculture data produced by their equipment. The equipment manufacturers legally and technically limit or prevent data access, integration and utilization. The RasPi ISOBUS solution enables growers to own, access and integrate the heterogeneous data produced by the growers' equipment and their suppliers' equipment while operating on the growers' farms.

Requirements:

The requirements echo those previously stated in this thread for a CAN Interface.


  • CAN bus interface

  • GPS (including RTC support when no Sat signal is present)

  • Opto isolated IO's (galvanic isolation on CANbus)

  • 12v-5v DC-DC Converter 

  • Input voltage range from 9-30, galvanically isolated added on the board



Electrical isolation is an important aspect that would be especially critical.

This implementation requires GSM/CDMA data transmission. This capability could be achieved by a combo chip such as the Telit GE864-GPS or by combining the GPS chip proposed with a USB GSM/CDMA solution.

Due to the operating environment, a rugged case will be required.

Note:

This is a read-only application, meaning no equipment or system control messages are transmitted to the CAN bus.

Support:

I can provide cost support for board level development.

Project:

While there are an increasing number of name-brand, commercial ISOBUS ECUs, task controllers, Virtual Terminals, etc., I have been unable to locate any open-source hardware, software and data systems.

The terms of service of all the commercial systems I have seen to date all stipulate that the manufacturer essentially "owns" the data. In addition, the proprietary systems all isolate the detail data behind closed web portals. Both of these factors prevent  growers and their vendors from integrating, aggregating or analyzing the data the grower's equipment is producing.

Essentially all agricultural operations are heterogeneous from the data source standpoint, including different brands of systems that generate precision agriculture data in the field. Growers have their own equipment, which may use Brand X equipment, while their input application supplier may use Brand Y equipment. Currently each of those brands locks up the data from their equipment in closed and proprietary data silos. For instance, that can mean the grower's planting data is separated from the herbicide as-applied variable rate application data from the supplier the grower paid for the application.

The resulting non-integrated, isolated data sets prevent the grower's agronomics, inputs (seed, chemicals, etc.) and financial suppliers and consultants from having visibility into an integrated view of a grower's operations. In essence, no one, including and especially the grower, has an overall, integrated view of what has been done to which crop in which field.

There is an agriculture industry program, AgGateway, to provide data integration that is making slow progress, but it will be years, probably many years, before it yields widely available and implemented data integration standards.

I am interested in developing RasPi CAN capabilities to enable the near-real-time transmission of ISOBUS data from agriculture equipment to a data integration, storage and retrieval system. This data would be wholly owned and controlled by the grower.

ISOBUS background:

ISOBUS is the brand (marketing) name for the ISO 11783 CAN standard for agriculture, forrestry, etc.

The key benefit of ISOBUS is that it enables any brand, model or model year of ISOBUS equipped tractor, harvester, sprayer or implement to share real-time data and status with any other similarly equipped equipment.

ISOBUS is used in precision agriculture and other applications.

In precision agriculture it enables the precise control and guidance of agricultural equipment, such as repeatable sub-inch accuracy in tractor/harvester/sprayer guidance. Precision agriculture, via ISOBUS communication between tractor and implement, also enables extremely precise variable rate application of agriculture inputs such as seed, fertilizer, pesticides and herbicides. This variable rate precision enables growers to use less chemicals by eliminating overlap, plant specific types of seed in precisely located types of soil to improve yields and to lower overall costs of production.

The technical development of the ISOBUS standard originated in Germany in 1991. Commercialization began in 2001. The standard is only relatively recently finding adoption in North America.

There is currently a lack of data storage structure standardization (beyond the standard's XML delivery format) and data integration as commercially realized in the NA market.

There are some academic data projects underway, such as the Komobar project from Hochschule Osnabrück http://www.komobar.de/

More information on the standard here:

http://en.wikipedia.org/wiki/ISO_11783  (English entry, very short)

http://de.wikipedia.org/wiki/Isobus  (German entry, extensive)

http://dictionary.isobus.net/isobus/
Posts: 11
Joined: Tue Apr 17, 2012 8:32 pm
Location: USA
by vlick » Fri Apr 20, 2012 11:04 pm
I'd like to start with a proposal: please feel free to comment and to improve/modify  it.

1) HW Components for CAN

- Controller: Microchip MCP21515, package TSS0P20, 16 MHz clock, with 3.3 V. powered.

- Transceiver: TI SN65HVD251, package SOIC 8, 5V. supplied. It's widely used in Can HS applications, like J1939, NMEA2000 and ISO11783.

- Buffer/shifter (like 74AHCT126) to interface them

2)Resorces (pins) used:

- SPI: SOUT, SIN, CLK                3 dedicated

- Chip Select                              1 dedicated (SFRM) or GPIO

- Reset                                      1 Hw driven or GPIO

- Interrupt                                 3 at least (up to 5)  lines (GPIO) interrupt enabled

With 3 lines we can maximize the reading efficency (recommended), with 5 lines also the writing efficency.

I tried to havea look to some cheap GPS module to be connected via UART, but a saw only expensive (> 30 Euro) products. Any suggestions?

vlick
Posts: 12
Joined: Wed Apr 04, 2012 8:35 am
by alxxg » Sun Apr 22, 2012 1:27 am
Suggestion for the can hardware

futurlec sells can node kits http://futurlec.com/CANNode.shtml

and a can mini board http://futurlec.com/Mini_CAN_Board.shtml

Used a few can node kits a few years ago in some old projects.

Their boards work reasonably well but documentation can be a bit liteweight

(Can take them a while to ship sometimes , their warehouse is in Thailand).

Their mini boards are rather handy for quick prototyping as a few are i2c based.

Cheap GPS ?

I"ve tended to stick with whats available from sparkfun and local resellers. The Trimble Lassen iq are easy to control and use but are getting a bit old. The fasttrax ug501 are similar but have a lot more channels, the LS20031 looks interesting.

</OT>

Though I"d like to get one of the funcube usb dongles running with a pii

http://www.funcubedongle.com/

When I eventually get some spare time

Apparently funcube works with the pii http://www.funcubedongle.com/?p=861

</OT>
Posts: 1
Joined: Sat Apr 21, 2012 11:35 pm