Author Topic: SPI to CAN bus mcu?  (Read 2711 times)

0 Members and 1 Guest are viewing this topic.

Offline WaldPinklerTopic starter

  • Contributor
  • Posts: 28
  • Country: au
SPI to CAN bus mcu?
« on: September 25, 2021, 08:49:25 am »
I've been enjoying a new found electronics hobby. I wanted to make a current sense device that communicates over CAN bus.

I need an mcu for that. I spent many hours looking at them and downloading IDEs etc. It feels so overwhelming now. I have played with arduinos and esp32s but wanted to try something lower level. Have programming experience.

I've made a PCB for an ina229 current sense ic that fits on a shunt. SPI communication. I was hoping to connect the MCU and CAN transceiver pcb with some u-shaped header pins.

Any recommendations on an MCU? Preferably something that can be hand soldered. Living on a boat so 700W for a hot air gun burns up my batteries.

My first pcb, so any critique there is welcome.
« Last Edit: September 25, 2021, 08:51:34 am by WaldPinkler »
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3378
  • Country: us
Re: SPI to CAN bus mcu?
« Reply #1 on: September 25, 2021, 10:08:17 am »
Microchip has CAN bus controllers that are SPI (e.g., MCP25625 and MCP2515).  Other vendors (e.g., Maxim) do too.

So, keeping it really simple, all you probably need is an 8-bit MCU with hardware SPI.  Of course you can go up from there.
 

Offline WaldPinklerTopic starter

  • Contributor
  • Posts: 28
  • Country: au
Re: SPI to CAN bus mcu?
« Reply #2 on: September 25, 2021, 10:41:05 am »
I looked at STM8S, PIC, AVR, ATTiny, MSP430. Just pick one? I go around in circles. I was trying to find one that was easy to get started without having to get much extra hardware, easy to solder, then the software side being accessable.
« Last Edit: September 25, 2021, 12:13:49 pm by WaldPinkler »
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3378
  • Country: us
Re: SPI to CAN bus mcu?
« Reply #3 on: September 25, 2021, 11:18:26 am »
Any of them will work.  It's a competitive market.  It all depends on what you have ("tool chain") and are familiar with programming.  I started with Microchip PIC's.  The 8-bit units are easy to program in Assembly, and you can pick ones with fewer peripherals to make starting simple.  The 12F1840 is an 8-pin device.  16F1xxx are also simple (almost identical in some cases) and have more ports/pins.  Most are still available in DIP or SOIC packages, which are easy to solder and can even be used with economical sockets or on a breadboard. 

If you stay with one brand, going to more complex chips is a little easier for setup.  You don't have to use all of the capabilities of any chip.  In the PIC series, I stay with the 1xF1xxx (14-bit core) and pick one with enough ports/pins for what I need.  My tool chain (MPLAB 8.92) is limited.  There are even newer ones that are not compatible with that tool.  I would stay away from the really old ones with a 12-bit core, as they do not have interrupts and have a more limited instruction set.
« Last Edit: September 25, 2021, 11:22:02 am by jpanhalt »
 

Online sicco

  • Regular Contributor
  • *
  • Posts: 164
  • Country: nl
Re: SPI to CAN bus mcu?
« Reply #4 on: September 25, 2021, 09:07:20 pm »
Can can be done with many many microcontrollers. Last year I would have picked a Microchip PIC and MPLAB, but now, if i were you, I’d get a Teensy module. Or something else Arduino ish. Especially if hand soldering is a given…

Probably wise for you to opt for galvanic isolation between your CAN host and the INA229. Consider isolated CAN transceiver ic’s. If you can get your hands on them, because they’re sold out globally like any chip….
 

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1923
  • Country: us
Re: SPI to CAN bus mcu?
« Reply #5 on: September 27, 2021, 08:03:51 am »
Many PIC's have an integrated CAN controller right on the die, eliminating the need to use SPI and giving you much easier and faster communication with all the registers. Very highly recommended. Then you just need a CAN PHY chip, which are available from numerous sources with a huge array of features such as isolation if you wish.
 

Offline Scrts

  • Frequent Contributor
  • **
  • Posts: 797
  • Country: lt
Re: SPI to CAN bus mcu?
« Reply #6 on: September 27, 2021, 07:05:16 pm »
Personally, I would go with a microcontroller that has the most examples and tutorials about the task I want to accomplish.
So you can check STM32:





