No, you will not be able to get any idea from my ATTiny25 mikroC PRO AVR code because it uses compiled libraries for adc and pwm. code is small, just 30 lines of C Code. Coding is almost complete. The PWM library functions are a little complex. I will have a chat with mikroE support and get a sample code to generate 100 Hz PWM using mikroC PRO AVR. I will provide you the code today.Ok. Try to implement on ATtiny25. I will take reference of the code and will try to implement the same on ATtiny10 and will share the results.
For ATtiny10 - Atmel studio compiler is used.
Build this circuit on hardware with good 5V power supply.Ok. Thanks in advance.
Ok. I thought you want to use low pass filter method. If you can use different pins for ADC i/p, PWM i/p and PWM o/p then I will write a new code and send it to you tonight. Still to generate PWM of 100 Hz using mikroC library I have to get support from mikroE.Hello,
If you are giving me code for i/p as a ADC and o/p as a PWM then I have done that case.
Please give me code to measure duty cycle of PWM at i/p of micro controller and o/p is also PWM.
Now I am ready to take two different pins for ADC i/p and PWM i/p.
I dont wanted to use low pass filter. Please let me know the detail.
unsigned int raw_adc_value[2] = {0, 0}, old_raw_adc_value[2] = {0, 0};
unsigned short pwm_duty = 0;
char i = 0;
void main() {
DDRB = 0x1B;
PORTB = 0x00;
Delay_ms(100);
//PWM1 Initialization 100 Hz
//PWM Duty 0
//PWM1 Start
while(1) {
for(i = 0; i < 2; i++) {
raw_adc_value[i] = ADC_Read(i);
Delay_us(80);
}
for(i = 0; i < 2; i++) {
if( (old_raw_adc_value[i] != raw_adc_value[i])
&& (raw_adc_value[i] > 0)
&& (raw_adc_value[(~i) & 1] == 0)) {
//PWM1 Set Duty
old_raw_adc_value[i] = raw_adc_value[i];
}
}
}
}
100 Hz o/p PWM is needed ?Hello,
Please forget about 100Hz at o/p. I will generate 100Hz at o/p/
According to duty at i/p PWM the duty of o/p will set. I will generate 100Hz duty. Please tell me about i/p side.
I have asked mikroE for an example code which generated 100 Hz PWM with 0-100% duty.OK.Thanks.I will wait for your update.
Are you reverse engineering a product ?My ATtiny 10 has only one 16 bit timer.
Enable to accept Private Message. I will provide you my email ID there.Hello Jayanthd,
Yes I need exact 100Hz at o/p. Also PWM duty mapping from i/p to o/p should be same.
I have made it successfully with low pass filter. I can give you the circuit and code.I have used it but not working for variable i/p frequency from 50Hz to 1kHz
Ok.No man during noise interference , it always misbehaves. That's why i am selecting microcontroller as an option.