View previous topic :: View next topic |
Author |
Message |
percramer
Joined: 20 Nov 2006 Posts: 5
|
Posted: Tue Apr 08, 2008 1:13 pm Post subject: interrupt count and easy tcp ip |
|
|
Hi all,
i have got the following issue. My current hardware / software design needs to calculate data from 3 counters. The counters all have differtent intervals. I use a Mega32 and i have connected each counter to 1 of the 3 interrupts of the Mega32. When i generates an interrupt i just update an internal variable in bascom quickly. This works fine. But now i would like to change my design to start using an tcp-ip interface instead of the serial port (for communication). I have bought the easy tcp-ip kit for this. This only uses the i2c port and a reset AND an interrupt. So now i have got an interrupt problem, because the mega32 only has got 3 interrupts. What do you think is the best way to solve this?
Combine the output of the 3 counters to 1 interrupt and re-route the outputs of the counters also to 3 inputs? Then on an interrupt check the 3 inputs to see which counter has generated the interrupt? |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Tue Apr 08, 2008 3:45 pm Post subject: |
|
|
good idea.
How long are your input signals?
can´t you just check the inputs in the main loop?
Have you checked if DEBOUNCE (see help) is a solution? |
|
Back to top |
|
|
percramer
Joined: 20 Nov 2006 Posts: 5
|
Posted: Tue Apr 08, 2008 8:43 pm Post subject: |
|
|
The Mega128 seems to have more interupts. Maybee that is a good alternative to? |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Tue Apr 08, 2008 9:18 pm Post subject: |
|
|
mega128 is not available in DIL, but shure is a good µC.
Why do you stick to interrupts so much? |
|
Back to top |
|
|
percramer
Joined: 20 Nov 2006 Posts: 5
|
Posted: Tue Apr 08, 2008 9:37 pm Post subject: |
|
|
well because it keeps the design that much easier (at least i think). I don't need to pol 3 inputs for their value (for the 3 external counter, which are a Kwh counter,and 2 flow counters). Just update the internal value when the interrupt fires. checking the 3 inputs in the main loop just doesn't look like the right way to do it (but i could be wrong). The device doesn't need to do much more though. Switch 3 relais and get values from 2 other analog values. It does all that at the moment and output it through the serial port. But i would like to swap this for a ethernet connection (or add an ethernet connection and keep the serial also).
But maybee i am thinking to diffecult and should i just tie the 3 counters together to 1 interrupt.... |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Tue Apr 08, 2008 11:14 pm Post subject: |
|
|
In spite of what all the textbooks say, polling is better for any low speed ( say < 10 ms ) signals than interrupts. Interrupts are for *high* speed, where you want the processor to take notice of some external event in at most a couple of clock cycles. It costs you no significant overhead to poll a port line, compared to the time taken to write to serial ports, displays, and the like. After all that is what all that processor power is for ! _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
|