PIC32 PI Controller in assembly

Thread Starter

JuPrgn

Joined Jul 4, 2024
4
Hello,
@Lourens
I wonder if someone has some assembly code for a PI Controller, I have some C code but it is a bit slow and I would like to try a faster approach.
I will be using a PIC32MZ with MIPS32 instructions and for now I do not have assembly coding skills but I start working on it right now.

Julien
 
Last edited by a moderator:

Thread Starter

JuPrgn

Joined Jul 4, 2024
4
This is quite fast for C code almost 600ns but I think there could be some optimisations done in assembly. The current code is a bit complex to be directly converted to assembly without assembly experience. I am using an integrator anti windup and doing many overflow checks but without the if branches those are all simple additions multiplications and variables shift (not using floating point). Would love to see an existing implementation of it if someone already did this
 

nsaspook

Joined Aug 27, 2009
16,325
This is quite fast for C code almost 600ns but I think there could be some optimisations done in assembly. The current code is a bit complex to be directly converted to assembly without assembly experience. I am using an integrator anti windup and doing many overflow checks but without the if branches those are all simple additions multiplications and variables shift (not using floating point). Would love to see an existing implementation of it if someone already did this
Converting to asm while possible, would be my last choice. Do you need the optimization or would you like it is the primary question. With xc32 you can request a trial full optimization license for testing.

I've used the pic32mz for several motor or inverter projects with PI routines with anti windup and overflow. Most versions of that chip have hardware floating point that can be faster than the equivalent integer operations. And you have lots of code/space to make memory/speed tradeoffs.

https://www.google.com/url?sa=t&sou...kQFnoECB4QAQ&usg=AOvVaw0QIVqaPsCJ1IlktxGRCBAB

https://forum.allaboutcircuits.com/threads/pic32mk-mc-qei-example.150351/post-1560143
 
Last edited:
Top