UPC EETAC Bachelor's Degree in Telecommunications Systems and in Network Engineering EEL

Chapter 3 problems

      - B3.1 -

Designing a wind compass

Problems

 

B3.2


1. Specifications

We want to design a digital wind direction meter (wind_compass) based on a 16-position optoelectronic rotary encoder as shown in Fig. 1 using a PIC18F4520. The same project is proposed in D1.1 as a combinational circuit based on logic gates.

Symbol

Fig. 1. Circuit symbol and its realisation in Proteus wind_compass.pdsprj for better comprehending how does it works.

Fig. 2 represents the wind compass subdivided in 16 directions each of which is assigned to a 4-bit Gray code.

Wind directions

Fig. 2. Wind compass describing the sixteen principal bearings used to measure wind direction and an example of commercial manufactured wind transducer.

Fig. 3 represents the sensor disk coded in Gray, which is used instead of binary radix-2 code to prevent spurious outputs from electromechanical switches. The objective is to develop the VHDL code and the final circuit to be synthesised into a target complex programmable device (CPLD) or a field programmable gate array (FPGA) chip.

Gray pattern and trnasducer details

Fig. 3. Gray code's error reduction with encoders (ref.) Adjacent codes differentiate themselves by only one bit.

 

Sensor

Fig. 4. Sensor codes assigning for instance the code "0000" to the NNW direction.

Some questions to organise the project:

- Write the truth table of the wind_compass. The inputs have to be ordered in this way: E, D(3..0).

Truth table

Fig. 5.Wind compass circuit and truth table.

- Use the following pin connections:

D3 --> RA0; D2 --> RA1; D1 --> RA2; D0 --> RA3

Y(15..8) --> RB(7..0); Y(7..0) --> RD(7..0)

E --> RC7

S(6..0) --> RC(6..0)

 - List all the RAM variables involved in this design.

From a simiar tutorial in P9 or LAB9 where to copy and adapt to the project location folder:

- Draw an sketch of the hardware circuit and capture it in Proteus wind_compass.pdsprj

- Write the software source file wind_compass.c. Start an MPLABX - XC8 project targeted to the PIC18F4520 chip. Use our software organisation.

As we have decided, start compiling and testing one input or output at a time:

- Write the funcion init_system(). Start configuring only one input, compile and test. Describe using pictures and annotations how you are configuring registers.

- Write the funcion read_inputs(). Start reading only one input, compile and test. Describe using pictures and annotations how you are reading an input using bitwise C instructions.

- Write the funcion write_outputs(). Start writing only one output, compile and test. Describe using pictures and annotations how you are writing a RAM variable in the corresponding pin using bitwise C instructions.

- Translate the truth table to C code and complete truth_table().

- Check the full project and report.