Week | 12


Output Devices


How I’m designing a board, adding an output device and programming it to do something.


17 April 2018 15:44:

This week’s assignment is again on electronics and about learning how to output something from a board. Since I was away for more than 10 days, I would have loved to make one single assignment for both weeks (input and output) but, unfortunately, it is not seen as the best practice, so I decided to “accomplish” both, the output and input assignments, with a simple task each. For the output, I decided to use Neil’s example the hello.LCD.44 board.

Designing/Redrawing the board


Based on Neil’s hello.LCD.44 board, I have used Eagle to redesign it. For Designing, Routing, Checking and Exporting, I have followed the same steps already documented on Week 6 - Electronics Design.

Here are my files: Eagle Schematic, Eagle Board, Traces Image, Interior Image,Traces .rml and Interior .rml.

Milling the board


I had an issue with the milling and had to do it again. When doing the DRC (Design Rules Check) on Eagle I have input the wrong clearance (6mil instead of 16mil), so, some traces were connected to others. If they were not so many, I could have manually cut the traces as a workaround, but in this case, it would not be worth to spend the time to meticulously cut it with a great risk of the board not working properly anyway. So I have adjusted the clearance and the design of the board on Eagle.

Here’s a comparison of all 3 files: Neil’s and mine (1st and second attempts):

Stuffing the board


I have, then, soldered all the components of the board, using the schematics and references as guides. I have already documented some of the soldering process here on week 4.

I also had to make a cable for the LCD connection and soldered one end of it to the LCD, following the dislplay’s datasheet and, as a visual reference, Neil’s video of the working board here.

Programming the board


I used my previously done FabISP to program the board and a 9V battery to power it:

I’ve copied Neil’s makefile hello.LCD.44.make and C code hello.LCD.44.c to a local directory and used my FabISP to program the board.

When I tried to use Neil’s file to compile, by typing the following command:

make -f hello.LCD.44.make

I would get an error: Error 1: hello.LCD.44.make:13: *** missing separator. Stop.

Apparently Neil’s code is with spaces instead of tabs in some parts and C requires these to be corrected. I had to open the files on an editor and made sure to replace all spaces by tabs in the lines mentioned in the error.

Here are the corrected files: hello.LCD.44.make and hello.LCD.44.c.

Which allowed me compile it:

Then I was able to flash the board by typing:

sudo make -f hello.lcd.44.make program-usbtiny

and the result:

Here’s a video of the board / LCD working together:


This board’s main objective is to allow “text output”.

So a 10 pin connector from the board goes to the LCD, in which 4 pins are used for data exchange and the others ares used to power and control it.

The code below basically initialises the LCD module (by telling its chip how to work and how will be the communication between the micro-controller and its chip) and prints pre-defined lines of text, which in this case were “Hello to the world”.

The code includes the following headers: avr/io.h: Enabling input/output pins. util/delay.h: enabling delay functions (ms). avr/pgmspace.h: a series of functions providing interface for a program to access data stored in the program space (flash memory) of the device.

Apparently, the initialisation requires a complicated programming, due to the LCD module’s chip, but the overall concept of the code is quite straight forward after the initialisation, by just writing strings of characters out:

  lcd_init();
   //
   // main loop
   //
   while (1) {
      //
      // go to zero position
      //
      lcd_putcmd(0);
      lcd_putcmd(DB5);
      //
      // print first line from flash
      //
      static const char line1[] PROGMEM = "Hello to";
      lcd_putstring((PGM_P) line1);
      //
      // move to second line
      //
      lcd_putcmd(DB7+DB6);
      lcd_putcmd(0);
      //
      // print second line from flash
      //
      static const char line2[] PROGMEM = "the world";
      lcd_putstring((PGM_P) line2);
      //
      // pause
      //
      long_delay();
      //
      // clear display
      //
      lcd_putcmd(0);
      lcd_putcmd(DB4);
      }
   }