# Switching Led

Discussion in 'General Electronics Chat' started by willeng, Jul 4, 2014.

1. ### MrAlWell-Known MemberMost Helpful Member

Joined:
Sep 7, 2008
Messages:
11,032
Likes:
952
Location:
NJ
Hi,

What triac circuit were you referring to?

All microcontrollers support floating point, if you dont need super fast response. You use a floating point library.
Do you have any idea what the fastest response you need is?

Triac phase control is very simple in principle. The triac is not turned on until some time after the zero crossing. For example, say we want about 50 percent power which would mean slowing a motor down. Here we would not turn on the triac until the voltage wave reached 90 degrees, and then it would turn on, then later turn off near 180 degrees assuming a mostly resistive load. Then we also turn it back on at 270 degrees (the half way point of the negative half cycle) and later it would turn off at 360 degrees. We then repeat that.
If we wanted more power, we would turn it on sooner, like say at 45 degrees and again at 180+45 degrees. If we wanted less power then we would turn it on say at 120 degrees and then later again at 180+120 degrees.
So we do the same for both half cycles, and change the delay according to what speed we want. If we detect the zero crossing then the delay is the same for both half cycles so that makes it a little easier.

When you turn the triac completely on and off then you dont have to generate a delay. This means you turn it on for a rather lengthy time, then turn it off for a good amount of time too. That's when you dont need speed control of the motor.
You might call this pulse skipping modulation.
It depends how the rest of the system works. If the vacuum builds up slowly then you would have to keep the motor on for some time anyway, so you would not need phase control of the triac. The motor would run for several seconds and then turn off and stay off for several seconds typically.

Last edited: Jul 8, 2014

Joined:
Oct 30, 2010
Messages:
9,918
Likes:
1,098
3. ### MrAlWell-Known MemberMost Helpful Member

Joined:
Sep 7, 2008
Messages:
11,032
Likes:
952
Location:
NJ
Hi,

I am pretty sure universal motors have brushes, therefore they can be controlled with a triac using phase control. There are products on the market which do this, and i've built several over the years using different topologies, one being for a rather heavy duty 120vac motor. Seems to work pretty well for speed control.

Joined:
Jan 12, 1997
Messages:
-
Likes:
0

5. ### KeepItSimpleStupidWell-Known MemberMost Helpful Member

Joined:
Oct 30, 2010
Messages:
9,918
Likes:
1,098

OK, I want to try to sell the PWM method because I think it's easier for rookie. Then I'll come back to PID.

So, I envision modifying two Velleimen kits to provide PWM and optoisolation and run at 240 VDC. To get the DC, one can use an isolation or buck-boost transformer. You'll end up with, I think, a 0-5V signal for 0 to 100%. The SAME end device can be used to play as well as being the end device used.

==

