seminars

The seminar sessions form the core of the practical work in this module. We will be using the FRDM-K64F ARM based platform. The practical work will have two themes, one based on the MBED libraries and abstractions, the other based on a pure C clean room implementation.

The MBED libraries are written in C++ and are a generic set of functions that abstract out the behaviour of supported devices. The device vendor provides an implementation of the routines on their device.

numbering convention

The seminar sessions are numbered 01, 02,… this is roughly aligned with the weeks in the semester, but it isn’t a fixed mapping.

Within each seminar exercises are numbered 1, 1,… the associated Githib repository is called s1.1 etc. Question parts an solutions are tagged as releases,

Getting started

You should study the Getting started notes to see the workflow that is recommended for the practical work.


Digital Signals

/seminars/01.html

Here we look at the digital input and output from the device. The typical hardware devices that handle the physical aspects of digital signals are LEDs and Switches.

more…


Events and interrupts

/seminars/02.html

Handling events, button interrupts and timer interrupts. We want to be able to respond to external events, as they occur. Or to create a precisely timed series of events.

more…


Analogue IO

/seminars/03.html

Analogue IO.

more…


LCD & serial comms

/seminars/04.html

more…


Consolidation

/seminars/05.html

Take the opportunity to make sure you are up to date with the exercises.

more…


Timing and Events

/seminars/06.html

Managing timings, threads, and events.

more…


UDP Communications

/seminars/07.html

In this seminar we’ll look at simple networked communications using UDP sockets.

more…


Control

/seminars/08.html

Control of systems

more…


Interaction

/seminars/09.html

more…


Basic use of the LCD

/seminars/lcd_basic.html

  1. Introduction
  2. LCD basics

Introduction

These exercises introduce you to using the LCD display on the applications board. This is a simple black-and-white display of 128 x 32 pixels. The top left corner of the display is at (0,0) and the bottom right corner of the display is at (127,31). At the end of these exercises you should be able to

LCD basics

  1. Obtain a copy of the repository LCD in your usual way. Open the folder in Atom. Build, download and run the code. Check that you can see some output on the LCD display. Now open the file main.cpp. Notice the lines

    #include <C12832.h>
    
    // Using Arduino pin notation
    C12832 lcd(D11, D13, D12, D7, D10);
    

    This shows you how to include the library header for the display and how to declare a variable (lcd) of the appropriate type (C12832) to access it. C12832 is a class that provides the methods that we can use to work with the display. Have a look at the description of the methods of the C12832 class to see what methods are available and how to use them. The rest of these exercises will require you to study this page carefully. Check your understanding by answering the following questions.

    1. How would you declare a variable called display that you could use to interact with the LCD? What are the advantages and disadvantages of declaring this as a global variable? If it was declared as a local variable, e.g. in main(), how would it be possible to write to the display from any other function?
    2. Which method is used to clear the screen?
    3. How would you position the next text write operation to occur at the top left of the display?
    4. Refer to the schematic for the application board. Based on the pins that are used in the constructor for the lcd variable in the example in the repository, identify what sort of communication bus is used by the microcontroller to interact with the LCD display.
  2. The mbed library provides macros called MBED_MAJOR_VERSION, MBED_MINOR_VERSION and MBED_PATCH_VERSION. The macros all evaluate to integers. It’s sometimes helpful to look at these values to see what version of the library has been used to build your program. Write a program to display a string on the LCD that shows the value of each of these macros, separated by . characters, e.g. 5.7.1

  3. Write a program that allows you to work out what is the maximum number of lines of text that you can display at the same time on the LCD, using the current font. Write a similar program to work out the maximum number of characters per line. Experiment to find out what happens if you try to exceed these limits.

  4. Write a program to display the current values of the potentiometers. When the board is held the right way up to read the LCD, Pot 1 should be on the left and Pot 2 on the right. Display their values to 2 decimal places, like this:

    L: 0.34
    R: 0.68
    

    Your program should execute in a loop with a short time delay and should repeatedly update the display. Experiment with the delay needed to keep your system responsive. Note: You may need to refer to repository s3.1 to remind yourself how to read the value of the potentiometers.

  5. Write some simple programs to become familiar with the graphics methods, e.g.

    • a program that draws a line from the top left to the bottom right, a line from the bottom left to the top right and a maximal open rectangle bordering the whole display;
    • a program that draws an open circle of radius 5 whose centre has coordinates (70, 12), and a filled circled of radius 3 whose centre has the same coordinates;
    • a program that draws an open rectangle, 104 px x 10 px, with top left corner at (20,0), and a filled rectangle 100 px x 6 px, with top left corner at (22,2).

    Experiment with these, and similar, programs until you are confident that you understand the main graphics methods.

  6. Now write a program that uses both text and graphics to show the status of the potentiometers. You should distinguish between the potentiometers using L and R, as in the earlier exercise, but instead of displaying the value of each potentiometer in a text field, show its value using a combination of an open and filled rectangle. The proportions of the open and filled parts should be determined by the potentiometer value, e.g. if the value of the potentiometer is 0.75, then the rectangle should be 75% filled and 25% unfilled.

more…



© 2017   Dr Alun Moon
alun.moon@northumbria.ac.uk