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

 

 

CSD_PICstick development board

Microchip


We can implement prototypes for simple circuits based on microcontrollers using standard commercial boards such as EXPLORER8 or older PICDEM2. However, it is interesting and educational to design a custom training board for solving our introductory CSD lab exercises. This is the purpose of the CSD_PICstick presented in this unit.


1. Specifications Planning Developing Testing Report

Let us conceive a simple training board containing these features:

- 40 pin and 28 pin sockets.

- Reset push-button (MCLR_L).

- Primary 8 MHz (OSC1, OSC2) and secondary 32.768 kHz (T1OSI, T1OSO) XTAL oscillators.

- Connector ICSP for chip programming and debugging using commercial MPLAB SNAP device, PICkit5 or ICD5.

- Unregulated DC input VIN from 7 V to 15V. Power LED indicator.

- Selectable PIC voltage: VCC = +5V or +3.3V.

- 8 LED to represent binary codes (or a 10-LED bar). 

- Active-low push-button at RB0/INT0.

- Switch at RA4.

- Analogue input at RA0/AN0.

- 20x2 header connector with all microcontroller pinning.

CSD_PICstick

Fig. 1. CSD_PICstick idea. Jumpers will be used to connect or disconnect some circuits. The 40-pin expansion connector allows the insertion of any daughter board.

 


Specifications 2. Planning Developing Testing Report

In this section we will imagine the hardware circuit and where all inputs and outputs are conencted. We will leave the schematic ready to be captured as a KiCad project.

Schematic ideas on the design of the CSD_PICstick

Fig. 2. Ideas on the schematic. We will use 40-pin and also 28-pin mC sockets.

 


Specifications Planning 3. Developing Testing Report

Proteus simulation. A series of design phases to check the circuit: phase #1, phase #2, phase#3, phase #4

Before designing the PCB, we can check whether the basic idea of the board and its inputs, outputs and oscillators work correcty solving as usual a given example in Proteus divided in phases. For instance:

(1) Design phase #1. Let us solve the same Counter_BCD_1digit as a FSM using plan X proposed in LAB10 targeting a PIC18F46K22.

Symbols and function table
Hardware details for the design phase #1

Fig. 3. Counter_BCD_1digit symbol , function table and hardware to drive the application and watch outputs.

Project location:

C:\CSD\CSD_PICstick\Counter_BCD_1digit\

This Counter_BCD_1digit.pdsprj is the hardware circuit and Counter_BCD_1digit.c the software C source program. The XC8 compiler versión is v3.0.  Include this config.h file in your project.

Proteus circuit running

Fig. 4. Counter_BCD_1digit captured and running in Proteus.

 


(A series of design phases to check the circuit: phase #1, phase #2, phase#3, phase #4)

(2) Design phase #2. Let us add an LCD to the circuit.

C:\CSD\CSD_PICstick\Counter_BCD_1digit_LCD\

 

Fig. 5. Counter_BCD_1digit_LCD using 6 pins to interface the LCD peripheral. We will assume the LCD as only a device to write, thus RW_L interface signal will be grounded.

We will use the RD(5..0) through the expansion connector to interface the LCD. Another option to reduce the pin number to only two pins is to use the I2C interface and the LCD to I2C adapter. For both application we need to find C libraries, as it was proposed in P11. The reference and LCD libraries for this design are found here.

Proteus schematic running the application

Fig. 6. Proteus schematic. 

Software organisation is like in counter_BCD_1digit_LCD.

The XC8 compiler versión is v3.0, C standard is C99. And these LCD library files lcd.c, lcd.h has to be included in the project. Config.h contains all the microcontroller configuration bits.

This Counter_BCD_1digit_LCD.pdsprj is the hardware circuit and Counter_BCD_1digit_LCD.c the software C source program.

Compiler options and source files

Fig. 7. Library files and compiler options. To disable some warnings you can add these additional XC8 Compiler options: -Xparser -Wno-implicit-int-conversion -Wno-implicit-int-float-conversion. MPLAB XC8 C Compiler User’s Guide for PIC MCU.

 


(A series of design phases to check the circuit: phase #1, phase #2, phase#3, phase #4)

(3) Design phase #3. In order to check that the secondary 32.768 kHz oscillator operates correctly, we can replace the external CLK or push-button by the internal TMR1 runnning as timer to generate the var_CLK_flag when TMR1 overflows. Timing period TP can be selected using the free push-button as a switch Sel_freq. For instance: 1 s (1 Hz) or 83.33 ms ( 12 Hz).

Project folder:

C:\CSD\CSD_PICstick\Counter_BCD_1digit_LCD_TMR1\

Counter using TMR1

Fig. 7. Counter_BCD_1digit_LCD_TMR1 symbol.

For this application we have to select the secondary oscillator, and adjust N1 and N2 parameters to obtain the desired TP.  For instance: TP = 1 Hz ==> N1 = 1, N2 = 32768. TP = 12 Hz ==> N1 = 1, N2 = 2731.

How to configure TMR1 for timing TP

Fig. 8. How to configure TMR1 peripheral to generate a) 1 Hz or b) 12 Hz from the external 32.768 kHz secondary oscillator.

