uranyumx
Advanced Member level 4
Hello,
On my circuit, there is an external 12-bit DAC. I want to modulate the DAC output with a sine wave. So I generate a sine wave with a lookup table. I set maximum value as 1575 (equals to 1.92 V) because the DAC output is amplified 2 times with another circuit. Because of the 5V compliance voltage. I set this value.
I set the external DAC value with this code. But the modulated maximum amplitude of the signals is not matching with non-modulated signal amplitude. The maximum value of the amplitude modulated signal is every time 0.5V. Do you have any suggestion about the problem? The below code is running in the TIM callback function.
On my circuit, there is an external 12-bit DAC. I want to modulate the DAC output with a sine wave. So I generate a sine wave with a lookup table. I set maximum value as 1575 (equals to 1.92 V) because the DAC output is amplified 2 times with another circuit. Because of the 5V compliance voltage. I set this value.
Code:
const uint16_t Wave_LUT_100_Per_Modulation[NS] = {788, 826, 865, 904, 942, 980, 1018, 1055, 1091, 1127, 1161, 1195, 1228, 1260, 1290,
1320, 1348, 1374, 1400, 1423, 1446, 1466, 1485, 1502, 1518, 1531, 1543, 1553, 1561, 1568,
1572, 1574, 1575, 1573, 1570, 1565, 1558, 1549, 1538, 1525, 1510, 1494, 1476, 1456, 1435,
1412, 1387, 1361, 1334, 1305, 1275, 1244, 1212, 1178, 1144, 1109, 1073, 1036, 999, 961,
923, 885, 846, 807, 768, 729, 690, 652, 614, 576, 539, 502, 466, 431, 397,
363, 331, 300, 270, 241, 214, 188, 163, 140, 119, 99, 81, 65, 50, 37,
26, 17, 10, 5, 2, 0, 1, 3, 7, 14, 22, 32, 44, 57, 73,
90, 109, 129, 152, 175, 201, 227, 255, 285, 315, 347, 380, 414, 448, 484,
[CODE]520, 557, 595, 633, 671, 710, 749, 787};
I set the external DAC value with this code. But the modulated maximum amplitude of the signals is not matching with non-modulated signal amplitude. The maximum value of the amplitude modulated signal is every time 0.5V. Do you have any suggestion about the problem? The below code is running in the TIM callback function.
Code:
Divison_Table[z] = round((102.4-(102.4*1)) + (1*round((Wave_LUT_100_Per_Modulation[z]/(1575/102.4)))));
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_RESET);
DACA_Buf = DAC_A_Write << 12 | Divison_Table[z];
HAL_SPI_Transmit(&hspi2,(uint8_t*)&DACA_Buf,2,100);
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_RESET);
DACB_Buf = DAC_B_Write << 12 | Divison_Table[z];
HAL_SPI_Transmit(&hspi2,(uint8_t*)&DACB_Buf,2,100);
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_SET);
z++;
if (z>=127)z=0; }
Last edited by a moderator: