Page 2 of 4

Re: Connecting electromagnet to pi

Posted: Thu Feb 28, 2019 11:16 am
by rpdom
Burngate wrote:
Thu Feb 28, 2019 11:13 am
However, many people often disagree with me, in particular mahjongg and rpdom.
Only occasionally. Most of the time you post very sensible information.

Re: Connecting electromagnet to pi

Posted: Thu Feb 28, 2019 11:17 am
by mahjongg
Burngate wrote:
Thu Feb 28, 2019 11:13 am
jadel wrote:
Wed Feb 27, 2019 7:32 pm
It is a 10SQ045, here's the data sheet: http://www.senocn.com/data/PDF/10SQ030-10SQ100.pdf
Looks good to me.
However, many people often disagree with me, in particular mahjongg and rpdom.
So watch this space.
Its certainly useable, just probably a bit overkill, but who cares.

Re: Connecting electromagnet to pi

Posted: Thu Feb 28, 2019 2:57 pm
by tlfong01
tlfong01 wrote:
Wed Feb 27, 2019 1:44 pm
Part 3 (Point 7) The lifting force is not easy to calculate. This is the part I found interesting. I am thinking of googling more readings and try to begin with calculating the inductance of solenoid or electromagnet which is useful for selecting a flyback diode.

Inductance Stuff - Hard to Understand, But Very Easy to Google, Cut, Paste, and Blindly Calculate

Yes, I agree AC circuits with inductance and capacitance are very hard to understand, but actually not that hard to calculate.

AC circuits is hard because it uses the phasor/vector notation, which in turn uses complex number representation which in turn uses imaginary number j, and Euler Identity e. Of course you also need to understand school maths like trigonometry and a little bit of analytic geometry.

But then I remember a year ago I listened to BBC In Our Time programmes about imaginary number and Euler Identity and was very relieved that these things troubled human for centuries. In other words, I am not that stupid afterall.

Another thing is that some weeks ago I read about the crazy scientist Heavyside who when criticized by other scientists that he did not understand the mathematics he applied to solve problems, says the following:

"Should I refuse a good dinner simply because I do not understand the process of digestion?"

Also long time ago when I read about the Laplace Transform, I also found it difficult. But then I read at the same time the French engineer, who when criticized that he does not understand that much mathematics, says something similar:

OK, OK, I admit I don't thoroughly understand why my Laplace Transform works, but the important thing is that it works!

So now I have read the references, watch the videos but still not thoroughly understand the weird phasors etc, but I think I am comfortable to start do the tests to find the inductance of my electromagnet.

Just thinking aloud. My apologies for the typos, ... :mrgreen:

Science Quotes by Oliver Heaviside - Today in Science History
https://todayinsci.com/H/Heaviside_Oliv ... ations.htm

Re: Connecting electromagnet to pi

Posted: Fri Mar 01, 2019 1:11 am
by tlfong01
jadel wrote:
Wed Feb 27, 2019 11:08 am
but can't a relay switch do the same thing, ...
what would be the advantage of using the FET system

Relay vs Power MOSFET vs Power NPN BJT

Well, it depends on 101 things. Perhaps you can let me know more about yourself and your project, to narrow down to, say, 10 questions.

Re: Connecting electromagnet to pi

Posted: Fri Mar 01, 2019 1:37 am
by tlfong01
Burngate wrote:
Thu Feb 28, 2019 11:13 am
... many people often disagree with me,
So watch this space.

I say high, you say low

Well, I say build a wall, you say fire a rocket, I say leave, you say stay, ...

