Pages: 1 [2] 3 4   Go Down
Author Topic: Analog switch IC behavior  (Read 3206 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 15
Posts: 477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I assume that is with PWM. You can not get that directly, you will have to filter the PWM first. PWM is a digital signal that goes from 0 to 5V all the time. The analogue write just controls the ratio of high to low.

It is, and although this was a concern of mine, it appears to work flawlessly. You can see an example here:



I originally intended to filter the output with a capacitor, but I lack the basic knowledge to design a network to filter the output correctly, so I just plugged it up and gave it a try. I'm still a little suspicious of feeding a PWM signal into an input that isn't expecting it. My preferred approach would be to use a digital pot, but (long story short) I can't find a digital pot that meets the requirements of this application. (If you are interested in reading more about why I can't find a digital pot that works, there is a thread here: http://forums.adafruit.com/viewtopic.php?f=25&t=43053) There are various other approaches that I've tried, and some others that could work that I haven't tried, but as long as the PWM appears to be working, I've decided to put my effort towards other parts of the project.

I haven't actually welded with the Arduino controlling the output yet, so it's still possible that the display is showing an "averaged" output value, but the actual output is swinging high/low in sync with the PWM. I think this is unlikely, though, because I used to feed 0 to 2.7 volts PWM into the welder, and it showed the correct output value on the screen. Then I switched to feeding 0 to 5 volts PWM through a voltage divider (pulling max output down to 2.7), and the same output value was shown. If the welder was tracking the actual voltage (vs. the averaged PWM voltage), I would expect to see a different output on the display between these scenarios, since in one case the actual voltage was swinging to 5v, and in the other it was swinging to a true 2.7v. Nevertheless, the final test will be actually welding with the unit.
« Last Edit: September 14, 2013, 06:34:15 pm by joshuabardwell » Logged

Offline Offline
Sr. Member
****
Karma: 15
Posts: 477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would suggest that all lines that you want to cut and insert a switch of some sort, or switches you want to parallel you do with a relay.
Any series switching resistance means you are open to noise being included on the switched signal, and a welder of any sort has a lot of noise.
This ensures no worries low resistance connection and isolation between controller and machine and no ground reference problems.
I gather these connections are low voltage low current so small a number of relays built on an interface board would do the job.

I 100% agree with you. Going into this project, I was a bit confused as to why one would choose a relay vs. an analog switch IC vs. a transistor for signal-level switching, but I am quickly coming to see the deficits in switches that are not galvanically isolated from the controlled circuit.

Quote
I understand that you want to control the wiper input to the welder, have you found the ground of the welder control board that you are trying to control.

What is the voltage on Pin 3 and Pin 5 with respect to the welder ground? This very important.

That is a good question. I am taking ground from pin 3 of the connection, which is the negative leg of the pot circuit. I originally did that because the voltage difference between pin 3 and pin 4 is what controls the output of the welder, so it was necessary to match pin 3 to the Arduino's ground so as to allow the Arduino's PWM output to range from 0-max volts relative to the welder's 0-volt reference. Whether the welder's 0-volt reference for pin 3 is the same as the general ground for the welder is something that I don't know, nor do I know how I would determine that.

You know, I do have a thought: the welder has a ground lug on the back of it, for use in case the welder's high-frequency output is causing interference with electronic devices. Sort of, by definition, this lug should be the same as the welder's ground, shouldn't it? I could easily take a voltage reading between the grounding lug and pin 3.

Quote
As Grumpy_Mike says, you will have to filter the PWM output to get a smooth DC voltage that is the same as what is supplied by the potentiometer.

It'd be rude to ask you to do my homework for me, and I wouldn't learn anything, so instead, can you maybe point me to a reference to begin learning how to build a filter circuit to do this? I assume it'll involve capacitors? That's about the level of knowledge I'm starting with.

PS: I played around with a circuit simulator, feeding a PWM signal through a capacitor, and part of the challenge was that a circuit that stabilized within a relatively narrow voltage range took a long time to respond to changes in PWM duty cycle, and responsive circuits had too much variation in their output. The welder's output range is between 0 and 160 amps, so ideally, a circuit would have 2.7v / 160 discrete steps = 16 mV / step, in order to achieve 1-amp output resolution. Designing a circuit with such resolution, and with sufficient responsiveness for welding, is totally beyond my current abilities.

Thanks much for your input.
« Last Edit: September 14, 2013, 06:43:15 pm by joshuabardwell » Logged

Offline Offline
Sr. Member
****
Karma: 15
Posts: 477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I measured voltage between the welder's ground lug and the grounding pin of the power plug, and as expected, it was 0v. I measured voltage between pin 3 of the remote connector and the ground lug and got no consistent voltage value. The multimeter just flopped around in the sub-100 mV range as if it was hunting for a reading.
Logged

Offline Offline
Sr. Member
****
Karma: 15
Posts: 477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

... still thinking about this: what if I was to install an optically-isolated relay between the Vcc and the wiper pin of the potentiometer circuit, then feed the relay with a PWM signal to modulate the amount of voltage that was seen on the wiper pin? In this case, it seems like I would dodge any issues with matching the ground of the Arduino with the ground of the welder, although any potential issues with PWM signal would remain. This assumes that the relay has fast enough switching speed to keep up with the PWM signal. IIRC, the Uno's PWM frequency is something like 500 Hz, so that's a 1 kHz signal, or sub-ms switch time. A relay like the CPC1219Y has a listed max switch time of 5 ms, but the detailed charts show a more typical time of around 0.5 ms, with outliers around 0.7 ms, so perhaps it could work.
« Last Edit: September 15, 2013, 01:32:51 am by joshuabardwell » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

... still thinking about this: what if I was to install an optically-isolated relay between the Vcc and the wiper pin of the potentiometer circuit, then feed the relay with a PWM signal to modulate the amount of voltage that was seen on the wiper pin? In this case, it seems like I would dodge any issues with matching the ground of the Arduino with the ground of the welder, although any potential issues with PWM signal would remain. This assumes that the relay has fast enough switching speed to keep up with the PWM signal. IIRC, the Uno's PWM frequency is something like 500 Hz, so that's a 1 kHz signal, or sub-ms switch time. A relay like the CPC1219Y has a listed max switch time of 5 ms, but the detailed charts show a more typical time of around 0.5 ms, with outliers around 0.7 ms, so perhaps it could work.

I suggest two opto isolators (or one dual opto isolator) configured as in the attached schematic. Choose R to be about half the value of the recommended potentiometer, and the product R * C to be about 0.1 to 0.2 seconds.

For the switches, use either opto isolators (if you can find a polarity that works), or reed relays.


* Scan 202.JPG (68.35 KB, 1653x1165 - viewed 60 times.)
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Sr. Member
****
Karma: 15
Posts: 477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your circuit is kind of blowing my mind a little bit.  smiley-eek-blue

Am I correct that the optical isolators are supposed to turn on and off opposite of each other? When Dout is LOW, there is 5v across the top isolator and it is closed, and there is 0v across the bottom isolator and it is open. When Dout is HIGH, there is 5v on both sides of the top isolator, so 0v across it, and it is open. There is 5v across the bottom isolator and it is closed. This is part of what is blowing my miind: that you could disable a switch by putting 5v on BOTH sides of it, creating 0v across it, vs. pulling both sides to ground. That never occurred to me.

So if I understand correctly, when fed a PWM signal, this circuit will basically switch R from between Vcc/wiper and wiper/Gnd according to the PWM duty cycle. You've diagrammed a potentiometer that is controlled by a PWM output. This is really brilliant. I had the idea to do exactly this, but lacked the knowledge to actually realize it.

Can you elaborate on the purpose of the capacitor? Is it for noise protection on the signal circuit, or some other purpose?
« Last Edit: September 15, 2013, 11:37:45 am by joshuabardwell » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Your circuit is kind of blowing my mind a little bit.  smiley-eek-blue

Am I correct that the optical isolators are supposed to turn on and off opposite of each other? When Dout is LOW, there is 5v across the top isolator and it is closed, and there is 0v across the bottom isolator and it is open. When Dout is HIGH, there is 5v on both sides of the top isolator, so 0v across it, and it is open. There is 5v across the bottom isolator and it is closed. This is part of what is blowing my miind: that you could disable a switch by putting 5v on BOTH sides of it, creating 0v across it, vs. pulling both sides to ground. That never occurred to me.

So if I understand correctly, when fed a PWM signal, this circuit will basically switch R from between Vcc/wiper and wiper/Gnd according to the PWM duty cycle. You've diagrammed a potentiometer that is controlled by a PWM output.

You got it.

Can you elaborate on the purpose of the capacitor? Is it for noise protection on the signal circuit, or some other purpose?

The capacitor smooths the PWM to produce DC (with a small ripple), so as to simulate what a potentiometer would do.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Sr. Member
****
Karma: 15
Posts: 477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The capacitor smooths the PWM to produce DC (with a small ripple), so as to simulate what a potentiometer would do.

Is there a formula that gives the relationship between the capacitor value and the frequency of the signal that would pass through vs. being smoothed? I think your C*R = 0.1s relationship probably touches on this. I realize that in reality, there won't be a fixed frequency threshold at which the signal switches from un-touched to smoothed, but perhaps there is a general engineering guideline, such as, "to pass a signal of frequency X, use a C*R value of X*N", or vice-versa, "to smooth a signal of frequency Y, use a C*R value of Y*N."

The capacitor on the wiper of the pot in your circuit looks just like the capacitor on the "tone" knob of an electric guitar. Although we are talking in terms of "smoothng" a PWM signal, would it also be true to say that we're designing a very rudimentary low-pass or high-pass filter?
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, it's a "first order low pass filter" (google that for more info). The corner frequency is given by f = 1/(2 * pi * C * R). Roughly speaking, frequencies below this will pass, and frequencies above this will be attenuated (the higher the frequency, the more the attenuation). I suggest you design for a corner frequency of 2 or 3 Hz so as to give a reasonably fast response to changes, but to severely attenuate the 490Hz PWm frequency.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Sr. Member
****
Karma: 15
Posts: 477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I will do the googling you suggested--thanks for the search terms.

I'm asking about the pass frequency because an additional goal of the project is to implement pulsed output in the welder. With pulsed output, the welder's output varies between a high and low value at a configured frequency and duty cycle, similar to PWM. Welders that are designed to pulse may have pulse frequencies between 0.5 and 250 or even 500 Hz. My welder is not designed to pulse, but I spoke with an engineer at the manufacturer, and he said that it would be okay to implement pulsing frequencies of as high as 10-30 Hz via the remote-control pins.

So, the ideal filter would be one that would pass the 10-30 Hz (max) pulse frequency relatively unchanged, while smoothing the 500 Hz PWM frequency. Is this something that could be accomplished with a first-order filter, or would that really be more in the realm of more sophisticated electronics?
« Last Edit: September 15, 2013, 01:31:54 pm by joshuabardwell » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want to pulse at 30Hz, then you need to increase the PWM frequency. See http://playground.arduino.cc/Main/TimerPWMCheatsheet.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Sr. Member
****
Karma: 15
Posts: 477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want to pulse at 30Hz, then you need to increase the PWM frequency.

Huh. I guess I thought 500 Hz PWM would be adequate for 30 Hz pulsing. I have a lot to learn. Frankly, I hadn't put a lot of thought into it yet, as I have been preoccupied with more fundamental aspects of the project. I see that 500 / 30 = only 16 samples / Hz. Not very good.

Increasing the PWM frequency will have the additional advantage of making it easier to filter it out while leaving the 30 Hz pulse frequency. Ah, but I guess the flip-side is that I will need to use opto-isolators that have a high enough rated bandwidth.
« Last Edit: September 15, 2013, 04:15:10 pm by joshuabardwell » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Increasing the PWM frequency will have the additional advantage of making it easier to filter it out while leaving the 30 Hz pulse frequency. Ah, but I guess the flip-side is that I will need to use opto-isolators that have a high enough rated bandwidth.

Correct on both counts. I suggest you use a PWM frequency of 3906.25Hz, which is a value you can get from the PWM pins associated with timer 1 and timer 2.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Sr. Member
****
Karma: 15
Posts: 477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Correct on both counts. I suggest you use a PWM frequency of 3906.25Hz, which is a value you can get from the PWM pins associated with timer 1 and timer 2.

This gives a period of 256 ns, and since there are two clock edges per period, this would require an opto-isolator with at most 128 ns on/off time (and, realistically, somewhat less than that) Correct?

EDIT: Holy cow! The cheapest "high-speed" optical isolator on Mouser is nearly $8, although it does have a 50-100 ns on/off time.
« Last Edit: September 15, 2013, 04:55:13 pm by joshuabardwell » Logged

Offline Offline
Sr. Member
****
Karma: 15
Posts: 477
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To eliminate the need for high-speed opto-isolators ($$$), could I put the low-pass filter on the PWM output pin instead? That way I would only need opto-isolators capable of handling the pulse frequency vs. the PWM frequency. Based on my research, it also sounds like it would be advantageous to swtich the PWM mode to "fast PWM" so as to double the frequency of the signal, and increase the attenuation/smoothing through the filter. This would be the opposite of what I would want to do if I was passing the raw PWM signal through the isolator and filtering on the welder side.
« Last Edit: September 16, 2013, 12:20:55 am by joshuabardwell » Logged

Pages: 1 [2] 3 4   Go Up
Jump to: