Page 1 of 1

SPWM (Sinusoidal Pulse Width Modulation) Programmer Needed

Posted: Thu Apr 28, 2022 6:03 pm
by Derrihj
Hi am looking for someone with good pic microcontroller C coding knowledge to code for me SPWM using PIC18F442, this should have an ac output feedback for output voltage control with an output frequency of 50Hz, i would like two complete flowcharts one using the ECCP module and the other using the CCP module as for most microcontrollers have only the CCP module. Strictly flowcode 8 should be used, All this must depend on the info I will provide in a one folder zip file.That is to say, the flowchats should be based on the info in the folder and the coder must be ready to exaplain every detail in the code because I like asking questions with seeable examples. The spwm should be 4 signals that I will feed to a high side / low side driver to drive my H bridge MOSFET config. For both ECCP and CCP flowchart versions, I only require the spwm part, these other things like LVD (battery Low Voltage Disconnect) , Temp sense, Display and the rest will be coded by me to make a complete project I only need the spwm generation part with feedback. PIC18F442 does not have ECCP so for the ECCP version please use PIC16F684 and for CCP version please use PIC18F442. The folder is included below, all files in there are PDF format and the password after extraction is 12345 Note: please am kindly asking don't be too expensive for me as this is a learning project and a complete one to be used in my home and my mother's home thanks guys.

Re: SPWM (Sinusoidal Pulse Width Modulation) Programmer Needed

Posted: Mon Jun 27, 2022 6:59 am
by Derrihj
No one has tried to have a solution here?

Re: SPWM (Sinusoidal Pulse Width Modulation) Programmer Needed

Posted: Mon Jun 27, 2022 7:13 pm
by mnf
The password doesn't seem to be correct...

Re: SPWM (Sinusoidal Pulse Width Modulation) Programmer Needed

Posted: Mon Jun 27, 2022 8:41 pm
by Derrihj
The password works very well it is 12345 but the PDF that explains it very well is down below read for download.

Re: SPWM (Sinusoidal Pulse Width Modulation) Programmer Needed

Posted: Mon Jun 27, 2022 10:15 pm
by Derrihj
For easy understanding please use exactly the same variables in flowcode as the guy used in his code in mikroC.Thanks for you time friend.

Re: SPWM (Sinusoidal Pulse Width Modulation) Programmer Needed

Posted: Tue Jun 28, 2022 11:24 pm
by Derrihj
Since most Microcontrollers don't have the ECCP but have the CCP instead, its better to use the PDF below to make it easy when choosing an MCU.Take note, in this PDF, he first shows the code with the use of the ECCP at the top of the page then after goes ahead and give you the CCP code showing all the changes.This is really great info guys.But if one wants to understand clearly how the code works then go thru' the PDF with the ECCP first, then get back to this one below. Thanks guys.

Re: SPWM (Sinusoidal Pulse Width Modulation) Programmer Needed

Posted: Wed Jun 29, 2022 9:24 pm
by Derrihj
I was trying to play around with the code trying to see if I can personally change the code to flow code and this is what I came up with but don't even know if it works because I couldn't compile it and test in proteus coz I think I exceeded the space on the MCU.But anyways, have a look at the code I came up with and advise me coz I love to learn from pro people .Thanks again guys.

Re: SPWM (Sinusoidal Pulse Width Modulation) Programmer Needed

Posted: Wed Jun 29, 2022 10:52 pm
by mnf
Good - progress!

A couple of things you need:

To access FC variables in C blocks - prefix them with FCV_ for global variables or FCL_ for local variables (and name is all uppercase - even if not so in FC)

You haven't defined a lookup table - called lut1 in your C code in the interrupt handler. You have used a LUT component (which gets called FCD_00fb1_lut1__INTLIST_LUT - which is stored in ROM). The easiest route here is to use an array and initialise that then you can use FCV_LUT[index] in the C block).

The interrupt handler doesn't need to check or clear TMR1F_bit - FC handles this for you.

Martin