Skip to content
alex7709 edited this page Dec 10, 2019 · 24 revisions

Project Idea

The project concerned the development of a printed circuit board (PCB) to take analog outputs from a strain gauge, translate them into I2C signals, and transform those signals into CAN signals which will be passed into a Georgia Tech Motorsports (GTMS) vehicle’s CAN bus. This PCB will enable the GTMS team to measure forces applied to vehicle aerodynamic elements and frame members through precise strain measurement and was initiated by Jack Glennon and Dylan Nektalov, who are both GTMS members. Alex Swartz provided additional support.

PCB construction, where possible, was to incorporate materials already in GTMS's possession to reduce expenditures and facilitate simple repair in the case of device failure. Physical simplicity, durability, signal accessibility, and compact design were primary considerations due to the device's critical status and its location in a compact formula-style vehicle.

Process  

This project combined many facets of embedded system creation, including component selection, CAD software utilization, surface-mount and through-hole soldering, microcontroller programming, and system testing.

Components 

A 24-bit Nuvoton NAU7802 analog-to-digital converter had been purchased before the project's start. An STM32F042P6 microcontroller and ON Semiconductor NCV7349 low-power CAN transceiver were later selected for the project and had to be ordered. An MBED microcontroller, two CAN SK Pang CAN bus breakout boards, and a variety of standard electronic components such as capacitors, resistors, switches, and transistors were readily-available from Georgia Tech, GTMS, and personal caches, and were trivial to acquire.

Design

Using Eagle CAD software, PCB layout and signal routing was finalized. All pad dimensions were sized with hand soldering in mind, and a silkscreen was created to guard against errors in manual assembly. Gerber files were generated from the software package and sent to a vendor for manufacture. A text file, also generated from Eagle, containing the PCB parts list is included in the MCU.txt file in the code section. Additionally, the Gerber files used for fabrication are included in a zip folder in the code section along with images of board at various project stages in the images folder.

Assembly

All components were attached to the PCB by hand, using a soldering iron to connect pins to their corresponding pad. No reflow soldering was needed, as the pads were designed and components selected to facilitate manual fabrication. The small size of status LEDs and the precision required for the ST chip presented a challenge, but most other components were straightforward by design. See photos in the images folder for documentation of the assembly process.

Programming

Using STM32 CubeMX, a desktop application provided by the microcontroller manufacturer, desired microcontroller pin functionality was first selected. Using Keil uVision, variables, function prototypes, peripherals, type definitions, and other supporting C code were then created while a custom program to initialize I2C and CAN on the chip was developed, largely from referencing included STM header files. This combined code, when written to the device, enabled I2C, ADC, CAN, GPIO, and system clock functionality with an emphasis on interrupt-driven operation. Code running on the ST microcontroller is provided under the code tab above, with core code in the code folder and supporting programs in surrounding locations. Files added last in the code folder are those essential for program operation and testing, while older ones and those elsewhere are earlier attempts or part of a standard ST package. See the StuffThatWorks folder in drive link in the read me for organized complete code packages that could run on a similar microcontroller.

Testing

After the microcontroller was attached to the PCB and the on-board power supply was assembled, a preliminary test was done to make sure the status LEDs powered on. Once the board had been completed, Keil uVision was used to verify the controller could read and display values from a potentiometer mimicking the analog strain gauge's output. At this point, I2C functionality was also confirmed by monitoring activity on relevant breakout pins with the chip running a test I2C output program. Work subsequently began on writing data to the CAN bus and involved the use of a logic analyzer and further use of Keil uVision to confirm correct data values and status bits were present. A hardware flaw was identified at this point, and corrected with a band-aid jumper wire to move forward. Validation then moved to the MBED.

To read the CAN messages placed on the bus and display them on a PC for easy proof of functionality, C++ code was developed using the online MBED compiler and then downloaded to the chip. First, open-source test code from the MBED wiki page was read in, and two CAN breakout boards were connected to the MBED's CAN pins for a loop-back test. Initially, the loop-back test failed, as it was incorrectly assumed that the 120 Ohm termination resistors were on the SK Pang board. However, two through-hole resistors connected to the breakout board's terminal blocks with jumper wires solved this issue. Once the the test finally proved successful, the second CAN board was disconnected, and the first hooked up to the CAN output from the project's PCB. Code enabling message filtering and masking on signal IDs was applied, and the system was activated. At first, the team was never able to eliminate all CAN errors received by the MBED, and no bytes were displayed on the terminal. Revised code using RTOS and interrupts failed as well. However, a frequency mismatch between the MBED and CAN board proved responsible, and everything worked as designed when the issue was resolved.

This video contains a demonstration, and the MBED code used to for both loop-back testing and displaying messages is included in the code section. As the video shows, the board places CAN messages on the bus, which can be viewed on the oscilloscope and terminal. This fulfills the desired functionality of the project.

Future Work

A modification will be made to future versions of the board, as a sleep pin on the CAN transceiver was not connected to the microcontroller to be pulled low, and prevented correct device operation until a jumper wire was soldered and grounded as a temporary fix. Additional silkscreen patterns for the Analog In header and a DIP switch for the Boot0 pin will also be added.

After modification, the board will be incorporated into the current GTMS competition vehicle and feed strain measurements onto its CAN bus, as this portion functions as intended. These signals can then be read by diagnostic tools to assist team members in improving vehicle design and logging stress events. It is anticipated this design will provide years of reliable service and can be transferred to new vehicle iterations with minimal modification.

Clone this wiki locally