ATMEGA4808 with CAN Bus

In This, Part 2 of my CAN Module series( Read Part 1 here), I will look at my recent modification of a previous ATMEGA4808 Development PCB to include CAN bus hardware. The ATMEGA4804 with CAN Bus development board is part of a set of “benchtop development tools” that I designed specifically to design some CAN Bus controlled Gadgets for use in my car…

The PCB is based on a previous project, in which we experimented with alternative chips to replace the ATMEGA328P.

MakerIoT2020 ATMEGA4808 Dev Board
MakerIoT2020 ATMEGA4808 Dev Board

As I was quite happy with the performance of this particular project, I thus decided to use it as the base for the CAN Bus module as well. The Added CAN Hardware adds only a few cm. to the board, keeping it quite compact, although, it will need a complete redesign once I finally get my gadgets finalised 🙂

What is on the PCB ?


The ATMEGA4808 and its supporting components dominate the left side of the PCB, with a USB connector and a CH340N providing the possibility to upload code to the chip using the Optiboot bootloader. I would however caution you, as there seem to be quite a lot of counterfeit CH340N chips floating around, I received two bad batches already, and from reliable suppliers as well… seems there is something fishy going on in the factory?? Answers anyone?

The Right side of the PCB is dedicated to the CAN Hardware, with the MCP2515 and TJA1050 taking centerstage here. While quite old, the MCP2515 is still readily available for the time being and is also quite affordable. Since I had a few left over from previous projects, I decided to once again make use of what I had on hand.

A 120-Ohm termination resistor ( selectable with a jumper), as well as a screw terminal connector, is provided. The board Reset button, as well as a power and user LED ( on D7), is also in that area of the PCB.

All GPIOs on the ATMEGA4808 were broken out onto header pins, to allow for maximum flexibility and access to features and peripherals on the chip.

Schematic and PCB Design

The Schematic, as mentioned before, is based entirely on a previous project of mine, with the CAN Hardware added onto that. ( I remind everyone once again, that this is a “tool” that I designed for myself to help in getting a specific job done. that will mean that it may or may not be very advanced, or suited for other peoples purposes… but , as a general bench module for CAN Bus development based on the ATMEGA4808, it will be perfect – that is what it was designed to do after all )

Schematic, ATMEGA4808 and supporting components
Schematic, ATMEGA4808 and supporting components
Schematic, CAN Bus Hardware, MCP2515 and TJA1050
Schematic, CAN Bus Hardware, MCP2515 and TJA1050

The PCB is a double layer approximately 8.1cm x 3.3cm rectangular module.
6 3.2mm mounting holes are provided.


Manufacturing

I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ), or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to that will do his/her best to resolve your issue as soon as possible.

Find out more here

Assembly

To save myself time, and ensure that the project is assembled to a high quality standard, I once again opted to have a stencil manufactured in addition to the PCB alone. This is however not strictly required with this board, as the components can still be hand soldered, or solder paste can be manually applied using the method of your choice.

High quality Stainless Stencil
High-quality Stainless Stencil

I used my standard hotplate reflow soldering technique on this board, and it turned out very well indeed, with no solder bridges, making any reworking completely unnecessary, which can in no small part be directly attributed to the super accurate stencil that I used for solder paste application…

Assemble PCB
Assembled PCB

Testing

After assembly, I went through my standard testing ritual, while of course remembering that the ATMEGA4808 is a UPDI programmable chip, which means that you can not just use a USB cable on a brand-new chip…

I uploaded the Optiboot bootloader via that UPDI header, using my own UPDI programmer, that was also a previous project, one that I am very happy to have these days 🙂

A standard blink sketch followed, and then it was time to test the CAN hardware. For this I used Gary J Fowler’s MCP Can Libray ( the same one that I used with the ATTiny1616 a few days ago ), as well as the ATTiny1616 CAN Module that I build a few days ago…

As for the firmware, at this stage, as I am only concerned about testing actual CAN functionality, I made use of the CAN Loopback on both units, and then THe CAN Sender on the ATTiny1616 and the CAN Receiver on the 4808… These sketches are all available in the library examples… so find them there.

Pinouts for the connections to the MCP2515 from the ATMEGA4808 is as follows:

CS is on Pin D7, MISO on D5, MOSI on D4, SCK on D6 and the Interrupt on D10

The ATTiny1616, which I did not mention in part one, is as follows:
CS on D13,MISO on D15, MOSI on D14, SCK on D16 and the Interrupt on D12

Conclusion

Testing went well, with everything working as expected, with the exception of another batch of CH340N chips being suspect… This does however not really bother me, as I am quite comfortable with using UPDI to upload code, as well as using an external USB-to-serial adapter, connected directly to the UART on the ATMEGA4808.

Cosmetically, I made a labelling error on the silkscreen of the CAN Bus connector, swapping Can H and CAN L… once again, this is not a problem to me.

My thanks to PCBWay for another extremely well-made PCB.

Leave a Reply

Your email address will not be published. Required fields are marked *