So, for testing I used a 500 W light bulb with a thermocouple sitting on top of it. It has very fast response time and you can instantly SEE the results. With a limited temperature range, you should be able to get away with a cheap thermister taped to the top of the bulb (base down usually) with Kapton tape. They are usually the Mongul (E39?), or bigger base. You also might be able to use the same or similar signal conditioning. Who knows. Kapton will withstand 200 C easily and peel away without leaving a mess. I used it all the time. A roll is about $18.00 USD. The thermister would use a simple voltage divider. You don;t have to care about temperature, just the output of the voltage divider. == I'm not against triac control. But a onesee, twosee thing with most of the stuff done for you, it doesn't seem that bad. You might have some troubles with stiction (static friction) and finding a frequency that works for the motor, but I don't think it would be too hard. Adds another constant for PID. Now, I don;t know if MOSFETS or IGBT's have to be used. With rectification, you get the peak value of 240 * 1.414 or 339 V DC. If you knocked 100 V+ off that, you would be good. Off the top of my head, I can;t remember the AC to DC current relationship to size the transformer. There is other losses missed like the diode losses and FET and diode. Does this make ANY sense? I'm not the simulating (LTSPICE) type, unfortunately. 6. ### KeepItSimpleStupidWell-Known MemberMost Helpful Member Joined: Oct 30, 2010 Messages: 9,918 Likes: 1,098 The Arduino might not be a bad platform to develop on. I got the Due and at least did the "hello world" program. One of the reasons to select the Due, I think, is that you may be able to use another emulator to replace the built in one and do a simple ASCII Art type of plot of measured variable vs time. This would be invaluable setting up the PID constants. I don't think you really need it, but you can make an ersatz strip chart recorder just using 80 columns and an infinite number if lines. 80 character is turned into measured variable and each line is a chunk of time. VT100 emulation gives you the ability to direct cursor address a 24 line by 80 character area of the screen. In the 8 loop PID system I wrote we decided to use indications for heating (+), cooling (-), conditionally stable (~), stable (=), (limits), open TC. Stability criteria was defined elsewhere as, it's conditionally stable if the temperature was within +- x degrees and stable if it has been there for a defined amount of time. We had a loop time on the order of seconds. It was like 6 s if I remember. This was mostly dependent on a 9600 baud serial link to measure all of the variables. There has been a multipart series about Makerplot http://makerplot.com/ in the Nuts and Volts Magazine lately which is an interesting option. 7. ### willengMember Joined: Jul 5, 2012 Messages: 303 Likes: 3 Thanks for the replies once again, I will have to go back & read them. Sorry for the delayed response. I have had trouble trying to find a suitable Triac locally so I can run all four motors together to test to see if the vacuum is proportional to voltage or current. I couldn't find a Triac so I thought a dual Potentiometer would allow me to control my two existing Triac circuits together instead of independently running all four motors together at the same speed or closer to it. After rewiring things to suit I ran a few tests & had some issues with the DMM reading the voltage from the Triacs to the Motors, I guess this is due to trying to read partial ac waveforms? After persisting I have some results which I will attach, the Power consumed at Maxium settings is around 4kW-APProx 5.3 HP, much less for test purposes. Cheers #### Attached Files: • ###### Test Bench Power Draw.PNG File size: 45.1 KB Views: 124 8. ### KeepItSimpleStupidWell-Known MemberMost Helpful Member Joined: Oct 30, 2010 Messages: 9,918 Likes: 1,098 Voltages and current wont be close unless you use a TRMS meter. The mains current and voltage is a good idea of power. The initial one sort of shows, an unloaded condition. . It's fairly linear given that your probably not measuring the RMS voltage. The currents are near each other rather than orders of magnitude apart which MAY mean finer control is necessary. 240 * I really doesn't alter the shape of the vacuum(current) curve. It could easily be vacuum(current * 240) or vacuum is likely proportional somewhat to power. Forget about V^2, unless you have a TRMS meter. We used normal meters too, but we knew they were wrong. It did provide info though, like a thermocouple is out of place. For one experiment we had to use a three phase power monitor (using only one phase) though, Nice. 9. ### willengMember Joined: Jul 5, 2012 Messages: 303 Likes: 3 MrAl, Triac circuits on the top of the previous page-Images. Yes Power control is quite simple in theory, it's like building an 800hp engine quite simple in theory but it's in the knowing of things that makes it a reality. I know how it works & am working on a circuit to make it work but that's a different story, later on that one. Kiss, If I go to primitive with a control system I may as well use a generator & use a foot pedal to control the rpm to the desired voltage setting on the test bench, haha joke of course--maybe. Thinking about this I just tried controlling my existing Triac circuits with an LDR in series with a resistor instead of the potentiometer & it works nicely, so why can't I revise my existing Triac circuit & get it isolated from the mains & with a suitable closed loop circuit control a super bright LED via PWM for the Power control. Ok granted the LDR isn't the fastest responding item that's available but stability should be ok. This way my original idea of a PLL controller may well work out I like the idea of PLL. Some thought's on this? I know I can buy things but to me this is about learning about control systems not off the shelf items. I test things in unusual ways that have served me well so I need to control things the way I test which is far from the norm. The only way I can do this is by learning more. After all I thought this is what this forum was about, it seems as soon as you mention mains power everybody runs & hides, I have been working with mains power my entire life & know the dangers only to well. High Hp engines on the dyno are very dangerous as well & each needs to be respected in there own right. Cheers 10. ### KeepItSimpleStupidWell-Known MemberMost Helpful Member Joined: Oct 30, 2010 Messages: 9,918 Likes: 1,098 I worked on vacuum tube shunt tube regulators (15 kV at 1.5 A). Equipment took 3 phase 50 A 240 V. A similar beast took 3 phase 70 A. Then there was the 100 kV supply at 0.1 A for generating X-rays and, of course, the 1000 W, tube RF transmitter. And don;t forget the goofy light bulbs - 1000 W (22 V 45 A), but it take 45 kV to get them to start. One false move and your dead. Then there was this early Scanning Electron Microscope from Japan. Used lots of 741 OP amps. Fun to fix. Not scared of a little mains. One equipment cabinet got 208 3 phase, 200A. An entire branch circuit. Last edited: Jul 9, 2014 11. ### willengMember Joined: Jul 5, 2012 Messages: 303 Likes: 3 Yes it can be very nasty indeed, 240V will do me except for some CDI ignitions I am building to test out, but that's small scale compared to what you mention. My son is a mechanic by trade & now a qualified linesman working with HT lines all the time, scares me to think about it. Can't seem to get an answer to my questions so i'll draw my circuit & post it to see what you think. Cheers 12. ### KeepItSimpleStupidWell-Known MemberMost Helpful Member Joined: Oct 30, 2010 Messages: 9,918 Likes: 1,098 PWMing the LED MIGHT work. I was unable to comprehend (nasty migraine) what you wrote in post #48 when I read it first. 13. ### willengMember Joined: Jul 5, 2012 Messages: 303 Likes: 3 Could you give me some thoughts about if this part of the circuit might work ok to control the LED to vary the resistance of the LDR which controls the Triac circuit & Motor speed. It's only the first part of the complete circuit, it's not PWM as such but instead the frequency of the pulse to the LED increases until the pulse is in phase with the reference frequency. I hope people didn't take my comment about mentioning when mains power is mentioned everybody drops out, I was referring to how many people don't answer due to the dangers of mains power which makes it difficult to learn. No smart remark from me as such. I can make a PWM circuit but just wondering how this would go? Cheers Last edited: Jul 10, 2014 14. ### KeepItSimpleStupidWell-Known MemberMost Helpful Member Joined: Oct 30, 2010 Messages: 9,918 Likes: 1,098 This is really encouraging. if you already did PID control before, then for the most part, you should be set. Maybe, you missed a few tweeks. My guess, Reset windup is probably one of them. The output is usually called p and p varies from 0 to 100%. Some things that help PID along is to scale the constants so they are in repeats/min, so you can change the loop rate independently. Graphing is good because it tells you that you have tuned it properly. p0 is another useful parameter. This would be the output when first turned on. So, if the motor didn't move at 1%, you can make 20%, the start. Pmin and Pmax are also useful for PID. In one of the hardware PID controllers I used, you could set the maximum output of the error amplifier. All of these things help PID along. So, foes voltage compensation control on V squared and current limits help the output along. If this was an aquarium heater, you don;t need much but on/off and a properly sized heater (W/gallon). My programiing partner and I did the unthinkable in the mid 80's. We used like a$10K USD computer and acquisition system and spent 9 months programming in FORTRAN making a 7 loop PID controller with recipes in 64K 16 bit words of memory. We were responsible for the overlays. We wanted to use an unfamiliar OS because of it's better memory management but were turned down by management. We also wanted to use C. These loops did voltage, current, power, temperature control all at the same time. We also addded a heat up energy limit and computed that energy. I even anticipated spreadsheets before they even existed.

