| Algorithm 1. Scaling of Input Error and Fuzzification (Negative Small (NS) MF) | |
| 1. | #Scale Input Error to −20 and 20. |
| 2. | if (err_cur < −20) |
| 3. | err_cur1 = −20; |
| 4. | else if (err_cur > 20) |
| 5. | err_cur1 = 20; |
| 6. | else |
| 7. | err_cur1 = err_cur; |
| 8. | #Convert Input Error to Digital Scale Format (0–255). Refer Equations (3)–(6) |
| 9. | err_scl = (((err_cur1 + 20) * 255)/40); |
| 10. | #Declare NS range of error |
| 11. | a=8’d0; b=8’d63; c=8’d127; |
| 12. | #Calculate the Error MF for NS. Refer Equations (14) and (15) |
| 13. | if ((err_scl <= a) || (err_scl >= c)) |
| 14. | e_NS = 0; |
| 15. | else if (err_scl > a && err_scl < b) |
| 16. | e_NS = (255/(b-0) * (err_scl - a)); |
| 17. | else if (err_scl > b2 && err_scl < c) |
| 18. | e_NS = (255/(c-b) * (c - err_scl)); |
| 19. | else |
| 20. | e_NS = 255; |