Sensing (interfacing) high voltage with arduino or any Microcontroller - Page 1
Forum section: electronics / beginners

author: Laszlo
author_rank: Contributor
timestamp: May 29, 2019, 02:13:15 pm
content: Hi all,I have a project in mind which involves sensing high voltage dc on/off signals. The voltage which is being sensed is in between 80-120V dc. I am not concerned about switching speed at all, as the signals I'd like to monitor do not change their state very quickly.My question is what is the best way of reducing the voltage to TTL logic level and provide isolation in between the two system.There would be above 60+ signals which I need to monitor at the same time, so using a buck converter is out of option I thinkI had a look at reducing the voltage down by a drop resistor, but then I realized that this solution is rubbish due to the lack of isolation in between the MCU and the high voltage source.My other idea was to use an optocoupler and a resistive voltage divider to bring the current/voltage down to a safe level, but I'm not so sure whether that would work in between the required ranges correctly.Then I found this SN65HVS882 IC.https://www.designnews.com/electronics-test/interface-high-voltage-onoff-signals-low-voltage-mcus/51223495829507According to its datasheet, I would still need an additional limiting resistor to use it on the voltage required but looks like an elegant solution with everything included. Has anyone ever worked with one of these devices? Are they as good as the article states?Also, is there any other solution for this problem? I am sure that I am not the first who had this in mind, but I can't really find much on the internet other than the usual opto-coupler+relay solution.As always, all inputs to the question are much appreciated.Cheers,Laszlo

author: bson
author_rank: Unknown
timestamp: May 29, 2019, 06:35:38 pm
content: You could divide them down and clock them into 74HC166's cascaded (Q7-to-DS). Then read them out as a bit stream. You can isolate the serial interface rather than the inputs using optocouplers; you need the serial out (final Q7), serial clock (CP), and latch edge (PE#). Maybe master reset (MR#) if you're ambitious. Of course you also need a supply rail.

author: rstofer
author_rank: Super Contributor
timestamp: May 29, 2019, 08:41:32 pm
content: In most industrial applications, they run the high voltage into an optoisolator. You would need a resistor to limit the LED current and wide variations in voltage make this an ugly computation. You need to provide 'enough' LED current at the minimum expected voltage and not too much current at the high expected voltage. I didn't try to work it out...On the output side, you can probably use the MCU internal pull-up resistors although I would probably use 1k to Vcc. See below about resistor size.Clearly, this solution takes more real estate than a simple divider but I just don't like having high voltages around the MCU.I would put all of the optos on one or more external PCBs and use an I2C or SPI IO Expander to read the output of the opto. Unless the IO Expander has internal pull-ups, you would need to provide that 1k pull-up.The thing about 1k pull-up is that it draws 3.3 mA when pulled down. Times 60 signals, we're talking about nearly 200 mA. Maybe 10k will work just as well. Check the datasheet for the opto and the MCU or IO Expander.

author: ptricks
author_rank: Frequent Contributor
timestamp: May 29, 2019, 10:55:11 pm
content: resistor ---> zener diode----> resistor---> optoisolator will workRoughly, 2K resistor, 12v zener , 330 ohm resistor , 4n25 works from 14V-120VDC

author: Laszlo
author_rank: Contributor
timestamp: May 30, 2019, 05:33:52 pm
content: Quote from: ptricks on May 29, 2019, 10:55:11 pmI've made a sample simulation in LTspice. Is that what you were recommending?

author: ptricks
author_rank: Frequent Contributor
timestamp: May 30, 2019, 08:06:15 pm
content: Quote from: Laszlo on May 30, 2019, 05:33:52 pmThe 330 ohm needs to be in series with the opto.The first resistor the 2K limits current to the zener. The zener clamps the voltage to 12VDC (80-120VDC range on input will always be 12VDC), and the 330 ohm limits current to the LED inside the optocoupler, so your always powering the optocoupler from a preset voltage.

