This shows you the differences between two versions of the page.
pm:prj2025:eradu:alexandru.sima1512 [2025/05/29 23:10] alexandru.sima1512 [Encountered challenges] |
pm:prj2025:eradu:alexandru.sima1512 [2025/05/30 09:49] (current) alexandru.sima1512 [Flow] |
||
---|---|---|---|
Line 4: | Line 4: | ||
===== Useful links ===== | ===== Useful links ===== | ||
+ | <note tip> | ||
* Short demo: [[https://youtube.com/shorts/3NDd_IlYnws?feature=share]] | * Short demo: [[https://youtube.com/shorts/3NDd_IlYnws?feature=share]] | ||
* Code repository: [[https://github.com/alx-sima/car-modulator]] | * Code repository: [[https://github.com/alx-sima/car-modulator]] | ||
+ | </note> | ||
===== Introduction ===== | ===== Introduction ===== | ||
Line 15: | Line 16: | ||
===== General description ===== | ===== General description ===== | ||
- | {{:pm:prj2025:eradu:block_diagram_asima.png?200|}} | + | {{ :pm:prj2025:eradu:alexandru.sima1512:diagram.png?700 |}} |
===== Hardware Design ===== | ===== Hardware Design ===== | ||
+ | {{ :pm:prj2025:eradu:alexandru.sima1512:schematic.png?800 |}} | ||
- | {{:pm:prj2025:eradu:schematic_as.png?200|}} | + | ==== List of components ==== |
- | + | ||
- | List of components: | + | |
* Arduino UNO R3 | * Arduino UNO R3 | ||
* Breadboard + dupont wires | * Breadboard + dupont wires | ||
Line 28: | Line 27: | ||
* MH-M28 BLE stereo receiver | * MH-M28 BLE stereo receiver | ||
* LCD 1602 (I2C) | * LCD 1602 (I2C) | ||
+ | * SD card reader | ||
* Push button | * Push button | ||
* 10K potentiometer | * 10K potentiometer | ||
- | * 1K resistor | + | * 2 1K resistors |
- | Pin connections: | + | ==== Pin connections ==== |
* KT0803K: | * KT0803K: | ||
- | * VCC - 5V (Arduino) | + | * VCC - 5V |
- | * GND - GND (Arduino) | + | * GND - GND |
* SDA - PC4 (Arduino) | * SDA - PC4 (Arduino) | ||
* SCL - PC5 (Arduino) | * SCL - PC5 (Arduino) | ||
* 3.5mm Jack - 3.5mm Jack (KT0803K) | * 3.5mm Jack - 3.5mm Jack (KT0803K) | ||
* MH-M28: | * MH-M28: | ||
- | * VCC - 5V (Arduino) | + | * VCC - 5V |
- | * GND - GND (Arduino) | + | * GND - GND |
+ | * R (stereo sound was too resource intensive) - PB1 (Arduino) | ||
* LCD 1602: | * LCD 1602: | ||
- | * VCC - 5V (Arduino) | + | * VCC - 5V |
- | * GND - GND (Arduino) | + | * GND - GND |
* SDA - PC4 (Arduino) | * SDA - PC4 (Arduino) | ||
* SCL - PC5 (Arduino) | * SCL - PC5 (Arduino) | ||
+ | * SD card reader: | ||
+ | * 5V - 5V | ||
+ | * GND - GND | ||
+ | * SCK - PB5 | ||
+ | * MISO - PB4 | ||
+ | * MOSI - PB3 | ||
+ | * CS - PB2 | ||
* Push button: | * Push button: | ||
* Vin - PD2 (Arduino) | * Vin - PD2 (Arduino) | ||
* GND - GND (Arduino) | * GND - GND (Arduino) | ||
* Voltage divider (1K resistor + 10K potentiometer) | * Voltage divider (1K resistor + 10K potentiometer) | ||
- | * Vin (resistor) - 5V (Arduino) | + | * Vin (resistor) - 5V |
* Vout (between resistor and potentiometer) - PC3 (Arduino) | * Vout (between resistor and potentiometer) - PC3 (Arduino) | ||
- | * GND - GND (Arduino) | + | * GND - GND |
===== Software Design ===== | ===== Software Design ===== | ||
- | External libraries used: | + | ==== External libraries used ==== |
* //[[https://registry.platformio.org/libraries/marcoschwartz/LiquidCrystal_I2C|marcoschwartz/LiquidCrystal_I2C]]// for easier interaction with the LCD. | * //[[https://registry.platformio.org/libraries/marcoschwartz/LiquidCrystal_I2C|marcoschwartz/LiquidCrystal_I2C]]// for easier interaction with the LCD. | ||
+ | * //[[https://registry.platformio.org/libraries/arduino-libraries/SD|arduino-libraries/SD]]// for reading data from SD cards. | ||
+ | * //[[https://registry.platformio.org/libraries/nrf24/PCM|nrf24/PCM]]// for playing ''.wav'' audio files. | ||
* //FMTX// for controlling the FM transmitter. Copy included in the //lib/// folder. | * //FMTX// for controlling the FM transmitter. Copy included in the //lib/// folder. | ||
- | Lab concepts used: | + | ==== Lab concepts used ==== |
* Lab 0 - GPIO | * Lab 0 - GPIO | ||
* Lab 2 - Interrupts | * Lab 2 - Interrupts | ||
* Lab 4 - ADC | * Lab 4 - ADC | ||
+ | |||
+ | Lab concepts abstracted away by libraries: | ||
+ | * Lab 3 - Timers + PWM | ||
+ | * Lab 5 - SPI | ||
* Lab 6 - I2C | * Lab 6 - I2C | ||
- | Arduino GPIO configuration: | + | ==== Arduino GPIO configuration ==== |
* PC3 - input (for ADC) | * PC3 - input (for ADC) | ||
* PD2 - input & pull-up (for button) | * PD2 - input & pull-up (for button) | ||
+ | * PD3 - output (Bluetooth receiver power) | ||
==== Flow ==== | ==== Flow ==== | ||
- | **Synopsis**: A button is pressed to toggle the frequency selection. While in frequency selection mode, the //ADC// is continuously running and reading values from a voltage divider containing a potentiometer (knob), while the LCD is displaying the current selected value (read from the //ADC// on interrupts) and the transmitter is playing on the previous established frequency. While not selecting, the //ADC// is turned off in order to save energy, and the transmitter is playing on the established frequency (selected when the mode changes), while the LCD displays it. | + | **Synopsis**: A button is pressed to toggle the frequency selection, or held (>1s) to switch between playing audio from Bluetooth or the SD card. While in frequency selection mode, the //ADC// is continuously running and reading values from a voltage divider containing a potentiometer (knob), while the LCD is displaying the current selected value (read from the //ADC// on interrupts) and the transmitter is playing on the previous established frequency. While not selecting, the //ADC// is turned off in order to save energy, and the transmitter is playing on the established frequency (selected when the mode changes), while the LCD displays it. While playing audio from the SD card, the power supply is cut from the Bluetooth receiver, and ''wav'' files are played, in order, from the disk. A press of the button skips to the next song. |
On setup, several registers are configured: | On setup, several registers are configured: | ||
Line 88: | Line 103: | ||
===== Results ===== | ===== Results ===== | ||
- | + | * The modulator manages to emit audio on the selected frequency at a reasonable quality. | |
- | ===== Encountered challenges ===== | + | * Its range is about 10 meters, but it can be extended via an antenna (a simple wire will suffice). However, this is not usually desired as we do not want to interfere with others' radios. |
+ | * Audio played from a SD card is very noisy (because it is reconstructed using PWM). A low-pass filter or a dedicated DAC would have improved the quality. | ||
+ | ===== Challenges ===== | ||
The initial plan was to use [[https://www.adafruit.com/product/1958|Adafruit Si4713]] as an FM transmitter. It was a circuit with more advanced capabilities (such as broadcasting text info about the radio "station"), and more (>0) documentation on the Internet. The order came late from China, and, to make matters worse, the chip was broken (wasn't even responding to a I2C address sweep). I couldn't find any replacement of the same model. | The initial plan was to use [[https://www.adafruit.com/product/1958|Adafruit Si4713]] as an FM transmitter. It was a circuit with more advanced capabilities (such as broadcasting text info about the radio "station"), and more (>0) documentation on the Internet. The order came late from China, and, to make matters worse, the chip was broken (wasn't even responding to a I2C address sweep). I couldn't find any replacement of the same model. | ||
Line 97: | Line 114: | ||
</note> | </note> | ||
- | The replacement, **KT0803K** has almost no documentation online, the retailer, [[https://www.elechouse.com/]], doesn't even list the product on their website and the only provided demo code didn't work with an **ESP32** (the initial microcontroller choice). More so, it accepts input only as //3.5mm jack//, so I had to buy a compatible Bluetooth receiver. | + | The replacement, **KT0803K** has almost no documentation online, the retailer, [[https://www.elechouse.com/|ElecHouse]], doesn't even list the product on their website and the only provided demo code didn't work with an **ESP32** (the initial microcontroller choice). More so, it accepts input only as //3.5mm jack//, so I had to buy a compatible Bluetooth receiver (**MH-M28**). |
Finally, SD card readers were very hard to find, as all customary sellers have gone out of stock. I managed to get one, but a new challenge arose: how to connect a //GPIO// pad audio output to a jack input? The answer was the Bluetooth receiver: it has both jack and pads output (connected to eachother), so I could drive the audio signal from the pads straight to the jack. | Finally, SD card readers were very hard to find, as all customary sellers have gone out of stock. I managed to get one, but a new challenge arose: how to connect a //GPIO// pad audio output to a jack input? The answer was the Bluetooth receiver: it has both jack and pads output (connected to eachother), so I could drive the audio signal from the pads straight to the jack. | ||