Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Technical Report for External Display of Doppler Radar Gun

General Description of RS485 daughter board and external display

RS485 STM32L476
Daughter Board Discovery Board
(MCU)

RS485 Crystal 7 Segment LED


Interface Oscillator Display

LED
Clock
Driver
CPLD Divider

Control Serial-Parallel BCD-7 Segment


Logic Shift Register Decoder

Power External
Supply Display Board

Figure 1: Block diagram of external display board.

The processed data from MCU, which is an integer with at most two digits indicating the
speed in miles per hour, is transmitted to the external display board through RS485 interface,
and is shown on the 7 segment LED displays. The data is transmitted in the form of binary-
coded decimal (BCD). This is passed into the XC2C64A CoolRunner-II CPLD chip where the
internal hardware such as serial-parallel shift register and BCD-7 segment decoder modify it
into signals that switch the LED segments on or off. In order to make the CPLD and LEDs
work, there are other structures on the display board, including power supply, crystal
oscillator and LED driver.

LED driver: Each LED segment is controlled by a CPLD pin. A segment will be turned on if
the corresponding CPLD pin is low and vice versa. The resistor between each connection is
to limit the current flowing through the LED and CPLD pins. When an LED is turned on, the
potential difference across its resistor is 3.3V (supply voltage) – 1.95V (LED forward voltage)
= 1.35V. For a maximum current of 8mA, every resistor should be at least 169Ω. To be safe,
the design uses 330Ω resistors.

RS485 driver: A twisted pair connects the daughter board to the display board. This enables
half-duplex communication between them. For the sn65hvd1781 chip, R is receiver and D is
transmitter on each board. The enable line is normally low. It will be raised to logic „1‟ during
transmission.

Power supply: MAX882 linear regulator chips are used to maintain two input voltages for
the CPLD. 3.3V supplies for IO drivers and other devices on the display board whilst 1.8V is
used for internal logic operations. The main voltage source is 5V coming from the MCU.
Serial Interface (MCU Daughter Board)

The 3.3V voltage source for sn65hvd1781 comes from the MCU. The enable line is pulled
down whereas the receiver pin is pulled up, both by a 10kΩ resistor. The MCU internal
hardware involved is USART2. The pin assignment from MCU is as follows:

MCU pin USART2 function sn65hvd1781 pin


PA1 DE (Polarity - High) DE, RE(bar)
PA2 Tx D
PA3 Rx R
Table 1: Pin assignment for daughter board.

The USART2 peripheral is initialized to have assertion time and deassertion time of 10 units
(1 unit = 1/16 bit period) to accommodate for driver enable time and driver propagation delay.
The system has a baud rate of 57600Hz, transmits in 9-bit words including 8-bit data and 1
even parity bit. There are also 1 start bit and 1 stop bit at the beginning and the end of the
word.

The speed result from MCU data processing stage has an update rate of about 1Hz. Thus
USART2 is transmitting every 1 second. It expects response from display board within 10ms,
or else timeout error will be triggered. The MCU also compares the returned value and sent
value to ensure that there is no communication error. USART2 receiver uses interrupt to
reduce unnecessary loops in main thread.

External Display Board

(1) Clock divider

The crystal oscillator produces square waves of 1.8432MHz. In order to have 57600Hz baud
rate, the clock divider reduces the input frequency to 32 times lower. The schematic design
uses 5 D-type flip-flops with inverted Q connected to D, as T-type flip-flops. Each flip-flop
divides the frequency by 2.

(2) Control logic

There are six stages for each transmit or receive cycle. Each stage is represented by one D-
type flip-flop output. The same flip-flops are used for both transmitting and receiving,
interchanged at the switching stage which inverts the tx_not_rx_flag signal. The control
starts by detecting the incoming start bit and clocking through all the stages without affected
by the serial data or communication error.

(3) Transmission error

The parity bit saved in a flip-flop is tested with the 8 data bits stored in the shift register using
XOR gates. If the parity does not match, XOR produces a „1‟ that indicates error. Then all
the data bits will be replaced by 1 and error is reported back to the MCU.

(4) BCD-7 segment decoder

Each BCD-7 segment decoder block receives an extra input called previous_blank. The
MSB block has this input always high. If the BCD received is 0000 and previous_blank is
high, all the segments will be turned off (i.e. output pins pulled high). When the speed is less
than 10mph, the MSB digit will be blank and MSB block will pull previous_blank input for
LSB digit high. If the BCD for LSB is also 0000, then both digits will be blank.
Self-reflection Document for Electronics Project

