From b8704d98e828c14682187c71f99a02adad94c321 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Mon, 8 Dec 2025 16:10:32 -0500 Subject: move proposal and midterm report to doc/ --- doc/midterm_report/breadboard.jpg | Bin 0 -> 1317467 bytes doc/midterm_report/midterm_report.tex | 261 ++++++++++++++++++++++++++++++++++ doc/proposal/diagram.fig | 120 ++++++++++++++++ doc/proposal/proposal.tex | 63 ++++++++ doc/references.bib | 100 +++++++++++++ midterm_report/breadboard.jpg | Bin 1317467 -> 0 bytes midterm_report/midterm_report.tex | 261 ---------------------------------- midterm_report/references.bib | 100 ------------- proposal/diagram.fig | 120 ---------------- proposal/proposal.tex | 63 -------- 10 files changed, 544 insertions(+), 544 deletions(-) create mode 100644 doc/midterm_report/breadboard.jpg create mode 100644 doc/midterm_report/midterm_report.tex create mode 100644 doc/proposal/diagram.fig create mode 100644 doc/proposal/proposal.tex create mode 100644 doc/references.bib delete mode 100644 midterm_report/breadboard.jpg delete mode 100644 midterm_report/midterm_report.tex delete mode 100644 midterm_report/references.bib delete mode 100644 proposal/diagram.fig delete mode 100644 proposal/proposal.tex diff --git a/doc/midterm_report/breadboard.jpg b/doc/midterm_report/breadboard.jpg new file mode 100644 index 0000000..e1974c3 Binary files /dev/null and b/doc/midterm_report/breadboard.jpg differ diff --git a/doc/midterm_report/midterm_report.tex b/doc/midterm_report/midterm_report.tex new file mode 100644 index 0000000..549751d --- /dev/null +++ b/doc/midterm_report/midterm_report.tex @@ -0,0 +1,261 @@ +\documentclass{article} +\usepackage{graphicx} +\usepackage{hyperref} +\usepackage[backend=biber]{biblatex} +\usepackage{amsmath} + +\addbibresource{../references.bib} + +\title{\textsc{Comp} 490 Mid-Term Report} + +\author{Sam Anthony 40271987 \\ +sam@samanthony.xyz \\ s\_a365@concordia.ca +\and +Hovhannes Harutyunyan, PhD \\ +Department of Computer Science and Software Engineering \\ +haruty@encs.concordia.ca +\and +Concordia University \\ +} + +\begin{document} + +\maketitle +\tableofcontents +\pagebreak + + +\section{Project introduction} + +The goal of the project is to build an electronic device for use in cars: it is an interface between the car's CAN bus (controller area network) \cite{can20b}, and some analog gauges installed in the cockpit. +An overview of the system is shown in Figure \ref{fig:system}. + +\begin{figure} + \centering + \includegraphics[width=\textwidth]{"../proposal/diagram.png"} + \caption{System diagram.} + \label{fig:system} +\end{figure} + + +\section{Desiderata} + +The device must be able to perform certain functions. +As well, there are some desirable properties that it should fulfil. + +These function and desirable properties are as follows: + +\begin{enumerate} + \item{Receive standard and extended CAN frames from the bus.} + \item{Decode information in the frames.} + \item{Generate four analog 0--5V signals suitable for driving temperature or pressure gauges.} + \item{Generate two variable-frequency square waves for a tachometer and a speedometer.} + \item{Be user-programmable for any encoding scheme and gauge combination.} + \item{Run on a 12V automotive electrical power supply.} + \item{Operate reliably in an automotive environment: resist heat, vibration, and EMI (electromagnetic interference).} +\end{enumerate} + + +\section{Component selection} + +A car is a harsh environment for an electronic device. +The device is subject to large variations in temperature, vibration, and EMI. +To increase reliability, AEC-certified parts were chosen wherever possible. + + +\subsection{Logic control} + +The microcontroller is at the heart of the design. +A Microchip PIC16F1459 was chosen because of its simplicity and robustness, its feature set, and its low cost \cite{pic16f1459}. +It is an 8-bit microcontroller that features a USB peripheral for communicating with the host PC, an SPI peripheral for communicating with the other ICs, and timers for waveform generation. +The PIC is a proven design that Microchip recommends for automotive applications. +It is available in a DIP package, making it convenient for prototyping on a breadboard (Figure \ref{fig:pic}). + +\begin{figure} + \centering + \includegraphics[width=0.5\textwidth]{"pic16f1459.png"} + \caption{Microchip PIC16F1459 8-bit microcontroller.} + \label{fig:pic} +\end{figure} + +A Microchip MCP2515 serves as the CAN controller \cite{mcp2515}. +It supports CAN 2.0B up to 1Mbps and it has an SPI interface for communicating with the PIC. +An MCP2561 transceiver goes along with it \cite{mcp2561}. +Like the PIC, both these chips are available in DIP packages for prototyping on the breadboard. + + +\subsection{Data storage} + +The EEPROM is used to store the configuration. +This includes the encoding scheme that defines how parameters are encoded in CAN frames, as well as a table that maps parameter values to output signal values. + +There are six such tables: one for each gauge. +Each table has 32 entries, and the mapping is between 16-bit words. +Thus, the required size is $6 \times 32 \times 16 \times 2 = 6144$ bits, or 768 bytes. +The encoding schemes will take a handfull of bytes per gauge in addition. + +a Microchip 25LC160C EEPROM was selected. +Its 16Kib (2KiB) of space is more than adequate to hold the configuration. + + +\subsection{Input/output} + +The PIC has an integrated USB peripheral for communicating with a host computer. +The configuration is sent to the PIC via USB and stored on the EEPROM. + +Four DACs (digital-to-analog converters) generate analog signals to drive the four pressure or temperature gauges. +Based on the characteristics of commonly-used pressure and temperature sensors \cite{bosch_pst}, it was determined that a resolution of 15mV/step was required. +Given the operating voltage of 5V, this meant that the DACs must have at least $5\text{V}/15\text{mV} \approx 333$ steps of resolution. +Thus, an 8-bit DAC with 256 steps would be insufficient, and so a 10-bit DAC was selected: namely a Microchip\footnote{It is purely a coincidence that all the ICs ended up being Microchip parts. I don't have any particular affinity to the company. It just so happens that they make all the right chips for this particular application.} MCP4912. +The MCP4912 incorporates two DACs in a single chip, so there are two chips per board. + + +\subsection{Power supply} + +The ICs require a 5V supply. + +A 12V automotive electrical system operates in a wide range of approximately 9--16V, with a nominal voltage of $\sim$13.7V. +The voltage ripple is often quite significant as well. +Thus, the power supply must be very robust to supply a stable voltage to the ICs. + +The voltage drop $V_\text{Drop} = V_\text{In} - V_\text{Out}$ is $16\text{V} - 5\text{V} = 11\text{V}$ in the worst case. +This ruled out the use of a linear regulator, since it would dissipate too much power. +The power dissipation of a linear regulator is linear in $V_\text{Drop}$: + +\begin{equation} + P = (V_\text{In} - V_\text{Out}) \times I +\end{equation} + +The load current is estimated to be $\le 250$mA \cite{power_budget}. +That means a linear regulator would dissipate up to $11\text{V} \times 0.250\text{A} = 2.75$W. +That amount of power from a single chip would be difficult to cool. +Thus, a switching regulator is the right choice for this design. + +The downside of a switching regulator is that it produces a lot of noise in the PDN (power distribution network). +To isolate the other components from this noise, a two-stage PDN is used. +The first stage is the switching regulator itself, also known as a buck converter. +The buck drops the voltage from 12V down to 7V. + +The second stage is composed of two linear regulators: one for the digital circuitry, and one for the analog circuitry. +The linear regulators drop the voltage from 7V down to the final 5V that the ICs require. + +Just like a buck converter, switched digital ICs introduce noise into the PDN. +Therefore, it is good practice to keep the digital and analog components separate. +The second power stage isolates the ICs from the noisy buck converter, and splitting the stage between two regulators keeps the digital and analog circuits isolated from one-another. +This design is certainly overkill for the application, but it is better than using too weak of a PDN that delivers an unstable voltage. + +The buck converter is a Texas Instruments TPS5430 \cite{tps5430}. +It is surrounded by a couple of LC and RC networks to regulate the voltage and to dampen the output ripple. +See the datasheet and \cite{power_supply} for the process of selecting the accompanying passive components. +The linear regulators are a pair of ST L78M05ABs \cite{l78m}. + + + +\section{PCB design and manufacture} + +KiCad was used to design the schematic (Figure \ref{fig:schematic}) and the PCB (Figures \ref{fig:pcb_pours} \& \ref{fig:pcb_3d}). +JLCPCB was chosen to manufacture the printed circuit board. +At the time of writing, the board design has been finalized and submitted to JLC for manufacturing. +It should arrive any day now. + +\begin{figure} + \centering + \includegraphics[width=\textwidth]{"schematic-v0.2.pdf"} + \caption{Schematic.} + \label{fig:schematic} +\end{figure} + +\begin{figure} + \centering + \includegraphics[width=\textwidth]{"pcb_pours-v0.2.pdf"} + \caption{PCB front and back copper pours; drill holes.} + \label{fig:pcb_pours} +\end{figure} + +\begin{figure} + \centering + \includegraphics[width=\textwidth]{"pcb_3d-v0.2.png"} + \caption{3D render of the PCB.} + \label{fig:pcb_3d} +\end{figure} + +The board is a 4-layer design that uses a combination of surface-mount (SMD) and through-hole (THT) components. +The top and bottom layers are for signals, and the two middle layers are solid ground planes. +This ensures that all signal traces' fields are tightly coupled to ground directly above or below. +Power is routed on the bottom layer. + +As mentioned above, most of the ICs are available in DIP (through-hole) packages, and I have been using them for prototyping on the breadboard (Figure \ref{fig:breadboard}). +Once the PCB arrives, I can transplant the chips into the board, along with the passive components. + +\begin{figure} + \centering + \includegraphics[width=\textwidth]{"breadboard.jpg"} + \caption{Breadboard circuit for MCP2515 system testing.} + \label{fig:breadboard} +\end{figure} + +The power supply parts, on the other hand, are SMD. +It is important to minimize loop lengths in power supply circuits. +That is why power regulator chips are generally only available in smaller SMD packages. +The SMD components will be assembled by JLC, as I have neither the equipment nor the skill for SMD soldering. + +The board was layed out with PCB design best-practices in mind. +Traces are widely-spaced to reduce coupling. +All signal vias are accompanied by a ground via to keep the electric fields from spreading in the dielectric. +All traces are microstripped above a solid ground plane, again to keep the fields tight and to give the current a return path. +The noisy switching regulator is placed far away from the other components to reduce EMI---the sensitive analog signals and the DACs are on the opposite side of the board. + + +\section{Firmware} + +Firmware is the program that runs on the PIC microcontroller. +It is responsible for interacting with the peripherals and transforming data from the CAN bus into output signals for the gauges. + +The firmware is written in C for Microchip's XC8 compiler \cite{xc8}. + +Each peripheral---MCP2515, 25LC160C, and MCP4912---has a corresponding translation unit. +So far, I have written and tested the MCP4912 DAC unit. +The 25LC160C and MCP2515 units are mostly written but still require more testing. + +The firmware must also communicate with a PC via USB. +The Microchip MLA USB library is employed for this purpose \cite{mla_usb}. +However, the USB code uses a lot of the PIC's flash memory. +Some system test builds already fail to link due to lack of space. +As a result, USB may have to be dropped from the project, and another method will have to be devised for programming the user configuration into the EEPROM. +This is a major disappointment, but I will have to work around it seeing as the hardware has already been finalized. + + +\section{Software} + +Software is any program that runs on a host PC, as opposed to on the microcontroller. + +I wrote a program called \texttt{usbcom} that communicates with the PIC via USB \cite{usbcom}. +It connects its standard input to the OUT USB endpoint, and its standard output to the IN USB endpoint. +It is written in Go, and uses libusb. + +\texttt{usbcom} and the PIC firmware communicate using a proprietary text-based protocol over the USB CDC (communications device class) interface. +The message format is defined using EBNF \cite{protocol}. +The semantics are a simple request-reply arrangement. + +I also wrote a Python script---\texttt{bittiming.py}---to calculate CAN bit timing parameters for the MCP2515 \cite{bittiming_py}. + + +\section{Next steps} + +When the board arrives, I will do a visual inspection to ensure that nothing went wrong during manufacturing. +Then I will solder the THT components in place. +Once that is done, I will test the board for continuity and shorts. +With a fully assembled board, I can flash the firmware and migrate system testing from the breadboard to the printed prototype board. +I will finish developing the rest of the firmware, and run through the full suite of system tests that I will have at that point. + +I bought some equipment for testing and debugging the system. +A USBtin USB/CAN interface will allow me test the reception of CAN frames \cite{usbtin}. +The EspoTek Labrador is a combined power supply, oscilloscope, and logic analyzer \cite{espotek_labrador}. +It will be used for powering the board and debugging the SPI lines. + +If I have time, I would also like to do some experiments with the power supply to see how it handles changes in input voltage. + + +\printbibliography + +\end{document} diff --git a/doc/proposal/diagram.fig b/doc/proposal/diagram.fig new file mode 100644 index 0000000..0be7b07 --- /dev/null +++ b/doc/proposal/diagram.fig @@ -0,0 +1,120 @@ +#FIG 3.2 Produced by xfig version 3.2.9a +#encoding: UTF-8 +Landscape +Center +Metric +A4 +300.00 +Single +-2 +1200 2 +6 4725 1575 5940 2115 +6 4837 1665 5827 2025 +4 1 0 50 -1 0 12.00 0.0000 4 165 435 5332 1800 CAN\001 +4 1 0 50 -1 0 12.00 0.0000 4 165 945 5332 2010 Transceiver\001 +-6 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 4725 1575 5917 1575 5917 2115 4725 2115 4725 1575 +-6 +6 4725 2565 5940 3105 +6 4860 2655 5805 3015 +4 1 0 50 -1 0 12.00 0.0000 4 165 435 5332 2790 CAN\001 +4 1 0 50 -1 0 12.00 0.0000 4 165 840 5332 3000 Controller\001 +-6 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 4725 2565 5917 2565 5917 3105 4725 3105 4725 2565 +-6 +6 5265 2115 5355 2565 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 5310 2115 5310 2565 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 5355 2295 5265 2385 +-6 +6 5265 3105 5355 3555 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 5310 3105 5310 3555 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 5355 3285 5265 3375 +-6 +6 5265 3960 5355 4410 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 5310 3960 5310 4410 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 5355 4140 5265 4230 +-6 +6 4905 4410 5670 4725 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 4905 4410 5670 4410 5670 4725 4905 4725 4905 4410 +4 0 0 50 -1 0 12.00 0.0000 4 165 570 4995 4635 PROM\001 +-6 +6 4635 3555 6075 3960 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 4635 3555 6075 3555 6075 3960 4635 3960 4635 3555 +4 0 0 50 -1 0 12.00 0.0000 4 165 1290 4725 3825 Microcontroller\001 +-6 +6 3600 3262 4230 3577 +2 2 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 5 + 3600 3262 4230 3262 4230 3577 3600 3577 3600 3262 +4 0 0 50 -1 0 12.00 0.0000 4 165 435 3690 3487 DAC\001 +-6 +6 1665 1665 2430 2565 +6 1755 1665 2340 2070 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 1755 1665 2340 1665 2340 2070 1755 2070 1755 1665 +4 0 0 50 -1 0 12.00 0.0000 4 165 405 1845 1935 ECU\001 +-6 +6 1665 2250 2430 2565 +2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 + 1665 2250 2430 2250 2430 2565 1665 2565 1665 2250 +4 0 0 50 -1 0 12.00 0.0000 4 165 615 1710 2475 Sensors\001 +-6 +2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 + 2025 2070 2025 2250 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 2070 2115 1980 2205 +-6 +6 1710 3105 2340 4410 +6 1710 3780 2340 4410 +1 3 0 1 0 7 50 -1 -1 4.000 1 0.0000 2025 4095 302 302 2025 4095 2160 4365 +4 0 0 50 -1 0 12.00 0.0000 4 165 540 1755 4140 Gauge\001 +-6 +6 1710 3105 2340 3735 +1 3 0 1 0 7 50 -1 -1 4.000 1 0.0000 2025 3420 302 302 2025 3420 2160 3690 +4 0 0 50 -1 0 12.00 0.0000 4 165 540 1755 3465 Gauge\001 +-6 +-6 +6 2475 3240 2745 4005 +6 2475 3240 2745 3330 +3 2 0 1 0 7 50 -1 -1 4.000 0 0 0 4 + 2475 3330 2565 3240 2655 3330 2745 3240 + 0.000 -0.500 -0.500 0.000 +-6 +6 2475 3915 2745 4005 +2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 7 + 2475 4005 2475 3915 2565 3915 2565 4005 2655 4005 2655 3915 + 2745 3915 +-6 +-6 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 6075 3780 6705 3780 +2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 4 + 4635 3645 4455 3645 4455 3420 4230 3420 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 4410 3375 4320 3465 +2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 + 3600 3420 2340 3420 +2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 4 + 4635 3870 4455 3870 4455 4095 2340 4095 +2 2 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 5 + 3510 1485 6210 1485 6210 4815 3510 4815 3510 1485 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 2340 1845 4725 1845 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 3150 1800 3060 1890 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + 6525 3735 6435 3825 +4 1 0 50 -1 0 12.00 0.0000 4 165 795 3060 1710 CAN Bus\001 +4 0 0 50 -1 0 12.00 0.0000 4 165 270 5400 3375 SPI\001 +4 0 0 50 -1 0 12.00 0.0000 4 165 270 5400 4230 SPI\001 +4 0 0 50 -1 0 12.00 0.0000 4 165 390 6300 3690 USB\001 +4 0 0 50 -1 0 12.00 0.0000 4 165 270 4320 3330 SPI\001 diff --git a/doc/proposal/proposal.tex b/doc/proposal/proposal.tex new file mode 100644 index 0000000..00aca85 --- /dev/null +++ b/doc/proposal/proposal.tex @@ -0,0 +1,63 @@ +\documentclass{article} +\usepackage{graphicx} + +\title{ +Analog Gauge Driver with CAN Interface \\ +\large COMP490 Project Proposal +} +\author{ +Sam Anthony 40271987 \\ +sam@samanthony.xyz \\ s\_a365@concordia.ca +\and +Hovhannes Harutyunyan, PhD \\ +Department of Computer Science and Software Engineering \\ +haruty@encs.concordia.ca +\and +Concordia University \\ +} + +\begin{document} + +\maketitle + +Installing aftermarket gauges in a car typically requires installing sensors as well. +However, such sensors are often already present, and are used by the ECU (engine control unit). +Thus, the installation of aftermarket gauges can result in duplicate sensors which add complexity without augmenting the functionality or reliability of the vehicle. +Sensors installed like this are not redundant. +In fact, they reduce reliability, because each is a single point of failure. + +The proposed device allows gauges to use the sensors already on the car. +It retrieves sensor data from the ECU via the CAN bus (controller area network bus) and transforms the data into a format that the gauges can understand: a 0--5V analog signal in the case of a temperature or pressure gauge, or a square wave in the case of a tachometer or speedometer. + +The device is an embedded system comprising a microcontroller, a CAN controller and transceiver, several DACs (digital-to-analog converters), and PROM (programmable read-only memory). +The CAN interface is used for retrieving data from the ECU via the bus. +The DACs drive analog signals to the temperature and/or pressure gauges. +The microcontroller has an integrated PWM peripheral for driving a square wave to the tachometer and/or speedometer. +The PROM stores the calibration: a table that maps CAN data values to voltages or frequencies. +The microcontroller has a USB interface for programming the PROM from a computer. + +\begin{figure} + \includegraphics[width=\textwidth]{diagram.png} + \caption{System diagram} +\end{figure} + +The project has three parts: hardware design, software development, and testing. +The hardware and software development can be carried out concurrently. +Testing is the final step. + +Hardware design involves selecting ICs (integrated circuits), creating a circuit schematic, and designing a PCB (printed circuit board). +Once the board design is finalized, it can be sent for manufacturing. + +Two pieces of software must be written. +The first runs on the microcontroller. +Essentially, it must communicate with the various peripherals by transforming and transferring data between them. +It must fetch frames from the CAN controller and decipher them. +The CAN data are used to lookup the output value in the ROM. +Either the PWM peripheral or a DAC is used to send the appropriate signal to the gauge. +The microcontroller uses SPI (serial peripheral interface) to communicate with the peripherals. + +The second piece of software runs on the user's computer. +It programs the PROM with calibration data. +It communicates with the microcontroller using a simple text-based protocol over USB. + +\end{document} diff --git a/doc/references.bib b/doc/references.bib new file mode 100644 index 0000000..60fc4b9 --- /dev/null +++ b/doc/references.bib @@ -0,0 +1,100 @@ +@standard{can20b, + title = {CAN Specification}, + subtitle = {Version 2.0}, + part = {B}, + year = {1991}, + organization = {Robert Bosch GmbH}, + url = {http://esd.cs.ucr.edu/webres/can20.pdf}, +}, +@online{pic16f1459, + title = {PIC16F1459}, + subtitle = {8-bit Microcontroller with USB}, + organization = {Microchip Technology Inc.}, + url = {https://www.microchip.com/en-us/product/PIC16F1459}, + urlseen = {2025-10-13}, +}, +@online{mcp2515, + title = {MCP2515}, + subtitle = {Stand-Alone CAN Controller with SPI Interface}, + organization = {Microchip Technology Inc.}, + url = {https://www.microchip.com/en-us/product/MCP2515}, + urlseen = {2025-10-13}, +}, +@online{mcp2561, + title = {MCP2561}, + subtitle = {High-Speed CAN Transceiver}, + organization = {Microchip Technology Inc.}, + url = {https://www.microchip.com/en-us/product/MCP2561}, + urlseen = {2025-10-13}, +}, +@online{tps5430, + title = {TPS543x}, + subtitle = {Wide Input Range Step-Down Converter}, + organization = {Texas Instruments}, + url = {https://www.ti.com/lit/ds/symlink/tps5430.pdf}, + urlseen = {2025-10-13}, +}, +@online{l78m, + title = {L78M}, + subtitle = {Precision 500mA Regulators}, + organization = {STMicroelectronics}, + url = {https://www.st.com/en/power-management/l78m.html}, + urlseen = {2025-10-13}, +}, +@online{bosch_pst, + title = {Pressure Sensor Combined PST-F 1}, + organization = {Bosch Motorsport}, + url = {https://www.bosch-motorsport.de/content/downloads/Raceparts/Resources/pdf/Data%20Sheet_70496907_Pressure_Sensor_Combined_PST-F_1.pdf}, + urlseen = {2025-10-13}, +}, +@online{mla_usb, + title = {MLA USB}, + organization = {Microchip Technology Inc.}, + publisher = {Github}, + url = {https://github.com/MicrochipTech/mla_usb}, + urlseen = {2025-10-13}, +}, +@online{xc8, + title = {MPLAB\textsuperscript{\textregistered} XC8 Compiler}, + organization = {Microchip Technology Inc.}, + url = {https://www.microchip.com/en-us/tools-resources/develop/mplab-xc-compilers/xc8}, + urlseen = {2025-10-14}, +}, +@online{usbtin, + title = {USBtin}, + subtitle = {USB to CAN Interface}, + author = {Thomas Fischl}, + url = {https://www.fischl.de/usbtin/}, + urlseen = {2025-10-13}, +}, +@online{espotek_labrador, + title = {EspoTek Labrador Board}, + organization = {EspoTek}, + url = {https://espotek.com/labrador/}, + urlseen = {2025-10-13}, +}, +@misc{power_budget, + title = {Power Budget Spreadsheet}, + author = {Sam Anthony}, + url = {doc/power/power_budget.ods}, +}, +@misc{power_supply, + title = {TPS5430 Power Supply Spreadsheet}, + author = {Sam Anthony}, + url = {doc/power/power_supply.ods}, +}, +@misc{protocol, + title = {Protocol}, + author = {Sam Anthony}, + url = {doc/protocol}, +}, +@misc{usbcom, + title = {\texttt{usbcom} Program}, + author = {Sam Anthony}, + url = {sw/usbcom}, +}, +@misc{bittiming_py, + title = {\texttt{bittiming.py} Script}, + author = {Sam Anthony}, + url = {sw/bittiming}, +}, diff --git a/midterm_report/breadboard.jpg b/midterm_report/breadboard.jpg deleted file mode 100644 index e1974c3..0000000 Binary files a/midterm_report/breadboard.jpg and /dev/null differ diff --git a/midterm_report/midterm_report.tex b/midterm_report/midterm_report.tex deleted file mode 100644 index e17af03..0000000 --- a/midterm_report/midterm_report.tex +++ /dev/null @@ -1,261 +0,0 @@ -\documentclass{article} -\usepackage{graphicx} -\usepackage{hyperref} -\usepackage[backend=biber]{biblatex} -\usepackage{amsmath} - -\title{\textsc{Comp} 490 Mid-Term Report} - -\author{Sam Anthony 40271987 \\ -sam@samanthony.xyz \\ s\_a365@concordia.ca -\and -Hovhannes Harutyunyan, PhD \\ -Department of Computer Science and Software Engineering \\ -haruty@encs.concordia.ca -\and -Concordia University \\ -} - -\addbibresource{references.bib} - -\begin{document} - -\maketitle -\tableofcontents -\pagebreak - - -\section{Project introduction} - -The goal of the project is to build an electronic device for use in cars: it is an interface between the car's CAN bus (controller area network) \cite{can20b}, and some analog gauges installed in the cockpit. -An overview of the system is shown in Figure \ref{fig:system}. - -\begin{figure} - \centering - \includegraphics[width=\textwidth]{"../proposal/diagram.png"} - \caption{System diagram.} - \label{fig:system} -\end{figure} - - -\section{Desiderata} - -The device must be able to perform certain functions. -As well, there are some desirable properties that it should fulfil. - -These function and desirable properties are as follows: - -\begin{enumerate} - \item{Receive standard and extended CAN frames from the bus.} - \item{Decode information in the frames.} - \item{Generate four analog 0--5V signals suitable for driving temperature or pressure gauges.} - \item{Generate two variable-frequency square waves for a tachometer and a speedometer.} - \item{Be user-programmable for any encoding scheme and gauge combination.} - \item{Run on a 12V automotive electrical power supply.} - \item{Operate reliably in an automotive environment: resist heat, vibration, and EMI (electromagnetic interference).} -\end{enumerate} - - -\section{Component selection} - -A car is a harsh environment for an electronic device. -The device is subject to large variations in temperature, vibration, and EMI. -To increase reliability, AEC-certified parts were chosen wherever possible. - - -\subsection{Logic control} - -The microcontroller is at the heart of the design. -A Microchip PIC16F1459 was chosen because of its simplicity and robustness, its feature set, and its low cost \cite{pic16f1459}. -It is an 8-bit microcontroller that features a USB peripheral for communicating with the host PC, an SPI peripheral for communicating with the other ICs, and timers for waveform generation. -The PIC is a proven design that Microchip recommends for automotive applications. -It is available in a DIP package, making it convenient for prototyping on a breadboard (Figure \ref{fig:pic}). - -\begin{figure} - \centering - \includegraphics[width=0.5\textwidth]{"pic16f1459.png"} - \caption{Microchip PIC16F1459 8-bit microcontroller.} - \label{fig:pic} -\end{figure} - -A Microchip MCP2515 serves as the CAN controller \cite{mcp2515}. -It supports CAN 2.0B up to 1Mbps and it has an SPI interface for communicating with the PIC. -An MCP2561 transceiver goes along with it \cite{mcp2561}. -Like the PIC, both these chips are available in DIP packages for prototyping on the breadboard. - - -\subsection{Data storage} - -The EEPROM is used to store the configuration. -This includes the encoding scheme that defines how parameters are encoded in CAN frames, as well as a table that maps parameter values to output signal values. - -There are six such tables: one for each gauge. -Each table has 32 entries, and the mapping is between 16-bit words. -Thus, the required size is $6 \times 32 \times 16 \times 2 = 6144$ bits, or 768 bytes. -The encoding schemes will take a handfull of bytes per gauge in addition. - -a Microchip 25LC160C EEPROM was selected. -Its 16Kib (2KiB) of space is more than adequate to hold the configuration. - - -\subsection{Input/output} - -The PIC has an integrated USB peripheral for communicating with a host computer. -The configuration is sent to the PIC via USB and stored on the EEPROM. - -Four DACs (digital-to-analog converters) generate analog signals to drive the four pressure or temperature gauges. -Based on the characteristics of commonly-used pressure and temperature sensors \cite{bosch_pst}, it was determined that a resolution of 15mV/step was required. -Given the operating voltage of 5V, this meant that the DACs must have at least $5\text{V}/15\text{mV} \approx 333$ steps of resolution. -Thus, an 8-bit DAC with 256 steps would be insufficient, and so a 10-bit DAC was selected: namely a Microchip\footnote{It is purely a coincidence that all the ICs ended up being Microchip parts. I don't have any particular affinity to the company. It just so happens that they make all the right chips for this particular application.} MCP4912. -The MCP4912 incorporates two DACs in a single chip, so there are two chips per board. - - -\subsection{Power supply} - -The ICs require a 5V supply. - -A 12V automotive electrical system operates in a wide range of approximately 9--16V, with a nominal voltage of $\sim$13.7V. -The voltage ripple is often quite significant as well. -Thus, the power supply must be very robust to supply a stable voltage to the ICs. - -The voltage drop $V_\text{Drop} = V_\text{In} - V_\text{Out}$ is $16\text{V} - 5\text{V} = 11\text{V}$ in the worst case. -This ruled out the use of a linear regulator, since it would dissipate too much power. -The power dissipation of a linear regulator is linear in $V_\text{Drop}$: - -\begin{equation} - P = (V_\text{In} - V_\text{Out}) \times I -\end{equation} - -The load current is estimated to be $\le 250$mA \cite{power_budget}. -That means a linear regulator would dissipate up to $11\text{V} \times 0.250\text{A} = 2.75$W. -That amount of power from a single chip would be difficult to cool. -Thus, a switching regulator is the right choice for this design. - -The downside of a switching regulator is that it produces a lot of noise in the PDN (power distribution network). -To isolate the other components from this noise, a two-stage PDN is used. -The first stage is the switching regulator itself, also known as a buck converter. -The buck drops the voltage from 12V down to 7V. - -The second stage is composed of two linear regulators: one for the digital circuitry, and one for the analog circuitry. -The linear regulators drop the voltage from 7V down to the final 5V that the ICs require. - -Just like a buck converter, switched digital ICs introduce noise into the PDN. -Therefore, it is good practice to keep the digital and analog components separate. -The second power stage isolates the ICs from the noisy buck converter, and splitting the stage between two regulators keeps the digital and analog circuits isolated from one-another. -This design is certainly overkill for the application, but it is better than using too weak of a PDN that delivers an unstable voltage. - -The buck converter is a Texas Instruments TPS5430 \cite{tps5430}. -It is surrounded by a couple of LC and RC networks to regulate the voltage and to dampen the output ripple. -See the datasheet and \cite{power_supply} for the process of selecting the accompanying passive components. -The linear regulators are a pair of ST L78M05ABs \cite{l78m}. - - - -\section{PCB design and manufacture} - -KiCad was used to design the schematic (Figure \ref{fig:schematic}) and the PCB (Figures \ref{fig:pcb_pours} \& \ref{fig:pcb_3d}). -JLCPCB was chosen to manufacture the printed circuit board. -At the time of writing, the board design has been finalized and submitted to JLC for manufacturing. -It should arrive any day now. - -\begin{figure} - \centering - \includegraphics[width=\textwidth]{"schematic-v0.2.pdf"} - \caption{Schematic.} - \label{fig:schematic} -\end{figure} - -\begin{figure} - \centering - \includegraphics[width=\textwidth]{"pcb_pours-v0.2.pdf"} - \caption{PCB front and back copper pours; drill holes.} - \label{fig:pcb_pours} -\end{figure} - -\begin{figure} - \centering - \includegraphics[width=\textwidth]{"pcb_3d-v0.2.png"} - \caption{3D render of the PCB.} - \label{fig:pcb_3d} -\end{figure} - -The board is a 4-layer design that uses a combination of surface-mount (SMD) and through-hole (THT) components. -The top and bottom layers are for signals, and the two middle layers are solid ground planes. -This ensures that all signal traces' fields are tightly coupled to ground directly above or below. -Power is routed on the bottom layer. - -As mentioned above, most of the ICs are available in DIP (through-hole) packages, and I have been using them for prototyping on the breadboard (Figure \ref{fig:breadboard}). -Once the PCB arrives, I can transplant the chips into the board, along with the passive components. - -\begin{figure} - \centering - \includegraphics[width=\textwidth]{"breadboard.jpg"} - \caption{Breadboard circuit for MCP2515 system testing.} - \label{fig:breadboard} -\end{figure} - -The power supply parts, on the other hand, are SMD. -It is important to minimize loop lengths in power supply circuits. -That is why power regulator chips are generally only available in smaller SMD packages. -The SMD components will be assembled by JLC, as I have neither the equipment nor the skill for SMD soldering. - -The board was layed out with PCB design best-practices in mind. -Traces are widely-spaced to reduce coupling. -All signal vias are accompanied by a ground via to keep the electric fields from spreading in the dielectric. -All traces are microstripped above a solid ground plane, again to keep the fields tight and to give the current a return path. -The noisy switching regulator is placed far away from the other components to reduce EMI---the sensitive analog signals and the DACs are on the opposite side of the board. - - -\section{Firmware} - -Firmware is the program that runs on the PIC microcontroller. -It is responsible for interacting with the peripherals and transforming data from the CAN bus into output signals for the gauges. - -The firmware is written in C for Microchip's XC8 compiler \cite{xc8}. - -Each peripheral---MCP2515, 25LC160C, and MCP4912---has a corresponding translation unit. -So far, I have written and tested the MCP4912 DAC unit. -The 25LC160C and MCP2515 units are mostly written but still require more testing. - -The firmware must also communicate with a PC via USB. -The Microchip MLA USB library is employed for this purpose \cite{mla_usb}. -However, the USB code uses a lot of the PIC's flash memory. -Some system test builds already fail to link due to lack of space. -As a result, USB may have to be dropped from the project, and another method will have to be devised for programming the user configuration into the EEPROM. -This is a major disappointment, but I will have to work around it seeing as the hardware has already been finalized. - - -\section{Software} - -Software is any program that runs on a host PC, as opposed to on the microcontroller. - -I wrote a program called \texttt{usbcom} that communicates with the PIC via USB \cite{usbcom}. -It connects its standard input to the OUT USB endpoint, and its standard output to the IN USB endpoint. -It is written in Go, and uses libusb. - -\texttt{usbcom} and the PIC firmware communicate using a proprietary text-based protocol over the USB CDC (communications device class) interface. -The message format is defined using EBNF \cite{protocol}. -The semantics are a simple request-reply arrangement. - -I also wrote a Python script---\texttt{bittiming.py}---to calculate CAN bit timing parameters for the MCP2515 \cite{bittiming_py}. - - -\section{Next steps} - -When the board arrives, I will do a visual inspection to ensure that nothing went wrong during manufacturing. -Then I will solder the THT components in place. -Once that is done, I will test the board for continuity and shorts. -With a fully assembled board, I can flash the firmware and migrate system testing from the breadboard to the printed prototype board. -I will finish developing the rest of the firmware, and run through the full suite of system tests that I will have at that point. - -I bought some equipment for testing and debugging the system. -A USBtin USB/CAN interface will allow me test the reception of CAN frames \cite{usbtin}. -The EspoTek Labrador is a combined power supply, oscilloscope, and logic analyzer \cite{espotek_labrador}. -It will be used for powering the board and debugging the SPI lines. - -If I have time, I would also like to do some experiments with the power supply to see how it handles changes in input voltage. - - -\printbibliography - -\end{document} diff --git a/midterm_report/references.bib b/midterm_report/references.bib deleted file mode 100644 index 60fc4b9..0000000 --- a/midterm_report/references.bib +++ /dev/null @@ -1,100 +0,0 @@ -@standard{can20b, - title = {CAN Specification}, - subtitle = {Version 2.0}, - part = {B}, - year = {1991}, - organization = {Robert Bosch GmbH}, - url = {http://esd.cs.ucr.edu/webres/can20.pdf}, -}, -@online{pic16f1459, - title = {PIC16F1459}, - subtitle = {8-bit Microcontroller with USB}, - organization = {Microchip Technology Inc.}, - url = {https://www.microchip.com/en-us/product/PIC16F1459}, - urlseen = {2025-10-13}, -}, -@online{mcp2515, - title = {MCP2515}, - subtitle = {Stand-Alone CAN Controller with SPI Interface}, - organization = {Microchip Technology Inc.}, - url = {https://www.microchip.com/en-us/product/MCP2515}, - urlseen = {2025-10-13}, -}, -@online{mcp2561, - title = {MCP2561}, - subtitle = {High-Speed CAN Transceiver}, - organization = {Microchip Technology Inc.}, - url = {https://www.microchip.com/en-us/product/MCP2561}, - urlseen = {2025-10-13}, -}, -@online{tps5430, - title = {TPS543x}, - subtitle = {Wide Input Range Step-Down Converter}, - organization = {Texas Instruments}, - url = {https://www.ti.com/lit/ds/symlink/tps5430.pdf}, - urlseen = {2025-10-13}, -}, -@online{l78m, - title = {L78M}, - subtitle = {Precision 500mA Regulators}, - organization = {STMicroelectronics}, - url = {https://www.st.com/en/power-management/l78m.html}, - urlseen = {2025-10-13}, -}, -@online{bosch_pst, - title = {Pressure Sensor Combined PST-F 1}, - organization = {Bosch Motorsport}, - url = {https://www.bosch-motorsport.de/content/downloads/Raceparts/Resources/pdf/Data%20Sheet_70496907_Pressure_Sensor_Combined_PST-F_1.pdf}, - urlseen = {2025-10-13}, -}, -@online{mla_usb, - title = {MLA USB}, - organization = {Microchip Technology Inc.}, - publisher = {Github}, - url = {https://github.com/MicrochipTech/mla_usb}, - urlseen = {2025-10-13}, -}, -@online{xc8, - title = {MPLAB\textsuperscript{\textregistered} XC8 Compiler}, - organization = {Microchip Technology Inc.}, - url = {https://www.microchip.com/en-us/tools-resources/develop/mplab-xc-compilers/xc8}, - urlseen = {2025-10-14}, -}, -@online{usbtin, - title = {USBtin}, - subtitle = {USB to CAN Interface}, - author = {Thomas Fischl}, - url = {https://www.fischl.de/usbtin/}, - urlseen = {2025-10-13}, -}, -@online{espotek_labrador, - title = {EspoTek Labrador Board}, - organization = {EspoTek}, - url = {https://espotek.com/labrador/}, - urlseen = {2025-10-13}, -}, -@misc{power_budget, - title = {Power Budget Spreadsheet}, - author = {Sam Anthony}, - url = {doc/power/power_budget.ods}, -}, -@misc{power_supply, - title = {TPS5430 Power Supply Spreadsheet}, - author = {Sam Anthony}, - url = {doc/power/power_supply.ods}, -}, -@misc{protocol, - title = {Protocol}, - author = {Sam Anthony}, - url = {doc/protocol}, -}, -@misc{usbcom, - title = {\texttt{usbcom} Program}, - author = {Sam Anthony}, - url = {sw/usbcom}, -}, -@misc{bittiming_py, - title = {\texttt{bittiming.py} Script}, - author = {Sam Anthony}, - url = {sw/bittiming}, -}, diff --git a/proposal/diagram.fig b/proposal/diagram.fig deleted file mode 100644 index 0be7b07..0000000 --- a/proposal/diagram.fig +++ /dev/null @@ -1,120 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.9a -#encoding: UTF-8 -Landscape -Center -Metric -A4 -300.00 -Single --2 -1200 2 -6 4725 1575 5940 2115 -6 4837 1665 5827 2025 -4 1 0 50 -1 0 12.00 0.0000 4 165 435 5332 1800 CAN\001 -4 1 0 50 -1 0 12.00 0.0000 4 165 945 5332 2010 Transceiver\001 --6 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 4725 1575 5917 1575 5917 2115 4725 2115 4725 1575 --6 -6 4725 2565 5940 3105 -6 4860 2655 5805 3015 -4 1 0 50 -1 0 12.00 0.0000 4 165 435 5332 2790 CAN\001 -4 1 0 50 -1 0 12.00 0.0000 4 165 840 5332 3000 Controller\001 --6 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 4725 2565 5917 2565 5917 3105 4725 3105 4725 2565 --6 -6 5265 2115 5355 2565 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5310 2115 5310 2565 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5355 2295 5265 2385 --6 -6 5265 3105 5355 3555 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5310 3105 5310 3555 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5355 3285 5265 3375 --6 -6 5265 3960 5355 4410 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5310 3960 5310 4410 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5355 4140 5265 4230 --6 -6 4905 4410 5670 4725 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 4905 4410 5670 4410 5670 4725 4905 4725 4905 4410 -4 0 0 50 -1 0 12.00 0.0000 4 165 570 4995 4635 PROM\001 --6 -6 4635 3555 6075 3960 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 4635 3555 6075 3555 6075 3960 4635 3960 4635 3555 -4 0 0 50 -1 0 12.00 0.0000 4 165 1290 4725 3825 Microcontroller\001 --6 -6 3600 3262 4230 3577 -2 2 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 5 - 3600 3262 4230 3262 4230 3577 3600 3577 3600 3262 -4 0 0 50 -1 0 12.00 0.0000 4 165 435 3690 3487 DAC\001 --6 -6 1665 1665 2430 2565 -6 1755 1665 2340 2070 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 1755 1665 2340 1665 2340 2070 1755 2070 1755 1665 -4 0 0 50 -1 0 12.00 0.0000 4 165 405 1845 1935 ECU\001 --6 -6 1665 2250 2430 2565 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 1665 2250 2430 2250 2430 2565 1665 2565 1665 2250 -4 0 0 50 -1 0 12.00 0.0000 4 165 615 1710 2475 Sensors\001 --6 -2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 - 2025 2070 2025 2250 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2070 2115 1980 2205 --6 -6 1710 3105 2340 4410 -6 1710 3780 2340 4410 -1 3 0 1 0 7 50 -1 -1 4.000 1 0.0000 2025 4095 302 302 2025 4095 2160 4365 -4 0 0 50 -1 0 12.00 0.0000 4 165 540 1755 4140 Gauge\001 --6 -6 1710 3105 2340 3735 -1 3 0 1 0 7 50 -1 -1 4.000 1 0.0000 2025 3420 302 302 2025 3420 2160 3690 -4 0 0 50 -1 0 12.00 0.0000 4 165 540 1755 3465 Gauge\001 --6 --6 -6 2475 3240 2745 4005 -6 2475 3240 2745 3330 -3 2 0 1 0 7 50 -1 -1 4.000 0 0 0 4 - 2475 3330 2565 3240 2655 3330 2745 3240 - 0.000 -0.500 -0.500 0.000 --6 -6 2475 3915 2745 4005 -2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 7 - 2475 4005 2475 3915 2565 3915 2565 4005 2655 4005 2655 3915 - 2745 3915 --6 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6075 3780 6705 3780 -2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 4 - 4635 3645 4455 3645 4455 3420 4230 3420 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4410 3375 4320 3465 -2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 - 3600 3420 2340 3420 -2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 4 - 4635 3870 4455 3870 4455 4095 2340 4095 -2 2 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 5 - 3510 1485 6210 1485 6210 4815 3510 4815 3510 1485 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2340 1845 4725 1845 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3150 1800 3060 1890 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6525 3735 6435 3825 -4 1 0 50 -1 0 12.00 0.0000 4 165 795 3060 1710 CAN Bus\001 -4 0 0 50 -1 0 12.00 0.0000 4 165 270 5400 3375 SPI\001 -4 0 0 50 -1 0 12.00 0.0000 4 165 270 5400 4230 SPI\001 -4 0 0 50 -1 0 12.00 0.0000 4 165 390 6300 3690 USB\001 -4 0 0 50 -1 0 12.00 0.0000 4 165 270 4320 3330 SPI\001 diff --git a/proposal/proposal.tex b/proposal/proposal.tex deleted file mode 100644 index 00aca85..0000000 --- a/proposal/proposal.tex +++ /dev/null @@ -1,63 +0,0 @@ -\documentclass{article} -\usepackage{graphicx} - -\title{ -Analog Gauge Driver with CAN Interface \\ -\large COMP490 Project Proposal -} -\author{ -Sam Anthony 40271987 \\ -sam@samanthony.xyz \\ s\_a365@concordia.ca -\and -Hovhannes Harutyunyan, PhD \\ -Department of Computer Science and Software Engineering \\ -haruty@encs.concordia.ca -\and -Concordia University \\ -} - -\begin{document} - -\maketitle - -Installing aftermarket gauges in a car typically requires installing sensors as well. -However, such sensors are often already present, and are used by the ECU (engine control unit). -Thus, the installation of aftermarket gauges can result in duplicate sensors which add complexity without augmenting the functionality or reliability of the vehicle. -Sensors installed like this are not redundant. -In fact, they reduce reliability, because each is a single point of failure. - -The proposed device allows gauges to use the sensors already on the car. -It retrieves sensor data from the ECU via the CAN bus (controller area network bus) and transforms the data into a format that the gauges can understand: a 0--5V analog signal in the case of a temperature or pressure gauge, or a square wave in the case of a tachometer or speedometer. - -The device is an embedded system comprising a microcontroller, a CAN controller and transceiver, several DACs (digital-to-analog converters), and PROM (programmable read-only memory). -The CAN interface is used for retrieving data from the ECU via the bus. -The DACs drive analog signals to the temperature and/or pressure gauges. -The microcontroller has an integrated PWM peripheral for driving a square wave to the tachometer and/or speedometer. -The PROM stores the calibration: a table that maps CAN data values to voltages or frequencies. -The microcontroller has a USB interface for programming the PROM from a computer. - -\begin{figure} - \includegraphics[width=\textwidth]{diagram.png} - \caption{System diagram} -\end{figure} - -The project has three parts: hardware design, software development, and testing. -The hardware and software development can be carried out concurrently. -Testing is the final step. - -Hardware design involves selecting ICs (integrated circuits), creating a circuit schematic, and designing a PCB (printed circuit board). -Once the board design is finalized, it can be sent for manufacturing. - -Two pieces of software must be written. -The first runs on the microcontroller. -Essentially, it must communicate with the various peripherals by transforming and transferring data between them. -It must fetch frames from the CAN controller and decipher them. -The CAN data are used to lookup the output value in the ROM. -Either the PWM peripheral or a DAC is used to send the appropriate signal to the gauge. -The microcontroller uses SPI (serial peripheral interface) to communicate with the peripherals. - -The second piece of software runs on the user's computer. -It programs the PROM with calibration data. -It communicates with the microcontroller using a simple text-based protocol over USB. - -\end{document} -- cgit v1.2.3