Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

VW CD Changer Emulator

An AVR firmware project that emulates a Volkswagen CD changer. This project allows you to control multimedia playback in VW vehicles through IR remote control and SPI communication protocols.

Project Overview

This repository contains the firmware, XCode project configuration, and PCB designs for a CD changer emulator that integrates with Volkswagen infotainment systems. The system supports:

  • NEC IR Protocol: Receives remote control commands from car radios
  • VW SPI-like Protocol: Communicates with the car's infotainment system
  • Bluetooth Audio: Integration with OVC3860 Bluetooth module
  • Multi-disc Support: Emulates up to 6 CD discs with 99 tracks each

Repository Structure

cd-changer-emulator/
├── platformio/                      # PlatformIO build (RECOMMENDED)
│   ├── platformio.ini               # PlatformIO configuration
│   ├── README.md                    # PlatformIO-specific docs
│   ├── src/                         # Source files
│   │   ├── main.c
│   │   ├── *.c *.h                  # All firmware source files
│   │   └── ...
│   └── .pio/                        # Build artifacts (auto-generated)
├── vwcdc-firmware/                  # Original firmware source (legacy)
│   ├── VWCDC/                       # Main firmware implementation
│   │   ├── main.c                   # Main entry point
│   │   ├── Makefile                 # Traditional AVR build (deprecated)
│   │   ├── VWCDC_protocol.c/h       # VW CD changer protocol
│   │   ├── NEC_protocol.h           # IR remote protocol (NEC)
│   │   ├── SPI_protocol.c/h         # SPI communication protocol
│   │   ├── USART_protocol.c/h       # USART serial protocol
│   │   ├── OVC3860_library.c/h      # Bluetooth module library
│   │   ├── timer.c/h                # Timer interrupt handlers
│   │   ├── counter.c/h              # Counter utilities
│   │   └── ASCII_table.h            # ASCII character definitions
│   ├── VWCDC.xcodeproj/             # XCode project configuration
│   └── README.md                    # Firmware-specific documentation
├── vwcdc-pcb/                       # PCB design files
│   └── [Various PCB versions]       # Different hardware configurations
├── PLATFORMIO_MIGRATION.md          # Migration guide from Makefile
└── README.md                        # This file

Hardware Requirements

  • Microcontroller: ATmega8 (7.3728 MHz external crystal)
  • Programmer: USBasp programmer (or compatible AVR programmer)
  • Bluetooth Module: OVC3860 (optional)
  • Other: IR receiver, SPI interface components

Prerequisites

macOS Setup

  1. Crosspack for AVR: Complete AVR development environment

    # Download and install from https://www.obdev.at/products/crosspack/index.html
  2. X-AVR: XCode integration for AVR development

    # Clone and install from https://github.com/jawher/xavr
  3. AVR GCC Tools: Typically installed with Crosspack

    • avr-gcc
    • avr-libc
    • avrdude

Verify Installation

# Check if AVR tools are available
avr-gcc --version
avr-libc --version
avrdude -v

Building the Project

Using PlatformIO (Recommended)

PlatformIO is a modern, cross-platform build system that simplifies AVR development.

# Install PlatformIO CLI
pip install platformio

# Build
cd platformio
pio run

# Build and upload to device
pio run -t upload

# Monitor serial output
pio device monitor -b 57600

For detailed instructions, see PLATFORMIO_MIGRATION.md.

From Command Line (Traditional Makefile)

Navigate to the firmware directory and build:

cd vwcdc-firmware/VWCDC/
make clean    # Clean previous builds
make all      # Build the project

This will generate:

  • main.hex - Hex file for programming the microcontroller
  • main.elf - ELF file for debugging

From XCode

  1. Open the project:

    open vwcdc-firmware/VWCDC.xcodeproj
  2. Select the appropriate build scheme

  3. Press Cmd + B to build

  4. Press Cmd + R to run/program the device (if connected)

Programming the Microcontroller

Using avrdude (Command Line)

cd vwcdc-firmware/VWCDC/

# Program the ATmega8
make program

# Or manually:
avrdude -c usbasp -p atmega8 -U flash:w:main.hex:i

Using XCode

  • Build the project (Cmd + B)
  • Connect the USBasp programmer to your computer and the ATmega8
  • Run the project (Cmd + R)
  • XCode will automatically program the device

Development

Project Configuration

The main build settings are located in vwcdc-firmware/VWCDC/Makefile:

  • MCU: atmega8
  • CPU Frequency: 7372800 Hz
  • Serial/SPI Baud Rate: 57600 Hz
  • Output Format: Intel HEX

Modifying the Firmware

  1. Edit source files in vwcdc-firmware/VWCDC/

  2. Key modules:

    • VWCDC_protocol.c/h: Modify CD changer behavior
    • NEC_protocol.h: Change IR remote handling
    • main.c: Add new features or protocol support
  3. Rebuild:

    make clean && make all

Adding New Features

Common modification points:

  • New IR Commands: Add to NEC_protocol.h and handle in main.c
  • Protocol Changes: Modify VWCDC_protocol.c or SPI_protocol.c
  • Bluetooth Integration: Extend OVC3860_library.c

Communication Protocols

NEC IR Protocol

Receives commands from car radio IR remotes:

#define VWCDC_ON             0x532CE41BUL
#define VWCDC_OFF            0x532C10EFUL
#define VWCDC_NEXT           0x532CF807UL
#define VWCDC_PREV           0x532C7887UL
#define VWCDC_PLAY           0x532C08F7UL
#define VWCDC_SHUFFLE        0x532C609FUL
#define VWCDC_SCAN_AUDI      0x532CA05FUL
// ... and more

VW SPI-like Protocol

Communication with the infotainment system:

  • Clock: 57600 Hz @ 7372800 Hz external crystal
  • Delay: 700µs after each byte, 50ms after each command
  • Disc Selection: 0xBE-0xB9 (CD1-CD6)
  • Mode: Play (0xFF), Shuffle (0x55), Scan (0x00)

Troubleshooting

Build Fails with "Command Not Found"

Ensure Crosspack is installed and in your PATH:

which avr-gcc

If not found, add Crosspack to your shell profile:

export PATH="/usr/local/CrossPack-AVR/bin:$PATH"

XCode Project Not Opening

Ensure you have the X-AVR plugin installed for XCode.

Device Not Programming

  1. Check USB connection and USBasp programmer
  2. Verify correct port in Makefile:
    AVRDUDE_PORT = /dev/cu.usbmodem*
  3. Test with:
    avrdude -c usbasp -p atmega8

Documentation

  • Bluetooth Module: See Bluetooth manual.pdf for OVC3860 specifications
  • Wiring Diagrams: See zapojenie.pdf for hardware connections
  • Firmware Details: See vwcdc-firmware/README.md for protocol specifics

Debugging

Enable serial output for debugging:

  1. Connect USART to a USB serial adapter

  2. Monitor output using a terminal:

    screen /dev/cu.usbserial-* 57600
  3. Add debug statements in C code using USART functions

License

This project is for personal and educational use.

Contributing

Feel free to fork, modify, and contribute improvements to this project.

References


Last Updated: 2024 Project Status: Active Development

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages