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.

Breaking out of the Chip Shortage – Attempt #3

The ATMEGA4808 provides a very attractive solution to replace the trusted ATMEGA328 or standard Arduino UNO /NANO.

These chips are slightly more difficult to get hold of than the ATTiny chips, and cost a little bit more ( about the same as what the ATMEGA328 used to cost before the mess with COVID-19 and resulting supply chain shortages + inflated costs), but they offer all of the functions of the ATMEGA328, with a few other enhancements that will definitely be very useful.

The extras include:
– Hardware interrupts on ALL GPIO pins; This is way more than the standard 2 interrupts on the ATMEGA328 ( We are not talking about the Pin Change interrupts, but real hardware interrupts, that can be triggered on RISING, FALLING, CHANGE, HIGH and LOW state of each pin

– Up to eight (8) PWM pins as opposed to the 6 on the Arduino UNO
– Up to eleven Analog inputs
– An Analog Comparator module
– Configurable Custom Logic (CCL)
– EVENT System (EVSYS)
– Peripheral pin swapping

It is also worth mentioning that these chips have accurate internal oscillators, capable of clocking the chip at up to 20MHz, further reducing the number of external components required to get a minimal configuration running…

Order your own version of this development board

The Prototype PCB

While I have had a Nano Every “Clone” lying in a drawer for quite a while now, I did not really pay a lot of attention to it. That was, until I needed an ATMEGA328 for a project, and could not find any for sale, or at least at a price that I was willing to pay for it… That incident was the spark that ignited this entire exercise, to find a suitable replacement…

The Nano Every “Clone” in my possession, used the ATMEGA 4808 chip and turned out to be the Thinary Nano 4808. I had quite a lot of problems with the provided core, as well as getting peripherals like I2c and SPI to work. This led to further investigations, and finally, I decided on building my own and to use the MCUdude/MegaCoreX Arduino Core to program it.

This led to the following prototype:

ATMEGA4808 Development board prototype

I did not bother with too much detail on the silk screen here, as the goal was to get a working board, test it, and then later, design a refined PCB.

What is important to note is that the board runs at 5v, but provides a single 3.3v output as well. Logic levels on the GPIO is also 5v. Use level converters for 3.3v only addons…

The MEGA4808 is programmed via UPDI, so we have a UPDI Header on the right-hand side of the PCB. It is also possible to use the Optiboot Bootloader, to flash the board in true Arduino style through a USB connection to a computer.

A CH340N USB-to-Serial converter chip is used instead of the CH340G that is common on the UNO clones. The CH340N provides only the USB D+ D- signals, as well as Rx, TX and RTS. RTS is being used to auto-reset the chip after flashing…

In comparison to the CH340G, which also required a crystal oscillator, but provides all the modem control signals, which, are usually not even broken out, the CH340N made much more sense.

PCB Bottom.

A power LED, as well as an indicator LED on pin 7 was also included.

Assembled PCB, Top Layer.

Assembly and Soldering

I normally assemble all my projects by hand and reflow-solder them with a hot plate. for this project, I decided to do things a bit differently, which ended up being a bit awkward, but still resulted in a perfectly useable PBC.

As you will know by now, I only do written articles, as I don’t consider myself ready for the Youtube and video thing, as well as because I believe a well-written article, with detailed pictures, is easier to understand than a video…

Well, today, we will have both… This article, with its writeups and pictures, as well as a short assembly and soldering video, with no sound, sped up 5x, as I did not want to bore anyone with a 25-minute silent video…

Let us begin then…

PCB and Stencil

We start with a blank PCB and the laser-cut stainless steel stencil that I got from PCBWay.

Solder paste applied

Solder paste is then applied with the stencil and a scraper, and afterwards, the stencil is removed… The PCB is now ready for component placement…

From here on, we will go to the video footage… showing component placement, with some awkwardness due to the camera being in the way, as well as hot-air soldering, with the same awkwardness, as I was forced to use my right hand ( I am left-handed), not to block the camera view…

Begin quite new to the video thing, I have also not quite figured out the editing software, so the video is in native resolution… not zoomed…

After assembly

After assembly, I checked for solder bridges and was quite happy that there were none. This also meant that the board worked perfectly the first time around… as it should…

Order your own version of this development board

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

Picture Gallery