Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

MCU Delta Sinewave Modulator and LPF Demodulator

Go down  Message [Page 1 of 1]

KerimF

KerimF

Hi,

In this project, the code (written in AVR8 assembly) is rather a complex one (DSS_08_08.zip).
It generates sine waves by using delta modulation (Delta Sinewave Synthesis, DSS).
The advantage of this technique is that its hardware could be made simple (the reverse situation of Direct Digital Synthesis, DDS).
One MCU pin outputs a delta bit stream which, by using a simple RC filter, a sinewave is generated at its output.
The frequency is determined by the number of bits per cycle and the delta clock frequency (bit rate).
In this project, the lowest number of bits is chosen to be 96 and the highest 3088 bits.

MCU Delta Sinewave Modulator and LPF Demodulator Dss_0812

Here, the MCU is ATmega32 running at 8 MHz.
With a bit rate of 2 MHz, frequencies between 20,833 Hz and 648.7 Hz are generated (there are 485 frequencies on their list).
And with a bit rate of 62,500 Hz (2MHz/32), the generated frequencies are between 651 Hz and 20.24 Hz (also 485 frequencies on their list).

These 970 frequencies have indexes from 0 to 969 (their complete list is attached below).
When the MCU gets a frequency index (by setting it before running the debugger, or perhaps via TWI, for example, on a real board), it generates internally the table (in SRAM) of the delta bit stream of the new requested frequency before it outputs it to the RC LPF.

Since I had to use only old versions of AVR Studio, LTspice and Excel (the only tools which I have the privilege to use in my designs lately) SimulIDE, version SimulIDE_1.0.1-R1386_Win32.exe, helped me discover/fix many bugs which were difficult to find/locate by AVR Studio.

Regards,
Kerim

Note: this code and sim1 are tested using SimulIDE_1.0.1-R1386_Win32.exe, I am not sure about other versions.
Attachments
MCU Delta Sinewave Modulator and LPF Demodulator AttachmentDSS_frequencies.txt
You don't have permission to download attachments.
(27 Kb) Downloaded 6 times
MCU Delta Sinewave Modulator and LPF Demodulator AttachmentDSS_08_08.zip
You don't have permission to download attachments.
(17 Kb) Downloaded 8 times

KerimF

KerimF

There is more to say and do about DSS.

The crucial parameter in the basic delta modulation is the delta step (besides the delta clock rate).

In the attached code above, the positive delta step is a 16-bit register and called dvFd_p (high and low, dvFd_pH and dvFd_pL). Its negative value is dvFd_n (also high and low, dvFd_nH\L).

The delta step affects mainly the amplitude of the generated sinewave and its level of distortion (THD).
But to test/debug that the code generates sinewaves, I simply applied the approximated formula (found empirically):
dvFd_p = 151231 / bits

The next step in this project is to find out the delta step that satisfies a certain criterion. For a practical project, the criterion could be to get the same amplitude for all frequencies.

In every synthesis technique, a sort of buffer is added for the generated signal. An active 3rd-order LPF of Sallen&Key could be used to work as a buffer besides being a filter (I will use the opamps of LM324 or LM358). And if a comparator (actually an opamp) will be added at the LPF output and the amplitude reaches a certain level (set by a reference voltage), the DSS loop could be interrupted and the dvFd_p (the delta step) will be saved for the generated frequency. It will likely be saved in the internal EEPROM (actually, only its 8-bit difference since the EEPROM size is 1K). This is repeated for all 970 frequencies.

The good news is that dvFd_p (for the same amplitude) decreases when the frequency decreases. So, by starting from the frequency of index 0 (highest frequency) down to the frequency of index 969 (lowest frequency), the value of dvFd_p (the delta step) also decreases from a certain high value down to its last one. This reduces greatly the number of iterations.

I will update this thread when I finish this step.

Meanwhile, I welcome any comment or remark (positive or negative) and any question as well.

Regards,
Kerim

I will try to see if this project could also be simulated and debugged by the newest version.

KerimF

KerimF

I tested the code above using ‘SimulIDE-R1657_Win32.exe’.

For index=0, the displayed 20.83 KHz sinewave was stable.
For index=484, the displayed 647.7 Hz sinewave became unstable.
Sorry, I didn’t continue the test for other indexes.

Since I still have 'SimulIDE_1.0.1-R1386_Win32.exe', this is not urgent.

Just in case, I also attached its hex and lst files.
Attachments
MCU Delta Sinewave Modulator and LPF Demodulator AttachmentDSS_08_08.zip
You don't have permission to download attachments.
(43 Kb) Downloaded 5 times

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum