Title: AVR controlled USBCAN Bus Interface
Author: Michael Wolf
A black bar on the left side marks changes since last issue.
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.
CAN controller interface
Use a PCA82C251 if 24V compatibility is required.
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.
USB communication controller
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
Red LED for error indication
Blinks if an error was detected by SJA1000.
Continuous light if a bus error was detected.
Green LED for CAN traffic indication, both Rx and Tx.
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).
CAN bus connector
Either 10 pin header or 9 pin Sub-D male connector
Pin out in accordance with CiA Draft Standard 102-2
USB type B connector
ISP header for in circuit programming of the AVR.
Compatible to Atmel STK500 ISP header.
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
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
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...
Please join StudyMode to read the full document