You are on page 1of 6

Hariyanto (1310125026) Selvira Rahadiningrum Ramelan (1310125027)

Praktikum V DSP dengan menggunakan ARM


Percobaan 1 (Gelombang Sinus)

List Program :
#include "stm32f4_discovery.h" #include <stdio.h> #include "arm_math.h" #define DEG2RAD

0.0174532925199432

//GPIO_InitTypeDef GPIO_InitStructure; float ts, T,delt,t; int n,ns,nh,ni; float fin,vm,ofset; float vt[2000]; /* Private function prototypes -----------------------------------------------*/ void TIM_Config(void); void ADC3_CH12_DMA_Config(void); void DAC_Config(void); int main(void) { /* ADC3 configuration *******************************************************/ /* - Enable peripheral clocks */ /* - DMA2_Stream0 channel2 configuration */ /* - Configure ADC Channel12 pin as analog input */ /* - Configure ADC3 Channel12 */ ADC3_CH12_DMA_Config(); /* Start ADC3 Software Conversion */ ADC_SoftwareStartConv(ADC3); /* TIM Configuration */ TIM_Config(); /* DAC Config */ DAC_Config(); /* GPIOD Periph clock enable */ // RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); // /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */ // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15; // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; // GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; // GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // GPIO_Init(GPIOD, &GPIO_InitStructure); if (SysTick_Config(SystemCoreClock / 1000)) { /* Capture error */ while (1); } ts = 0.001; fin = 10; vm =4000; ofset = 2000; T = 1/fin; ns = T / ts; nh =1; for (ni=0;ni<ns;ni++) {

DIGITAL SIGNAL PROCESSING (DSP)

Hariyanto (1310125026) Selvira Rahadiningrum Ramelan (1310125027)


vt[ni]=2000; } for(n=1;n<=nh;n=n+2) { for(ni=0,t=0;ni<=ns;ni++) { t=t+ts;

vt[ni]=vt[ni] + (4 * vm / n / PI) * arm_sin_f32(2 * n * PI * t / T);


} } ni=0; while (1) {

/* DAC_SetChannel1Data(DAC_Align_12b_R, ADC3ConvertedValue); */ /* convert the ADC value (from 0 to 0xFFF) to a voltage value (from 0V to 3.3V)*/ // // } } // ADC3ConvertedVoltage = ADC3ConvertedValue *3300/0xFFF; voltage = ADC3ConvertedValue *3.30/0xFFF; count++;

void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } }

Bentuk sinyal :

DIGITAL SIGNAL PROCESSING (DSP)

Hariyanto (1310125026) Selvira Rahadiningrum Ramelan (1310125027) Percobaan 2 (Gelombang Square Wave) List Program :
#include "stm32f4_discovery.h" #include <stdio.h> #include "arm_math.h" #define DEG2RAD

0.0174532925199432

//GPIO_InitTypeDef GPIO_InitStructure; float ts, T,delt,t; int n,ns,nh,ni; float fin,vm,ofset; float vt[2000]; /* Private function prototypes -----------------------------------------------*/ void TIM_Config(void); void ADC3_CH12_DMA_Config(void); void DAC_Config(void); int main(void) { /* ADC3 configuration *******************************************************/ /* - Enable peripheral clocks */ /* - DMA2_Stream0 channel2 configuration */ /* - Configure ADC Channel12 pin as analog input */ /* - Configure ADC3 Channel12 */ ADC3_CH12_DMA_Config(); /* Start ADC3 Software Conversion */ ADC_SoftwareStartConv(ADC3); /* TIM Configuration */ TIM_Config(); /* DAC Config */ DAC_Config(); /* GPIOD Periph clock enable */ // RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); // /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */ // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15; // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; // GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; // GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // GPIO_Init(GPIOD, &GPIO_InitStructure); if (SysTick_Config(SystemCoreClock / 1000)) { /* Capture error */ while (1); } ts = 0.001; fin = 10; vm =4000; ofset = 2000; T = 1/fin; ns = T / ts; nh =1000; for (ni=0;ni<ns;ni++) { vt[ni]=2000; } for(n=1;n<=nh;n=n+2) { for(ni=0,t=0;ni<=ns;ni++) { t=t+ts;

DIGITAL SIGNAL PROCESSING (DSP)

Hariyanto (1310125026) Selvira Rahadiningrum Ramelan (1310125027)


vt[ni]=vt[ni] + (4 * vm / n / PI) * arm_sin_f32(2 * n * PI * t / T); } } ni=0; while (1) {

/* DAC_SetChannel1Data(DAC_Align_12b_R, ADC3ConvertedValue); */ /* convert the ADC value (from 0 to 0xFFF) to a voltage value (from 0V to 3.3V)*/ // // } } // ADC3ConvertedVoltage = ADC3ConvertedValue *3300/0xFFF; voltage = ADC3ConvertedValue *3.30/0xFFF; count++;

void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } }

Bentuk sinyal :

DIGITAL SIGNAL PROCESSING (DSP)

Hariyanto (1310125026) Selvira Rahadiningrum Ramelan (1310125027) Percobaan 3 (sinyal segitiga)

List Program :
#include "stm32f4_discovery.h" #include <stdio.h> #include "arm_math.h" #define DEG2RAD

0.0174532925199432

//GPIO_InitTypeDef GPIO_InitStructure; float ts, T,delt,t; int n,ns,nh,ni; float fin,vm,ofset; float vt[2000]; /* Private function prototypes -----------------------------------------------*/ void TIM_Config(void); void ADC3_CH12_DMA_Config(void); void DAC_Config(void); int main(void) { /* ADC3 configuration *******************************************************/ /* - Enable peripheral clocks */ /* - DMA2_Stream0 channel2 configuration */ /* - Configure ADC Channel12 pin as analog input */ /* - Configure ADC3 Channel12 */ ADC3_CH12_DMA_Config(); /* Start ADC3 Software Conversion */ ADC_SoftwareStartConv(ADC3); /* TIM Configuration */ TIM_Config(); /* DAC Config */ DAC_Config(); /* GPIOD Periph clock enable */ // RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); // /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */ // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15; // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; // GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; // GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // GPIO_Init(GPIOD, &GPIO_InitStructure); if (SysTick_Config(SystemCoreClock / 1000)) { /* Capture error */ while (1); } ts = 0.001; fin = 10; vm =4000; ofset = 2000; T = 1/fin; ns = T / ts; nh =1000; for (ni=0;ni<ns;ni++) { vt[ni]=2000; } for(n=1;n<=nh;n=n+2) { for(ni=0,t=0;ni<=ns;ni++)

DIGITAL SIGNAL PROCESSING (DSP)

Hariyanto (1310125026) Selvira Rahadiningrum Ramelan (1310125027)


{ t=t+ts; vt[ni]=vt[ni] + (8 * vm / (n*n)/ (PI*PI)) * arm_sin_f32( n * PI / 2) * arm_sin_f32( 2 * n * PI * t / T); } } ni=0; while (1) {

/* DAC_SetChannel1Data(DAC_Align_12b_R, ADC3ConvertedValue); */ /* convert the ADC value (from 0 to 0xFFF) to a voltage value (from 0V to 3.3V)*/ // // } } // ADC3ConvertedVoltage = ADC3ConvertedValue *3300/0xFFF; voltage = ADC3ConvertedValue *3.30/0xFFF; count++;

void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } }

Bentuk sinyal :

DIGITAL SIGNAL PROCESSING (DSP)

You might also like