I'm a student, wanted to design and implement a Digital Equalizer. I have designed the project, but no idea on programming, in which i want to use PIC18F452 and Assembly Language. Help me Please.
Yes fast Fourier transformations I think ( Lots of theory very, very, very difficult and all maths based ) Might pay you to learn adc techniques first, matricing , matrices , memory addressing , offset addressing , sample and hold , capture and compare just a few topics you will have to cover never mind the rest of the subjects that you need to do Ho Ho " What a shock yo your system huh "
Libraries are written in the new amicus compiler but Its knowing what to do with them and how to use them
Uhm ,, your difficulties have just begun Truly Horrible !! Id start with high level languages if i were you before attempting this in assembler "Ouch talk about make this hard for yourselves"
I quite pleased Collin said this ha ha ha ha !! Ever so funny GOAL_OPTO_LEVEL || sample_ad_channel(REFLEX_BODY) > GOAL_OPTO_LEVEL) && ((SUM_IR(OFF_GOAL) > IR_LIMIT_GOAL) || (SUM_IR(DEF_GOAL) > IR_LIMIT_GOAL))) //If the robot is the offensive goal area #define IN_OFF_GOAL_AREA ((sample_ad_channel(REFLEX_STICK) > GOAL_OPTO_LEVEL || sample_ad_channel(REFLEX_STICK) > GOAL_OPTO_LEVEL) && ((SUM_IR(OFF_GOAL) > IR_LIMIT_GOAL) )) //If the robot is on the mid line #define ON_MID_LINE ((sample_ad_channel(0) > GOAL_OPTO_LEVEL || sample_ad_channel(1) > GOAL_OPTO_LEVEL) && ((SUM_IR(OFF_GOAL) < IR_LIMIT_GOAL) && (SUM_IR(DEF_GOAL) < IR_LIMIT_GOAL))) //Pause for a certain time #define WAIT(time) sometime=soft_time(); while(!passed(sometime+time)) ; #define STUCK (stuck_timer+STUCK_TIMESUM_IR(DEF_GOAL))?DEF_GOAL:OFF_GOAL):target; midtime=soft_time(); finished=0; C SOURCE CODE 30 //Reset the speed calculation variables cnt = 0; //Number of loops since last calculation sp_lastpos_l=0; sp_lastpos_r=0; sp_lasttime=some_time(); //Main loop, while R2D2 is not finished while ( !finished ) { if ( STUCK ) get_unstuck( ); //Check that R2D2 is not stuck //Calculate speed every 10:th loop to get more even speed calculation if ( cnt++%10==0 ) { double dt = (some_time()-sp_lasttime) * 0.00001; speed_left = (int)(1.28*(steps_left-sp_lastpos_l) / dt); //v=ds/dt speed_right= (int)((steps_right-sp_lastpos_r) / dt); //v=ds/dt //reset variables sp_lasttime = some_time(); sp_lastpos_r = steps_right; sp_lastpos_l = steps_left; } ir_wait(); //to synchronise to IR reception for(i=0;iIR_VALUE(IR_FR)) highest=IR_RL; else if (highest==IR_FR && IR_VALUE(IR_RR)>IR_VALUE(IR_FL)) highest=IR_RR; switch (highest) { //change turnspeed according to which IR-sensor has highest values case IR_LR: //Left rear switch(emitter) { case OFF_GOAL: motors( -105, 120 ); break; default: motors( -127, 127 ); break; } break; case IR_RR: //Right rear switch(emitter) { case OFF_GOAL: motors( -105, 120 ); break; default: motors( 127, -127 ); break; } break; default: //Front sensors diff = (int)(2.0*(IR_VALUE(0)/(double)IR_VALUE(1) - IR_VALUE(1)/(double)IR_VALUE(0))); diff=(abs(diff)>MAXDIFF)?((diff>0)?MAXDIFF:-MAXDIFF):diff; //Miximum difference is +-MAXDIFF //Set base speed, so that one motor always has MAXSPEED speed=MAXSPEED-abs(diff); //Slow down if looking for puck in high speed and puck is near if ((emitter==PUCK) && (SUM_IR(PUCK)>IR_LIMIT_PUCK_NEAR) && (max(speed_left,speed_right)>MAX_SPEED_NO_PUCK)) speed -= 14; //Slow down if looking for GOAL in high speed with puck and goal is near else if ((emitter==OFF_GOAL) && ((max(speed_left,speed_right)>MAX_SPEED_WITH_PUCK) || (SUM_IR(OFF_GOAL)>IR_LIMIT_GOAL_NEAR))) speed -= 14; C SOURCE CODE 31 //Turn fast towards a goal while not facing it (when difference of front //sensors is large or the rear sensor has a low relative signal) if ((emitter==OFF_GOAL||emitter==DEF_GOAL) && facing_goal==0 && (diff >SMALLDIFF || diff1)) { motors(-104, 119); } //Go to goal! else { facing_goal=1; motors( speed-diff, speed+diff ); } break; } //Is R2D2 finished? switch(target) { case PUCK: finished=IN_GOAL_AREA||HAS_PUCK; //Stop if has puck (success) or in goal area (failure) if (IN_GOAL_AREA) get_out_of_goal_area(); if (HAS_PUCK) play_tune(r2d2happy); break; case OFF_GOAL: finished=IN_GOAL_AREA||!HAS_PUCK; //Stop if puck lust (failure) or in goal area (success) break; case MID_FIELD: finished=(ON_MID_LINE||passed(midtime+2000)); //Stop when on mid line or too long time has passed if (IN_GOAL_AREA) //Make sure R2D2 does not try to go into a goal area get_out_of_goal_area(); break; } update_display(); //Update display with current values } //end while loop } //Function to shoot the puck in goal and drives out of the goal area. //Plays the tune ’starwars’ and prints "GOAL!" on the LCD before returning void shoot () { go(24,-127, 24, -127); //Go backwards 24 steps go(0, 0, 40, -110); //Turn right and backwards go(60,-110,0,0); //Turn left and backwards motors(0,0); //Stop steps_left = steps_right = 0; //Drive as fast as possible to puck while(!IN_GOAL_AREA &&!STUCK) { lcd_print1("Going for goal! : ",0); motors(127,127); } //Drive a little more go(5,127,5,127); steps_left = steps_right = 0; //Back out again get_out_of_goal_area(); lcd_print1("GOAL! ",0); play_tune(starwars); } //Function to go a certain number of steps with left and right wheel, with a given speed //Returns when the step number is reached on both wheels or is stuck void go(unsigned int go_left, int left_speed, unsigned int go_right, int right_speed) { C SOURCE CODE 32 go_left = (int)(1.28*go_left); //compensate for different motors! steps_left = steps_right = 0; while ( ((steps_left < go_left) || (steps_right < go_right)) &&!STUCK ) { if ( steps_left >= go_left ) left_speed = 0; if ( steps_right >= go_right ) right_speed = 0; motors( left_speed, right_speed ); } } //Function to back out of the goal area. The function does not return until R2D2 //is out. void get_out_of_goal_area() { static unsigned int sometime; sometime=soft_time(); if (IN_GOAL_AREA) { //Check that he really is in the goal area motors(0,0); while(IN_GOAL_AREA) //As long as he still is in the goal area if (!passed(sometime+150)) { motors(-127,-127); //Backwards full speed } else { motors(-114,-114); //Backwards slower after a while } motors(0,0); } } //Function to get R2D2 unstuck, by first trying to turn left and if //that does not help back 30 steps. void get_unstuck() { set_not_stuck(); go(40,-127,2,127); if (STUCK) { set_not_stuck(); go(30,-127,30,-127); } } //Function to update the LCD. The global variable display_mode handles what //is printed. The function checks the status of the buttons to see if the //imperial tune should be played or if the display_mode is to be changed. //The available modes are: //1: Display all IR values and the IR sum //2: Display number of steps on left and right wheel //3: Display reflex detector values //4: Display the difference between the front IR sensors, and if R2D2 is facing forward //5: Display sum of all IR sensors for the targets OFF_GOAL, DEF_GOAL and PUCK //6: Display the current speed on left and right wheel. void update_display() { bank1 static char buffer[7]; button_pressed_imperial(); //Play tune if imperial button pressed if (button_pressed()) { //Change display mode if (++display_mode>6) display_mode-=6; } switch(display_mode) { //Display IR values on the 5 sensors on the current target, and the sum of all sensors case 1: sprint16(buffer,ir_value(0,emitter)); lcd_print1("k",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered sprint16(buffer,ir_value(1,emitter)); lcd_print1("l",5); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered sprint16(buffer,ir_value(2,emitter)); lcd_print1("m",11); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered sprint16(buffer,ir_value(3,emitter)); lcd_print2("n",0); C SOURCE CODE 33 lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered sprint16(buffer,ir_value(4,emitter)); lcd_print2("p",5); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered sprint16(buffer,SUM_IR(emitter)); lcd_print2("s",11); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered break; //Display number of steps on left and right wheel case 2: sprint16(buffer,steps_left); lcd_print1("Steps l ",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered sprint16(buffer,steps_right); lcd_print2("Steps r ",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered break; //Display reflex detector values for the detectors on the stick and on the body case 3: sprint16(buffer,sample_ad_channel(REFLEX_BODY)); lcd_print1("Opto body: ",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered sprint16(buffer,sample_ad_channel(REFLEX_STICK)); lcd_print2("Opto stick: ",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered break; //Display the difference between the front IR sensors, and if R2D2 is facing forward case 4: sprint16(buffer,diff); lcd_print1("Diff: ",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered sprint16(buffer,facing_goal); lcd_print2("Facing: ",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered break; //Display sum of all IR sensors for the targets OFF_GOAL, DEF_GOAL and PUCK case 5: sprint16(buffer,SUM_IR(OFF_GOAL)); lcd_print1("o ",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered sprint16(buffer,SUM_IR(DEF_GOAL)); lcd_print1("d ",8); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered sprint16(buffer,SUM_IR(PUCK)); lcd_print2("sum puck: ",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); // spaces to make sure previous value is covered break; //Display the current speed on left and right wheel. case 6: sprint16(buffer,speed_left); //Speed of left wheel lcd_print1("L u/s: ",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); sprint16(buffer,speed_right); //Speed of left wheel lcd_print2("R u/s: ",0); lcd_print_at_cursor(buffer); lcd_print_at_cursor(" "); C SOURCE CODE 34 break; } } C.4 adc.h // ***************************** adc.h //sample an A/D channel and return the eight most //significant bits (the two least significand can be //fetched from ADRESL as its bit 6 and 7) // //This function includes a delay for the required //acquisition time (enough for source impedances up //to 10kOhms) and then waits for the converion to //complete. All in all a call will take about 40 us. // //(waiting for the acquisition time is really a waste //of time if the same channel is sampled again and //not immediately after the previous conversion) // //Do not forget to configure which pins you will use //for A/D in ADCON1 and TRISA (and maybe TRISE too) //once before first using this function //Example (if you want only one A/D channel): //ADCON1=0b00001110;TRISA0=1; //Example (if you want 5 A/D channels): //ADCON1=0b00000010;TRISA0=TRISA1=TRISA2=TRISA3=TRISA5=1; //See fig 11-2 in data sheet // //The pin each channel uses is marked on the front page //of the data sheet as ANx, wher x is the channel number extern char sample_ad_channel(char channel); C.5button.h //Initialize the buttons extern void init_buttons(); //Return if the display button has been pressed extern bit button_pressed(); //Plays the tune imperial if the sound button is pressed extern void button_pressed_imperial(); C.6 button.c #include #include "defines.h" #include "button.h" #include "intr.h" extern const char imperial[]; //tune to play when pressing sound button // I/O pins for the buttons #define BUTTON_DISPLAY !RB4 #define BUTTON_IMPERIAL !RB5 //the previous state of the buttons C SOURCE CODE 35 bank2 static bit button_state; bank2 static bit button_state_imperial; //Initialize the buttons void init_buttons() { TRISB4=1; //inputs TRISB5=1; RBPU=0; //use the internal pull-up resistors on PORTB button_state=0; button_state_imperial=0; } //Return if the display button has been pressed bit button_pressed() { if(BUTTON_DISPLAY && !button_state) { button_state=BUTTON_DISPLAY; return 1; } button_state=BUTTON_DISPLAY; return 0; } //Plays the tune imperial if the sound button is pressed void button_pressed_imperial() { if(BUTTON_IMPERIAL && !button_state_imperial) { button_state_imperial=BUTTON_IMPERIAL; play_tune(imperial); } button_state_imperial=BUTTON_IMPERIAL; } C.7 intr.h // pins for reading encoder wheels // note that the use of port E pins as digital I/O requires ADCON1 to be properly set #define OPTO_LEFT RA4 #define OPTO_RIGHT RE0 extern bit has_passed; extern unsigned int soft_tmr; extern unsigned int soft_tmr_copy; // Macro to read the soft timer atomically // Use only this macro to read the time outside the interrupt routine // USE passed(time_to_check) MACRO INSTEAD FOR COMPARISONS!!! #define soft_time() (di(),soft_tmr_copy=soft_tmr,ei(),soft_tmr_copy) // Macro to check if a time is in the past (or present) atomically // Use only this macro to compare to current time (outside the // interrupt routine). // Returns 1 if time_to_check has been passed. Because the time vars // are only 16 bits it must then return 0 again after some amount of // time here chosen to be 1024 ms. // Maximum time for delays is then 65535ms-1024ms or about 64.5 sec. #define passed(time_to_check) (di(),has_passed=((unsigned int)(soft_tmr-(time_to_check))
Sir, I saw the sample program in c, but i will like to know the Parameters of the digital equalizer used in your program for me to study what the program codes doing at each line. Thank you.
This "sample program" has nothing to do with a Digital Equalizer (more like a game -- looks like some form of hockey -- with _perhaps_ R2D2 sounds and the Star Wars theme (if the Functions and variables are appropriately named).
I think the point of it's presentation is to illustrate the complexity before you.
I am designing excel code39 barcode generator and i need to implement a Digital Equalizer.
I know there are a lot of questions about equalizers in so, but I didn't get what I was looking. What I want to do is an equalizer for modifying audio samples in such a way like:
I'm not sure if that is the exact interface that I want because I know little about DSP in terms of implementing them (I used filters, limiters, compressors but not made them).
So Googling about this I read that I must do a FFT to the samples so I get the data per frequency ranges instead of amplitude, process it the way I want and then make the inverse of the FFT so I get the result in audio samples again. I looked for an implementation of this FFT and found JTransform for Java. This library has an implementation of a FFT related algorithm called Discrete Cosine Transform (DCT).
Well, Am I in the right way?Since FFT gives me data about frequency, I should pass to the FFT algorithm a chunk of samples. How big this chunk must be?Is there a good book about DSP programming that explains equalizers ?
The discussion centers on implementing a digital equalizer using the PIC18F452 microcontroller programmed in Assembly Language. The original poster, a student, seeks guidance on programming the digital equalizer after designing the project. Responses highlight the complexity of the task, emphasizing the need to understand advanced digital signal processing concepts such as Fast Fourier Transform (FFT), sample and hold, ADC techniques, memory addressing, and matrix operations. It is suggested that starting with high-level languages might be more practical before attempting Assembly. The conversation also clarifies that sample code previously referenced is unrelated to digital equalizers and serves only to illustrate programming complexity. Additionally, one contributor mentions the general approach to digital equalizers involving FFT to analyze frequency components, processing these components, and then applying an inverse FFT to reconstruct the audio signal. The use of libraries like JTransform for FFT and Discrete Cosine Transform (DCT) implementations in other programming environments is noted, but no direct Assembly or PIC18F452-specific code examples are provided. Summary generated by the language model.