![]() Since it is always flipping Pin 11 first and then Pin 12 it will cause shoot-through when Pin 11 is turning ON and Pin 12 is turning OFF. Your sketch is using WGM 9 but not using it for the PWM features! It's using a single interrupt and flipping output pins in the ISR. I think you will want to have OCR1A different by 1 from OCR1B to avoid the shoot-through problem. The COM1A0 and COM1B0 bits in TCCR1A should allow you to invert either of the channels. ISR(TIMER1_COMPA_vect) //Interrupt service routine for triggering outputsĭigitalWrite(IGBT1, digitalRead(IGBT1) ^ 1) //toggles IGBT1 pinĭigitalWrite(IGBT2, digitalRead(IGBT2) ^ 1) //toggles IGBT2 pinīe sure to put pull-down resistors on your outputs so when the processor resets and the two pins become inputs they won't accidentally float HIGH. ![]() TIMSK1 |= (1 << OCIE1A) //Enable timer compare interrrupt TCCR1B |= (1 << CS10) //Clock select bits for 1024 prescaler TCCR1B |= (1 << CS12) //Clock select bits for 1024 prescaler TCCR1B |= (1 << WGM13) //Waveform Generation Mode 9 TCCR1A |= (1 << COM1A0) //Set OC1A/OC1B/OC1C on compare match when upcount and clear OC1A/OC1B/OC1C when downcount TCCR1A |= (1 << COM1A1) //Set OC1A/OC1B/OC1C on compare match when upcount and clear OC1A/OC1B/OC1C when downcount TCCR1A |= (1 << WGM10) //Waveform Generation Mode 9 OCR1A = 52 //compare match register value 16MHz/1024(which is TCCR1B CS12 and CS10 below)/300Hz desired = 52 TCNT1 = 0 //initialize counter value to 0 TCCR1B = 0 //Initialize entire timer 1 register B to 0 TCCR1A = 0 //Initialize entire timer 1 register A to 0 Lcd.init() //start lcd serial communicationĭelay(1000) //delay of 1000 milliseconds PinMode(IGBT2, OUTPUT) //sets pin 12 as an output PinMode(IGBT1, OUTPUT) //sets pin 11 as an output #define IGBT2 12 //Designating pin 12 as IGBT2 #define IGBT1 11 //Designating pin 11 as IGBT1 Here is the program with all the notes edited out so that it is in the correct format #include I am sorry that I had to upload the program as a JPEG but the program is chock FULL of comments and supporting notes. I really appreciate any help that any of you can give me! So when a potentiometer knob is turned on pin A0, both outputs will change frequency. I need the program to trigger these pins alternately and have variable frequency. As it stands, this program (I think) will output a square wave on both pin 11 and pin 12 but they are in phase (high as the same time and low at the same time). I megged them and they meg at over 60 M ohm so they are healthy. Each IGBT is rated for 400 amps because they are out of a VFD. If pin 11 and pin 12 are ever high at the same time the breaker will trip. Pin 11 needs to be High ONLY if pin 12 is Low and vis-versa. (it's not homework it's just a hobby project) I have included pictures from the mega 2560 datasheet as well. I have already written 90% of the program and am not looking for anybody to do my homework for me. ![]() The inverter I am creating takes two 120v poles from a breaker panel and converts it to a DC bus using input diode. One IGBT will handle the positive half of the square wave and the other will handle the negative. I have two IGBTs mounted on a heatsink that will pulse current from a 330 V DC bus. I am attempting to create a single phase output variable frequency square wave generator that can pass high current. ![]() I am not looking for a free ride here, just a proof-read and some pointers from the seasoned programming professionals. 90% of the program is already written so bear with me.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |