Wiseguy New Inverter Build Nano R6

Author Message


Joined: 02/02/2017
Location: Australia
Posts: 1404
Posted: 09:40am 12 May 2024      

canbus support might be possible but it depends on interrupt priority.
the PWM interrupt must not be preempted.

a common canbus interface uses SPI.
I would avoid Arduino SPI library and do it in steps
as allowed by the time spare in the PWM interrupt routine.

the canbus code (that does the data conversations) will need to be
in something that is NOT the PWM interrupt code block.

It sounds like a lot of work (and "work" is a 4 letter word in my world)

the PWM interrupt needs to run at 20 kHz and complete in less than
1/20,0000 seconds, in fact a lot less than that time (50 ms)

my bit bang serial data output needs only 5 uS, on top of the 10-15 us for the
inverter PWM code to complete.
there is NO spare time to use for canbus conversations in the interrupt code block.

You can use the spare time (what is left after the PWM interrupt code ran) to
do the canbus conversation but if you choose to use the SPI library or even worse, the canbus library for various chips, then there will be long and unexpected
pauses inside the PWM code block.
think much longer PWM pulses. this means over current situations for inductors and FEts

I will not help you with this idea. I do not like it at all.