avr controlled usbcan bus interface

Topics: Software versioning, Byte, Universal Serial Bus Pages: 15 (2259 words) Published: December 21, 2013
Title: AVR controlled USBCAN Bus Interface
Issue: E
Author: Michael Wolf
Printed: 02/08/2009
A black bar on the left side marks changes since last issue.

Intro
The purpose of this project is a simple and easy to use USB CAN bus interface. Heart of the circuit is an Atmel AVR ATmega162 microcontroller which controls the Communication between FTDI FT245BM USB to parallel converter and Philips SJA1000 Stand-alone CAN bus controller.

The SJA1000 is memory mapped into memory space of the AVR, which reduces data and address line handling and increases data transfer speed.
An FT245BM handles all USB communication and provides data transfer from and to PC application. An extra EEPROM can store the multi device template for the FT245BM. A Philips PCA82C250/251 works as CAN controller interface.

Firmware is written in C, compatible to latest compiler version WinAVR. Since version v1.07 the firmware is compatible to the CANDIP hardware. See the CANDIP homepage for more details about the required hardware CANDIP/M162.

Hardware description
IC1
CAN controller interface
Note:
Use a PCA82C251 if 24V compatibility is required.
IC2
CAN controller
IC3
Main microcontroller
The AVR is clocked from the SJA1000 with same crystal frequency (16MHz) Note:
The pin out shown in schematic is for ATmega162 in SMD TQFP44 package! IC4
Voltage converter for power supply via CAN bus connector
The circuit is also powered via USB via D3.
IC5
USB communication controller
IC6
EEPROM for multi device template
A template is needed if more than one of the same device is connected to a PC. JP1
Jumper for CAN bus termination
D1
Red LED for error indication
Blinks if an error was detected by SJA1000.
Continuous light if a bus error was detected.

D2
Green LED for CAN traffic indication, both Rx and Tx.
D3
Power supply via USB connection. This diode must be a low drop version! The diode is just a safety feature but reduces the voltage for the main circuit. I run my own circuit without diode. The power supply is then shared between USB and 78M05 (if externally powered).

K1
CAN bus connector
Either 10 pin header or 9 pin Sub-D male connector
Pin out in accordance with CiA Draft Standard 102-2
K2
USB type B connector
K3
ISP header for in circuit programming of the AVR.
Compatible to Atmel STK500 ISP header.
Pin out:
1 - MISO
4 - MOSI
2 - +5V
5 - Reset
3 - SCK
6 - GND

Firmware configuration and description
In file main.h:
- Hardware version
- Software version
- Device serial number
- Control commands
In file sja1000.h:
- Pin connection for SJA1000
- SJA1000 modes of operation
- Fixed bit rate values for BTR0 and BTR1
In file usb.h:
- Pins for USB FT245BM connection

The current firmware uses NO FIFO so far for Rx and Tx messages. Some more practice tests are necessary to check if FIFOs are needed in further versions.

ATmega162 Fuse setting
The ATmega162 controller will run with external clock source enabled. This controller is shipped with internal RC oscillator enabled at 1MHz. After changing the fuses the AVR is only accessible via ISP if the SJA1000 is connected!

Fuse Settings in AVR-Studio
Checked Boxes:
Preserve EEPROM memory;(EESAVE=0)
Boot flash section size = 128 words;(BOOTSZ=11)
Brown-out detection level at Vcc=2.7V;(BODLEVEL=101)
Ext. Clock; Start-up time: 6CK + 4.1ms;(CKSEL=0000;SUT=01)
All other boxes unchecked.
Fuse Settings in PonyProg2000
Checked Boxes:
EESAVE
BOD1LEVEL
SUT1
CKSEL3
CKSEL2
CKSEL1
CKSEL0
All other boxes unchecked.

Use our favourite AVR programmer to download the firmware into the microcontroller. These fuse settings are also valid for the CANDIP hardware.

USB Driver installation
A virtual COM port (VCP) driver is required for used FT245BM USB to parallel converter. The driver can be found on FTDI website at: http://www.ftdichip.com/ This device works also with DirectDLL D2XX drivers from FTDI. The D2XX driver is required for use with...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Avr Tutorial Essay
  • the bus Essay
  • Essay about bus reservation
  • BUS 346 Essay
  • BUS M4 A2 Essay
  • Avr Microcontroller and Embedded Systems Essay
  • Avr Programming Methods Essay
  • Can Health Care Costs Be Controlled Essay

Become a StudyMode Member

Sign Up - It's Free