imranahmed
Advanced Member level 3
- Joined
- Dec 4, 2011
- Messages
- 822
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,298
- Location
- Karachi,Pakistan
- Activity points
- 6,533
Dear KlausST,
Welcome to new thread about Digital Multimeter.
The meter I need design ammeter with selectable ampere detector.
The code I wrote its interrupt is working well with 5ms time and cases are
select nicely but issue is I want scroll digits with buttons for setting required
ampere and store it,when ammeter detect pre-select ampere it operates a relay
(PORTD==PD7 for relay signal).
In my code it is run when I delete two IF conditions but when I wrote it,it was not work.
:thinker:
Welcome to new thread about Digital Multimeter.
The meter I need design ammeter with selectable ampere detector.
The code I wrote its interrupt is working well with 5ms time and cases are
select nicely but issue is I want scroll digits with buttons for setting required
ampere and store it,when ammeter detect pre-select ampere it operates a relay
(PORTD==PD7 for relay signal).
In my code it is run when I delete two IF conditions but when I wrote it,it was not work.
:thinker:
Code:
void InitTimer2(){ //CTC timer2
OCR2 = 155;
TCCR2 |= 0x0E;
TIMSK |= 0x80;
TCNT2 = 0;
}
ISR(TIMER2_COMP_vect){
TCNT2 = 0;
if((PINC & (1<<PC3)) == 0)
{
swcount2++;
if(swcount2==100){
q++;
swcount2=0;
}}
switch(q){
case 0:
av=read_adc(3); // yellow amps
dv1 = dv1 + (av - dv1) * fc ;
mcount2++;
if(mcount2==100)
{
mcount2=0;
dispv1=dv1;
}
break;
case 1:
ampset = read_eeprom_word(&my_eeprom_word);
dispv1 = ampset;
if((PINC & (1<<PC4)) == 0){
mcount2++;
if(mcount2==50)
{
mcount2=0;
ampset++;
write_eeprom_word(&my_eeprom_word,ampset);//store value in eeprom
dispv1=ampset;
}
}
if((PINC & (1<<PC5)) == 0){
mcount2++;
if(mcount2==50)
{
mcount2=0;
ampset--;
write_eeprom_word(&my_eeprom_word,ampset); // store value in eeprom
dispv1=ampset;
}
}
break;
default:
q=0;
break;
}
while(1)
{
cli();
tmp1=dispv1;
tmp=dispv;
sei();
Print1(tmp1); // Print1 for digit 1-3
Print(tmp); // Print for digit 4-6
if(tmp1>ampset)
{
PORTD |= 1<<PD7;
}
}