Help adding pulse width limiting

Hello all,

I have this code (not mine)

/*
Created by ISandhu
*/
#define _DISABLE_ARDUINO_TIMER0_INTERRUPT_HANDLER_  //Please read instruction to see what this line means
//otherwise you'll get error during compiling and uploading. 

void ADC_setup(){
ADMUX=0;
ADMUX|=(1<<ADLAR) |(1<<REFS0);
ADCSRA|=(1<<ADEN) | (1<<ADIE) | (1<<ADPS2) | (ADPS0<<1);  
ADCSRB|=(1<<ADTS2);    
DIDR0|=(1<<ADC0D);
ADCSRA|=(1<<ADATE) | (1<<ADSC);
}
void CW_setup(){//Carrier Wave Setup 
 pinMode(9,OUTPUT);
 pinMode(10,OUTPUT);
 TCCR1A=0;
 TCCR1B=0;
 TCCR1A |=(1<<COM1A1) | (1<<WGM11);
 TCCR1B |= (1<<CS10) | (1<<WGM12) | (1<<WGM13);
 ICR1=258;
 OCR1A=128;
} 
void SI_setup(){//Sample Interrupt Setup
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
 TCCR0A=0;
 TCCR0B=0;
 TCNT0=0;
 TCCR0A |=(1<<COM0A1) |(1<<WGM00) | (1<<WGM01);// (1<<COM0B1) | 
 TCCR0B |= (1<<CS01) | (1<<WGM02);
 TIMSK0|=(1<<TOIE0);
 OCR0A=60; //Sample Freq=33.37KHz
 }

void setup() {
cli();
SI_setup();
CW_setup();
ADC_setup();
sei();
}

ISR(TIMER0_OVF_vect){
}
  
ISR(ADC_vect){
 OCR1A=ADCH;
}

void loop() {
}

and I would like to be able to use it for a DRSSTC (coding is not my strong suite lol)

Is there a way that I could add say a 10k potentiometer to another analog pin and use that to limit pulse width? If not that is there a way to add a hard limit to the pulse width (around 300us)

any help is appreciated, thanks so much!

You ask: Is there a way that I could add say a 10k potentiometer to another analog pin and use that to limit pulse width? Yes you can. Is there a way to add a hard limit to the pulse width (around 300us)? Yes you can. Why not study the code a bit and I think you can figure it out. The Arduino Cookbook would be a big help.

Looks like this post.

-jim lee

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.