So I am watching a rocket to fly over my head, and I will make a wish. :(

Yes, this is life, la-la-la, la-la-la :mrgreen:

Hello, Goodbye - The Beatles 88,074,062 views
https://www.youtube.com/watch?v=rblYSKz_VnI

Karel Gott - C'est La Vie 1,338,743 views
https://www.youtube.com/watch?v=w4q3HXBfwpA

C'est La Vie Lyrics English Translation
https://lyricstranslate.com/en/cest-la-vie-life.html

Re: Connecting electromagnet to pi

Posted: Fri Mar 01, 2019 5:02 am
by tlfong01
tlfong01 wrote:
Thu Feb 28, 2019 2:57 pm
Inductance Stuff - Hard to Understand, But Very Easy to Google, Cut, Paste, and Blindly Calculate
So now I have read the references, watch the videos but still not thoroughly understand the weird phasors thing, but I think I am comfortable to start do the tests to find the inductance of my electromagnet.

Measuring the inductance of my electromagnet - Trial #1

This is the first time I am trying to find the inductance of a coil. I have little confidence. So I might do more than one trial and error. This is trail number 1. :mrgreen:

The best tutorial for newbies I googled is by Rose Hullman. The procedure is something like:

..... (1) go to the imaginary number galaxy,

..... (2) do the simple arithmetic (not even algebra!), then

..... (3) come back to the real world (remember taking results with you) and you done! :mrgreen:


/ to continue, ...

How to measure inductance - Rose-Hulman Online 8,195 views
https://www.youtube.com/watch?v=ajycdvKyCEw
...

Re: Connecting electromagnet to pi

Posted: Fri Mar 01, 2019 8:15 am
by tlfong01
tlfong01 wrote:
Fri Mar 01, 2019 5:02 am
How to measure inductance - Rose-Hulman
https://www.youtube.com/watch?v=ajycdvKyCEw

Inductance Measurement Trail #1

So I setup the hardware and blindly selected R = 10k. But there is no phase difference between Vs and Vr. :(

I guess the lazy student has not paid attention in the Rose Hullman classes and so had no idea what is going on in the testing.

Anyway, I looked closely the coil, and found it is 100uH, not 1uH as I thought. I think I also need to do some calculation, like Zi = ω something, or 2fLπ, at least get some idea of what should be the absolute value of Zi, if equivalent to R etc, then select R with at least some idea of the range, or the frequency range etc, ...

Any way, I should for sure fail the Rose Hullman final examination if I don't work hard now. :mrgreen:


...

Re: Connecting electromagnet to pi

Posted: Fri Mar 01, 2019 2:46 pm
by tlfong01
tlfong01 wrote:
Fri Mar 01, 2019 8:15 am
Inductance Measurement Trail #1
So I setup the hardware and blindly selected R = 10k. But there is no phase difference between Vs and Vr. :(


Inductance Measurement Trail #1 = Total Failure! :(

I found Vr = Vs, same amplitude and phase, and I could not do any adjutments to make Vr not equal to Vs.

After some thought, I realized that it is because the inductance of 100uH is too small, compared with 10k. So the Vr at the L-R junction, because of the potential divider effect, very small L, big R is almost the same as Vs.

I tried to reduce R from 10k down to 1k, and then to 560R and 330R, I found Vr getting smaller, and there is also phase difference. However, when R reaches 330R, the sine wave has heavy distortion. I guess it is because too small L + R overloads the cheap function generator.

So I concluded that 100uH is too small for my testing setup. I replaced the 100uH inductor by the electromagnet which is much bigger in size, I found Vr becomes smaller, and there is phase difference between Vs and Vr.

...

Re: Connecting electromagnet to pi

Posted: Fri Mar 01, 2019 6:51 pm
by Burngate
What frequency is your sine-wave generator producing?

Given that the time constant of an inductance and resistance is given by t=L/R, 100μH and 100k that gives 10ns, so you're not going to see much phase difference at frequencies much lower than 100MHz

100μH and 1k gives 100ns, so 10MHz ball-park figure, and 1/3 that resistance will give 1/3 the frequency.

Re: Connecting electromagnet to pi

Posted: Fri Mar 01, 2019 7:29 pm
by jadel
mahjongg wrote:
Thu Feb 28, 2019 11:17 am
Burngate wrote:
Thu Feb 28, 2019 11:13 am
jadel wrote:
Wed Feb 27, 2019 7:32 pm
It is a 10SQ045, here's the data sheet: http://www.senocn.com/data/PDF/10SQ030-10SQ100.pdf
Looks good to me.
However, many people often disagree with me, in particular mahjongg and rpdom.
So watch this space.
Its certainly useable, just probably a bit overkill, but who cares.
So would this type of circuit work for it.
https://forum.allaboutcircuits.com/prox ... c79773d9f3
Also from this circuit would I have to use both the GPIO pins and the relay or could I just use one?

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 2:26 am
by tlfong01
Burngate wrote:
Fri Mar 01, 2019 6:51 pm
1. What frequency is your sine-wave generator producing?
2. Given that the time constant of an inductance and resistance is given by t=L/R, 100μH and 100k that gives 10ns, so you're not going to see much phase difference at frequencies much lower than 100MHz
3. 100μH and 1k gives 100ns, so 10MHz ball-park figure, and 1/3 that resistance will give 1/3 the frequency.

L/R Time Constant etc

I forgot the time constant thing. I need to go back to electronics-tutorials.ws to refresh my memory.

I do remember why I bought the 100uH inductor. It was my Arduino days when I DIYed a LM2596 based switching regulator, and the switching frequency should be in the order 100kHz. I need to check the LM2596 data sheet to make sure, ... :mrgreen:


LM2596 Datasheet
http://www.ti.com/lit/ds/symlink/lm2596.pdf
...

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 3:10 am
by tlfong01
tlfong01 wrote:
Sat Mar 02, 2019 2:26 am
Burngate wrote:
Fri Mar 01, 2019 6:51 pm
1. What frequency is your sine-wave generator producing?
2. Given that the time constant of an inductance and resistance is given by t=L/R, 100μH and 100k that gives 10ns, so you're not going to see much phase difference at frequencies much lower than 100MHz
3. 100μH and 1k gives 100ns, so 10MHz ball-park figure, and 1/3 that resistance will give 1/3 the frequency.
L/R Time Constant etc
I forgot the time constant thing. I need to go back to electronics-tutorials.ws to refresh my memory.

L-R Circuit Memory Refreshing Notes (Actually no notes, only pictures! :mrgreen: )

So I quickly skimmed the tutorial. I did not jot down any notes, because I am a picture guy, couldn't memorize any words, but pictures!

I found that to understand the pictures thoroughly ("deep" learning, not merely scratching the surface!), you need to have the following prerequisites:

Lenz Law, Kirchoff Law, Calculus (first order differential equation), Euler Identity.

But sadly I got no time to dive deeper, because there are a couple of elementary things I forgot and need to refresh my memory as well:

What is the meaning of exponents (arithmetic power), power to a negative number (eg, 2^(-3)), exponential (my goodness, too many Wikipedia ambiguities here! :( ), and Euler number e (= 2.17128, ...).

Actually I mixed up all the "e"s together! :mrgreen:

...

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 3:57 am
by tlfong01
Burngate wrote:
Fri Mar 01, 2019 6:51 pm
Given that the time constant of an inductance and resistance is given by t=L/R, 100μH and 100k that gives 10ns, so you're not going to see much phase difference at frequencies much lower than 100MHz, ...

R-L Time constant and phase differences etc

Sir, actually I did not know that the L-R time constant is related to the real clock time. I also found that Henry x Ohm = Seconds weird (only geeks and nerds understand! :mrgreen: )

Anyway, now let me check your demo calculation (I am using the strangely looking symbols to show off that I "know" Greek) :

τ = L / R = 100 µ H / 100 k Ω
= (100 x 0.000001) / (100 x 1000)
= 0.000000001 seconds
= 0.000000001 x 1,000,000,000 nano seconds
= 10nS (not proofread, because I cannot count more than 5 zeros! :mrgreen: )

And converted to frequency it becomes:

f = 1 / 0.000000001 Hz
100,000,000 Hz
= 100MHz (ὅπερ ἔδει δεῖξαι = QED (Quite Easily Done! :mrgreen: ))

...

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 4:05 am
by tlfong01
jadel wrote:
Fri Mar 01, 2019 7:29 pm
So would this type of circuit work for it.
https://forum.allaboutcircuits.com/prox ... c79773d9f3
Also from this circuit would I have to use both the GPIO pins and the relay or could I just use one?
Your link is broken!

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 7:27 am
by tlfong01
tlfong01 wrote:
Fri Mar 01, 2019 2:46 pm
I tried to reduce R from 10k down to 1k, and then to 560R and 330R, I found Vr getting smaller, and there is also phase difference. However, when R reaches 330R, the sine wave has heavy distortion. I guess it is because too small L + R overloads the cheap function generator.

ICL8038 Function Generator Output is TTL compatible

To confirm if 330R indeed overloads the waveform generator, I googled the datasheet and made a summary as the picture at the very bottom.

I found that for 12V power supply, the sine amplitude can go at most to about 2.5V. So if the output current limit is 25mA, then the TTL loading is 2.5V / 25mA ~= 100R. In other words,

...100R ~ 330R should not overload the device.

ICL8038 Precision Waveform Generator/Voltage Controlled Oscillator Datasheet - Harris Semi 1998
http://www.mit.edu/~6.331/icl8038data.pdf

Absolute Maximum
Supply Voltage (V- to V+) - 36V
Input Voltage (Any Pin) - V- to V+
Input Current (Pins 4 and 5) - 25mA
Output Sink Current (Pins 3 and 9) - 25mA

Electrical Specification
Single supply - 10V to 30V
Vsat = 0.4V 2mA
Output impedance - 200R 5mA

...

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 12:18 pm
by jadel
tlfong01 wrote:
Sat Mar 02, 2019 4:05 am
jadel wrote:
Fri Mar 01, 2019 7:29 pm
So would this type of circuit work for it.
https://forum.allaboutcircuits.com/prox ... c79773d9f3
Also from this circuit would I have to use both the GPIO pins and the relay or could I just use one?
Your link is broken!
Can you see it now

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 1:25 pm
by tlfong01
jadel wrote:
Fri Mar 01, 2019 7:29 pm
So would this type of circuit work for it.
Also from this circuit would I have to use both the GPIO pins and the relay or could I just use one?

Using (1) small NPN BJT (eg 2N2222) and Relay or (2) Power NPN (eg TIP122 and no relay) or (3) Power MOSFET (eg IRL540N and no relay)

So there are at least three circuits you can choose.

(1) Small NPN BJT such as 2N2222 and 5V relay (Note 1),

(2) Power MOSFET such as IRL540N (direct switch electromagnet, no relay),

(3) Power NPN BJT, such as TIP122 (direct switch electromagnet, no relay)


(4) Using 3V to 5V logic level converter (EL817C) or TSX010n to control relay or power MOSFET or power NPN BJT.

Note - if you have already bought a 12V relay, you can use it, getting the same 12V power for electromagnet.

AliExpress TIP122 TO220 US$1/10 pcs
https://fr.aliexpress.com/item/Tip122-t ... d500855f-2
...

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 2:14 pm
by tlfong01
Burngate wrote:
Fri Mar 01, 2019 6:51 pm
1. What frequency is your sine-wave generator producing?
2. Given that the time constant of an inductance and resistance is given by t=L/R, 100μH and 100k that gives 10ns, so you're not going to see much phase difference at frequencies much lower than 100MHz
3. 100μH and 1k gives 100ns, so 10MHz ball-park figure, and 1/3 that resistance will give 1/3 the frequency.

Selection of R for Inductance Measurement Using L-R -45 Degrees Phase Method

1. My function generator can only go up to 450kHz.

2. Yes, using resistance of 10K/100K would need order of 10/100 MHz.

3. To fit the < 450kHz range, I need to use very low resistance 1R or 2R. The problem is that the function generator can only output TTL, which means at least 100R. If I use 100R to limit the current, then it won't be accurate to measure the low ohm voltage, ... :(

4. Or forget the 100uH, and try the electromagnet which I think should be 1000uH or more.

...

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 2:57 pm
by tlfong01
tlfong01 wrote:
Sat Mar 02, 2019 2:14 pm
4. Or forget the 100uH, and try the electromagnet which I think should be 1000uH or more.[/i][/color]

Phase shift of L = Electromagnet ZYE1-P20/15 , R = 100Ω

The phase shift appears to be 30 degrees, frequency ~= 200 kHz (H = 20uS). But I don't know how to do the calculation for this case! :mrgreen:
...

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 3:26 pm
by mahjongg
jadel wrote:
Sat Mar 02, 2019 12:18 pm
tlfong01 wrote:
Sat Mar 02, 2019 4:05 am
jadel wrote:
Fri Mar 01, 2019 7:29 pm
So would this type of circuit work for it.
https://forum.allaboutcircuits.com/prox ... c79773d9f3
Also from this circuit would I have to use both the GPIO pins and the relay or could I just use one?
Your link is broken!
Can you see it now
the relay also needs a flyback diode.

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 10:05 pm
by jadel
mahjongg wrote:
Sat Mar 02, 2019 3:26 pm
the relay also needs a flyback diode.
I forgot to mention I don't have a single relay. I'm using a "relay module driver board module with optocoupler", so I am using female to female pins to connect between the pi and the pins on the board. How would I add a flyback diode between them? Does that mean I can't connect directly and have to use a breadboard to connect the board and GPIOs?
Thanks

Re: Connecting electromagnet to pi

Posted: Sat Mar 02, 2019 10:08 pm
by jadel
tlfong01 wrote:
Sat Mar 02, 2019 1:25 pm

Note - if you have already bought a 12V relay, you can use it, getting the same 12V power for electromagnet.
This question might seem silly but I'm a bit confused by the phrasing.
Does this mean I don't have to use an external power supply and just connecting the solenoid to the board will supply it with enough voltage?

Re: Connecting electromagnet to pi

Posted: Sun Mar 03, 2019 1:10 am
by tlfong01
jadel wrote:
Sat Mar 02, 2019 10:05 pm
mahjongg wrote:
Sat Mar 02, 2019 3:26 pm
the relay also needs a flyback diode.
I forgot to mention I don't have a single relay. I'm using a "relay module driver board module with optocoupler", so I am using female to female pins to connect between the pi and the pins on the board. How would I add a flyback diode between them? Does that mean I can't connect directly and have to use a breadboard to connect the board and GPIOs?
Thanks

Confusion between Relay and Relay Module/Board

Well, you already mentioned in your very first post that "I have a 12V relay board", so I have always been assuming that you are using a module (usually has one or two transistors inside the module, with or without optical isolation, and flyback diode).

In other words, I have assumed the "relay" in your schematic is a "functional block diagram" to show the top level functional connections, skipping the lower level, internal connecting driving transistor and flyback diodes.

Re: Connecting electromagnet to pi

Posted: Sun Mar 03, 2019 1:53 am
by tlfong01
jadel wrote:
Sat Mar 02, 2019 10:08 pm
tlfong01 wrote:
Sat Mar 02, 2019 1:25 pm
Note - if you have already bought a 12V relay, you can use it, getting the same 12V power for electromagnet.
This question might seem silly but I'm a bit confused by the phrasing.
Does this mean I don't have to use an external power supply and just connecting the solenoid to the board will supply it with enough voltage?

Relay Newbie Total Confusion Guide

Well, perhaps you can give me a link to the Amazon/AliExpress/eBay ad of your relay module.

If you don't have the link, you can show me a picture of you module, or skim the following posts and tell me which relay looks like yours.


Relay Newbie Confusion Guide

NPN High Trigger (KY019, S8050 J3Y)
https://www.raspberrypi.org/forums/view ... 8#p1323061

PNP Low Trigger (S8550 2TY)
https://www.raspberrypi.org/forums/view ... 5#p1331732

Basic Optoisolated Relays (Hardwired either High level or Low level triggered)
https://www.raspberrypi.org/forums/view ... 0#p1329256
https://www.raspberrypi.org/forums/view ... 0#p1329639
https://www.raspberrypi.org/forums/view ... 5#p1329641
https://www.raspberrypi.org/forums/view ... 5#p1329642

Basic Optoisolated Relay (Jumper select either High or Low Trigger)
https://www.raspberrypi.org/forums/view ... 5#p1330108
https://www.raspberrypi.org/forums/view ... 5#p1330571
https://www.raspberrypi.org/forums/view ... 5#p1330999

Optical Relay (JD-Vcc Jumper select relay logical power)
https://www.raspberrypi.org/forums/view ... 5#p1330739
https://www.raspberrypi.org/forums/view ... 5#p1331076
https://www.raspberrypi.org/forums/view ... 5#p1331550
https://www.raspberrypi.org/forums/view ... 5#p1331884

Types of Relays
https://www.raspberrypi.org/forums/view ... 0#p1328069
https://www.raspberrypi.org/forums/view ... 5#p1330476
https://www.raspberrypi.org/forums/view ... 5#p1331538

Using Logical Level Converters
https://www.raspberrypi.org/forums/view ... 0#p1328090

Opto Relay Summary Big Picture (penzu)
https://penzu.com/p/ea1dd169
...

Re: Connecting electromagnet to pi

Posted: Sun Mar 03, 2019 4:02 am
by tlfong01
tlfong01 wrote:
Sat Mar 02, 2019 2:57 pm
Phase shift of L = Electromagnet ZYE1-P20/15 , R = 100Ω
The phase shift appears to be 30 degrees, frequency ~= 200 kHz (H = 20uS). But I don't know how to do the calculation for this case!

Finding Inductance of Electromagnet ZYE1-P20/15 DC6V 0.5A (Coil Resistance = 11.7Ω)
...