Only occasionally. Most of the time you post very sensible information.
Re: Connecting electromagnet to pi
Unreadable squiggle
- mahjongg
- Forum Moderator
- Posts: 13692
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Connecting electromagnet to pi
Its certainly useable, just probably a bit overkill, but who cares.Burngate wrote: ↑Thu Feb 28, 2019 11:13 amLooks good to me.jadel wrote: ↑Wed Feb 27, 2019 7:32 pmIt is a 10SQ045, here's the data sheet: http://www.senocn.com/data/PDF/10SQ030-10SQ100.pdf
However, many people often disagree with me, in particular mahjongg and rpdom.
So watch this space.
Re: Connecting electromagnet to pi
tlfong01 wrote: ↑Wed Feb 27, 2019 1:44 pmPart 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, ...

Science Quotes by Oliver Heaviside - Today in Science History
https://todayinsci.com/H/Heaviside_Oliv ... ations.htm
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
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.
Last edited by tlfong01 on Fri Mar 01, 2019 3:38 am, edited 1 time in total.
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
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

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
Last edited by tlfong01 on Fri Mar 01, 2019 2:50 pm, edited 1 time in total.
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
tlfong01 wrote: ↑Thu Feb 28, 2019 2:57 pmInductance 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.

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!

/ to continue, ...
How to measure inductance - Rose-Hulman Online 8,195 views
https://www.youtube.com/watch?v=ajycdvKyCEw
...
- Attachments
-
- measure_inductance_2019mar0101s2.jpg (149.97 KiB) Viewed 1852 times
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
tlfong01 wrote: ↑Fri Mar 01, 2019 5:02 amHow 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.

...
- Attachments
-
- inductance_test_2019mar0101.jpg (154.59 KiB) Viewed 1843 times
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
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.
...
I am an electronics and smart home hobbyist.
- Burngate
- Posts: 6427
- Joined: Thu Sep 29, 2011 4:34 pm
- Location: Berkshire UK Tralfamadore
- Contact: Website
Re: Connecting electromagnet to pi
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.
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
So would this type of circuit work for it.mahjongg wrote: ↑Thu Feb 28, 2019 11:17 amIts certainly useable, just probably a bit overkill, but who cares.Burngate wrote: ↑Thu Feb 28, 2019 11:13 amLooks good to me.jadel wrote: ↑Wed Feb 27, 2019 7:32 pmIt is a 10SQ045, here's the data sheet: http://www.senocn.com/data/PDF/10SQ030-10SQ100.pdf
However, many people often disagree with me, in particular mahjongg and rpdom.
So watch this space.
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
Burngate wrote: ↑Fri Mar 01, 2019 6:51 pm1. 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, ...

LM2596 Datasheet
http://www.ti.com/lit/ds/symlink/lm2596.pdf
...
- Attachments
-
- lm259_switching_reg_2019mar0101.jpg (167.62 KiB) Viewed 1783 times
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
tlfong01 wrote: ↑Sat Mar 02, 2019 2:26 amL/R Time Constant etcBurngate wrote: ↑Fri Mar 01, 2019 6:51 pm1. 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.
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!

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!

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

...
- Attachments
-
- lr_circuit_analysis_2019mar0102s.jpg (175.16 KiB) Viewed 1779 times
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
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!

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!

And converted to frequency it becomes:
f = 1 / 0.000000001 Hz
100,000,000 Hz
= 100MHz (ὅπερ ἔδει δεῖξαι = QED (Quite Easily Done!

...
- Attachments
-
- inductance_measurement_2019mar0201.jpg (106.71 KiB) Viewed 1757 times
Last edited by tlfong01 on Sat Mar 02, 2019 4:49 am, edited 2 times in total.
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
Your link is broken!jadel wrote: ↑Fri Mar 01, 2019 7:29 pmSo 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?
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
tlfong01 wrote: ↑Fri Mar 01, 2019 2:46 pmI 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
...
- Attachments
-
- icl8038_spec_2019mar0201.jpg (189.94 KiB) Viewed 1746 times
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
Can you see it nowtlfong01 wrote: ↑Sat Mar 02, 2019 4:05 amYour link is broken!jadel wrote: ↑Fri Mar 01, 2019 7:29 pmSo 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?
- Attachments
-
- Capture.PNG (74.7 KiB) Viewed 1719 times
Re: Connecting electromagnet to pi
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
...
- Attachments
-
- npn_bjt_2n2222__and_relay_electromagnet_2019mar0201.jpg (119.42 KiB) Viewed 1714 times
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
Burngate wrote: ↑Fri Mar 01, 2019 6:51 pm1. 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.
...
- Attachments
-
- frequency_calculation_2019mar0202.jpg (127.35 KiB) Viewed 1702 times
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
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!

...
- Attachments
-
- l_r_phase_shift_2019mar0201.jpg (164.51 KiB) Viewed 1695 times
I am an electronics and smart home hobbyist.
- mahjongg
- Forum Moderator
- Posts: 13692
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Connecting electromagnet to pi
the relay also needs a flyback diode.jadel wrote: ↑Sat Mar 02, 2019 12:18 pmCan you see it nowtlfong01 wrote: ↑Sat Mar 02, 2019 4:05 amYour link is broken!jadel wrote: ↑Fri Mar 01, 2019 7:29 pmSo 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
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
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
jadel wrote: ↑Sat Mar 02, 2019 10:05 pmI 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.
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
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
...
- Attachments
-
- opto_relay_summary_2019mar0301s.jpg (116.67 KiB) Viewed 1643 times
Last edited by tlfong01 on Sun Mar 03, 2019 4:11 am, edited 2 times in total.
I am an electronics and smart home hobbyist.
Re: Connecting electromagnet to pi
Finding Inductance of Electromagnet ZYE1-P20/15 DC6V 0.5A (Coil Resistance = 11.7Ω)
...
- Attachments
-
- inductance_test_2019mar0302.jpg (161.37 KiB) Viewed 1623 times
I am an electronics and smart home hobbyist.