Fuzzy	Logic	Controller	Realization	
Using	Microcontrollers
Luis	Santiago,	Abdiel	Vega,	William	Morales
Advisor:	Rogelio	Palomera-Garcia
Introduction
• Fuzzy	Logic	(FL)	controlling	system	is	based	on	a	set	of	rules	
established	by	an	expert.	
• These	rules	are	translated	into	mathematical	steps	used	to	realize		
a	physical	controller.
• FL	controllers	can	be	physically	realized	in	different	forms.
• We	adopt	look	up	tables	and	function	realizations
• Microcontrollers	to	use	are	one	from	the	MSP430	family	(Texas	
Instruments)	and	one	from	the	Kinetis	series	(NXP)
FL	Architecture:
Fuzzification	Stage:
Involves	a	function	
transformation	where	
crisp	input	are	
transformed	into	fuzzy	
inputs.
Fuzzy	Rule	Steps
Is	defined	as	a	
conventional	statement	
in	the	form:	IF	x	is	A	
THEN	y	is	B,	where	A	and	
B	are	linguistic	values	
determined	by	fuzzy	
sets.
Defuzzification	Stage
Converts	fuzzy	items	to	
crisp	value.
FL	Memberships	and	Membership	Value
Objectives
• To	develop	a	method	to	introduce	fuzzy	controllers	schemes	derived	from	
applications	for	use	in	microcontrollers
• Present	focus:	Texas	Instruments	MSP430	and	NXP	Kinetis	series	
microcontrollers
• To	develop	two	microcontroller	based	fuzzy	controller	methods	using
• Look	up	tables,	and
• Function	development	inside	the	micro
• To	prove	the	controller	with	a	specific	application
• A	stabilizer	for	a	quadcopter
Problem	&	Hypothesis
• Methods	proposed	to	implement	the	FL	function:
• A)	Compute	the	outputs	using	Matlab	and	build	a	look-up	table	within	the	
microcontroller.
• Advantage:	useful	for	small	controllers
• Disadvantage:	memory	consumption
• B)	To	implement	the	membership	functions,	rules	and	defuzzification	rule	in	
the	microcontroller.
Methodology
• Study,	analyze,	and	comprehend	the	design	process	of	a	Fuzzy	Logic	
Controller	
• Understand	and	master	the	use	of	microcontroller	to	establish	the	
system	to	be	designed
• Implement,	program,	and	experiment	with	the	system	designed	in	it’s	
both	forms	using	two	different	microcontrollers
Results
Flowchart	of	
Rules
Rules	in	Matlab
Rules	and	Membership	Function	via	Matlab
Some	Subroutines	Functions
Triangular	Subroutines	Functions
Triangular:	mov			R6,R14;
cmp			R7,R14;
jhe MPos2;
add #0,R12;
jmp			Continue2;
MPos2: cmp			R8,R14;
jhe				MNeg2;
sub				R7,R14;
sub				R7,R8;
mov			#0,R11;
Div3: sub				R8,R14;
inc					R11;
cmp			R8,R14;
jhe				Div1;
add R11,R12;
jmp Continue2;
MNeg2: cmp				R10,R14;
jhe Zero2;
mov				R10,R15;
sub					R14,R15;
sub					R9,R10;
mov				#0,R11;
Div4: sub					R10,R15;
inc						R11;
cmp				R10,R15;
jhe					Div2;
add					R11,R12;
jmp					Continue2;
Zero2: add					#0,R12;
Continue2:		ret;
Trapezoid	Subroutines	Functions
Trapezoide:	mov				R6,R14;
cmp				R7,R14;
jhe MPos;
add #0,R12;
jmp				Continue;
MPos: cmp			R8,R14;
jhe				MZero;
sub				R7,R14;
sub				R7,R8;
mov			#0,R11;
Div1: sub				R8,R14;
inc					R11;
cmp			R8,R14;
jhe					Div1;
add R11,R12;
jmp Continue;
MZero: cmp				R9,R14;
jhe						MNeg;
add					#1,R12;
MNeg: cmp				R10,R14;
jhe					Zero;
mov				R10,R15;
sub					R14,R15;
sub					R9,R10;
mov				#0,R11;
Div2: sub					R10,R15;
inc						R11;
cmp				R10,R15;
jhe					Div2;
add					R11,R12;
jmp				Continue;
Zero: add				#0,R12;
Continue:	ret
Look-Up	Table
Input Angle Output Portion of
Voltage
0.46875 0.25
1.40625 0.25
2.34375 0.25
3.28125 0.25
4.6875 0.25
… …
10.3125 0.2534965
14.0625 0.2996183
20.15625 0.3957399
24.84375 0.496114
… …
Input Angle Output Portion of
Voltage
25.3125 0.5031513
28.59375 0.5397465
30.46875 0.5640244
35.625 0.6482558
39.84375 0.7456897
… …
40.78125 0.75
45.9375 0.75
50.625 0.75
54.375 0.75
59.53125 0.75
Function	Developed
For	the	Defuzzification process	we	use	the	Weighted	Average	
Function	to	calculate	the	output	number according	with	the	
simulation	on	Matlab.
𝑂𝑢𝑡𝑝𝑢𝑡 =	
Σ	𝜇 𝑥 ∗	 𝑥+,
Σ	𝜇 𝑥
𝜇 𝑥 	𝑔𝑟𝑎𝑑𝑒	𝑜𝑓	𝑤𝑒𝑖𝑔ℎ𝑡	𝑜𝑛	𝑡ℎ𝑒	𝑚𝑒𝑚𝑏𝑒𝑟𝑠ℎ𝑖𝑝
			𝑥+, weighted	average	input
Future	Work
• Set	up	the	one	input	system	as	a	proof	of	concept.	We	are	in	the	
process	of	building	the	hardware	set	up.
• Based	on	the	first	system,	make	a	selection	of	the	microcontroller	
models	appropriate	for	a	two	and	three	input	system
• Build	the	controller	with	two	axes,	hence,	two	inputs	or	three	inputs,	
depending	on	the	rules.
References
1.John	Yen,	Reza	Langari,	Fuzzy	Logic	Intelligence,	control	and	Information,	
Prentice-Hall	Inc,	1999
2.Jimenez,	M.,	Palomera,	R.,	and	Couvertier,	I.,	Introduction	to	Embedded	
Systems	Using	Microcontrollers	and	the	MSP430,	Springer,	2014
3.Texas	Instrument.	(APRIL	2011–REVISED	JANUARY	2012).	MSP430Gx53-
MSP430G2x13,	Data	Sheet.	Retrieved	from	
www.ti.com/lit/ds/symlink/msp430g2553.pdf
4.Freescale.	(2012-09-24).	FRDM-KL25Z,	User’s	Manual.	Retreived	from	
http://www.farnell.com/datasheets/1651277.pdf
Questions?

Fuzzy Logic Controller Realization Using Microcontrollers_Presentation