There are also plenty of examples with STM32 SPI Master, i.e.:

 

Offline WaldPinklerTopic starter

  • Contributor
  • Posts: 28
  • Country: au
Re: SPI to CAN bus mcu?
« Reply #7 on: September 28, 2021, 09:31:07 pm »
I was thinking stm32 is overkill for configuring INA229 sensor then reading registers by SPI and sending them by CAN.

Yes it could be easy. I could just hook it up to my esp32 board or arduino board but I also wanted to get everything under the cover of the shunt approx 30x40mm.
 

Offline fchk

  • Regular Contributor
  • *
  • Posts: 240
  • Country: de
Re: SPI to CAN bus mcu?
« Reply #8 on: September 29, 2021, 10:50:39 am »

Any recommendations on an MCU? Preferably something that can be hand soldered. Living on a boat so 700W for a hot air gun burns up my batteries.


https://www.microchip.com/en-us/product/dsPIC33CK256MP502

Has CAN-FD, only 28 pins (SSOP),  and -most important: Digikey has 2080 pieces ready to ship. (DSPIC33CK256MP502T-I/SSCT-ND)

You will need a CAN-FD transceiver. E.g.: TJR1443AT/0Z. Digikey has 2121 pieces ready to ship. (568-TJR1443AT/0ZCT-ND).

fchk




 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3448
  • Country: it
Re: SPI to CAN bus mcu?
« Reply #9 on: September 29, 2021, 11:03:18 am »

Any recommendations on an MCU? Preferably something that can be hand soldered. Living on a boat so 700W for a hot air gun burns up my batteries.


https://www.microchip.com/en-us/product/dsPIC33CK256MP502

Has CAN-FD, only 28 pins (SSOP),  and -most important: Digikey has 2080 pieces ready to ship. (DSPIC33CK256MP502T-I/SSCT-ND)

You will need a CAN-FD transceiver. E.g.: TJR1443AT/0Z. Digikey has 2121 pieces ready to ship. (568-TJR1443AT/0ZCT-ND).

fchk

I would not recommend that part for beginners in microcontrollers and can controllers. That can controller require more effort than usual to set up and to interface with.. I'd rather suggest one of the older dsPICs (33EV which is 5V, or 33EP MU series which has also USB) or the PIC18F K83 series, or the PIC32MX 530 series since they all use an older, simpler peripheral (same as the MCP2515)... which is more or less the same across all devices so it's easier to port the code
 

Offline fchk

  • Regular Contributor
  • *
  • Posts: 240
  • Country: de
Re: SPI to CAN bus mcu?
« Reply #10 on: September 29, 2021, 11:37:51 am »
I would not recommend that part for beginners in microcontrollers and can controllers. That can controller require more effort than usual to set up and to interface with.. I'd rather suggest one of the older dsPICs (33EV which is 5V, or 33EP MU series which has also USB) or the PIC18F K83 series, or the PIC32MX 530 series since they all use an older, simpler peripheral (same as the MCP2515)... which is more or less the same across all devices so it's easier to port the code

Maybe. Problem is availability. My suggestions are actually buyable, and that's what counts when you start a project in these days.

fchk
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3448
  • Country: it
Re: SPI to CAN bus mcu?
« Reply #11 on: September 29, 2021, 03:15:55 pm »
Meh, stopped worrying about that for now. Our numbers mean that we can actually find stuff from distributors (every few days a reel or two of parts appear, we buy what we need plus some to set aside for the following order n months from now)
Then there's the fact that what you propose could already be gone by the time he decides to use it, though we are not seeing that recently (it used to be that we had to instant buy, components would disappear in an hour or less)
Availability is also not a problem for single, small quantity hobby project (which from what i understand is the case here)

Bonus: microchip IS less affected than other manufacturers, one of the perks of having their own fabs. Prototype quantities ("samples") are still available AFAIK and their lead times have already started shortening
 

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1923
  • Country: us
Re: SPI to CAN bus mcu?
« Reply #12 on: September 29, 2021, 03:47:23 pm »
Maybe. Problem is availability. My suggestions are actually buyable, and that's what counts when you start a project in these days.
True, but a quick search at (just) DigiKey reveals 24 versions of the PIC18 family in stock that have throughhole packages and contain a CAN peripheral. They start at $2.41 in quantity one for a 28DIP package. Refinement of the search is left as an exercise for the OP, but the parts ARE out there in conveniently breadboardable packages.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf