A Python implementation of Code Division Multiple Access (CDMA) communication system using Walsh codes for orthogonal signal separation.
This project demonstrates how CDMA technology works by implementing a simulation where multiple stations can transmit data simultaneously over the same channel. The system uses Walsh codes (Hadamard codes) to ensure orthogonal separation between different transmitters, allowing for interference-free communication.
- Walsh Code Generation: Generates orthogonal Walsh codes of order 3 (8x8 matrix)
- Multi-Station Transmission: Supports 8 simultaneous transmitters
- Signal Encoding: Encodes data bits using station-specific Walsh codes
- Channel Simulation: Combines all signals into a single resultant channel
- Signal Decoding: Recovers original data from any specific station
- Interactive Interface: User-friendly input system for data bits and station selection
- Walsh Code Generation: Creates an 8x8 Walsh matrix using recursive Hadamard construction
- Data Input: Each of the 8 stations inputs a data bit (0 or 1)
- Signal Encoding: Each station's data bit is multiplied by its unique Walsh code
- Channel Combination: All encoded signals are summed to create the resultant channel
- Station Selection: User selects which station to decode
- Signal Decoding: Uses inner product with the selected station's Walsh code to recover the original data
main.py
: Improved main implementation with object-oriented design and input validationcdma_advanced.py
: Advanced version with visualization, noise simulation, and analysis featurestest_cdma.py
: Test suite to verify functionality and demonstrate improvementslogo_CDMA.py
: ASCII art logo for the applicationrequirements.txt
: Python package dependenciesREADME.md
: This documentation file
- Python 3.7+
- NumPy (for mathematical operations)
- Matplotlib (for advanced visualization features, optional)
- Clone the repository:
git clone https://github.com/Navid-Rahman/CDMA-Implementation.git
cd CDMA-Implementation
- Install required dependencies:
pip install -r requirements.txt
Or install individually:
pip install numpy matplotlib
Run the improved main program:
python main.py
Run the advanced version with additional features:
python cdma_advanced.py
Choose from:
- Basic CDMA Simulation - Interactive version with input validation
- Advanced Analysis - Includes orthogonality checking and batch decoding
- Noise Simulation - Tests system performance with channel noise
- Visualization Mode - Visual representation of Walsh codes (requires matplotlib)
Run the test suite to verify functionality:
python test_cdma.py
This will test:
- Walsh code generation and orthogonality
- Encoding and decoding processes
- Error handling capabilities
The codebase has been significantly improved with the following enhancements:
- Class-based architecture:
CDMASystem
class encapsulates all CDMA functionality - Modular functions: Each operation is separated into logical methods
- Reusable code: Easy to extend and modify for different configurations
- Robust input validation: Ensures only valid data bits (0 or 1) are accepted
- Error handling: Graceful handling of invalid inputs and exceptions
- User-friendly prompts: Clear instructions and error messages
- Visualization: Graphical representation of Walsh code matrix
- Orthogonality analysis: Mathematical verification of code properties
- Noise simulation: Testing system robustness against channel noise
- Batch processing: Simultaneous decoding of all stations
- Performance metrics: Bit Error Rate (BER) calculation
- Documentation: Comprehensive docstrings and comments
- Type hints: Better code readability and IDE support
- Clean structure: Elimination of repetitive code
- Efficient algorithms: Optimized Walsh code generation
- Professional formatting: Following Python best practices
Enter D1 for Station 1: 1
Enter D2 for Station 2: 0
Enter D3 for Station 3: 1
...
Enter the station to listen for C1=1 ,C2=2, C3=3, C4=4, C5=5, C6=6, C7=7, C8=8 : 1
Data bit that was sent: 1.0
Walsh codes are binary sequences that are mutually orthogonal, meaning their inner product is zero. This orthogonality property ensures that:
- Multiple signals can be transmitted simultaneously without interference
- Each signal can be perfectly recovered using its corresponding Walsh code
- The system is robust against noise and interference
This project is open source and available under the MIT License.
Navid Rahman
Feel free to fork this project and submit pull requests for any improvements!