author: Laszlo
author_rank: Contributor
timestamp: September 04, 2019, 02:47:20 pm
content: Hi,So, I've built a prototype circuit using voltage dividers and Zener clamps and a sharp PC817 optocoupler. The output of the transistor is driving a 74HC4050 hex High/Low-to-level shifter and its output is being fed to the Arduino's digital I/O. The whole circuit is taking 265uA from the input 110Vdc, so I was quite happy about that. The optocoupler is switching 5Vdc which is a 9Vdc battery voltage regulated to 5Vdc via a 7805 linear regulator.The circuit works reasonably well, but only if I pull the Emitter of the Opto's transistor down to the ground via a 1M resistor. Otherwise, the output of the 74HC will always be high, irrespective of the state of the optocoupler. I've tried searching for info but I could not find anything similar.Looking through the datasheet of the 74HC, and it only mentions that the logic device should have a 100-ohm resistor in series with the input. Would that mean that the 100-ohm resistor needs to be in series with the input of the 74HC or the output?Could anyone point me in the right direction regarding the 74HC4050, and how it should be driven from an optocoupler? I've looked at the datasheet, and some other forum questions, but I've just got further confused. I've read through the relevant chapters of AOE, but this ic never gets mentioned in that book.On the attached screenshot, the pink line is the output of the Opto, and the dark blue trace is the output of the 74HC4050. The attached circuit is what I've built on the breadboard.I've found a topic regarding a similar issue but it is still not clear whether I should add the 100-ohm resistor or not and where should I add it.https://www.eevblog.com/forum/projects/74hc4050-vs-sn74lvc125a/msg825657/#msg825657Cheers,Laszlo

author: ledtester
author_rank: Super Contributor
timestamp: September 04, 2019, 09:16:07 pm
content: 1 M is a huge value for a pull down/pull resistor - most pull-ups in logic circuits are less than 10K. With a 1M pull-down you'll get a logical state change with only microamps flowing through the transistor. I am not an EE, but it seems the circuit would be prone to false triggering in the presence of noise.Going with a smaller resistor value means you would have to expend at least a couple of milliamps through the opto-coupler led to fully turn it on.

author: fourfathom
author_rank: Super Contributor
timestamp: September 04, 2019, 09:42:22 pm
content: Quote from: Laszlo on May 29, 2019, 02:13:15 pmSo what is your of/off threshold voltage, and acceptable tolerance for that? Absolute maximum and minimum voltage? s there a good common ground between the high-voltage and the processor circuitry or will there be significant common-mode voltages? How far are these high voltage signals from the processor circuit? Optoisolators may not be necessary (although they still may be a good idea.) We can't help you optimize a circuit without knowing these parameters. I

author: ledtester
author_rank: Super Contributor
timestamp: September 04, 2019, 10:01:01 pm
content: Quote from: Laszlo on September 04, 2019, 02:47:20 pmWhere do you see the advisory about the 100R resistor? I've looked at a couple of datasheets but couldn't find any reference to it.In the 74hc4050-vs-sn74lvc125a thread is this the reference to a 100R resistor you are referring to?QuoteI think that's just to compensate for the high speed of the 74LVC when feeding it a slower varying signal.

author: Mr. Scram
author_rank: Super Contributor
timestamp: September 04, 2019, 10:03:32 pm
content: How would using an optoisolator work? I'm probably misunderstanding something but I can't imagine that being anywhere near linear.

author: fourfathom
author_rank: Super Contributor
timestamp: September 04, 2019, 10:10:34 pm
content: Quote from: Mr. Scram on September 04, 2019, 10:03:32 pmThe OP saidQuoteLinearity not required.

author: Mr. Scram
author_rank: Super Contributor
timestamp: September 05, 2019, 12:01:28 am
content: Quote from: fourfathom on September 04, 2019, 10:10:34 pmAs it turns out I was right while being an idiot.

author: ledtester
author_rank: Super Contributor
timestamp: September 05, 2019, 02:50:41 am
content: Another reason to avoid using large pull-up/pull-down resistors is that the effect of the input leakage current of a digital input pin becomes significant. At room temperature the leakage current for the 74HC4050 is only a fraction of a microamp, but over the entire temperature range it can be as high as a couple microamps. 1 uA of leakage into 1 M ohm is 1 V which is dangerously close to the 1.35V maximum for a low logic level at an input.Quote from: Laszlo on September 04, 2019, 02:47:20 pmI would try something like this:The idea is to pick R1 and D1 so that you get 2 to 10mA through the led when a high voltage is present on B+. You can create a higher voltage zener by putting two or more in series. You can also move R2 to the emitter to invert the output signal.

