Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Implementing fuzzy logic in PIC18F4431 with MPLAB using c language programming

Status
Not open for further replies.

Faniah

New Member
Hi,

My project is 'optimum solar cell implementation using dc-dc boost converter controlled by fuzzy logic controller'. I'm using MPLAB IDE for programming the PIC18F4431. I really don't have any idea about the c programming for fuzzy logic controller. I had done the inference rules in Matlab fuzzy logic toolbox. The input is error, E and change in error, CE. The output is the duty ratio, D of the boost converter. Below is the rules.

upload_2014-2-25_1-37-23.png


For example, If E is NB and CE is ZE then D is NB.
So any examples of fuzzy logic controller c programming which are related to this project will be helpful to me. Thank you.
confused.gif
 
I don't know fuzzy logic but looking at your inference rules, I would treat it like a quadrature decoder. Have a function for each "E" condition and loop there waiting for a change. Then you can assign that value to your variable, return to Main(), which would call function for the new "E" condition and wait for a change.

Code:
void EisNB (void)
    {
    while(1)                // endless Loop
        {
 if(CE == ZE)
{
D = NB;
return ;
}
              
if(CE == PB)
{
D = NS;
return ;
} 
             
if(CE == PS)
{
D = ZE;
return ;
}                      
        } // while(1)
    }// EisNB (void)
 
Last edited:
What sensor that can be use to sense the voltage and current separately for solar cell? Anybody help me. o_O
 
That looks like a good chip but it has a lot of errata.
PIC18F2x31, 4x31 Data Sheet
SSP Module Errata
PIC18F2x31, 4x31 Rev A2 Silicon Errata
PIC18F2x31, 4x31 Rev A3 Silicon Errata
PIC18F2x31, 4x31 Data Sheet Errata
Timer1 Errata
PIC18F2x31, 4x31 Programming Specification
You have up to 9 ADCs. You can use a voltage divider to bring you voltage down to a compatible amount. Use the Search>more option to search the microcontroller section of this forum for "measure amps". It says the word ADC is too short so it won't search for it.
You will probably use a shunt. This thread may help.
https://www.electro-tech-online.com...y-on-lcd-using-pic18f4520.100480/#post-820939
 
What sensor that can be use to sense the voltage and current separately for solar cell? Anybody help me. o_O

For voltage, simply use voltage divider. For current, it's best to use a shunt/resistor. Both will go to ADC.

For your algorithm, simply use 2-dimensional lookup array - int[5][5]
 
I want sensor to track the voltage and current of the solar cell which will be send the signal to PIC for fuzzy logic programming.
 
I want sensor to track the voltage and current of the solar cell which will be send the signal to PIC.

Most PICs have built-in ADCs, which can be used to measure voltage, so you do need a separate device to do measurements.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top