Pages: 1 [2]   Go Down
Author Topic: Using Arduino instead of a TL494  (Read 3688 times)
0 Members and 1 Guest are viewing this topic.
Italy
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino = Tecnologia
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A couple of MM??? What??? is impossible... it will be around 1/3 cm...

The P and D constants are a user defined costants or Potentiometer constants.

i don't understands this two lines of codes:

Quote
int pwmOutput = 128 + P * error + D * (error - oldError) + I * accumulatedError;
analogWrite(outputPin, (pwmOutput < 0) ? 0 : (pwmOutput > 255) ? 255 : pwmOutput);

It's possible to regulate the P D and I constants automatically???
you may better describe the three variables P D and I?

Thank You smiley
Logged

Se ritieni che la mia risposta ti abbia aiutato a risolvere il problema non esitare! ringraziami dandomi il Karma! smiley-wink
_-_-_-_-_-_-_-_-_-_-_-

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24322
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
int pwmOutput = 128 + P * error + D * (error - oldError) + I * accumulatedError;
Simple PID.

This:
Code:
analogWrite(outputPin, (pwmOutput < 0) ? 0 : (pwmOutput > 255) ? 255 : pwmOutput);
is simply setting up the PWM, making sure it doesn't write a value less than zero or greater than 255.

Quote
A couple of MM??? What??? is impossible... it will be around 1/3 cm...
2mm vs 3.3mm doesn't seem to me to be that big a deal.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Italy
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino = Tecnologia
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't understand...why 3 mm?
Logged

Se ritieni che la mia risposta ti abbia aiutato a risolvere il problema non esitare! ringraziami dandomi il Karma! smiley-wink
_-_-_-_-_-_-_-_-_-_-_-

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24322
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't understand...why 3 mm?
You said a third of a centimetre, which is 3.3mm
Quote
it will be around 1/3 cm.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Depends on size of the magnet, weight of the object to be levitated. Magnetic force decrease at square of the distance.

Logged

Italy
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino = Tecnologia
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For Example, if i use similar electromagnet and magnet used in this site: http://uzzors2k.4hv.org/index.php?page=magneticlevitation
I could get similar effects??
Logged

Se ritieni che la mia risposta ti abbia aiutato a risolvere il problema non esitare! ringraziami dandomi il Karma! smiley-wink
_-_-_-_-_-_-_-_-_-_-_-

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, you could get similar effects, if your electromagnet and magnet are as strong as the ones used in those pictures.
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.

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

you may better describe the three variables P D and I?

If you google for "pid controller" you will find articles explaining the roles of P, D and I. With any luck, the system will be stable with I=0 and D=0, if you have a suitable value of P. Then you can add enough I to make the levitation height independent of weight, and then enough D to cancel the oscillatory behaviour that adding the I term introduces. Using the TL494 is probably equivalent to having the P term only.
« Last Edit: September 02, 2011, 07:25:58 am by dc42 » 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.

Italy
Offline Offline
Full Member
***
Karma: 0
Posts: 158
Arduino = Tecnologia
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all...now i'm going to make a STRONG electromagnet to use in this project...any suggestions???
Logged

Se ritieni che la mia risposta ti abbia aiutato a risolvere il problema non esitare! ringraziami dandomi il Karma! smiley-wink
_-_-_-_-_-_-_-_-_-_-_-

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

1. Further to my previous post, I note that the Wikipedia article at http://en.wikipedia.org/wiki/PID_controller has a section on tuning P, I and D.

2. Re the electromagnet, following a few links from the one you gave I found http://www.coilgun.info/levitation/liftingcoil.htm which is fairly detailed.
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.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31431
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Magnetic force decrease at square of the distance.
Well actually inverse cube, see:-
http://www.physicsforums.com/showthread.php?t=450414

Quote
i'm going to make a STRONG electromagnet to use in this project...any suggestions
Lots of turns and a soft iron core, make sure the field is not going to saturate your core. However, as you will want to be able to turn it off quickly then as few turns as possible. This points to using as high a voltage as you can. One problem you will find is that you can't just turn on an off a field it takes time to build up as the current builds up in the inductor. Make this inductive time constant short compared with the mechanical movement of your target. Do use a ball bearing anything else is going to be so tricky it will not work.
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