Software organisation is like in Counter_BCD_1digit_LCD_TMR0 replacing TMR0 by TMR1.

These are the source files: Counter_BCD_1digit_LCD_TMR1.pdsprj, Counter_BCD_1digit_LCD_TMR1.c.

Phase #3 schematic in Proteus

Fig. 9. Counter_BCD_1digit_LCD_TMR1 captured in Proteus. It is running using TMR1 interrupts driven by the secondary oscillator. Use breakpoints, watch window and follow the Program Counter to check how the microcontroller executes instructions.

 


(A series of design phases to check the circuit: phase #1, phase #2, phase#3, phase #4)

(4) Design phase #4. In order to check that the analogue input signal from the potentiometer AN0 is captured correctly, we can enhance the application adding analogue to digital (A/D) conversions. We can use the previous phase timing periods TP = 1 s or TP = 8.33 ms as sampling periods. 

Symbol adding the analogue to digital conversion

Fig. 10. Analogue to digital conversion.

We need to synchronise analogue to digital conversion on TMR1 interrupts. In this simple application, A/D conversion will be running nonstop, thus A/D parameters will be fixed all in init_system(). The function analogue_read() will start conversions and wait for end of conversion in a few microseconds. 

empty box

Fig. 11. Software organisation.

These are the source files: Counter_BCD_1digit_LCD_TMR1_AD.pdsprj, Counter_BCD_1digit_LCD_TMR1_AD.c.

Proteus capture of the Analogue to digital converter

Fig. 12. Counter_BCD_1digit_LCD_TMR1_AD captured in Proteus.

 


PCB design

We will capture the full circuit in a new KiCad project to draw the complete schematic and its PCB. Many additional components are required at this level: connectors, jumpers, footprints, power regulators, decoupling capactitors, etc.

Schematic in KiCad

Fig. 13. The PCB schematic contains many more resourcs, like headers, test points, etc.

The full KiCad project PCB_CSD_PICstick_v2.zip. Project location:

C:\CSD\CSD_PICstick\PCB\

CSD_PICstick_3D_picture

Fig. 14. The 3D view of the finished board.

NOTE: Current CSD and DEE KiCad symbols, footprints and 3D tuned components are available in these three libraries: symbols.zip, footprints.zip and 3dmodels.zip, to be unzipped and placed in the corresponding KiCad 3rdparty user directory. Basically, in this introductory PCB design level, the idea behind tuning components is to enlarge their pads for easy soldering.

You can use this prototype as a base model for copying and adapting your new application. Daughter or shield boards with additional components can be plugged through the 40-pin connector.

Another interesting option for developing a professional kit is miniaturise the prototype board selecting surface mount technology (SMT) components to be able to place components on both sides of the PCB.

 


Specifications Planning Developing 4. Testing Report

The board soldered and ready for testing an example project.

Prototype board running

Fig. 15. Prototype ready for running an application.

 


Specifications Planning Developing Testing 5. Report

Project report: sheets of paper, scanned and annotated figures, file listings, notes or any other resources. In CSD follow this rubric of indications for writing reports.