Re: Loop problem: CPU usage
Quote:
Originally Posted by shoppinit
The micro has 2 external interrupts that are driven (via industrial optos) by 2 inductive sensors (24v PNP). The EINTs proved extremely sensitive to line noise, EMI emissions, etc. I'm getting a lot of false activations - exactly as if the EINT inputs were floating, but they're pulled high. I tried shielding everything (and I mean everything!) and this helps slightly.
Ben,
It sounds like you need to improve the input structures of the external interrupt lines.
When you say 24v PNP what exactly do you mean? Are you using something like a Natinal Instruments NI 6224? What are the output voltage levels of the signals? It sounds llike you might need to make a high-pass filter combined with a voltage divider. Possibly the use of a schmitt-trigger could clean up the inputs, but that should not really be necessary.
Tell me how you have designed the input circuitry for the external interrupt pins and how these are connected to the sensor outputs.
You are right: You need to get this straightened out on the test bench before you get into the production facility. Otherwise it will really be a disaster.
BTW: Your software should also have some sort of mechanism which disables the external interupts within the ISR. They can be re-enabled several tens or hundreds of microseconds later with an independent time-base. This is necessary in order to prevent a CPU overload exactly in case there is high-frequency noise on the external interrupt pins. But the hardware has to be clean in the first place. This piece of software is simply a double-check mechanism.
Sincerely, Chris.
1 Attachment(s)
Re: Loop problem: CPU usage
Hi Chris,
The proximity sensors I'm using are 3 wire PNP ones - I feed them 24v and when there's an object, the 3rd wire goes up to 24V which activates an opto. When the opto activates, the signal goes to ground and the interrupt fires.
See attached image. The 'output' goes straight to my EINT pin.
The proximity sensor is similar to this:
http://www.am.pepperl-fuchs.com/prod...oduct_id=15642
Someone has suggested that I put a second pull-up on the micro side with a 1nF cap on both sides. I've yet to try this, but am leaning more towards putting the opto on the PCB. Possibly to reduce the impedance difference.
Ben.
Re: Loop problem: CPU usage
Is the raw output going into the microcontroller? What are the logic levels of the output?
If the raw output is directly fed to the microcontroller, then the system could benefit from a simple low-pass filter. Use something like 10k-20k resistor between the output and the microcontoller pin in combination with something around 1nF from the microcontroller pin to ground. Optionally you can use an additional block capacitance of about 1nF in series with the output resistor placed on the signal side.
Impedence mismatch should not be playing a role because the external interrupt pins should be set to input and as such high-Z.
You can, in addition to the low-pass described above, follow up on the suggestion sketched in your previous post. This will augment the low-pass.
Can you follow these ideas?
Sincerely, Chris.
Re: Loop problem: CPU usage
Hi Chris,
Thanks for that. Yes, the raw input is going straight into the micro. The signal is 5v that comes from the same source that's powering the micro, ie. the PC PSU 5V rail.
I'm going to try putting the caps and resistors as you suggested on one set-up and I'll try with the 4N37 optos on the other then I'll use my trusty 1970's EMI generator (AKA oscilloscope) to see what happens.
I'll let you know!
Ben.
Re: Loop problem: CPU usage
Quote:
Originally Posted by dude_1967
Optionally you can use an additional block capacitance of about 1nF in series with the output resistor placed on the signal side.
Sorry. The description of the optional block capacitor was wrong. It is on the signal side before the 10k-20k resistor, but to ground. It could even be a bit larger like 10nF.
Code:
Optional pull-up Optional pull-up
~10k to Vcc ~10k to Vcc
| |
| 10k-20k |
Output ------------------/\/\/\------------------ Extern Int Pin µC
| |
| |
----- -----
~10n ----- <= 1n -----
| |
| |
----- -----
--- ---
- -
2 Attachment(s)
Re: Loop problem: CPU usage
Hi Chris,
Thanks for that. I've attached my interpretation of your schematic (opto2.jpg) - does that look right?
Also attached is another schematic for replacing the whole lot with the 4N37 opto (RC.jpg). How does that look to you?
Thanks again.
Ben.
PS. It looks like the noise (or some of it) may be coming from the +24V sensor cable which isn't shielded. That's why I added the 100nF cap there. It's funny how when I use the DIO card in the PC instead of the micro I don't get these noise problem. I guess the DIO card is doing some filtering...
1 Attachment(s)
Re: Loop problem: CPU usage
Quote:
Originally Posted by shoppinit
Hi Chris,
Thanks for that. I've attached my interpretation of your schematic (opto2.jpg) - does that look right?
Ben, I can comment on the µC input structure, but not on the entire system. Here is what I mean for the µC input circuit.
Sincerely, Chris.
Re: Loop problem: CPU usage
Chris, that seems to work nicely. I can't generate enough noise to falsely trigger the EINTs. Despite turning the scope on and off next to the unshielded board. I'm giving this a tentative thumbs up.
My confidence in the micro is slightly restored. Now if I can sort the communication out, and that seems to work reasonably well if the CPU isn't too loaded, then I think I'll have found my solution.
Thanks for all your help.
Ben.
Re: Loop problem: CPU usage
Quote:
Originally Posted by shoppinit
Chris, that seems to work nicely. I can't generate enough noise to falsely trigger the EINTs. Despite turning the scope on and off next to the unshielded board. I'm giving this a tentative thumbs up.
Good. I had hoped it would be sufficient. Make a mental note of that input circuit and store it away in your bag of tricks.
Quote:
Originally Posted by shoppinit
My confidence in the micro is slightly restored. Now if I can sort the communication out, and that seems to work reasonably well if the CPU isn't too loaded, then I think I'll have found my solution.
That sounds promising. Remember Ben, you are 'taking it on' with a difficult design involving a µC target and peripheral hardware as well as a PC host system. I know you have worked hard on this and I encourage you to continue with your design. You have already solved many key problems.
Sincerely, Chris.
Re: Loop problem: CPU usage
Hi Chris,
I've got the system installed and am testing it on site. The micros doing a great job. Thanks you and everyone else for steering me in that direction.
The noise issue still turned out to be a slight problem, despite the shielding and the pull-up circuit. I seem to have solved that in the micro code by deactivating the interrupt for a couple of milliseconds then testing the input to see if it's still high. I'm not sure if that's good practice, but it seems to work pretty good.
The PC side is a little less stable, as to be expected. I'm doing some serious debugging - mostly due to some poor coding (buffer overruns being amongst the most serious).
I have one issue that keeps arising concerning the comms between the micro and the PC. My RS232 thread occasionally terminates with a ERROR_IO_INCOMPLETE error. Having looked it up a little, it doesn't seem like this is a real error, just a message saying that there's some ongoing comms. What's your take on this?
Thanks.
Ben.