author: fourfathom
author_rank: Super Contributor
timestamp: September 05, 2019, 07:10:16 am
content: If you aren't too particular about the on/off voltages, you can simply use a two-resistor voltage divider feeding the opto. Say a 10K to the high voltage, and a 270 Ohm resistor to ground. Connect the 10K/270 junction to the opto diode. Opto current will start to flow around 40V and it will linearly increase to 10mA at 100V (roughly). The 10K resistor will dissipate close to 1.5W at 120V input. so you will need a power resistor. You can adjust the threshold voltage and opto current by playing with the resistor values. Put a capacitor at the opto input if you want filtering. If you use a high-sensitivity opto you can increase these resistor values significantly, reducing dissipation and current drain.The zener circuits will give you a more abrupt on/off transition.So another parameter that would be good to know is the source impedance of the high-voltage source. How much current can you draw from these sources?

author: Laszlo
author_rank: Contributor
timestamp: September 05, 2019, 02:24:43 pm
content: Quote from: fourfathom on September 05, 2019, 07:10:16 amI am trying to design it in a way so it would draw the least amount of current from the source. Under 0.5mA was my target.Quote from: ledtester on September 04, 2019, 10:01:01 pmPage 4 Figure 6. In here;https://www.nexperia.com/products/analog-logic-ics/asynchronous-interface-logic/voltage-translators-level-shifters/series/74HC4050.htmlQuote from: ledtester on September 04, 2019, 09:16:07 pmThe same issue, it would draw way too much current from source if I do that. I was/still hoping that I could make the 5V rail noise-free enough to eliminate false triggering. I've also considered using and LM324 to drive the 74HC4050, but I haven't tried that option yet.Quote from: fourfathom on September 04, 2019, 09:42:22 pm85-120Vdc is when the signal is considered to be onGrounds are fully separate on HV/LVThe HV signals and LV will be on the same PCB, with suitable separation in between them. Physical distance is negligible.I just can't think of anything else other than the opto, to provide full galvanic isolation and keeping the price at a reasonable levelTo summarize, you think I should be driving the driving the opto with more current, so it would be more stable? Is that really the only option? The circuit does work on breadboard, but I haven't tested it on the field yet. Before I start soldering, I'd like to make sure that it will have a fighting chance to perform.Thanks for all the input!Laz

