Long cable and external interrupt

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm developing a timer system for dog agility matches. Using ATmega8 for the timing and display etc. and planning to use tiny15 for the start and stop ports.

My question is, will there be problems if I use external interrupts to start and stop the counting as I need to have atleast 25 meters (80 feet ?) of cable between the ports and mainboard. I haven't got all the parts yet so I'm asking in advance for any suggestions on how to avoid falsely starting or stopping the timing.

The ports only sends an 1 or 0, depending on if it has been toggled (ir beam broken).
For the cable I'm planning to simply use outdoor mains cable (three wires, vcc, gnd and signal).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Even in a trial field, you may very well have problems with mains (50/60Hz) pickup. I would try the following:

1. Maike sure that you use a twisted cable. Some are not.

2. Filter at the AVR input. Use a series R and shunt C. I would try for about a 10Hz bandwidth or less. That would give a 30ms rise time and would take a 1uf cap and 15K resistor.

3. Use an input with "Schmitt Trigger" processing. All or some of the inputs of most AVRs have this. It will turn the slow edges from the RC filter into fast edges for the processor int.

Make sure that you have transient protection at the point where the wires connect to your device. ESD can kill electronics. I would use a single-polarity transorb, probably rated just over 5V (if you use internal 5V power).

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks ka7ehk.

Well, it has to be faster than that I'm afraid. The pulse takes only 500 us minimum, extending the time is a possibility but it still needs to be faster, 5 ms max. I was thinking of coding the pulse somehow, so emi pulses would't have any effect. But at the moment that is beond my programming knowledge :(

So any ideas to filter it faster or some 1-wire knowledge...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would use a 25 cent optocoupler between the wire and the AVR, rather than connect an antenna like that to the chip directly.. even if it is via RC. Wire that long can pick up static and EMF currents you don't want.

..that's just my twenty five cents worth of advice!

Regards,
Scott

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good suggestion!

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the advice, before I burned my mega :D

But there's still the question of how to prevent false pulses...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The opto advice is indeed good advice - and will go a very very long way to preventing false pulses. I think that will pretty well solve your problem. The LED of the opto coupler will provide a low impedance path for noise to go away and it shouldn't cause false tripping like directly-connected electrical noise would.

Please note - this post may not present all information available on a subject.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That pretty much answered my questions, thanks for the help!

Do I have to add any other components besides the opto ? Haven't used them before. And is there much difference in which kind of opto I should choose for this application ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wiith an opto, you only need to make sure that you take into account the minimum current "gain" (also "current transfer ratio", or CTR).

Inexpensive optos commonly have a minimum CTR of 50%. This means that if you put one milliamp into the LED input, you could get as little as 1/2 ma out of the transistor.

So, I would start with your source. What voltage does it produce? And what is the recommended input current. Lets take 10ma since that is common, but it could be as low as 1ma. Lets assume that the LED forward voltage is 1.8V. You will have to see what it is for the opto you choose, but lets use that as an example. If your source voltage is 5V, then the series resistor you want to use at the input is (5V - 1.8V) = 10ma * R. Then, R would be 320 ohms and 330 would be just fine. Remember, this is just a worked example!

Now, on the output side, you will get a current that is minimum CTR times the input current. That would be, in the example, 0.5 * 10ma = 5ma.

Finally, you want the output transistor to saturate in order to get full logic swing. If the supply is 5V, the collector (ie, pullup) resistor would then be 5V = 5ma * Rc or Rc = 1K.

Hope this helps,.
Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Start with the internal pullup, nominal 30k to 120k, IIRC.
So just connect the collector of the phototransistor side of the optocoupler to the AVR pin and its emitter to ground. If you need snappier response, then add an external pullup resistor (load) on the collector to Vcc and drive the LED half of the optocoupler harder (less current limiting resistance).

I've attached a couple PDF's from Fairchild that are good beginner guides for opto's.

Regards,
Scott

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I thought I attached... drat new forum.. trying again

oh to heck with it, what's the secret? these files are on the order of 300K is that too much?

Regards,
Scott

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

scottm wrote:
oh to heck with it, what's the secret? these files are on the order of 300K is that too much?

Yes.
See https://www.avrfreaks.net/phpBB2/...

/* John Butera */

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the help. I think I can manage this now, if I don't, I'll be back asking more stupid questions... :twisted: