Stage 6 - Servo Control Using Freertos Queues and Cli
Stage 6 - Servo Control Using Freertos Queues and Cli
Stage 6 - Servo Control Using Freertos Queues and Cli
NOTE:
Failure
to
attempt
this
stage
by
not
attending
a
stage
session,
having
your
workbook
signed
off
and
not
uploading
your
code
to
your
get
repository
will
result
in
a
deduction
of
5%
from
your
project
total.
Workbook
Requirements
NOTE:
The
workbook
must
be
well
advanced
BEFORE
your
come
to
your
prac
session.
Points
1
4
must
be
present
in
your
workbook,
before
you
attend
your
prac
session.
You
require
the
following
sections
to
be
present
in
your
workbook:
1. Objectives
of
Stage
2. Implementation
o Hardware
block
diagram
(top-down)
o Show
input/output
signals
and
key
components
3. Software
flow
chart
o Describe
key
sections
of
your
code
as
signal
flow
charts,
state
diagrams
and
flow
charts.
o List
details/notes
relating
to
key
software
functionality
4. Testing
Procedure
o Describe
or
Draw
how
you
will
test
key
components
5. Conclusions
and
Question
Responses
Introduction
FreeRTOS
is
a
commonly
used
realtime
operating
system
for
various
embedded
platforms.
This
stage
will
introduce
you
to
Command
Line
Library
(CLI)
with
FreeRTOS.
This
stage
will
also
introduce
queues
used
in
FreeRTOS
for
inter-task
communication
and
interfacing
to
peripherals.
You
will
use
the
CLI
to
control
the
pan
and
tilt
servo
modules.
FreeRTOS
Queue
A
FreeRTOS
Queue
is
a
memory
object
that
used
to
share
information
between
tasks.
The
Queue
allows
a
task
to
write
and
read
variables
with
other
tasks.
A
Queue
can
hold
a
number
of
fixed
data
items
(integer,
float,
etc).
Multiple
tasks
can
write
or
read
to
a
Queue
simultaneously
and
a
task
can
block
or
suspend
on
a
Queue
read
or
write.
Stage
6
Servo
control
using
FreeRTOS
Queues
and
CLI
Page 1
FreeRTOS
Command
Line
Interface
(CLI)
The
Command
Line
Interface
(CLI)
is
a
FreeRTOS-Plus
Library
that
allows
users
to
integrate
terminal
command
control
with
their
programs.
The
CLI
allows
a
user
to
specify
callback
functions
to
be
executed,
when
the
user
types
a
command
in
the
terminal.
The
CLI
provides
functions
to
parse
and
process
strings,
typed
into
a
terminal
window.
When
the
CLI
detects
a
command,
it
will
then
execute
the
users
callback
function.
NOTE:
callback
functions
are
NOT
substitutes
for
tasks.
A
CLI
callback
function
should
only
extract
the
command
parameters
and
give
a
return
string
argument.
All
major
processing
should
be
done
in
a
task.
A
CLI
function
should
control
a
task
using
semaphores,
mutexes
and
queues.
Refer
to
ex18_fr_cli
example
See:
http://www.freertos.org/FreeRTOS-
Plus/FreeRTOS_Plus_CLI/FreeRTOS_Plus_Command_Line_Interface.shtml
Page 2
Design Tasks
FIRST:
update
your
source
files
using
git:
1. Open
a
terminal
window
and
navigate
to
/home/csse3010/np2git
2. Type
git
pull
mylib
Setup
Task:
Your
mylib
code
must
meet
the
guidelines
specified
in
the
mylib
guide,
on
Black
Board.
You
will
create
the
library
source
(sxxxxxx_cli.c)
and
header
files
(sxxxxxx_cli.h)
in
your
mylib
folder.
Your
source
file
(sxxxxxx_cli.c)
should
contain
your
CLI
callback
functions
function.
Your
header
file
(sxxxxxx_cli.h)
should
contain
the
callback
function
prototypes
and
CLI_Command_Definition_t
structs.
You
will
need
to
have
the
CLI
functions,
listed
in
design
task
1
and
table
1,
implemented
in
your
mylib
source
and
header
files.
Notes:
You
may
add
an
additional
header
file
in
your
stage
folder,
to
share
commonly
used
semaphores
and
queues
(i.e.
common.h).
You
must
also
use
your
servo
mylib
driver
to
control
the
pan
and
tilt.
You
can
modify
your
servo
mylib
driver,
if
needed.
Task
Stack
Usage
and
Delay:
For
each
task
created,
you
will
need
to
calculate
and
document
in
your
workbook
the
following
parameters:
Estimate
of
memory
used
for
each
task
(i.e.
task
stack
usage)
Priority
of
each
task
Estimate
of
each
task
delay
(including
blocking
time
on
queues)
You
can
use
the
parameters
to
budget
for
memory
and
delay
time
of
each
task.
This
can
be
used
to
identify
possible
time
and
resource
starvation
of
tasks
Design
Task
1
Laser
CLI
Control
Write
a
CLI
command
to
control
the
laser
(type:
laser
on
or
laser
off
See
Table
1).
The
laser
should
be
controlled
with
a
task
and
semaphore.
The
laser
task
should
turn
on
the
laser,
when
a
semaphore
is
given.
The
Pan/Tilt
laser
pin
should
be
connected
to
NP2
D0
pin.
DO
NOT
control
the
laser
directly
with
the
CLI
callback
function.
It
will
not
be
considered
as
a
pass,
if
the
CLI
callback
directly
controls
the
laser.
Refer
to
ex18_fr_cli
example.
Design
Task
2
Pan/Tilt
Servo
Control
using
a
CLI
Control
the
Pan/Tilt
using
CLI
commands.
The
Pan/Tilt
should
be
connected
to
NP2
D2
and
D3
pins.
Implement
the
commands
in
table
2.
Create
two
tasks
(Pan
and
Tilt
control
tasks)
to
control
the
Pan/Tilt
servos.
You
must
use
two
queues
to
transfer
the
Pan/Tilt
angles
calculated
by
the
pan
and
tilt
CLI
commands,
to
the
Pan/Tilt
task.
You
must
use
either
semaphores
or
queues
to
control
the
Pan/Tilt,
from
the
left,
right,
up
and
down
CLI
commands.
Note:
you
can
send
a
struct
through
a
queue.
String
functions,
like
atoi
and
strok
can
be
used.
Stage
6
Servo
control
using
FreeRTOS
Queues
and
CLI
Page 3
Table
1:
CLI
Pan/Tilt
Commands
Command
Parameter
Description
pan
Angle
Degrees
Move
the
pan
to
the
specified
angle
(limits:
-70
to
70)
tilt
Angle
Degrees
Move
the
tilt
to
the
specified
angle
(limits:
-70
to
70)
left
Move
the
pan
left
5
from
the
current
position
right
Move
the
pan
right
5
from
the
current
position
up
Move
the
tilt
up
by
5
from
the
current
position
down
Move
the
tilt
down
by
5
from
the
current
position
Laser
on
or
off
Turn
the
laser
on
or
off
Refer
to
ex16_fr_queue
and
ex18_fr_cli
examples.
Also
refer
to
www.freertos.org
for
the
latest
FreeRTOS
queue
API.
Challenge
Task
1:
Laser
Drawing
(OPTIONAL)
Create
a
CLI
command
(box)
that
will
draw
the
outline
of
a
box
or
a
pentagon
(pentagon)
on
a
wall,
using
the
Tilt
modules
laser.
You
must
use
an
additional
task
to
control
the
Pan
and
Tilt
control
tasks.
References:
STM32F4xx
Datasheet
Lecture
6b,
7a,
7b,
8.
www.freertos.org
http://www.freertos.org/FreeRTOS-
Plus/FreeRTOS_Plus_CLI/FreeRTOS_Plus_Command_Line_Interface.shtml
Page 4