author: Ian.M
author_rank: Super Contributor
timestamp: September 05, 2019, 03:18:50 pm
content: Sharp PC817X datasheetYou are running the opto in your circuit well below the recommended minimum current for If of 1mA. You are on the dotted portion of the transfer characteristic curve (datasheet fig.6), below 0.5mA, which I would read as probably being extrapolated data, not to be relied on.If you decrease the pull-down in an attempt to improve reliability, device to device variation of the opto's CTRR between batches and even on the same reel is probably going to bite you in the ass, and result in a significant number of failures. CTRR also declines with age as the LED output decreases and declines with increasing ambient temperature, so if your design doesn't have enough excess If margin, a specific individual opto that works on the bench today, in the field may not pull the output high reliably on a hot day a few years later.A major design difference is whether the input channels need to be individually isolated, or whether they can share a common ground (with each other, not the MCU side).If the latter, it would be economic use comparator ICs to provide input buffering to allow you to use much higher divider resistances and thus reduce the loading on the voltage sources you are sensing. It should be possible to go as low as 50 to 100 uA divider current without issues, if you are careful about layout, put slots under the upper divider resistors to increase creepage distance and clean the board thoroughly after assembly. Use an isolated DC-DC converter to power the comparators (and the opto-LEDs) from the Arduino side (but beware of the Arduino regulator's limited 5V output current). Add a voltage reference IC to provide a stable and well defined threshold voltage for all the comparators to switch at.If you need more than about four input channels, and you don't need a vary fast response, consider using a SPI I/O expander on the HV side of the isolation barrier and optoisolate the SPI bus. There's three lines going MCU => SPI device, and one the other way, so that only needs one quad and one single optocoupler. If your chosen I/O expander has a reset pin its probably worth hooking it up to the spare channel of the quad opto, or you could use that for a second /SS signal to access an extra I/O expander for more channels. It may be worth swapping the single opto for a double to bring the expander's IOC interrupt output (if it has one) to the MCU side so you can hook it up to an interrupt input so your code doesn't have to poll the expander continuously.

author: ledtester
author_rank: Super Contributor
timestamp: September 05, 2019, 03:43:23 pm
content: Is this a one-off or will be it mass produced?Besides driving the LED at a higher current you can reduce the value of the pull-up/down resistor by using a Darlington configuration on the low-voltage side, or use a opto-coupler that has a Darlington output.Another way to reduce to power draw on the high voltage side is to have your microcontroller use an opto-isolated signal to briefly switch in the measuring circuit when it wants to know the state of the high voltage side. A measurement should take less than a millisecond, so you can save 1000 times the power if you only need to sample the high voltage side once a second.

author: fourfathom
author_rank: Super Contributor
timestamp: September 05, 2019, 04:08:03 pm
content: Quote from: Laszlo on September 05, 2019, 02:24:43 pmYou might consider a more sensitive optoisolator. I quickly searched Digikey and found this Toshiba TLP2703 :https://www.digikey.com/product-detail/en/toshiba-semiconductor-and-storage/TLP2703-TPE/TLP2703-TPETR-ND/6051974. This one seems to work well with 0.1 mA input current. The output is a Darlington stage so the output saturation voltage won't be as high as a single-transistor output, but with 0.1 mA input current the output will sink at least 0.5 mA. Use a 47k pull-up resistor feeding your CMOS Schmitt trigger and things should be good.This device will let you scale up the input divider resistors to meet your requirements.There may be better optos, perhaps ones with built-in logic-level Schmitt trigger outputs. You should do some component research.

author: ledtester
author_rank: Super Contributor
timestamp: September 05, 2019, 08:33:54 pm
content: Quote from: Laszlo on September 05, 2019, 02:24:43 pmI think it is just showing you what the input protection circuitry looks like for the device, not that you need to use a 100R resistor on the inputs.

author: Laszlo
author_rank: Contributor
timestamp: September 09, 2019, 04:47:23 pm
content: Hi,Thanks for pointing out the different type of optos, I am new to electronics design, so most components are new to me, as well as most design quirks.I've done a little search, and a 4N32M looks also suitable (and I can get those cheap in small quantities.) This is going to be a one off trial solution, so price is a big factor for me to consider.After looking around some more, I've seen some similar circuit with a flyback diode before the optocoupler led. Can I go around this by adding an additional TVS diode after the first stage of the voltage divider?Cheers,Laszlo

author: fourfathom
author_rank: Super Contributor
timestamp: September 09, 2019, 06:01:49 pm
content: Something like this should be pretty robust, and is about as simple as you can get. The 6.2V zener will protect the optoisolator against overvoltage (over-current) and reverse-voltage. You could add a capacitor in parallel with the Zener for noise suppression, say a 0.1uF part. I have no idea if the optoisolator I picked is appropriate, but it does work in the circuit. A high-sensitivity opto would be best. To adjust the on/off switching voltage, change the value of R1 (the 150K resistor). This circuit will draw less than 1mA from your high-voltage input. You want to follow the opto with a cmos schmitt trigger.I have the input and output grounds connected together, just to make the simulation easier. You would obviously want to keep these isolated.

author: fourfathom
author_rank: Super Contributor
timestamp: September 10, 2019, 12:54:20 am
content: Quote from: fourfathom on September 09, 2019, 06:01:49 pmJust to be clear, my circuit above is far from precise, and will have a very sloppy on/off threshold. Your specifications are still quite loose, so I am assuming that any additional precision is not necessary. If you do need more precision, the previously suggested circuits that had zener diodes as voltage dropping elements will provide a sharper and better-defined switching point.Also, the zener diode and resistor values as shown will provide a good degree of protection from voltage spikes, etc, but it's entirely possible that some outsized transient might cause damage. Again, without a specification we don't know if more is required.

author: Laszlo
author_rank: Contributor
timestamp: September 10, 2019, 02:27:28 pm
content: Hi,Thanks for the input Fourfathom, it's much appreciated.Quote from: fourfathom on September 10, 2019, 12:54:20 amPrecision is not necessary. The signals are coming from various limit switches, auxiliary microswitch contacts, relays and long as the speed of switching is within 0.5s I am happy, There is the chance of odd transients, hence I was thinking a TVS is necessary.This thing will only provide an indication that certain equipment was energized, preferably by taking as little current as possible from the source. This is an absolute must requirement because it's going to be used on rolling stock and trust me, battery power is not something I want to drain offI've been working on this for quite some time now, and I've tried multiple solutions, like;Driving the Arduino straight from the Opto - what a stupid idea that wasDrving a relay from an LM324, and have the relay switch in between 10kto ground and 5vDc to the Arduino digital input. - This worked like a charm but uses too much power due to the relays and it still needed an LM324+the opto for isolation.Using an inverting Schmitt trigger, but I didn't like the idea of inverted logic.And finally the 74HC4050, and this seems to be the best solution so farI know that a single voltage divider would work in this case, but I would like to minimize the stresses on components, so I think multiple levels of attenuation with two voltage dividers+2 zeners will be something I will implement. This is where I was struggling the most because there just isn't anything I could find regarding good design practices with multiple stages of "signal" attenuation. I'd be extremely grateful if someone could point me towards a book or something where I can try to understand more about this topic. I've got Horowitses AOE, but I can't seem to find much about this in that book.Cheers,Laszlo

author: mariush
author_rank: Super Contributor
timestamp: September 10, 2019, 03:03:49 pm
content: If you want fewer components, you could look into LR8 linear regulators:http://ww1.microchip.com/downloads/en/DeviceDoc/20005399B.pdfThey can work with minimum 12v, max 440v, and they can output as little as 1.2v ...Has a 1.2v reference voltage, so if you want it to output 1.2v you only need a single resistor between output and adjust (datasheet says 2.4k) and maybe a couple capacitors at input and output.The datasheet says typical 0.3mA, max 0.5mA output current (through the adjust voltage resistor divider and the load), so it may be a bit higher heat produced if you have some optocoupler that needs less than this to operate.They're cheap at 50 cents each and they're available in to92, dpak, to243 ... yeah a zener is cheaper at less than 10 cents but maybe a regulator will be more rugged and have some additional protections inside and tolerate heat better.

author: fourfathom
author_rank: Super Contributor
timestamp: September 10, 2019, 03:10:58 pm
content: Quote from: Laszlo on September 10, 2019, 02:27:28 pmI don't think that multiple stages really buy you anything. The stress on the components can be calculated quite easily as long as your assumptions are correct. The first step is to check the power dissipation. In the simple divider the 150K resistor (or whatever value you select) will see the bulk of the power. With 150V input, the voltage across this resistor will be about 148V. That's essentially 150V, so the dissipation will be 1502/ 150,000 = 0.15W (simple Ohms Law stuff). A quarter-watt resistor will comfortably dissipate this amount of power, but you could use 1/2W part if you want even more margin or if you think the input voltage will greatly exceed 150V. The power dissipation in the rest of the components is trivial in comparison.You then look at the current in the optodiode. This is being fed by the resistive voltage divider plus the series resistor, which has an equivalent output impedance of 1K + (150K || 2.7K) = 3.65K. At 150V input, the effective voltage driving this impedance will be 2.65V. Assuming the Optodiode forward voltage is 0.9V, the input current will be (2.65 - 0.9) / 3.65K = 0.48 mA. You could double the input voltage and still be nowhere near stressing the optodiode.If you were to reverse the 150V polarity the reverse voltage at the optodiode would be -2.65V. Again, no stress on the opto. In fact, that zener or the 1K series resistor really don't add much in the way of protection -- this circuit is already pretty bulletproof.You do want to consider the high-voltage input, and make sure that the 150K resistor and connections aren't going to leak or flash-over. A common 1/4W 5% resistor will have a voltage rating of around 350V (this is not related to power dissipation). Should be OK.

author: ledtester
author_rank: Super Contributor
timestamp: September 11, 2019, 12:33:28 pm
content: In this design how necessary is R2?It seems that R2 is just an additional load on the Zener regulated power supply formed by R1 and D1.

author: Laszlo
author_rank: Contributor
timestamp: September 11, 2019, 03:07:34 pm
content: Quote from: mariush on September 10, 2019, 03:03:49 pmTried it. Also tried the TL783, but the power dissipated was greater than I wanted it to be.Quote from: fourfathom on September 10, 2019, 03:10:58 pmGreat answer. I've done the simulations, and you are right, the second voltage divider dissipates next to nothing, and the majority of the power gets "burned" at the first resistor. Built both circuits on a breadboard, and the only difference is the voltage levels in between the different stages at the divider. The first picture is the original, second is what you suggested. Ch1 is opto-led in, Ch2 is measured at the divider.The other reasons why I was thinking of doing 2 stages of attenuation is to reduce the effect of EMI on the device. For example, the last Zener clamp would do nothing other than dissipating the occasional spikes. Am I wrong in there too?Also, wouldn't an additional stage effect the ruggedness of the circuit (for example, the first resistor fails short.)?Cheers,Laszlo

author: fourfathom
author_rank: Super Contributor
timestamp: September 11, 2019, 03:28:33 pm
content: Quote from: ledtester on September 11, 2019, 12:33:28 pmR1 and r2 form the voltage divider that establishes the drive source for the opto. In normal operation the zener might as well not be there, it only serves to clamp transients that vastly exceed the positive or negative voltage input range. I doubt if you need it. You could also eliminate the series resistor going to the opto,

author: ledtester
author_rank: Super Contributor
timestamp: September 11, 2019, 08:55:33 pm
content: Quote from: fourfathom on September 11, 2019, 03:28:33 pmOk, after thinking about it here's my reasoning on why R2 is desirable -- it effectively raises the trigger voltage of the opto. If we assume the opto's LED doesn't conduct until it has a forward voltage of, say, 1V, then the voltage divider requires the input voltage to be >= 1V * 153/3 = 50V before the opto LED starts to turn on. Without R2 the LED would start to turn on at a much lower voltage.

author: Ian.M
author_rank: Super Contributor
timestamp: September 11, 2019, 09:56:56 pm
content: Also, R3 is essential if you keep the clamping Zener, but pointless if you omit it as then it simply adds to the Thévenin equivalent resistance of the R1:R2 divider.If you are going to add a second Zener, put it in series with the opto LED to give a higher and better defined threshold voltage.

author: fourfathom
author_rank: Super Contributor
timestamp: September 12, 2019, 02:47:52 am
content: Quote from: ledtester on September 11, 2019, 08:55:33 pmYes, exactly.Quote from: Ian.M on September 11, 2019, 09:56:56 pmYes.I would have been less terse in my explanation, but I was posting from my phone.Since the on/off threshold voltage requirement is so loose, I decided that the simple resistive divider (without a series Zener) would be adequate, and would make it easier to control the opto-diode current. Using a series Zener would have tightened up the switching threshold, but would have made the opto-diode current range be greater over the wide input voltage range. You can play with this in simulation to get a feel for the tradeoffs. There is no single "correct" answer.Looking at the reverse-voltage spec for the 4N32N opto, I see a -3V maximum. If you want to protect against reversed input connections (and you probably should) then you want either the Zener as shown in my schematic, or a simple diode (1N400X) reverse-polarity across the opto-diode. The forward current spec is high enough that you really don't need the Zener or the series resistor R3. If you eliminate R3 you could increase the values of R1 and R2, which has the benefit of reducing the load on your input. By the way, that 4N32N opto isn't particularly sensitive, but it should work OK.As far as worrying about the ruggedness of the components, as long as the voltage and power dissipation specs are kept in mind there isn't really anything to worry about. To be extra-sure you could specify a special high-voltage resistor for R1, or use two 1/4W 75K resistors in series to double the power and standoff-voltage values. Component layout and human factors will be more critical than component failure.

author: fourfathom
author_rank: Super Contributor
timestamp: September 12, 2019, 05:00:28 pm
content: Quote from: Laszlo on September 11, 2019, 03:07:34 pmHere's a simplified schematic. The opto is just one chosen at random from the LTSpice library, there are no doubt more sensitive ones available. I used a 1N4148 diode to clamp the reverse voltage, and even with 1 1KV sinewave applied the opto and D1 currents are under 6mA. Of course at 1KV, R1 is getting fried. Remember that with this simple resistive divider the switching threshold is not tightly controlled.EMI suppression can be accomplished with a simple 0.1uF capacitor across the opto-diode. With the approx 4K effective source resistance the -3dB frequency will be around 300Hz. Any EMI in to 100 KHz-100 MHz will be well-suppressed. For EMI over 100 MHz you might want a 0.01uF cap in parallel with the 0.1uF part. For really bad EMI we can give you advice on more effective filters, but for normal bad EMI the single capacitor should work well. Also, if your opto has the base of the phototransistor brought out (as does the one in my schematic), you can tie this to the output-side emitter through a small capacitor (say 0.01uF) to provide additional noise filtering. This will slow down the on/off switching time, but since you are following this section with a Schmitt trigger this shouldn't matter.