Knightrider::kitty

About the project

Autonomous car which can fast race alone on white track and can omit obstacles. Also it can react to some special patterns noticed on the ground.

NXP Cup Electromaker Innovation Challenge Contest WinnerNXP Cup Electromaker Innovation Challenge contest winner

Project info

Difficulty: Difficult

Platforms: MATLABNXPTexas Instruments

Estimated time: 7 months+

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

MKV58F1M0VLQ24 MKV58F1M0VLQ24 Main microcontroller x 1
MKL25Z128 MKL25Z128 Microcontroller for detecting obstacles using laser sensors or ultrasonic sensors x 1
Pixy2 CMUcam5 Sensor Pixy2 CMUcam5 Sensor x 1
LPC4330-Xplorer Board LPC4330-Xplorer Board x 1
Servo Motor Servo Motor x 1
DC Motors DC Motors x 1
Battery pack - 14 AAA cells Battery pack - 14 AAA cells x 1
Ultrasonic Sensor Hc-sr04 Ultrasonic Sensor Hc-sr04 x 1
VL53L0X V2 VL53L0X V2 Laser Ranging Sensor Module x 1

View all

Software apps and online services

CLion CLion Smart easy C and C++ editor,
CMake CMake Tools designed to build our projects for MKV58F1M0VLQ24 , LPC4330 and MKL25Z128
GNU  Make and Ninja GNU Make and Ninja Tools which controls the generation of executables
Matlab Matlab Control car from PC using bluetooth
LPCXpresso LPCXpresso Create basic code examples for PIXY camera microcontroller
MCUXpresso MCUXpresso Create basic code examples for mainboard
PixyMon v2 PixyMon v2 PixyMon v2 is the configuration utility for Pixy2
PrusaSlicer PrusaSlicer
SOLIDWORKS SOLIDWORKS
Visual Studio Visual Studio For LPC PDF PARSER

View all

Hand tools and fabrication machines

Soldering satation Soldering satation x 1
3D printer 3D printer x 1
Oscilloscope Oscilloscope x 1
Logic analyzer Logic analyzer x 1
Basic mechanical tools Basic mechanical tools x 1

Story

  1. All repository we have is here:

https://github.com/witek117/NXPCup_2020

It contains firmware, software and hardware directories.

1. Hardware

All hardware contains 3D printed models and two PCB.

We used the chassis from Alamak

https://pl.aliexpress.com/item/32817153828.html?spm=2114.12010612.0.0.45fa4693xcQzfH

but we changed motors and all steering system. 

a) steering 

b) battery holder

c) back with extra hole for second camera stick (second camera is not used now)

d) back panel

 

e) PIXY CAM holder with lens holder

 

f) encoder disc (for feedback how hast the car is moving)

 

g) main board with:

-  MKV58F1M0VLQ24

-  MKL25Z128VLK4

- double H bridge driver

- double wireless connectivity via  Bluetooth (we can plug BT adapters directly to connectors and debug both processors)

-  seven-segment display

- buttons 

- connectors for ultrasonic and laser sensors, encoders, servo, two line cameras (not used now) and PIXY CAM

h) laser sensors extension board with:

- connectors for six laser sensors 

- PIXY CAM 2 connector (compatible with J2 connector on PIXY PCB board)

- connector for  external LEDs

And all electric circuit is shown here:

2. Firmware, what we did so far

All source code is on github

https://github.com/witek117/NXPCup_2020/tree/master/firmware/car

CMake project

CMake is used to control the software compilation process for three targets:

 - MKV58 - main microcontroller 

 - MKL25Z - microcontroller responsible for obstacle detection

 - x86 - GoogleTest library for testing algorithms 

So we do not need IDE for compiling this project, in the simplest case, all is needed  is a command terminal console. But we used MCUXpresso for creating basic peripheral source code e.g. timers, ADC, PWM.

Structure of project in lcp branch:

C++20 

Just for fan and learn something new.

PID – let’s get what we really want to

Commonly known problem is that some mechanical parts often don’t act exactly like they should and so the motors do. We put some voltage on them counting on achieving some result, but motors final value differs from our expectation due to friction and strengths distribution during the motion. That’s why we have implemented PID regulator algorithm to reduce occurring error and always get the proper value of motors. Such algorithm uses output signal from optical encoders to get real value of motors, compares it with demanded one and performs some changes of controlling signal to bring real value as close as it possible to the assumed one.

PIXY CAM 2

In µVision IDE we redesigned some source code. Camera can detect black and white lines and communicate with main board. We got rid of given code for line detecting. We wrote our new, because it caused us less problems with calibration.

3. Software 

a) LPC PDF PARSER (lpc branch)

https://github.com/witek117/NXPCup_2020/tree/lpc/software/LPC_PDF_PARSER

For PIXY, LPCOpen was not enough, we needed some CMSIS-like registers description. It took long time to write it on our way, so we created pdf-table parser using C# and .NET with Visual Studio. 

Table like this: 

just copy and click "PARSE" in LPC_PDF_PARSER and we have code like this:

b) MATLAB app for simple car control

https://github.com/witek117/NXPCup_2020/tree/lpc/software/matlab

4. Make Pixy great again

We also decided to rewrite PixyCam source code. In this project we only need to stream video via USB and detect edges to decide where the track is. Also we do not like using  µVision IDE. For us better is CMake with C++20. We bought a  LPC4330-Xplorer Board with the same microcontroller that is in Pixy.

Source code is on github in lpc branch and LCP directory (target):

https://github.com/witek117/NXPCup_2020/tree/lpc/firmware/car

We use LPCOpen library and old Pixy code. By now all pins are set, both cores (M4 and M0) are working and  USB is properly working with PC.

5. First loops with new firmware

6. Plans

  • fully implement obstacle detection
  • design and print models for six  VL53L0X  
  • rewrite the rest of Pixy source code
  • finish and trim all algorithms 
  • design new main board with better H Bridges, build in VL53L0X  connectors and Pixy connector

Code

Car

Credits

Leave your feedback...