Contribution

I handled most of the coding for STM32L476 Discovery Board, especially for communication,
interrupts for ADC timer and comparator, LCD menu and full systems. Besides that, I was
involved in quite a lot of the hardware design and helped other group members. Among
these were filter design for ADC and comparator, amplifier and filter circuit testing, RS485
communication interface (hardware and software), display board connections, pin
assignment and external clock source. Relative to other members in my group, my
contribution is about 120% if only technical parts are considered. Including the poster design
and report writing, my contribution is in line with the others, as I only provided some
information and materials for these jobs. My technical contribution is slightly more than
average because I am involved in almost all the aspects in the project, directly or indirectly.
I can understand new materials fast, and I am quite used to programming and circuit testing
compared to other members, therefore I can explain the concepts and spot design errors,
supporting everyone through peer review.

Skills learned

From this project, I learned various software and programming skills. Examples are LTSpice,
KiCad, STM32 System Workbench and Xilinx ISE. I studied different parameters that have to
be considered when configuring systems like ADC and UART. I encountered VHDL
language and digital circuit design in semester 2. Besides, I also learned a lot about IC chips
and circuits, for instance, single rail op-amp circuit topology and RS485 electrical protection.
Compared to other members of the group, I spent more or less the same effort to complete
this project. Even though I had most of the basic skills and was able to achieve the
objectives fast, but I went on to research more or tried to improve the codes, such as to use
interrupts wherever possible. In terms of soft skills, I improved my communication skills and
time management skills through this project.

Group Working

I think my group works very well. Everyone has their own main field of expert and thus job
distribution can be done effectively. If any information is needed from another part of the
project, the member responsible for that was able to provide the data. The links between
different jobs could be seen quite obviously. Once a member had completed the assigned
part, he or she would try to help others who were still struggling. The only negative part
might be that not every member was very well prepared for the start of project weeks. If
another piece of group work were to be done, I would suggest that every member should
research about the project beforehand so that we will not waste time understanding what
have to be done.
PCB Design

Schematic diagram for the daughter board

Figure 2: RS485 daughter board schematic.


PCB diagram for the daughter board

Figure 3: RS485 daughter board PCB (top).

Figure 4: RS485 daughter board PCB (bottom).


PCB plot files

File Name Content


DaughterBoard-B.Cu.pdf Back copper layer
DaughterBoard-B.Mask.pdf Solder mask on board‟s back
DaughterBoard-Edge.Cuts.pdf Board‟s perimeter definition
DaughterBoard-F.Cu.pdf Front copper layer
DaughterBoard-F.Mask.pdf Solder mask on board‟s front
DaughterBoard-F.SilkS.pdf Silkscreen on board‟s front
DaughterBoard-drl_map.pdf Drill hole positions
Table 2: List of plot files. (Appended at the end of this document in the same order)

PCB Bill of Materials

Part Number Supplier Number Cost per part/ £ Total Cost/ £


MC0201X104K6R3CT Multicomp 2000 0.0066 13.20
CRCW120610K0JNEA Vishay 2000 0.0117 23.40
CRCW060310R0JNEAHP Vishay 2000 0.0314 62.80
CDSOT23-SM712TR-ND Bourns Inc. 1000 1.2200 1220.00
SN65HVD1781DR Texas Instruments 1000 1.6500 1650.00
MKDS1,5/2 Phoenix Contact 1000 0.6130 613.00
MKDSN1,5/5 Phoenix Contact 1000 1.2700 1270.00
Total/ £ 4852.40
Table 3: Bill of materials for 1000 orders.

References

[1] Farnell. Farnell element 14 UK [Online]. Available: http://uk.farnell.com/


[2] Digikey. Digikey Electronics [Online]. Available: https://www.digikey.co.uk/
[3] Texas Instruments, “SN65HVD178x Fault-Protected RS-485 Transceivers With 3.3-V to
5-V Operation,” SN65HVD1781 datasheet, Dec. 2007 [Revised March 2017].
[4] U. Nanda, S. K. Pattnaik, “Universal Asynchronous Receiver and Transmitter (UART),” in
2016 3rd ICACCS [Online], Coimbatore, India, 2016. Available: https://doi-
org.ezproxy.nottingham.ac.uk/10.1109/ICACCS.2016.7586376

You might also like