diff --git a/docs/autonomous_cars/0.mechanics/0.lecture.md b/docs/autonomous_cars/0.mechanics/0.lecture.md new file mode 100644 index 0000000..f3fddcd --- /dev/null +++ b/docs/autonomous_cars/0.mechanics/0.lecture.md @@ -0,0 +1,64 @@ +--- +title: "Assembly Tutorial" +--- + +In this chapter, the steps for putting the kit together are described. The steps will also be explained live for you to follow. + +Let's dive into them. + +## Step 1. Motors + +Begin by securing the motors to the chassis using M3x8mm screws. + +
+![Motors](./assets/1.png) +
+ +## Step 2. HexSpacers and SteerShafts + +Now screw the HexSpacers and SteerShafts to be chassis. + + +
+![HexSpacers](./assets/2.png) +
+ +## Step 3. The bearing and wheels + +Use screws to connect the bearing and wheel to the hexshaft. + +
+![Bearing and wheel](./assets/3.png) +
+ +## Step 4. Linchpin + +Place the Linchpin over the SteeringShaft. + +
+![Linchpin](./assets/4.png) +
+ +## Step 5. Putting the car together + +First, use the screws that came with the MG995/MG996 servo to attach the direction arms to both the Linchpin and the servo arm. + +Then secure the servo arm into the servo spline using the M3x5 screw provided in the Servo package. + +Finally, place the Upper Chassis and use screws to connect it to the Hex Spacers. + +
+![Car assembly](./assets/5.png) +
+ +Pass the rod into the UpperPlate and screw the rod to fix it in place. + +
+![Rod](./assets/6.png) +
+ +Screw the camera to the adjustable mount and the adjustable mount to the rod mount. + +
+![Camera](./assets/7.png) +
\ No newline at end of file diff --git a/docs/autonomous_cars/0.mechanics/assets/1.png b/docs/autonomous_cars/0.mechanics/assets/1.png new file mode 100644 index 0000000..0918482 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/1.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/2.png b/docs/autonomous_cars/0.mechanics/assets/2.png new file mode 100644 index 0000000..74167c7 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/2.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/2mm_hole.png b/docs/autonomous_cars/0.mechanics/assets/2mm_hole.png new file mode 100644 index 0000000..6cfe525 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/2mm_hole.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/3.png b/docs/autonomous_cars/0.mechanics/assets/3.png new file mode 100644 index 0000000..9ac2b6f Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/3.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/4.png b/docs/autonomous_cars/0.mechanics/assets/4.png new file mode 100644 index 0000000..c503502 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/4.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/4mm_hole.png b/docs/autonomous_cars/0.mechanics/assets/4mm_hole.png new file mode 100644 index 0000000..83a140a Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/4mm_hole.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/5.png b/docs/autonomous_cars/0.mechanics/assets/5.png new file mode 100644 index 0000000..b5693d7 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/5.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/6.png b/docs/autonomous_cars/0.mechanics/assets/6.png new file mode 100644 index 0000000..c8b9d01 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/6.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/7.png b/docs/autonomous_cars/0.mechanics/assets/7.png new file mode 100644 index 0000000..ab02799 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/7.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/CreateSketch.png b/docs/autonomous_cars/0.mechanics/assets/CreateSketch.png new file mode 100644 index 0000000..bbe3466 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/CreateSketch.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/Fusion_interface.png b/docs/autonomous_cars/0.mechanics/assets/Fusion_interface.png new file mode 100644 index 0000000..6868194 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/Fusion_interface.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/Logo_body.png b/docs/autonomous_cars/0.mechanics/assets/Logo_body.png new file mode 100644 index 0000000..7bd2f36 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/Logo_body.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/Logo_extrude.png b/docs/autonomous_cars/0.mechanics/assets/Logo_extrude.png new file mode 100644 index 0000000..f0e457f Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/Logo_extrude.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/Sketch1.png b/docs/autonomous_cars/0.mechanics/assets/Sketch1.png new file mode 100644 index 0000000..c95a1ed Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/Sketch1.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/Sketchtools.png b/docs/autonomous_cars/0.mechanics/assets/Sketchtools.png new file mode 100644 index 0000000..571a53a Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/Sketchtools.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/Smooth_edges.png b/docs/autonomous_cars/0.mechanics/assets/Smooth_edges.png new file mode 100644 index 0000000..fe7f73f Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/Smooth_edges.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/Smooth_edges2.png b/docs/autonomous_cars/0.mechanics/assets/Smooth_edges2.png new file mode 100644 index 0000000..9938012 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/Smooth_edges2.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/Smooth_edges3.png b/docs/autonomous_cars/0.mechanics/assets/Smooth_edges3.png new file mode 100644 index 0000000..24818da Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/Smooth_edges3.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/TEXT.png b/docs/autonomous_cars/0.mechanics/assets/TEXT.png new file mode 100644 index 0000000..d450396 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/TEXT.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/ViewCube.png b/docs/autonomous_cars/0.mechanics/assets/ViewCube.png new file mode 100644 index 0000000..d0e3f3b Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/ViewCube.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/centerrectangle.png b/docs/autonomous_cars/0.mechanics/assets/centerrectangle.png new file mode 100644 index 0000000..53c4c99 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/centerrectangle.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/chamfer.png b/docs/autonomous_cars/0.mechanics/assets/chamfer.png new file mode 100644 index 0000000..db96152 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/chamfer.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/chamfer_result.png b/docs/autonomous_cars/0.mechanics/assets/chamfer_result.png new file mode 100644 index 0000000..4824ccc Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/chamfer_result.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/clamp_rectangle.png b/docs/autonomous_cars/0.mechanics/assets/clamp_rectangle.png new file mode 100644 index 0000000..524ab03 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/clamp_rectangle.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/constraints.png b/docs/autonomous_cars/0.mechanics/assets/constraints.png new file mode 100644 index 0000000..59b2f07 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/constraints.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/cornerconstraints.png b/docs/autonomous_cars/0.mechanics/assets/cornerconstraints.png new file mode 100644 index 0000000..2843d61 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/cornerconstraints.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/drawrectangle.png b/docs/autonomous_cars/0.mechanics/assets/drawrectangle.png new file mode 100644 index 0000000..c50f4a0 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/drawrectangle.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/exitsketching.png b/docs/autonomous_cars/0.mechanics/assets/exitsketching.png new file mode 100644 index 0000000..b6e404b Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/exitsketching.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/extrude.png b/docs/autonomous_cars/0.mechanics/assets/extrude.png new file mode 100644 index 0000000..e178a68 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/extrude.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/extude_the_hole.png b/docs/autonomous_cars/0.mechanics/assets/extude_the_hole.png new file mode 100644 index 0000000..058f09f Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/extude_the_hole.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/formattext.png b/docs/autonomous_cars/0.mechanics/assets/formattext.png new file mode 100644 index 0000000..0b6ec2a Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/formattext.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/fusion360.mp4 b/docs/autonomous_cars/0.mechanics/assets/fusion360.mp4 new file mode 100644 index 0000000..ba10cca Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/fusion360.mp4 differ diff --git a/docs/autonomous_cars/0.mechanics/assets/locker_hole.png b/docs/autonomous_cars/0.mechanics/assets/locker_hole.png new file mode 100644 index 0000000..b3e8edc Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/locker_hole.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/logoandrectangle.png b/docs/autonomous_cars/0.mechanics/assets/logoandrectangle.png new file mode 100644 index 0000000..3397fe8 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/logoandrectangle.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/pipie_hole.png b/docs/autonomous_cars/0.mechanics/assets/pipie_hole.png new file mode 100644 index 0000000..64ad8a5 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/pipie_hole.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/plateextrude.png b/docs/autonomous_cars/0.mechanics/assets/plateextrude.png new file mode 100644 index 0000000..22404e8 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/plateextrude.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/rectangle_extrude.png b/docs/autonomous_cars/0.mechanics/assets/rectangle_extrude.png new file mode 100644 index 0000000..a2a7249 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/rectangle_extrude.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/schetchtools.png b/docs/autonomous_cars/0.mechanics/assets/schetchtools.png new file mode 100644 index 0000000..e1ebe59 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/schetchtools.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/sketchcontraints.png b/docs/autonomous_cars/0.mechanics/assets/sketchcontraints.png new file mode 100644 index 0000000..e9a9071 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/sketchcontraints.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/sketchresult.png b/docs/autonomous_cars/0.mechanics/assets/sketchresult.png new file mode 100644 index 0000000..113b1b0 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/sketchresult.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/test.png b/docs/autonomous_cars/0.mechanics/assets/test.png new file mode 100644 index 0000000..8faf889 Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/test.png differ diff --git a/docs/autonomous_cars/0.mechanics/assets/textextrude.png b/docs/autonomous_cars/0.mechanics/assets/textextrude.png new file mode 100644 index 0000000..88f1aed Binary files /dev/null and b/docs/autonomous_cars/0.mechanics/assets/textextrude.png differ diff --git a/docs/autonomous_cars/0.mechanics/index.md b/docs/autonomous_cars/0.mechanics/index.md new file mode 100644 index 0000000..5cde8f8 --- /dev/null +++ b/docs/autonomous_cars/0.mechanics/index.md @@ -0,0 +1,234 @@ +--- +title: Mechanics +--- + +# Course: Introduction to Autodesk Fusion 360 + +## 🎯 Objective: +Become familiar with Autodesk Fusion 360 as a platform and learn how to create a 3D model. + +--- + +## 🔍 What is Autodesk Fusion 360? + +Autodesk Fusion 360 is an all-in-one, cloud-based 3D modeling platform that combines: +- **CAD (Computer-Aided Design)** +- **CAM (Computer-Aided Manufacturing)** +- **CAE (Computer-Aided Engineering)** + +It is widely used in mechanical design, product design, and rapid prototyping. + + + +--- + +## 🧩 Installation and System Requirements + +- Download from: [https://www.autodesk.com/products/fusion-360](https://www.autodesk.com/products/fusion-360) +- Educational licenses are **free** for students and educators: [Link](https://www.autodesk.com/education/edu-software/overview#FSN) +- Minimum requirements: + - Windows 10/11 or macOS + - 4+ GB RAM (8+ GB recommended) + - Graphics card with DirectX 11 support + - Internet connection (for cloud sync) + +--- + +## 🖥️ Interface Overview + +When you open Fusion 360, you’ll see: + +- **Toolbar**: Contains modeling tools depending on the workspace. +- **Browser**: A tree view of your components and features. +- **Canvas**: The main modeling window. +- **Timeline**: History of all modeling operations. +- **Projects**: Project management panel. + +![Fusion Interface Overview](./assets/Fusion_interface.png) + +--- + +## 🧭 3D Navigation Basics + +You can navigate the 3D space using: + +- **Orbit**: Rotate the view – _Hold Shift + Middle Mouse Button_ +- **Pan**: Move the view – _Hold Middle Mouse Button_ +- **Zoom**: Scroll the mouse wheel + +Also, use the **ViewCube** in the top-right corner to switch views. + +![ViewCube Navigation](./assets/ViewCube.png) + +--- + +# ✏️ Creating a 3D Logo for Your Team in Fusion 360 + +## 🧱 Main Steps +- **Sketching**: The starting point for most 3D modeling tasks. Create a 2D profile on a plane. +- **Extruding**: Turn the 2D sketch into a 3D solid by pulling it in a specific direction. + +--- + +## 🔹 Step 1: Create a New Design File +- Open Fusion 360. +- Go to **File > New Design** or press `Ctrl + N`. +- Save the file (`Ctrl + S`) with a meaningful name like `Sketch_Extrude_Example`. + +--- + +## 🔹 Step 2: Create the Logo Body + +### 1. **Create a New Sketch** +1. Click on the **“Create Sketch”** button in the toolbar. +2. Select a **plane** to draw on: + - XY (top view) + - XZ (front view) + - YZ (side view) + +![ViewCube Navigation](./assets/CreateSketch.png) + +--- + +### 2. **Drawing the Base Shape (Rectangle)** +Use the sketch tools from the **Sketch menu** to create the base shape: +- From the **Sketch** menu, select the **Rectangle** tool. + +![ViewCube Navigation](./assets/schetchtools.png) + +- Choose the **Center Rectangle** option. + +![ViewCube Navigation](./assets/centerrectangle.png) + +- Draw a rectangle with dimensions **50 x 20 mm**. + +![ViewCube Navigation](./assets/drawrectangle.png) + +### 3. **Adding the Logo Text** +- Select the **Text** tool from the **Create** menu. + +![ViewCube Navigation](./assets/TEXT.png) + +- Type the desired text and choose your preferred font and style. + +![ViewCube Navigation](./assets/formattext.png) + +- Position the text inside the rectangle. + +![ViewCube Navigation](./assets/logoandrectangle.png) + +### 4. **Centering and Applying Constraints** +To keep the logo in place even if the rectangle is resized: +- Use the **Constraints** tool to center the logo inside the rectangle. +- Apply corner constraints to align the logo with the rectangle. + +![ViewCube Navigation](./assets/constraints.png) +![ViewCube Navigation](./assets/cornerconstraints.png) + +- Final constrained sketch result: + +![ViewCube Navigation](./assets/sketchresult.png) + +### 5. **Exit Sketch Mode** +Once the sketch is complete, exit sketch mode by clicking **Finish Sketch**. + +![ViewCube Navigation](./assets/exitsketching.png) + +### 6. **Extrude the Text** +- Select the **Extrude** tool from the **Create** menu. + +![ViewCube Navigation](./assets/extrude.png) + +- Select the text to extrude. + +![ViewCube Navigation](./assets/textextrude.png) + +### 7. **Extrude the Base (Rectangle)** +- Extrude the rectangle to create a 3D plate for the text. + +![ViewCube Navigation](./assets/plateextrude.png) + +### 8. **Final Logo Body** +- This is how the logo body should look. + +![ViewCube Navigation](./assets/Logo_extrude.png) + +--- + +## 🔹 Step 5: Create the Pipe Clamp + +### 1. **Open Sketch1** +- Double-click **Sketch1** in the Browser. + +![ViewCube Navigation](./assets/Sketch1.png) + +### 2. **Draw Clamp Rectangle** +- Place a rectangle centered within the logo rectangle. + +![ViewCube Navigation](./assets/clamp_rectangle.png) + +### 3. **Extrude the Clamp Rectangle** +- Exit sketch mode. +- Use the **Extrude** tool and set the depth to 20 mm. + +![ViewCube Navigation](./assets/rectangle_extrude.png) + +### 4. **Create Sketch for the Pipe Hole** +- Create a sketch on the top face of the clamp. +- Draw a circle 8 mm from the logo, centered left-to-right. +- Add two parallel lines from the circle to the rectangle edge (to allow pipe insertion and locking). + +![ViewCube Navigation](./assets/pipie_hole.png) + +### 5. **Extrude the Hole** +- Exit the sketch. +- Use **Extrude**, select the circle and area between the lines. +- Set **Extent Type** to "To Object" and select the opposite face of the clamp. + +![ViewCube Navigation](./assets/extude_the_hole.png) + +### 6. **Create a Clamp Locker** +- Create a sketch on the right side of the clamp. +- Draw two circles (2 mm and 4 mm diameter), 5 mm from the back, vertically centered. + +![ViewCube Navigation](./assets/locker_hole.png) + +### 7. **Extrude the Clamp Locker** +- Use **Extrude** to create the 4 mm hole. Set **Extent Type** to "To Object". + +![ViewCube Navigation](./assets/4mm_hole.png) + +- Use **Extrude** to create the 2 mm hole. Set **Start** to "Object" (the inside face), and **Extent Type** to "To Object". + +![ViewCube Navigation](./assets/2mm_hole.png) + +### 8. **Use Fillet to Smooth Edges** +- Select the **Fillet** tool from the **Create** menu. +- Choose the edges to smooth and set the radius to 9 mm (or any value). + +![ViewCube Navigation](./assets/Smooth_edges.png) + +- Repeat for other edges as desired: + +![ViewCube Navigation](./assets/Smooth_edges2.png) +![ViewCube Navigation](./assets/Smooth_edges3.png) + +### 9. **Create Chamfer for the Locker Screw** +- Select **Chamfer** from the **Create** menu. + +![ViewCube Navigation](./assets/chamfer.png) + +- Select the hole edge and set the chamfer value to 2 mm. + +![ViewCube Navigation](./assets/chamfer_result.png) + +--- + +## 🔹 Final: Logo Body Finished + +![ViewCube Navigation](./assets/Logo_body.png) + + diff --git a/docs/autonomous_cars/1.electronics/0.components/index.md b/docs/autonomous_cars/1.electronics/0.components/index.md new file mode 100644 index 0000000..738dbba --- /dev/null +++ b/docs/autonomous_cars/1.electronics/0.components/index.md @@ -0,0 +1,229 @@ +--- +title: Electronic components breakdown +--- + +## Components + +The main components of the car are: + +- Camera +- Motor driver +- Servo +- FRDM MCXN947 Development Board +- Two brushed DC motors +- Battery + +### Camera + +The Pixy (also known as the Pixy2) is a compact, fast vision sensor designed for embedded applications. Rather than streaming raw image data, Pixy processes frames on-board to detect objects based on color signatures, then outputs only the relevant information (e.g., object type, position, size). This makes it ideal for robotics projects where low latency and minimal host-processor load are critical. + +
+![pixy_cam](../assets/pixy_cam.png) +
+ + +When configured for line tracking, the Pixy camera leverages its on-board algorithms to detect and follow high-contrast (typically black-on-white) lines at up to 60 FPS. This mode is perfect for guiding our car along a predefined track without burdening the main processor with pixel-level image analysis. + +
+![line_track](../assets/line_track.png) +
+ +#### Key Features for Line Detection +- **High-Speed Processing** + Processes up to 60 frames per second, ensuring smooth, responsive line following. +- **Adaptive Thresholding** + Automatically adjusts to varying ambient light to maintain robust line contrast. +- **Blob & Edge Detection** + Identifies contiguous line segments (blobs) and computes their centroids and angles. +- **Centroid & Angle Output** + Provides `(x, y)` centroid position of the line within the frame and the line’s orientation angle relative to the camera. + +#### How Line Detection Works +1. **Contrast Calibration** + PixyMon lets you set the threshold so Pixy isolates the line (e.g., black tape) against the background (e.g., white surface). +2. **Blob Extraction** + In each frame, Pixy finds contiguous dark regions (blobs) matching the threshold. +3. **Line Fitting** + Pixy fits a straight line to the blob cluster and calculates its orientation and center position. +4. **Data Output** + Sends a small packet containing the blob’s centroid `(x, y)`, width, height, and the fitted line’s angle. + +#### Wiring & Integration + +
+![pixy_pinout](../assets/pixy_pinout.png) +
+ +- **Power** + 5 V supply (150 mA typical). +- **Interfaces:** + - **SPI:** Connect MISO/MOSI/SCK/SEL → MCU SPI pins + - **I²C:** SDA/SCL with pull-ups to match MCU logic level + - **UART:** TX/RX at 115200 baud +- **USB (for setup):** + Use Mini-USB to connect to PixyMon for threshold tuning and firmware updates. + +#### Resources +- You can find the documentation [here](https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:start). +- Downloads [here](https://pixycam.com/downloads-pixy2/). + + +### Motor driver + +A motor driver serves as the interface between your microcontroller and the DC motors. It provides the necessary current amplification, voltage switching, and direction control that small logic pins cannot supply directly. In our car project, we use a dual H-bridge MOSFET driver to independently control two brushed DC motors. + +
+![motor_driver](../assets/motor_driver.png) +
+ +#### What It Does +- **Current Amplification:** MOSFETs switch high currents (up to several amps) with low voltage drop, delivering sufficient power to the motors. +- **Voltage Switching:** Allows the motors to run forward, backward, brake, or coast by switching the polarity of the supply voltage. +- **Direction Control:** Two input pins per motor control its rotation direction. +- **Speed Control:** PWM on the input pins modulates the effective voltage, enabling precise speed regulation. + +#### H-Bridge Basics +An H-bridge is a circuit of four MOSFET switches arranged in an “H” pattern around the motor: + +
+![h_bridge](../assets/h_bridge.png) +
+ +- **Q1/Q4 ON:** Current flows left-to-right → motor spins forward. +- **Q2/Q3 ON:** Current flows right-to-left → motor spins backward. +- **Q1/Q3 or Q2/Q4 ON (both same side):** Dynamic braking by shorting the motor terminals. +- **All OFF:** Motor coasts. + +#### Pinout & Signal Mapping +| Input Pin | Function | Output Pin | +|-----------|---------------------|------------| +| IN1 | Motor A direction | OUT1 | +| IN2 | Motor A direction | OUT2 | +| IN3 | Motor B direction | OUT3 | +| IN4 | Motor B direction | OUT4 | + +- **INx = HIGH:** Turns ON the corresponding high-side MOSFET (Q1 or Q2). +- **INx = LOW:** Turns ON the corresponding low-side MOSFET (Q3 or Q4). +- **PWM on INx:** Modulates switching speed for speed control. + +#### Example Operation for Motor A +- **Forward:** + ```text + IN1 = PWM signal + IN2 = LOW + Current flows through motor for forward rotation + ``` + + +- **Reverse:** + ```text + IN1 = LOW + IN2 = PWM signal + Current reversed for backward rotation + ``` + +- **Brake:** + ```text + IN1 = HIGH + IN2 = HIGH + Both MOSFETs conduct, shorting motor terminals for rapid stop + ``` + +- **Coast:** + ```text + IN1 = LOW + IN2 = LOW + Both MOSFETs off, motor spins down freely + ``` + + +#### Wiring & Integration + +1. **Power Connections** + - **Vₛ (Motor Supply):** 6–12 V (depending on motor rating) to the driver’s VIN pin + - **GND:** Common ground between driver, battery, and MCU + +2. **Control Lines (to FRDM MCXN947)** + - **IN1/IN2 (Motor A):** Connect to two PWM-capable GPIOs + - **IN3/IN4 (Motor B):** Connect to two PWM-capable GPIOs + +3. **Motor Outputs** + - **OUT1/OUT2:** To Motor A terminals + - **OUT3/OUT4:** To Motor B terminals + +4. **Logic Supply** + - **VCC:** 3.3 V or 5 V (matches MCU logic level) to the driver’s logic-level input pin + +### Servomotor + +The 996R is a high-torque, digital hobby servomotor commonly used in robotics and RC applications. Its robust metal-geared design and precise PWM control make it ideal for steering and positioning tasks in an autonomous car project. + +
+![mg996r](../assets/mg996r.png) +
+ +#### Key Specifications + +- **Operating Voltage:** 4.8 – 7.4 V (nominal 6 V) +- **Stall Torque:** ~12 kg·cm @ 6 V +- **Speed:** ~0.12 s/60° @ 6 V +- **Gear Type:** Metal (reinforced for durability) +- **Control:** Digital PWM, 0.5 µs resolution +- **Deadband:** 3 µs (high precision) +- **Dimensions:** 40 × 20 × 38 mm +- **Weight:** ~60 g + +#### How It Works + +1. **PWM Signal Input** + - A pulse every 20 ms (50 Hz), with pulse width between 1 ms (0°) and 2 ms (180°). +2. **Internal Controller** + - Measures incoming pulse width and compares to potentiometer feedback from the output shaft. + - Drives the motor (via metal gears) to minimize error. +3. **Position Feedback** + - Built-in potentiometer provides continuous position feedback for tight, jitter-free control. + +#### Wiring & Integration + +| Servo Pin | Function | Connection | +|---------------|--------------------|-------------------------------------| +| Red | VCC | 5 – 6 V regulated power supply | +| Black/Brown | GND | Common ground with MCU & battery | +| White/Orange | PWM signal | PWM-capable GPIO on FRDM MCXN947 | + +1. **Power** + - Use a stable 5–6 V supply (separate from logic regulator if possible). +2. **Ground** + - Tie servo GND to the MCU’s GND to ensure common reference. +3. **Control** + - Connect the signal line to a timer/PWM output pin on the FRDM MCXN947 and configure for a 20 ms period with a 1–2 ms pulse width. + +#### Use Case in the Car Project + +The 996R servo is used for steering control. By reading the line-detection data from the Pixy camera, the FRDM MCXN947 computes the desired steering angle and updates the servo position accordingly, enabling smooth, accurate cornering and line-following behavior. + + +### FRDM MCXN947 Development Board + +A versatile microcontroller platform for embedded projects. + +
+![frdm_board](../assets/frdm_board.png) +
+ +The FRDM MCXN947 features: + +- **Core MCU:** Dual Arm® Cortex® -M33 cores @150MHz each +- **Memory:** Up to 2MB dual-bank flash with optional full ECC RAM, External flash +- **On-board Debugger:** USB-to-SWD (OpenSDA) for programming and realtime tracing +- **Expansion:** Arduino™ Uno-compatible headers +- **Power:** USB-powered or external 3.3 V supply +- **SDK Support:** MCUXpresso SDK with drivers, RTOS examples, and CLI demos + +Ideal for rapid prototyping of sensor, motor-control, and communication applications. + +#### Pinout + +
+![frdm_pinout](../assets/frdm_pinout.png) +
diff --git a/docs/autonomous_cars/1.electronics/1.basics/index.md b/docs/autonomous_cars/1.electronics/1.basics/index.md new file mode 100644 index 0000000..f2c0c7c --- /dev/null +++ b/docs/autonomous_cars/1.electronics/1.basics/index.md @@ -0,0 +1,391 @@ +--- +title: Electronic basics +--- + +# Electronics + +This page offers a brief introduction to basic electronics and harwdare related concepts. We'll cover a few relevant laws of physics, some examples of simple components and how they're used, as well an overview of datasheets and what to look out for when reading one. + +## Resources +**Charles Platt**, *Encyclopedia of Electronic Components*, chapters 1, 5 and 10 Volume 1, chapter 22 Volume 2 and Volume 3 + +## Basic electronics + +### Definitions + +#### Electric voltage + +The electric voltage represents the potential difference between two points in a circuit and it's proportional to the energy required to move an electric charge between the two points. + +$$ +V = \frac{W}{Q} +$$ + +V = Electromotive voltage (U in romanian); +W = Mechanical work of the electric force (L in romanian); +Q = Electric charge; + +The unit of measurement of the electric voltage in the SI[^si] is the **Volt**(V) + +$$ +[V]_{SI} = V(Volt) +$$ +$$ +[W]_{SI} = J(Joule) +$$ +$$ +[Q]_{SI} = C(Coulomb) +$$ + +:::info + +Electric voltage is always measured between two points in a circuit. In general, voltages are measured against a reference point called circuit mass **(GND)**. Circuit mass is a convention and represents the point which potential is consider null. + +::: + +#### Electrical resistance + +Electrical resistance is a physical quantity that expresses the property of a material to oppose the passage of electric current. The SI[^si] unit of resistance is the **Ohm**, noted Ω. + +$$ +[R]_{SI} = \Omega(Ohm) +$$ + +#### Intensity of electric current + +The intensity of the electric current, also called the electric current, is a scalar physical quantity equal to the variation of the electric charge that crosses the section of a conductor in the unit of time. The unit of measurement in SI[^si] is the **Ampere**(A). + +$$ +[I]_{SI} = A(Ampere) +$$ + +### Ohm's law + +The intensity(I) of the electric current passing through a resistor is directly proportional to the voltage(V) applied to the resistor and inversely proportional to its resistance value(R). + +
+![Ohm's Law](../assets/ohm.png) +
+ +$$ +I = \frac{V}{R}; +$$ + +I = intensity of electric current(A) +V = electric voltage(V) +R = circuit's resistance(Ω) + +### Kirchhoff's First Law + +The sum of currents flowing into a junction is always equal to the sum of currents flowing out of the same junction. + +$$ +\sum_{k=1}^{n} I_k = 0 +$$ + +
+![Kirchhoff's First Law](../assets/kirchhoff_1.png) +
+ +$$ +I_1 + I_2 = I_3 + I_4 + I_5 +$$ +$$ +I_1 + I_2 - I_3 - I_4 - I_5 = 0 +$$ + +### Kirchhoff's Second Law + +Around any closed loop in a circuit, the directed sum of potential differences across components is zero. + +$$ +\sum_{k=1}^{n} V_k = 0 +$$ + +
+![Kirchhoff's Second Law](../assets/kirchhoff_2.png) +
+ +$$ +-V_A - V_B - V_C + V_D + V_E = 0 +$$ + +### Voltage divider + +There are many types of voltage dividers, being named according to the type of component elements: resistive divider, capacitive divider, compensated divider, etc... +The **resistive voltage divider** is obtained by applying a voltage $$E$$ to a group of resistors in series and thus a fraction of the voltage applied to one of the resistors of the group can be obtained. + +
+![Voltage divider on GND](../assets/voltage_divider_gnd.png) +
+ +$$ +V_{out} = V_{in} * \frac{R_{2}}{R_{1} + R_{2}}; +$$ + +:::warning +The voltage divider can be considered a power source only if it operates in the empty state. It is **not recommended** to use a voltage divider to supply a circuit as the internal resistance is high and energy is lost due to heating. It can be used to provide reference points. +::: +#### What happens if we use the voltage divider to supply a circuit. + +We consider a voltage divider that provides $$3V3$$ from a $$5V$$ power source $$E$$ and a load resistance, $$R_s$$, representing the current consumption of a sensor or a circuit that needs to be supplied at $$3V3$$. + +
+![Voltage divider with load](../assets/voltage_divider_rs.png) +
+ +From Kirchhoff's First Law, the current through $$R_1$$ must be equal to the sum of the current through $$R_2$$ and $$R_s$$. + +$$ +I_{R_1} = I_{R_2} + I_{R_S} +$$ +$$ +V = V_{E} * \frac{R_2 || R_S}{R_1 + R_2 || R_S}; +$$ + +:::note +Equivalent resistor value +- series + +
+![R series](../assets/r_series.png) +
+ +$$ +R_{series} = R_1 + R_2 +$$ + +- parallel + +
+![R parallel](../assets/r_parallel.png) +
+ +$$ +R_{parallel} = R_1 || R_2 +$$ +$$ +\frac{1}{R_{parallel}} = \frac{1}{R_1} + \frac{1}{R_2} +$$ +::: + +The output voltage depends on the current intensity through $$R_s$$, on the current consumption of the circuit that needs to be supplied at $$3V3$$. This is not a viable power supply solution. + +Beside the instability of the voltage divider with a load, the power rating for the $$R_1$$ must be suitable. + +$$ +P_{R_1} = V_{R_1} * I_{R_1} +$$ + +The power dissipation on the resistor is directly proportional with the current through the resistor. Resistor are fabricated with predefined power ratings, most common $$1/4W$$, $$1/2W$$, $$1W$$. + +:::note +For a better understanding, please read the chapter 10 of *Encyclopedia of Electronic Components*, Volume 1 +::: + +:::info +In case we want to use the voltage divider between two chosen voltage values, we can use the generalized formula: + +$$ +V_{out} = ( V_{1} - V_{2} ) * \frac{R_{2}}{R_{1} + R_{2}}; +$$ + +
+![Voltage divider](../assets/voltage_divider.png) +
+::: + +## Electronic Components + +### Actuators and sensors + +In order to interface with the external environment, various electronic components are used, serving either as actuators (modifying the state of the external environment) or as transducers/sensors (influenced by the external environment and providing information to the microcontroller about various parameters). + +Examples of actuators: +- Fans +- Audible indicators (buzzers) +- Light indicators +- Heating resistors + +:::tip +Sometimes, to activate an actuator, an actuating element is needed. For instance, to start a motor, the microcontroller simply sends a logical start command to a transistor that opens and allows a high current to pass through it (here, by "high current", we compare it to the maximum of a few milliamperes that a microcontroller can output). +::: + +Examples of sensors: + +- Buttons +- Photo resistors - their electrical resistance is influenced by the amount of light +- Thermistors - their electrical resistance is influenced by temperature + +:::tip +Depending on the type of transducers, they may require signal processing before being taken in by the microcontroller (signal conditioning). For example, a photo resistor needs to be used in a circuit with a voltage divider or a current source. Alternatively, some sensors can be connected directly to the microcontroller, such as buttons. +::: + +:::note +For a better understanding, please read *Encyclopedia of Electronic Components*, Volume 3 +::: + +### LEDs + +LEDs - Light Emitting Diode - also called electroluminescent diodes - emit light when they are directly polarized. Not to be confused with light bulbs as they have radically different methods of operation. + + +LEDs can be used as indicator lights (often used in various appliances to signal that the appliance is on and doing something), or for illumination, in which case power LEDs are used. In the lab, LEDs are used to indicate the status of a pin. + +#### Calculation of current limiting resistor + + +To use an LED for the purpose of indicating the status of a pin (rather said to indicate the presence of voltage), the current through the LED must be limited. This can be done most simply by stringing a resistor with the LED. + +An LED is designed to operate at a nominal current (ex: 10mA). The voltage drop at this current across low power indicator LEDs is given by the chemistry of the LED (this also gives the color of the LED). In the lab, since we are using such a low current LED, we can power it directly from the logic pins of the MCU. + +
+![LED](../assets/led.png) +
+ +$$ +R_{1} = \frac{(V_{pin} - V_{led})}{I_{led}} +$$ + +#### Example: + +If the MCU has a pin voltage of 3.3V, also noted as 3V3, to light up an LED with a nominal current of 10mA and a voltage drop of 2V we need +a resistance of 130 Ω. + +:::tip +We can use a resistor with a higher resistance value. The nominal current will light up the LED at it's maximum brightness. For status LEDs we can pick a resistance even 10 times bigger and the LED will light up slightly. +::: + +:::danger +If there is no resistor in the circuit, the resistance will be almost 0 Ω, the current will tend to $$\infty$$, meaning a short circuit. This will absolutely burn the LED and make it unusable, but it can also burn the MCU. Most MCUs have short circuit protection, but is safer to not rely on that. +::: + +:::note +For a better understanding, please read the chapter 22 of *Encyclopedia of Electronic Components*, Volume 2 +::: + +### Buttons + +The simplest way for the user to interact with a MCU is through the use of buttons. + +There are various ways to connect a button to the MCU, but these are the most used versions: + +:::warning[Incorrect] +
+![Floating button](../assets/floating_btn.png) +
+ +This diagram shows a button connected to the MCU pin. When the button is pressed, the MCU input pin will be connected to GND, so it will be in the logic "0" state. This way of binding is **incorrect** because when the button is not pressed, the input is in **an undefined state** (as if left in the air), not being connected to either GND or Vcc! This state is called the **increased impedance state**. In practice, if we now read the value of the pin, it will produce a result of 1 or 0 depending on the environmental conditions. For example, if we bring our finger closer to that input, the reading will be 1, and if we move our finger away, the reading will be 0. +::: + +:::tip[Correct] +
+![Pulled up button](../assets/pullup_btn.png) +
+ + This is the correct way to connect the button, using a **pull-up resistor** between the input pin and Vcc. This resistance has the role of bringing the input to the logic "1" state when the button is free by "raising" the line potential to Vcc. Alternatively, a **pull-down resistor** (connected to GND) can be used, in which case the input is held in the logic "0" state while the button is not pressed. +::: + +:::info +To save external space, in most MCUs these resistors have been included inside the integrated circuit. Initially they are disabled and their activation can be done through software. +::: + +:::note +For a better understanding, please read the chapter 5 of *Encyclopedia of Electronic Components*, Volume 1 +::: + +### Breadboard and jumper wires + +#### Breadboard + +A breadboard is a rectangular board with a grid of holes that allows you to create temporary electronic circuits without soldering. The board typically has metal strips underneath the surface, connecting the holes in certain patterns. These patterns follow a standard layout, facilitating circuit building. Breadboards are reusable and provide a convenient way to prototype circuits quickly and make changes easily by rearranging components. + +
+![Breadboard](../assets/breadboard.png) +![Breadboard connection](../assets/breadboard_connections.png) +Breadboard connection +![Small breadboard connection](../assets/small_breadboard.png) +Small breadboard connection +
+ +#### Jumper wires + +Jumper wires are flexible wires with connectors at each end, typically male connectors (pins) or female connectors (sockets). They are used to create electrical connections on a breadboard by plugging one end into a hole on the breadboard and the other end into another hole, forming a connection between the two points. + +
+![Jumper wires](../assets/jumper_wires.png) +Jumper wires +
+ +:::note +For a better understanding, please read the chapter 1 of *Encyclopedia of Electronic Components*, Volume 1 +::: + +## Datasheets + +### What is a datasheet + +Datasheets, also referred to as data sheets or spec sheets, are documents that offer a concise overview of a product, machine, component (such as an electronic part), material, subsystem (like a power supply), or software. The purpose is to provide enough information for a buyer to understand the product and for a design engineer to grasp the component's role in the overall system. + +While datasheets are essential, they have limitations. Some are comprehensive, while others are brief. Certain datasheets include sample schematics as a guide for using a component, but many do not. It's important to note that datasheets typically do not go into the detailed inner workings of a component, as their primary focus is to convey essential information rather than providing in-depth explanations of functionality. + +### How to read a datasheet + +We will use a [presence sensor](https://ro.mouser.com/datasheet/2/365/GP2Y0A02YK0F_13May05_Spec_ED-05G127-1652666.pdf), a [voltage regulator](https://www.ti.com/lit/ds/symlink/tps74801-q1.pdf?ts=1709627122770&ref_url=https%253A%252F%252Fwww.mouser.at%252F) and a [microcontroller](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf?_gl=1*1xsgcfj*_ga*MTYzNjcwMTY1Ny4xNzA4MDAxNDU5*_ga_22FD70LWDS*MTcwOTY0NzM1Mi40LjEuMTcwOTY0NzM2MS4wLjAuMA..) datasheets for example. + +#### Pin Configuration + +For commonly used components, the pin configuration, or pinout, is specified directly on the board. + +
+![C2102](../assets/cp2102.png) +C1202 USB to UART module +
+ +If the pinout is not present on the component, there is a sign, a dot on the case that indicates the perspective in which you need to look at the component. + +
+![Pinout Sharp sensor](../assets/pinout_sharp.png) +Distance sensor - Sharp + +![Pinout LDO](../assets/pinout_ldo.png) +Voltage regulator - Texas instruments + +![RP2040 pinout](../assets/pinout_rp2350a.png) +RP2350A MCU - Raspberry Pi +
+ +The pin configuration diagrams are accompanied by pin descriptions. In this sections, the manufacturers present the functionality of every pin. + +
+![Pin description LDO](../assets/pin_description.png) +Voltage regulator - Texas instruments +
+ +#### Operating conditions + +Every electronic component has it's own characteristics and different operating conditions. The first thing tackled is the supply voltage. + +
+![Sharp supply](../assets/sharp_supply.png) +Distance sensor - Sharp +
+ +There are two sections about the operating conditions: **absolute maximum ratings** and **recommended operating conditions**. Even if they are mentioned, you should never use your component at absolute maximum ratings as it will probably burn the component or have an undefined behavior. + +
+![Absolute maximum ratings LDO](../assets/amr_ldo.png) +![Recommended operating conditions LDO](../assets/roc_ldo.png) +Voltage regulator - Texas Instruments +
+ +#### Output + +Some components, like sensors, that are used to measure a value or to determine a condition, for simplicity, use analog output. This output is usually described in a graph. + +
+![Sharp output](../assets/sharp_output.png) +Distance sensor - Sharp +
+ +[^si]: The International System of Units, the world's most widely used system of measurement. \ No newline at end of file diff --git a/docs/autonomous_cars/1.electronics/2.soldering/index.md b/docs/autonomous_cars/1.electronics/2.soldering/index.md new file mode 100644 index 0000000..7c63061 --- /dev/null +++ b/docs/autonomous_cars/1.electronics/2.soldering/index.md @@ -0,0 +1,3 @@ +--- +title: Soldering +--- \ No newline at end of file diff --git a/docs/autonomous_cars/1.electronics/assets/amr_ldo.png b/docs/autonomous_cars/1.electronics/assets/amr_ldo.png new file mode 100644 index 0000000..8d57b3c Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/amr_ldo.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/breadboard.png b/docs/autonomous_cars/1.electronics/assets/breadboard.png new file mode 100644 index 0000000..dcf12fb Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/breadboard.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/breadboard_connections.png b/docs/autonomous_cars/1.electronics/assets/breadboard_connections.png new file mode 100644 index 0000000..ed163df Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/breadboard_connections.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/cp2102.png b/docs/autonomous_cars/1.electronics/assets/cp2102.png new file mode 100644 index 0000000..4de9ae4 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/cp2102.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/floating_btn.png b/docs/autonomous_cars/1.electronics/assets/floating_btn.png new file mode 100644 index 0000000..a1b564c Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/floating_btn.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/frdm_board.png b/docs/autonomous_cars/1.electronics/assets/frdm_board.png new file mode 100644 index 0000000..3844814 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/frdm_board.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/frdm_pinout.png b/docs/autonomous_cars/1.electronics/assets/frdm_pinout.png new file mode 100644 index 0000000..6074c76 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/frdm_pinout.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/h_bridge.png b/docs/autonomous_cars/1.electronics/assets/h_bridge.png new file mode 100644 index 0000000..e4195d3 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/h_bridge.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/jumper_wires.png b/docs/autonomous_cars/1.electronics/assets/jumper_wires.png new file mode 100644 index 0000000..b8bfe16 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/jumper_wires.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/kirchhoff_1.png b/docs/autonomous_cars/1.electronics/assets/kirchhoff_1.png new file mode 100644 index 0000000..1629459 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/kirchhoff_1.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/kirchhoff_2.png b/docs/autonomous_cars/1.electronics/assets/kirchhoff_2.png new file mode 100644 index 0000000..b399c08 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/kirchhoff_2.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/led.png b/docs/autonomous_cars/1.electronics/assets/led.png new file mode 100644 index 0000000..6cb747a Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/led.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/line_track.png b/docs/autonomous_cars/1.electronics/assets/line_track.png new file mode 100644 index 0000000..4e3da3c Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/line_track.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/mg996r.png b/docs/autonomous_cars/1.electronics/assets/mg996r.png new file mode 100644 index 0000000..bf4b01a Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/mg996r.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/motor_driver.png b/docs/autonomous_cars/1.electronics/assets/motor_driver.png new file mode 100644 index 0000000..90f97d0 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/motor_driver.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/ohm.png b/docs/autonomous_cars/1.electronics/assets/ohm.png new file mode 100644 index 0000000..7babcf5 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/ohm.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/picow-pinout.svg b/docs/autonomous_cars/1.electronics/assets/picow-pinout.svg new file mode 100644 index 0000000..9e22e72 --- /dev/null +++ b/docs/autonomous_cars/1.electronics/assets/picow-pinout.svg @@ -0,0 +1,9061 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/autonomous_cars/1.electronics/assets/pin_description.png b/docs/autonomous_cars/1.electronics/assets/pin_description.png new file mode 100644 index 0000000..45afaeb Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/pin_description.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/pinout_ldo.png b/docs/autonomous_cars/1.electronics/assets/pinout_ldo.png new file mode 100644 index 0000000..4efabe0 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/pinout_ldo.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/pinout_rp2350a.png b/docs/autonomous_cars/1.electronics/assets/pinout_rp2350a.png new file mode 100644 index 0000000..e55e966 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/pinout_rp2350a.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/pinout_sharp.png b/docs/autonomous_cars/1.electronics/assets/pinout_sharp.png new file mode 100644 index 0000000..cb604b2 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/pinout_sharp.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/pixy_cam.png b/docs/autonomous_cars/1.electronics/assets/pixy_cam.png new file mode 100644 index 0000000..526cfea Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/pixy_cam.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/pixy_pinout.png b/docs/autonomous_cars/1.electronics/assets/pixy_pinout.png new file mode 100644 index 0000000..a16d2d8 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/pixy_pinout.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/pullup_btn.png b/docs/autonomous_cars/1.electronics/assets/pullup_btn.png new file mode 100644 index 0000000..07c32a4 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/pullup_btn.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/r_parallel.png b/docs/autonomous_cars/1.electronics/assets/r_parallel.png new file mode 100644 index 0000000..cf1f3ca Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/r_parallel.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/r_series.png b/docs/autonomous_cars/1.electronics/assets/r_series.png new file mode 100644 index 0000000..efa2654 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/r_series.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/resistor_footprint.png b/docs/autonomous_cars/1.electronics/assets/resistor_footprint.png new file mode 100644 index 0000000..e479249 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/resistor_footprint.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/roc_ldo.png b/docs/autonomous_cars/1.electronics/assets/roc_ldo.png new file mode 100644 index 0000000..d8f1999 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/roc_ldo.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/sharp_output.png b/docs/autonomous_cars/1.electronics/assets/sharp_output.png new file mode 100644 index 0000000..b24cc2d Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/sharp_output.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/sharp_supply.png b/docs/autonomous_cars/1.electronics/assets/sharp_supply.png new file mode 100644 index 0000000..09b2bcd Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/sharp_supply.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/small_breadboard.png b/docs/autonomous_cars/1.electronics/assets/small_breadboard.png new file mode 100644 index 0000000..1e2748b Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/small_breadboard.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/voltage_divider.png b/docs/autonomous_cars/1.electronics/assets/voltage_divider.png new file mode 100644 index 0000000..46b7a35 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/voltage_divider.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/voltage_divider_gnd.png b/docs/autonomous_cars/1.electronics/assets/voltage_divider_gnd.png new file mode 100644 index 0000000..eaf6bf7 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/voltage_divider_gnd.png differ diff --git a/docs/autonomous_cars/1.electronics/assets/voltage_divider_rs.png b/docs/autonomous_cars/1.electronics/assets/voltage_divider_rs.png new file mode 100644 index 0000000..3a39117 Binary files /dev/null and b/docs/autonomous_cars/1.electronics/assets/voltage_divider_rs.png differ diff --git a/docs/autonomous_cars/1.electronics/index.md b/docs/autonomous_cars/1.electronics/index.md new file mode 100644 index 0000000..9d827c2 --- /dev/null +++ b/docs/autonomous_cars/1.electronics/index.md @@ -0,0 +1,6 @@ +--- +title: Electronics +--- + +## General description +In this section, we’ll cover basic electronics: break down each component in the project to understand how it works, then learn soldering techniques and build a protoboard. diff --git a/docs/autonomous_cars/2.programming/0.introduction/index.md b/docs/autonomous_cars/2.programming/0.introduction/index.md new file mode 100644 index 0000000..896c38d --- /dev/null +++ b/docs/autonomous_cars/2.programming/0.introduction/index.md @@ -0,0 +1,193 @@ +--- +title: "From Zero to Blinky: Setup & Sanity Check" +--- + +## Get started with the board + +The FRDM-MCXN947 board comes pre-programmed with an LED blinky demo. This built-in example serves as a quick sanity check to confirm that the board is functioning correctly right out of the box. + +#### Let’s walk through the setup process step by step. + +### Step 1: Plug in the board + +Connect a USB Type-C cable from connector J17 on the FRDM-MCXN947 board to your host computer or a USB power supply. This will power up the board and automatically run the pre-programmed demo application. + +#### What to expect: +The onboard RGB LED should start blinking at a steady rhythm. This indicates that the board is functioning correctly and the demo firmware is running as expected. + +![board](../assets/image.png) + +### Step 2: Get needed tools + +To access the tools required for this project, you’ll need to create an NXP account. You can use either your personal or student email address. + +Create your account by [visiting this page](https://www.nxp.com/mynxp/home). + +#### Get MCUXpresso IDE + +Download the latest version of the MCUXpresso IDE from the [NXP website](https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-integrated-development-environment-ide:MCUXpresso-IDE?&tid=vanMCUXPRESSO/IDE). +Make sure to select the installer that matches your operating system (Windows, Linux, or macOS). + +
+![ide_download](../assets/image-1.png) +
+ +
+![ide_download](../assets/image-2.png) +
+ +
+![ide_download](../assets/image-3.png) +
+ +Now let's dive into the installation process. + +Continue clicking "Next" until you reach the install window. +
+![alt text](../assets/image-6.png) +
+ +In this step, you may be prompted to install additional drivers during the installation process, allow these to be installed. +
+![alt text](../assets/image-5.png) +
+ +
+![alt text](../assets/image-7.png) +
+ +Now launch the MCUXpresso IDE and install the SDK. On the IDE Welcome page, click “Download and Install SDKs”. + +
+![alt text](../assets/image-9.png) +
+ +Search for “mcxn947” and click “install”. + +
+![alt text](../assets/image-10.png) +
+ +#### Get MCUXpresso Config Tools + +Next you will get the [MCUXpresso Config Tools](https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-config-tools-pins-clocks-and-peripherals:MCUXpresso-Config-Tools?tab=Design_Tools_Tab&ticket=ST-4323-Qmwtn3ubbT9FY0GemUx-wSxRs6U-nxp), which is suite of utilities that simplifies the configuration of pins, peripherals, and clocks for your project. + +
+![alt text](../assets/image-11.png) +
+ +Get the correct installation for the machine you are using. + +
+![alt text](../assets/image-12.png) +
+ +Accept the "License Agreement" and press "Next" until you get to the installation window. + +
+![alt text](../assets/image-13.png) +
+ +Congratulations! You have successfully tested the board and installed the needed tools! + +### Step 3: Dive into the LED blinky demo + +First let's create a Workspace Folder. Launch workspace where you want to locate it. Keep in mind that workspace switching restarts IDE. + +
+![alt text](../assets/image-15.png) +
+ +Close the Welcome page and select "Import SDK example(s)...". Select the correct MCXN947 board and press "Next". + +
+![alt text](../assets/image-16.png) +
+ +Now from the Import Wizard, drop down on the demo_apps section and select the "led_blinky" application. Then press "Finish" and wait for the project to open. + +
+![alt text](../assets/image-17.png) +
+ +You can see what the project window is split into. + +
+![alt text](../assets/image-18.png) +
+ +Let's take a look at the code. The top part of the code contains the includes files present in the project tree and visible in the Project Explorer tab. + +
+![alt text](../assets/image-19.png) +
+ +The next section is the SysTick_Handler function that toggles the red LED on the board. + +
+![alt text](../assets/image-20.png) +
+ +This function will be periodically called to switch ON and OFF the LED. Ctrl + click on the GPIO_PortToggle function opens the declaration present in fsl_gpio.h header file. + + +
+![alt text](../assets/image-21.png) +
+ +The main function starts by calling the initialization function. + +
+![alt text](../assets/image-22.png) +
+ +The initialization function can be found in the hardware_init.c file. +
+![alt text](../assets/image-23.png) +
+ +This function enables a clock and initializes the board pinds. Then the BOARD_BootClockFRO12M() sets the clock frequency to 12 MHz. SysTick_Config(12000000UL) sets a counter with a value of 12.000.000 that makes the LED blink once per second. More on timers will be covered later. +Changing the counter value will increase/decrease the blinking frequency but note that it needs to be slow enough for the human eye to notice it. +LED_RED_INIT(LOGIC_LED_OFF) calls GPIO_PinWrite() that changes the output of the GPIO (in this case to the OFF state). + +
+![alt text](../assets/image-24.png) +
+ +Now let's divo into how to build and download the code on your board. + +In order to build a project, have it selected and then either click on the "build icon" in the shortcuts provided above or by clicking "Build" in the Quickstart Panel. + +
+![alt text](../assets/image-25.png) +
+ +The project should finish the build without any errors or warnings in the console. + +
+![alt text](../assets/image-26.png) +
+ +For the download step, make sure your board is connected to the computer through the J17 'MCU-LINK' port. + +
+![alt text](../assets/image-28.png) +
+ +Download the application to your board by either cliking on the "debug" icon above or clicking "Debug" in the Quickstart Panel. + +
+![alt text](../assets/image-27.png) +
+ +In the next window, select the MCU-LINK CMSIS-DAP debug probe. + +
+![alt text](../assets/image-29.png) +
+ +To run the application, press the "run" icon. + +
+![alt text](../assets/image-30.png) +
\ No newline at end of file diff --git a/docs/autonomous_cars/2.programming/1.Functions Overview/index.md b/docs/autonomous_cars/2.programming/1.Functions Overview/index.md new file mode 100644 index 0000000..88d264b --- /dev/null +++ b/docs/autonomous_cars/2.programming/1.Functions Overview/index.md @@ -0,0 +1,123 @@ +--- +title: "Overview of Key Functions" +--- + +In this section, we will explore the main functions used in the car application. + +### Download the Project Archive + +To begin working on the actual application, download the provided project archive. This archive contains.... TODO + +Download the project archive from: [insert link] TODO + +### Import the archive into the MCUXpresso IDE + +Inside the MCUXpresso IDE, go to File and choose the import option. + +
+![alt text](../assets/image-31.png) +
+ +In the popup window that will open, dropdown the "General" menu and choose the "Existing Projects into Workspace" option and then go "Next". + +
+![alt text](../assets/image-32.png) +
+ +In the next opopup window, select "Select Archive File" and choose the downloaded zip. Then press "Finish". + +
+![alt text](../assets/image-33.png) +
+ +### Generate the configuration of the drivers + +To generate the configuration of the drivers, go to the Peripherals Tab. Click on the icon in the top right and in the "Open perspective" popup, select "Pins". + +
+![alt text](../assets/image-34.png) +
+ +In the new perspective, choose the right project and wait for the configuration to be completed. + +
+![alt text](../assets/image-35.png) +
+ +To return to the previous perspective, clik again on the "Open Perspective" icon on the top right, and choose the "Develop (default)" option. + +
+![alt text](../assets/image-36.png) +
+ +## Drivers description and usage + + +## 1. Hbridge + +### HbridgeSpeed() +
+![alt text](../assets/image-8.png) +
+ +This function sets both the speed and direction of the car's motors. +It takes two inputs: speed1 and speed2, one for each motor. Each value can range from -100 to +100. +The sign determines the direction the motor spins, where positive values make the motor spin forward,while negative values make it spins backwards. +The higher the number the faster the motor spins. + +### HbridgeBrake() +
+![alt text](../assets/image-7.png) +
+ +This function stops the motors by setting their PWM duty cycle to 0%, which means no power is sent to them. It also sets the direction control pins to a safe state, ensuring the motors remain stopped. + +## 2. Servo + +### Steer() + +
+![alt text](../assets/image-9.png) +
+ +This function tells the steering servo which way to turn. +It takes an angle value between -100 and +100, where -100 means full turn in one direction, +100 means full turn in the opposite direction and 0 keeps the wheels straight. + +Based on this value, it calculates the PWM duty cycle needed to position the servo as requested. Then it reads the current timer period (periodTicks) and uses it in order to calculate the number of timer ticks (pulseTicks) that will produce the correct duty cycle. + +In the end, it updates the timer's register with this value so the servo received the new command. + + +## 3. Pixy Camera + +The Pixy camera communicates with the board using the I2C protocol. +When the board needs information from the camera, such as detected lines, the process is: +1. Build a request packet: a sequence of bytes starting with a special header, followed by a command number, the message length and any extra data. +2. Send the packet to the Pixy. +3. Receive the response packet from the Pixy. +4. Interpret the received data (eg. converting a series of bytes into coordinates for the detected lines). + +In this communication, DMA (Direct Memory Access) acts as a helper inside the microcontroller that transfers data between peripherals and memory without the CPU handling each byte. +This allows the CPU to perform other tasks while the transfer is in progress, making communication faster and more efficient. + +## 4. Main function + +Here the main logic of the car is implemented. + +### Steps: +#### 1. Start-up and setup +The main components, such as the motors, steering servo and Pixy camera, are initialized. Then the Pixy camera's LED is turned to red to show it is ready. + +#### 2. Main loop +Here the main algorithm is implemented. These steps are repeated by the car over and over. + + 1. Pixy camera sends coordinates for lines as vectors, each vector representing the start and end coordinates of a line segment. + 2. The algorithm looks for intersections. When two lines seems to be almost perpendicular, there is an assumption that there is an intersection. The program picks the line that best represents the lane to follow. + 3. If there is no intersection, the program combines the angles of all visible lines in order to find the general direction of the road. + 4. It calculates the steering angle. The angle is limited so the wheels never turn more than 45 degrees in either direction. + 5. The calculated angle is sent to the steering servo so the wheels turn to follow the road. + 6. The two drive motors are set to the same speed so the car keeps moving ahead. + +#### Main idea: + +In this algorithm, the car is constantly asking the Pixy for the latest view of the lines, deciding the road it continues on and acting based on the previous informations by steering toward the road's direction, all while keeping the motors running. \ No newline at end of file diff --git a/docs/autonomous_cars/2.programming/2.drivers/index.md b/docs/autonomous_cars/2.programming/2.drivers/index.md new file mode 100644 index 0000000..0927378 --- /dev/null +++ b/docs/autonomous_cars/2.programming/2.drivers/index.md @@ -0,0 +1,169 @@ + +# PWM Control with CTIMER on the FRDM–MCXN947 Board + +## 🎯 Objective: + +Learn how to configure and generate PWM signals using the CTIMER peripheral in MCUXpresso IDE on the FRDM–MCXN947 development board. + +--- + +## 🔍 What are CTIMER and PWM? + +**CTIMER (Counter/Timer)** is a versatile on-chip peripheral found in NXP microcontrollers that can operate as a timer, counter, or PWM generator. +**PWM (Pulse-Width Modulation)** is a technique to encode analog values using a digital signal by varying the duty cycle. It is widely used for motor control, LED dimming, and signal generation. + +--- + +## 🖥️ Tools and Requirements + +* **IDE**: MCUXpresso IDE (v11.5.0 or later) +* **Board**: FRDM–MCXN947 development kit +* **Compiler**: GNU Arm Embedded Toolchain (bundled with IDE) +* **Connectivity**: USB cable for board programming and debugging + +--- + +## 🧭 Workspace Overview + +When you open your project in MCUXpresso IDE: + +* **Peripherals Perspective**: Configure on-chip peripherals visually. +* **Problems View**: Displays configuration errors and quick-fix suggestions. +* **Pins Perspective**: Assign and route physical pins to peripheral functions. +* **Project Explorer**: Browse source files and configuration. + +--- + +# ✏️ Step-by-Step PWM Configuration + +## 🧱 Main Steps + +* **Enable CTIMER Driver** in Peripheral Drivers section. +* **Set Mode to PWM** and configure clock prescaler. +* **Define PWM Channels** and default duty cycles. +* **Route Pins** in Pins Perspective or via quick-fix. +* **Generate Code** and call the PWM update function in your application. + +--- + +## 🔹 Step 1: Open Peripherals Perspective + +1. In MCUXpresso IDE, click the **Peripherals** tab or switch via the perspective icon. +2. Expand **Peripheral Drivers (Device specific)** and click **+** to add a new driver. + + +![ERROR](../assets/1_peripheral_drivers.png) + + +## 🔹 Step 2: Enable CTIMER and Set Mode + +1. Search for **ctimer** in the drivers list and press **OK**. +![ERROR](../assets/2_add_ctimer.png) + +2. In the CTIMER instance list, select the desired timer (e.g., CTIMER1). +![ERROR](../assets/3_select_ctimer.png) + +3. Under **Mode**, choose **PWM**. +![ERROR](../assets/4_mode_pwm.png) + +--- + +## 🔹 Step 3: Resolve Clock Errors + +* Go to the **Problems** tab (right corner). +* Right-click any CTIMER_clock error (bulb icon) and apply the suggested fix to enable its clock. +![ERROR](../assets/5_clock_enable.png) + +--- + +## 🔹 Step 4: Configure Timer Frequency and Prescaler + +1. In the CTIMER settings, set the **Input Clock Frequency** or **Prescaler** so that the timer base frequency supports your desired PWM frequency. + + * *Explanation*: The prescaler divides the bus clock to achieve a timer tick rate matching the PWM period requirements. + +![ERROR](../assets/6_set_prescaler.png) + +2. **Start the timer in initialization code.** + + * *Explanation*: The CTIMER counter must be running for PWM outputs to be generated. Check “Start the timer in initialization code” so the timer starts automatically during peripherals initialization—no manual CTIMER_StartTimer(...) call needed. +![ERROR](../assets/9_start_timer.png) + +3. Enter the **PWM Frequency** for the selected CTIMER channel. +![ERROR](../assets/7_set_pwm_freq.png) + + +--- + +## 🔹 Step 5: Add and Configure PWM Channels + +1. In the **PWM Channels** section, click **+** to add a channel. +2. Choose a channel number (1‒n, avoid channel 0) and set the **Default Duty Cycle** (applied at initialization before runtime updates). +![ERROR](../assets/8_add_pwm_channels.png) + +--- + +## 🔹 Step 6: Route the PWM Pin + +* **Quick-Fix Method**: In the **Problems** view, right-click the PWM pin assignment error and accept the suggested route. +![ERROR](../assets/10_route_quick_fix.png) + +* **Pins Perspective Method**: Switch to **Pins**, search for `ctimer:match`, enable the pin, and set **Direction** to **Output** (Routing Details - bottom section). +![ERROR](../assets/11_route_pin_tool.png) + +> **Tip**: Verify the routed pin is available on a board header by consulting the FRDM–MCXN947 schematic. + +--- + +## 🔹 Step 7: Generate Code + +* After completing configuration, click **Update Code** to regenerate driver initialization based on your configuration. +![ERROR](../assets/12_update_code.png) + +--- + +## 🔹 Step 8: Using PWM in Application Code + +Call the generated driver function to update duty cycle at runtime: + +```c +CTIMER_UpdatePwmDutycycle( + CTIMER_PERIPHERAL, // e.g., CTIMER1_PERIPHERAL + CTIMER_PWM_PERIOD_CH, // the period channel defined in config + CTIMER_PWM__CHANNEL, // the channel index + dutyPercent // new duty cycle in percent (integer) +); +``` + +--- + +## ⚙️ Advanced: Using Match Registers for Precise Duty Control + +When you need more precise control—for example, fractional duty cycles for servos or fine-grained LED brightness—you can calculate and write directly to the timer's match registers. + + +```c +uint32_t periodTicks = CTIMER_PERIPHERAL->MR[CTIMER_PWM_PERIOD_CH]; +uint32_t pulseTicks = (uint32_t)((periodTicks * dutyPercent) / 100.0); +CTIMER_PERIPHERAL->MR[] = pulseTicks; +``` + +### Explanation of Ticks and Duty Translation + +* **`periodTicks`**: Total number of timer ticks for one full PWM period. It is read from the match register `MR[CTIMER_PWM_PERIOD_CH]` which defines the period channel. +* **Timer Tick Duration**: With a bus clock of, say, 48 MHz and a prescaler value `P`, each tick occurs every `P / 48 000 000` seconds. +* **`dutyPercent`**: Desired duty cycle as a percentage (0–100). +* **Calculating `pulseTicks`**: + + 1. Multiply `periodTicks` by `dutyPercent / 100.0` to get the fractional portion of the period. + 2. Cast to `uint32_t` to obtain an integer tick count. +* **Writing to `MR[channelIndex]`**: Setting this register tells the timer when (in ticks) to toggle the PWM output from high to low, achieving the specified duty cycle. + + +This method translates your percentage-based duty into concrete timer ticks, leveraging the full resolution of the CTIMER peripheral for precise PWM control. + +--- + +# 🎉 Congratulations! + +You have successfully configured and generated PWM signals on the FRDM–MCXN947 board using the CTIMER peripheral. Explore varying frequencies, multiple channels, and advanced timer features to build complex control applications. diff --git a/docs/autonomous_cars/2.programming/assets/10_route_quick_fix.png b/docs/autonomous_cars/2.programming/assets/10_route_quick_fix.png new file mode 100644 index 0000000..d36f498 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/10_route_quick_fix.png differ diff --git a/docs/autonomous_cars/2.programming/assets/11_route_pin_tool.png b/docs/autonomous_cars/2.programming/assets/11_route_pin_tool.png new file mode 100644 index 0000000..2d6bacd Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/11_route_pin_tool.png differ diff --git a/docs/autonomous_cars/2.programming/assets/12_update_code.png b/docs/autonomous_cars/2.programming/assets/12_update_code.png new file mode 100644 index 0000000..cdc6b9d Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/12_update_code.png differ diff --git a/docs/autonomous_cars/2.programming/assets/1_peripheral_drivers.png b/docs/autonomous_cars/2.programming/assets/1_peripheral_drivers.png new file mode 100644 index 0000000..c955dc2 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/1_peripheral_drivers.png differ diff --git a/docs/autonomous_cars/2.programming/assets/2_add_ctimer.png b/docs/autonomous_cars/2.programming/assets/2_add_ctimer.png new file mode 100644 index 0000000..983d04a Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/2_add_ctimer.png differ diff --git a/docs/autonomous_cars/2.programming/assets/3_select_ctimer.png b/docs/autonomous_cars/2.programming/assets/3_select_ctimer.png new file mode 100644 index 0000000..9017d58 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/3_select_ctimer.png differ diff --git a/docs/autonomous_cars/2.programming/assets/4_mode_pwm.png b/docs/autonomous_cars/2.programming/assets/4_mode_pwm.png new file mode 100644 index 0000000..a2cdee3 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/4_mode_pwm.png differ diff --git a/docs/autonomous_cars/2.programming/assets/5_clock_enable.png b/docs/autonomous_cars/2.programming/assets/5_clock_enable.png new file mode 100644 index 0000000..90c0408 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/5_clock_enable.png differ diff --git a/docs/autonomous_cars/2.programming/assets/6_set_prescaler.png b/docs/autonomous_cars/2.programming/assets/6_set_prescaler.png new file mode 100644 index 0000000..6e5a4ea Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/6_set_prescaler.png differ diff --git a/docs/autonomous_cars/2.programming/assets/7_set_pwm_freq.png b/docs/autonomous_cars/2.programming/assets/7_set_pwm_freq.png new file mode 100644 index 0000000..9318f7b Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/7_set_pwm_freq.png differ diff --git a/docs/autonomous_cars/2.programming/assets/8_add_pwm_channels.png b/docs/autonomous_cars/2.programming/assets/8_add_pwm_channels.png new file mode 100644 index 0000000..c9625ce Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/8_add_pwm_channels.png differ diff --git a/docs/autonomous_cars/2.programming/assets/9_start_timer.png b/docs/autonomous_cars/2.programming/assets/9_start_timer.png new file mode 100644 index 0000000..a3258da Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/9_start_timer.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-1.png b/docs/autonomous_cars/2.programming/assets/image-1.png new file mode 100644 index 0000000..3db409b Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-1.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-10.png b/docs/autonomous_cars/2.programming/assets/image-10.png new file mode 100644 index 0000000..17dc704 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-10.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-11.png b/docs/autonomous_cars/2.programming/assets/image-11.png new file mode 100644 index 0000000..31fe788 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-11.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-12.png b/docs/autonomous_cars/2.programming/assets/image-12.png new file mode 100644 index 0000000..aa47d36 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-12.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-13.png b/docs/autonomous_cars/2.programming/assets/image-13.png new file mode 100644 index 0000000..32c715a Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-13.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-14.png b/docs/autonomous_cars/2.programming/assets/image-14.png new file mode 100644 index 0000000..e5cae30 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-14.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-15.png b/docs/autonomous_cars/2.programming/assets/image-15.png new file mode 100644 index 0000000..9b95692 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-15.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-16.png b/docs/autonomous_cars/2.programming/assets/image-16.png new file mode 100644 index 0000000..f32f0b5 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-16.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-17.png b/docs/autonomous_cars/2.programming/assets/image-17.png new file mode 100644 index 0000000..1c3d5da Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-17.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-18.png b/docs/autonomous_cars/2.programming/assets/image-18.png new file mode 100644 index 0000000..5754782 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-18.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-19.png b/docs/autonomous_cars/2.programming/assets/image-19.png new file mode 100644 index 0000000..4ed7f48 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-19.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-2.png b/docs/autonomous_cars/2.programming/assets/image-2.png new file mode 100644 index 0000000..7d8634e Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-2.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-20.png b/docs/autonomous_cars/2.programming/assets/image-20.png new file mode 100644 index 0000000..13b7239 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-20.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-21.png b/docs/autonomous_cars/2.programming/assets/image-21.png new file mode 100644 index 0000000..25b2087 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-21.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-22.png b/docs/autonomous_cars/2.programming/assets/image-22.png new file mode 100644 index 0000000..14911fe Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-22.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-23.png b/docs/autonomous_cars/2.programming/assets/image-23.png new file mode 100644 index 0000000..b1502cc Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-23.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-24.png b/docs/autonomous_cars/2.programming/assets/image-24.png new file mode 100644 index 0000000..5b43b4c Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-24.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-25.png b/docs/autonomous_cars/2.programming/assets/image-25.png new file mode 100644 index 0000000..43b7a3b Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-25.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-26.png b/docs/autonomous_cars/2.programming/assets/image-26.png new file mode 100644 index 0000000..fe087dc Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-26.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-27.png b/docs/autonomous_cars/2.programming/assets/image-27.png new file mode 100644 index 0000000..63f2ea3 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-27.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-28.png b/docs/autonomous_cars/2.programming/assets/image-28.png new file mode 100644 index 0000000..1762663 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-28.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-29.png b/docs/autonomous_cars/2.programming/assets/image-29.png new file mode 100644 index 0000000..2e3fa7a Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-29.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-3.png b/docs/autonomous_cars/2.programming/assets/image-3.png new file mode 100644 index 0000000..6ff82c0 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-3.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-30.png b/docs/autonomous_cars/2.programming/assets/image-30.png new file mode 100644 index 0000000..bf45241 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-30.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-31.png b/docs/autonomous_cars/2.programming/assets/image-31.png new file mode 100644 index 0000000..ec0d633 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-31.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-32.png b/docs/autonomous_cars/2.programming/assets/image-32.png new file mode 100644 index 0000000..b27fb5e Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-32.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-33.png b/docs/autonomous_cars/2.programming/assets/image-33.png new file mode 100644 index 0000000..30ebb87 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-33.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-34.png b/docs/autonomous_cars/2.programming/assets/image-34.png new file mode 100644 index 0000000..8210291 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-34.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-35.png b/docs/autonomous_cars/2.programming/assets/image-35.png new file mode 100644 index 0000000..70d5f2e Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-35.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-36.png b/docs/autonomous_cars/2.programming/assets/image-36.png new file mode 100644 index 0000000..506a6aa Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-36.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-4.png b/docs/autonomous_cars/2.programming/assets/image-4.png new file mode 100644 index 0000000..0ba30a2 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-4.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-5.png b/docs/autonomous_cars/2.programming/assets/image-5.png new file mode 100644 index 0000000..388936a Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-5.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-6.png b/docs/autonomous_cars/2.programming/assets/image-6.png new file mode 100644 index 0000000..fbc0c93 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-6.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-7.png b/docs/autonomous_cars/2.programming/assets/image-7.png new file mode 100644 index 0000000..1f0cb8d Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-7.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-8.png b/docs/autonomous_cars/2.programming/assets/image-8.png new file mode 100644 index 0000000..4642e99 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-8.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image-9.png b/docs/autonomous_cars/2.programming/assets/image-9.png new file mode 100644 index 0000000..ef51076 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image-9.png differ diff --git a/docs/autonomous_cars/2.programming/assets/image.png b/docs/autonomous_cars/2.programming/assets/image.png new file mode 100644 index 0000000..1697763 Binary files /dev/null and b/docs/autonomous_cars/2.programming/assets/image.png differ diff --git a/docs/autonomous_cars/2.programming/index.md b/docs/autonomous_cars/2.programming/index.md new file mode 100644 index 0000000..76fa1a8 --- /dev/null +++ b/docs/autonomous_cars/2.programming/index.md @@ -0,0 +1,7 @@ +--- +title: Programming +--- + +## General description +In this section, programming concepts needed to build the project are covered. + diff --git a/docs/autonomous_cars/image-1.png b/docs/autonomous_cars/image-1.png new file mode 100644 index 0000000..a1e1fe1 Binary files /dev/null and b/docs/autonomous_cars/image-1.png differ diff --git a/docs/autonomous_cars/image.png b/docs/autonomous_cars/image.png new file mode 100644 index 0000000..c314e31 Binary files /dev/null and b/docs/autonomous_cars/image.png differ diff --git a/docs/autonomous_cars/index.md b/docs/autonomous_cars/index.md index b382a27..3c75522 100644 --- a/docs/autonomous_cars/index.md +++ b/docs/autonomous_cars/index.md @@ -1,3 +1,37 @@ -# Intorduction +--- +sidebar_position: 6 +title: Autonomous Cars +--- +# Autonomous Cars Course +### Course team: +- Cristian Pătru cristian.patru@nxp.com +- Teodor Dicu teodor.dicu@wyliodrin.com +- Cristina Grosu cristina.grosu@nxp.com +- Sebastian Matei sebastian.matei@nxp.com +- Cezar Băluță cezar.baluta@nxp.com + +
+![alt text](image-1.png) +
+ +This hands-on, interdisciplinary course aims to guide participants in building their own autonomous vehicle, capable of following a line-marked path. During this course, students gain skills in: 3D design for custom parts, hardware assembly and soldering, basic electronics and microcontrollers, embedded programming and control algorithms for navigation. + +The final part of the course consists of a timed competition where teams test their vehicles on a designated track. + +The course has a duration of 8 days during which the students have a chance of developing skills and sharing experiences. + +The course takes inspiration from the [NXP Cup Competition](https://nxp.gitbook.io/nxp-cup). + +# NXP Cup: An Autonomous Vehicle Challenge + +
+![alt text](image.png) +
+ +The NXP Cup is a hands-on autonomous car competition designed to give students a unique opportunity to explore the world of self-driving vehicles. Participants work with small, affordable model cars equipped with real NXP automotive components, similar to those used in actual vehicles on the road today. + +Just like a full-scale autonomous vehicle, your car will be able to sense, think, and act. Using a camera sensor integrated with a motor control system, the vehicle detects its surroundings and navigates the race track entirely on its own. + +The entry kit is budget friendly and includes everything you need to get started. All that’s required is a basic understanding of embedded software programming and electronics, and a strong desire to learn and innovate.