Later, someone wrote a FORTRAN program that would create the recipes with a few inputs. Like all, things the parts don;t last forever, BTW, this was my very first FORTRAN program. My first C program was an Operating System.

15. ### willengMember

Joined:
Jul 5, 2012
Messages:
303
Likes:
3
Kiss, it would appear we posted at about the same time.

Could you have a look at the circuit I posted, just before your last post.

Cheers

16. ### KeepItSimpleStupidWell-Known MemberMost Helpful Member

Joined:
Oct 30, 2010
Messages:
9,918
Likes:
1,098
Just missed ya. I never played with PLL's, but I have another idea that might be worthwhile thinking about.

it's something that i want to use for a project. Use a FET optocoupler where the control, say 0-5 V, makes a certain voltage across the FET essentially simulating a potentiometer.
The FET opto is good for 300 ohms to 300 Megs. I might be barking up the wrong tree though.

It's nearly 3:00 AM in the morning where I am, and I SHOULD really be asleep. MrAl and I are in the same time zone hence the sense of antsyness. You post, I sleep. then we don;t see it again for awhile.
This stuff is like bedtime relaxation, believe it or not.

Last edited: Jul 9, 2014
17. ### willengMember

Joined:
Jul 5, 2012
Messages:
303
Likes:
3
The Arduino PID I did before turned out to be to slow to react, it would move up & down to set points with no issues at all besides the time taken, the initial response was good but then varying the set points to different values quickly the PID was slow to react.
I will build an analogue PID & study it before looking into a software version again, best to know what your looking at instead of jumping in head first unaware of things like I did before.

