EmbDev.net

Forum: µC & Digital Electronics Watchdog with ATTiny 2313 not working


von Peter (Guest)


Rate this post
useful
not useful
Hello,
could someone please help me?
I'm pretty new at this. I tried to make a simple watchdog that resets my 
server when it freezes.

I have made a windows program which sets one bit of the parallel port 
every minute for a second. The Attiny 2313 is programmed that is resets 
the server when this doesn't happen for more than ten minutes.

I have connected the attiny 2313 to the following pins:
+5V --- to +5V on the mainboard connector
GND --- to one of the GNDs from the parallel port
PB0 --- (as input) to the pin on the parallel port which is set by the 
windows program; and a 10k resistor which is connected to GND on the 
other end
PB7 --- (as output) to the reset pin on the mainboard connector

Behavior: when the windows program isn't running, the server resets 
after 11 minutes (as it should)
When the windows program is running, the server runs for about 20 
minutes and then resets (it shows that i use the correct pin of the 
parallel port, at least).

Maybe someone has an idea what i did wrong?

Here is the c-code:
1
#include <avr/io.h>
2
#include <util/delay.h>
3
#include <avr/pgmspace.h>
4
#include <inttypes.h>
5
6
int main(void) {
7
8
  int timer;
9
  int value;
10
  int oldvalue;
11
12
  const int TIMERMAX = 6000;
13
14
  DDRB = 0xFE; // 11111110 - PB0 is input
15
16
  PORTB = 0;  
17
18
  oldvalue = 0; timer = 0;
19
20
  while (1) {
21
    if (bit_is_set(PINB,0)) { value = 1; } else { value = 0; }
22
    if (oldvalue != value) {
23
       oldvalue = value;
24
       timer = 0;
25
    }
26
    timer++;
27
    _delay_ms(100);      
28
  
29
    if (timer > TIMERMAX) {  // no change on PB0 for more than 10 min.
30
       PORTB = 0x80;    // set PB7 to 1      
31
       _delay_ms(100);
32
       PORTB = 0;
33
       timer = 0;
34
    }
35
  } // while
36
}


Thank You very much for Your help,
Peter

von MagIO (Guest)


Rate this post
useful
not useful
Sorry ... I don't use AVRs currently, but as nobody else replies .. here 
are my 2 cents:

I'd simply use the good old LED-debugger to watch what the AVR thinks it 
sees on the parallel port. Did you check the LPT with a scope?

I remember that there are different LPT-interface modes you can choose 
in the BIOS setup. Maybe there's a problem with the mode you use?

Good luck!

von Peter (Guest)


Rate this post
useful
not useful
Hi,
thank You for Your answer! I've tried the LEDs. A LED connected to the 
concerning pin of the LPT does go on and off, just as the windows 
program dictates (on for 1 second, off for a minute).

To test the avr, I put a led to the output port (PB7) and decreased the 
inactivity interval to a few seconds.
As long as I touched a wire with +5V to the input port (PB0) often 
enough, nothing happened, when I didn't the LED would be on for about 
1/10 of a second, just like it should.

Of course, I didn't try it for 20 minutes...

Does it have to be exactly +5V on the input port? I think the LPT of my 
servers delivers something between 3V and 4V.
Do I have a problem with the 10k resistor? Should I activate the 
internal pullup of the input instead?

Thank You,
Peter

von MagIO (Guest)


Rate this post
useful
not useful
I'd make sure that the parallel port is running in SPP mode, not EPP or 
ECP.

Whether the 10k resistor is a problem or not can be checked with LED 
debugger as well. Use another port pin and set it similar to your value 
variable. Then you see what the AVR sees on the input-pin.

I don't see a problem in the program.

von Peter (Guest)


Rate this post
useful
not useful
Thank You!
I will try changing the lpt settings.
Great idea with the value variable! Maybe that will help me!

Thank You,
Peter

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.