top of page

Documentation

LCD

 

The LCD incorporated on the board comes with several control functions. The first thing to do before actually working with the LCD is to initialize it. The initialization function simply changes the content of the register with the LCD address on the mcp23s17 to be 0x00, and for that, it uses the function mcp23s17_write_reg. To initialize the display, the following function should be used:

​

int lcdInit (const int rows, const int cols, const int bits, const int rs, const int strb, 

                            const int d0, const int d1, const int d2, const int d3, const int d4, const int d5,                                              const int d6, const int d7);

​

The main purpose of the function is to initialize the LCD and if it's done correctly, the function returns a handle to the LCD, else returns -1. Functions to write chars, strings and even messages are also given. 

​

void lcdPutchar (const int fd, unsigned char data);

​

void lcdPuts (const int fd, const char *string);

​

void lcdPrintf (const int fd, const char *message);

​

Also, functions that allow control over the position to write, like setting the pointer on the position x=y=0, clearing the display, blinking the display and other are presented below.

​

extern void lcdHome (const int fd);

​

extern void lcdClear (const int fd);

​

extern void lcdDisplay (const int fd, int state);

​

extern void lcdCursor (const int fd, int state);

​

extern void lcdCursorBlink (const int fd, int state);

​

extern void lcdSendCommand (const int fd, unsigned char command);

​

extern void lcdPosition (const int fd, int x, int y);

​

extern void lcdCharDef (const int fd, int index, unsigned char data [8]);

​

extern void lcdPutchar (const int fd, unsigned char data);

​

extern void lcdPuts (const int fd, const char *string);

​

extern void lcdPrintf (const int fd, const char *message, ...);

​

​

7-Segment display

​

The 7-segment display should also be initialized. The initialization function simply changes the content of the register with the 7-seg display address on the mcp23s17 to be 0x00, and for that, it uses the function mcp23s17_write_reg.

​

void semb_7_segment_init(void);

​

The function that allows the user to write to the 7-segment display is also provided below. 

​

void semb_7_segment_set_digit(int num, int digit);

​

​

Functions implemented to connect all the other peripherals are used to change the state from ON to OFF and OFF to ON, on the optocouplers, relays and LEDs, read state on the switches and digital inputs and set outputs on the digital outputs.

​

Optocouplers

​

The two Optocouplers are connected in parallel to output pins 0 and 1 respectively. 

​

void semb_set_opto (int num, enum STATE state);

​

Relays

​

The two Relays are connected in parallel to output pins 2 and 3 respectively. When you set output pin 2 ON relay 0 activates.

​

void semb_set_relay (int num, enum STATE state);

​

LEDs

​

LED's are configured using the following GPIO's, which when set to STATE ON illuminate.

​

void semb_set_led (int num, enum STATE state);

​

Switches

​

The four switches are connected in parallel to the last four input pins, more specifically switch 1 is connected to the last input and so on.

​

int semb_get_button (enum STATE state);

​

Digital Intputs

​

The eight input pins detect a connection to ground (provided as the ninth pin). The inputs are pulled up to 5V.

​

enum STATE semb_get_input (int num);

​

Digital Outputs

​

The outputs are open collectors, they can be thought of as switches connecting to ground which makes it possible to control devices that operate using different voltages.

​

void semb_set_output (int num, enum STATE state);

​

Comments

​

Functions arguments that are called "num" have the objective of providing information about the number of the respective class peripheral to communicate with. Argument referred to as "state" can be one of two possible, either "ON" or "OFF".

​

Figure 1 - expansion board complete peripherals pinin/pinout diagram

Figure 1 shows all the peripheral pins on the expansion board.

©2017-2018 by RaspPiExpansionTeam

bottom of page