Not really getting anywhere with this so i'll keep drawing my circuits in the hope someone will bash me on the head & point me in the right direction..

Cheers

18. ### willengMember

Joined:
Jul 5, 2012
Messages:
303
Likes:
3
I finally found some information on phase control regarding SCR's with an explanation on how the delay is created once zero crossing is detected, now it makes sense to me & at least I understand in part how it works.
The mention of the Arduino again has made me have a look at was I was doing before with the PID, could I get some help with this & properly control something before moving on?

I started before using a LM35 Temperature sensor & using a small dc motor with a model aircraft propeller on the shaft to control temperature, the response time of the LM35 is very slow.

I then attempted to control motor speed using a small eddy current brake that I made, basically I have an aluminium disc-rotor on the shaft of a small 12v dc motor with 4 holes drilled in the outer edge of it for an optical tacho pickup. I couldn't work out how to get the Arduino to sense frequency from the Tacho so I used a frequency to voltage converter to sense voltage, which was a mistake I believe.
To run the unit I selected a set point using a pot & then could perform several procedures from the set point with the push of a button. The control on the brake was PWM into a transistor which supplied the current for the brake coil. Like I mentioned it worked very well & fast & stable to set point but slow to respond when performing the procedures I wanted to run.

Is there something I can setup that is quick to respond so I can try again, I have a few things here.

The Arduino I have is the MEGA 2560.

Cheers

19. ### KeepItSimpleStupidWell-Known MemberMost Helpful Member

Joined:
Oct 30, 2010
Messages:
9,918
Likes:
1,098
Sorry: equations didn't turn out. LATEX broken. Type the code in the text box on this http://www.codecogs.com/eqnedit.php website to see the resulting equation.

This is what would happen if you didn't clamp the integrated term. Recovery would be very long.

Remember this
term. The integral of the error.

The LATEX code is: \int \frac{\mathrm{de} }{\mathrm{d} t}

With the error large the integral of the error can grow unbounded. There is absolutely NO REASON for it to be greater than 100%. No point at all. You have to clamp it at 100%.. Better yet, you can clamp the integral term at 100%-(proportional term).

This is the same as the power supply limits of an analog controller.

Think of the integral term going to 1,000,000. How much time would it take to get it back to a reasonable level. Lots.

Does this make ANY sense?

Fixing that, ought to make your controller behave, Adding graphing, would verify that it is behaving.

Two other variables are worth adding:

P0 = the initial output

is also useful.

The LATEX code is: \frac{\mathrm{dp} }{\mathrm{d} t}

The 2560 is kinda close to the Due. Same shield anyway.

I suppose your in the uk (time and 240 vac) but not sure. Can you locate a thermister that can read from say 25 to 200C and a 500 W lamp and base? Don't buy anything yet?

Can you locate your PID Sketch?

Last edited: Jul 10, 2014
20. ### willengMember

Joined:
Jul 5, 2012
Messages:
303
Likes:
3
Kiss,

Yes I have a 240V 500W lamp & base, it's a small lamp out of an old projector.
I have some Thermistors, I can't find any datasheets on them to find the ratings, I have a TDC 210 which has around 1K resistance at room temp, I have more but with decreasing numbers 150, 110 etc.

You said, don't buy anything yet, I wish it was that simple I live about an hour away from civilisation & can't buy anything in a hurry. Australia actually.

Yes, I will have a look to see if I have the PID sketch, it's saved somewhere?

Doesn't the Thermistor have a slow response to temp & changing resistance?
I have some K Type Thermocouples as well that I use for my engine if of any use?

Cheers

Joined:
Oct 30, 2010
Messages:
9,918
Likes:
1,098