However, as you will want to be able to turn it off quickly then as few turns as possible. This points to using as high a voltage as you can. One problem you will find is that you can't just turn on an off a field it takes time to build up as the current builds up in the inductor. Make this inductive time constant short compared with the mechanical movement of your target.

Actually, if you do the sums, you will find that it makes no difference at all whether you use a large number of turns of thin wire/high voltage/low current or a low number of turns of thick wire/low voltage/high current, if the cross-sectional packing efficiency (i.e. copper area divided by total area) is the same for both cases. On the other hand, switching (say ) 80v @ 2A with a mosfet will generally give lower losses than switching 20v @ 8A. I say "generally" because the gate charge will be higher at the high voltage due to the Miller effect; but as the PWM interval should be much lower than the switching time in this case, I think losses due to the on-resistance of the mosfet will dominate.

You can get a faster current decay by putting a resistor in series with the flyback diode, at the expense of increasing the peak Vds seen by the mosfet.

I think it's quite difficult if not impossible to saturate the core when using an open magnetic circuit.
« Last Edit: September 02, 2011, 12:04:19 pm by dc42 » 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.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31431
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You can get a faster current decay by putting a resistor in series with the flyback diode,
So by slowing down the rate the inverse current decays you get faster decay?

Having re invented physics can you tell me why my stepping motors can run faster with high voltages and chopping current limiting rather than a low voltage on for the whole of the step size?
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

So by slowing down the rate the inverse current decays you get faster decay?

Mike, if you are going to accuse people of re-inventing physics (especially people who have a PhD in physics), the least you should do is work out or look up the physics yourself first.

Your assumption appears to be that putting a resistor in series with the diode slows down the rate of decay. Basic physics tell us it has the reverse effect. If we ignore iron losses and capacitance, we can model the solenoid as a perfect inductor in series with a resistor. The rate of change of current in an inductor is given by V/L. When the transistor or mosfet switches off, the current in the inductor is unable to change instantaneously and the inductor produces enough back EMF to maintain the same current flow (through the diode) just after switch-off as if was (through the transistor) just before switch off. To see what happens next, we solve the equations V = IR (where R is the total resistance in the circuit - in this case, just the resistance of the coil) and dI/dt = -V/L. I'm assuming a perfect flyback diode (no forward voltage drop). Solving these equations, we find that the current decays exponentially with a time constant L/R. So increasing the resistance R at constant inductance L in an L-R circuit decreases the time constant, unlike an R-C network. If R is zero (= superconductor), we get infinite time constant and the current flows for ever.

If we add a resistor in series with the diode, we increase the total R. For example, if we add a resistor in series with the diode equal to the resistance of the solenoid, we double R, so the current decays twice as fast - but we get a peak voltage across the resistor (just after switch-off) equal to the supply voltage. Therefore the peak collector or drain voltage doubles.

Even better is to use a zener diode instead of a resistor. [EDIT: the following sentence is only true if the on-time is short enough for the resistance of the inductor to be ignored.] If we use a zener diode with a voltage rating equal to the supply voltage, then the switch-on and switch-off times will be the same and the waveforms will be similar. Of course, a zener diode is only practical if the current is low enough.

This effect of the diode causing a slow current decay is noticeable with some relays. With a diode connected directly across the relay coil, if you know when the transistor switches on and off, you can often sense the delay between the current switching off and the click of the relay opening.
« Last Edit: September 04, 2011, 11:09:15 am by dc42 » 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.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This effect of the diode causing a slow current decay is noticeable with some relays. With a diode connected directly across the relay coil, if you know the switch on/off times, you can often sense the delay between the current switching off and the click of the relay opening.

That has been my experience also when doing some experiments trying to measure relay 'kickback' voltage spikes. Relays with no diode release faster and make a sharp 'clicking' sound. Relays with diodes across the coil release slower and make a 'thunking' sound. The effect was quite noticable with the larger industrial 24vdc relays used in process control world.

Lefty
« Last Edit: September 02, 2011, 04:28:53 pm by retrolefty » Logged

Pages: 1 [2]   Go Up
Jump to: