User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 6:57 am

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!

Inductance Measurement Frequency and Resistance Adjustment Newbie Tips

I read a good eBook on AC circuits and now have a better idea of what is going on in the Rose Hullman inducance measurement. I also know the constraints of my poorman's function generator: (1) maximum frequency is 450kHz, (2) output current limit is TTL (25mA).

So I think I need to adjust two parameters to get the required condition of absolute reactance and resistance equal.

I also guess the following: when the required condition is met, two things must happen at the same time (1) phase shift 45 degrees, (2) Vr = 0.707 Vs.

It is a bit difficult to measure the phase shift, because the two waves are too "flat", therefore difficult to locate the peak or bottom. On the other hand, wave amplitude is relatively easy to measure.

My measurement procedure is summarised below.

(1) By trial and error, select a frequency range, turn frequency trim pot to about middle, try a couple of discrete resistors to get a resistor value where Vr is roughly 0.7 of Vs.

(2) Then fine tune frequency to get Vr/Vs ~= 0.7.

It took me less than 10 minutes to get the result, as shown below. :mrgreen:

Big penzu picture
https://penzu.com/p/0c21c49f

...
Attachments
electromagnet_inductance_2019mar0301s.jpg
electromagnet_inductance_2019mar0301s.jpg (164.88 KiB) Viewed 928 times
Last edited by tlfong01 on Sun Mar 03, 2019 8:48 am, edited 1 time in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 7:44 am

tlfong01 wrote:
Sun Mar 03, 2019 6:57 am
Inductance Measurement Frequency and Resistance Adjustment Newbie Tips
I read a good eBook on AC circuits and now have a better idea of what is going on in the Rose Hullman inducance measurement.

All About Circuits Free EE eBook

I found the following All-About-Circuits' free EE eBook very good. I quickly read the following chapters to refresh my memory on inductive circuits.

Text Book Lessons in Electric Circuits
https://www.allaboutcircuits.com/textbook/

Vol. II Chapter 1 - Basic AC Theory
https://www.allaboutcircuits.com/textbo ... urrent-ac/

Vol. II Chapter 2 - Complex Numbers
https://www.allaboutcircuits.com/textbo ... x-numbers/

Vol. II Chapter 3 - Reactance and Impedance -- Inductive
https://www.allaboutcircuits.com/textbo ... nductive/

Reading Notes
1. Reactance is symbolized by the capital letter X and is measured in ohms just like resistance.
2. Inductive reactance can be calculated using this formula: X = 2πfL = ωL
3. Ohm’s Law holds true for the instantaneous values of voltage and current.


Vol. II Chapter 5 - Reactance And Impedance -- R, L, And C
https://www.allaboutcircuits.com/textbo ... -r-x-and-z/

Vol. I Chapter 15 - Inductors
https://www.allaboutcircuits.com/textbo ... nductance/


Appendix - Textbook Volumes and Chapters

Vol. I - Direct Current (DC)
Vol. II - Alternating Current (AC)
Vol. III - Semiconductors
Vol. IV - Digital
Vol. V - Reference
Vol. VI - Experiments

Vol. I - Direct Current (DC)
Chapter 1 - Basic Concepts Of Electricity
Chapter 2 - Ohm's Law
Chapter 3 - Electrical Safety
Chapter 4 - Scientific Notation And Metric Prefixes
Chapter 5 - Series And Parallel Circuits
Chapter 6 - Divider Circuits And Kirchhoff's Laws
Chapter 7 - Series-parallel Combination Circuits
Chapter 8 - DC Metering Circuits
Chapter 9 - Electrical Instrumentation Signals
Chapter 10 - DC Network Analysis
Chapter 11 - Batteries And Power Systems
Chapter 12 - Physics Of Conductors And Insulators
Chapter 13 - Capacitors
Chapter 14 - Magnetism and Electromagnetism
Chapter 15 - Inductors
Chapter 16 - RC and L/R Time Constants
Chapter 17 - Contributor List

Vol. II - Alternating Current (AC)
Chapter 1 - Basic AC Theory
Chapter 2 - Complex Numbers
Chapter 3 - Reactance and Impedance -- Inductive

Chapter 4 - Reactance And Impedance -- Capacitive
Chapter 5 - Reactance And Impedance -- R, L, And C
Chapter 6 - Resonance
Chapter 7 - Mixed-Frequency AC Signals
Chapter 8 - Filters
Chapter 9 - Transformers
Chapter 10 - Polyphase AC Circuits
Chapter 11 - Power Factor
Chapter 12 - AC Metering Circuits
Chapter 13 - AC Motors
Chapter 14 - Transmission Lines
Chapter 15 - Contributors List
Last edited by tlfong01 on Sun Mar 03, 2019 2:57 pm, edited 1 time in total.
I am an electronics and smart home hobbyist.

jadel
Posts: 18
Joined: Tue Feb 26, 2019 2:33 pm

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 10:20 am

tlfong01 wrote:
Sun Mar 03, 2019 1:53 am
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.
https://www.amazon.co.uk/gp/product/B07 ... UTF8&psc=1
I only wanted to clarify that it was a board because I'm unsure how I would add a flyback diode across the relay.

pcmanbob
Posts: 7138
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 10:26 am

jadel wrote:
Sun Mar 03, 2019 10:20 am
https://www.amazon.co.uk/gp/product/B07 ... UTF8&psc=1
I only wanted to clarify that it was a board because I'm unsure how I would add a flyback diode across the relay.

That is a ready made relay board that will have all the protection already built in, just be aware it uses 5v on the control circuit and will be active low and you may have problems switching relays off.

typical diagram and operation explanation here : https://www.raspberrypi.org/forums/view ... 2&start=25
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 2:26 pm

jadel wrote:
Sun Mar 03, 2019 10:20 am
https://www.amazon.co.uk/gp/product/B07 ... UTF8&psc=1
I only wanted to clarify that it was a board because I'm unsure how I would add a flyback diode across the relay.

SaintSmart/Boladge 16 Channel 12V Low Trigger Relay

1. I am 90% sure that you don't need any flyback diodes for the relays, because the relays are driven by ULN2803 octal darlingtons with built in flyback diodes.

2. The schematic is dated 2011. There is 80% chance that it is Arduino/TTL compatible, which means High Level should be 4V or higher to switch off. Arduino High signal is 4.2V+ and there is no problem switching off. However Rpi High signal is only around 3V and therefore not high enough to switch off. In other words, relays always on, and so Arduino guys LOL! :mrgreen:


SAINSMART 16-Channel 12V Relay Module $15.99
https://www.sainsmart.com/products/16-c ... lay-module

Features
* 12V 16-Channel Relay interface board
* able to control various appliances, and other equipments with large current
* can be controlled directly by Micro-controller (Raspberry Pi, Arduino, 8051, AVR, PIC, DSP, ARM, ARM, MSP430, TTL logic) .

Specification
* optocoupler isolation
* 12V 16-Channel Relay interface board, and each one needs 15-20mA Driver Current
* 1-16 load can be any full on/off
* relay, AC250V 10A, DC30V 10A
* can be controlled directly by microcontroller (Arduino, 8051, AVR, PIC, DSP, ARM, ARM, MSP430, TTL logic)
* Indication LED’s for Relay output status

Schematic (2011)
https://www.sainsmart.com/zen/documents ... -relay.rar

ULN2803A Darlington Transistor Arrays To Drive Relay
http://www.ti.com/lit/ds/symlink/uln2803a.pdf

LM2576 Voltage Regulator 12V to 5V for Optoisolator
http://www.ti.com/lit/ds/symlink/lm2576.pdf

Boladge 12V 16 Channels Relay Module Driver Board Module with Optocoupler for Arduino Raspberry Pi 51 AVR ARM PIC - £12.99
https://www.amazon.co.uk/gp/product/B07 ... UTF8&psc=1

* trigger signal is low 0-2V
* high voltage must not exceed 5V.
* trigger current is only 3mA.
Last edited by tlfong01 on Mon Mar 04, 2019 3:06 am, edited 1 time in total.
I am an electronics and smart home hobbyist.

jadel
Posts: 18
Joined: Tue Feb 26, 2019 2:33 pm

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 3:41 pm

tlfong01 wrote:
Sun Mar 03, 2019 2:26 pm

1. I am 90% sure that you don't need any flyback diodes for the relays, because the relays are driven by ULN2803 octal darlingtons with built in flyback diodes.

Just checking you mean I don't need it across the relay not the whole circuit, right?
tlfong01 wrote:
2. The schematic date is dated 2011. There is 80% chance that it is Arduino/TTL compatible, which means High Level should be 4V or higher to switch off. Arduino High signal is 4.2V+ and there is no problem switching off. However Rpi High signal is only around 3V and therefore not high enough to switch off. In other words, relays always on, and so Arduino guys LOL! :mrgreen:

I'll have to test it and see. Fingers crossed it works

jadel
Posts: 18
Joined: Tue Feb 26, 2019 2:33 pm

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 3:42 pm

Also just for my own understanding, can someone please explain the need for the transistor.
Thanks

pcmanbob
Posts: 7138
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 3:58 pm

jadel wrote:
Sun Mar 03, 2019 3:42 pm
Also just for my own understanding, can someone please explain the need for the transistor.
Thanks
In reference to which diagram or post as this thread has many
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

jadel
Posts: 18
Joined: Tue Feb 26, 2019 2:33 pm

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 4:36 pm

pcmanbob wrote:
Sun Mar 03, 2019 3:58 pm

In reference to
Capture2.PNG
This diagram
Capture2.PNG (112.12 KiB) Viewed 856 times
And this
tlfong01 wrote:
So there are at least three circuits you can choose.

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


User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12354
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 4:47 pm

Two reasons:
  • The GPIO drives a 3.3V signal, and the relay needs 5V
  • The relay needs more current than the 10 to 15mA a GPIO can deliver
So the transistor is used as a current amplifier, and 5V switch.

jadel
Posts: 18
Joined: Tue Feb 26, 2019 2:33 pm

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 5:18 pm

mahjongg wrote:
Sun Mar 03, 2019 4:47 pm
Two reasons:
  • The GPIO drives a 3.3V signal, and the relay needs 5V
  • The relay needs more current than the 10 to 15mA a GPIO can deliver
So the transistor is used as a current amplifier, and 5V switch.
Currently I am powering the relay board with a separate 12 V power supply. Wouldn't this be enough to provide the voltage and current needed?
Or are they needed to trigger the relay when other components are attached. I have tested the board on its own and the LED lights come on to show that the relay has been triggered according to the code.
Otherwise, does this mean I can't directly connect the Rpi to the relay board with female to female cables?

pcmanbob
Posts: 7138
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Connecting electromagnet to pi

Sun Mar 03, 2019 5:32 pm

The difference here is the diagram is showing you using a single relay not on a relay board as you are using , your relay board will have a driver chip which contains both the transistor and diodes required to drive each relay, along with some other components which includes an opto isolator to interface the pi to the driver chip.

If your relay board is working with just a direct connection to the pi gpio then you are lucky as many of them will allow the to switch the relay on but not off due to the board using 5v for the control circuit and the pi gpio only being 3.3v

Did you look at the link I posted in answer to your earlier question which included a diagram of a typical relay board .
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 4:45 am

tlfong01 wrote:
Sun Mar 03, 2019 6:57 am
My measurement procedure is summarised below.
(1) By trial and error, select a frequency range, turn frequency trim pot to about middle, try a couple of discrete resistors to get a resistor value where Vr is roughly 0.7 of Vs.
(2) Then fine tune frequency to get Vr/Vs ~= 0.7.
It took me less than 10 minutes to get the result

Inductance Measurement - 100uH Second Trial

Now that I seemed to have successfully measured the inductance of the ZYE1-P20/15 electromagnet, I have gained some confidence. But I am only 50% sure that my steps are OK. So I decided to measure the 100uH core again.
...
Attachments
inductance_measurement_2019mar0401.jpg
inductance_measurement_2019mar0401.jpg (198.67 KiB) Viewed 822 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 4:53 am

tlfong01 wrote:
Mon Mar 04, 2019 4:45 am
Now that I seemed to have successfully measured the inductance of the ZYE1-P20/15 electromagnet, I have gained some confidence. But I am only 50% sure that my steps are OK. So I decided to measure the 100uH core again.

Inductance Measurement - 100uH Second Trial

Now I have got a pretty picture.

Lunch time. Will "read" this picture after tea.
:mrgreen:

...
Attachments
inductance_100uh_2019mar0401.jpg
inductance_100uh_2019mar0401.jpg (195.82 KiB) Viewed 819 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 5:57 am

jadel wrote:
Sun Mar 03, 2019 5:18 pm
Currently I am powering the relay board with a separate 12 V power supply. , ...

PSUs for 144 Water Jet Music Fountain

I am day dreaming of building a water feature in my rooftop garden. Currently I am using 1A, 2A PSUs to test the waters.

I have more than 20 small Amp PSUs ready to fry, and another couple of 20A+ PSUs standby. :mrgreen:
...
Attachments
psu_2019mar0401.jpg
psu_2019mar0401.jpg (151.48 KiB) Viewed 813 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 6:18 am

jadel wrote:
Sun Mar 03, 2019 3:41 pm
tlfong01 wrote:
Sun Mar 03, 2019 2:26 pm
I am 90% sure that you don't need any flyback diodes for the relays, because the relays are driven by ULN2803 octal darlingtons with built in flyback diodes.
Just checking you mean I don't need it across the relay not the whole circuit, right?

No flyback diodes across relay switch

I am only 90% sure. The picture below shows the flyback D1 across the relay switch. Now Q1 is replaced by 1/8 ULN2803 darlington with built in flyback. You may like to tell me where the scary flyback goes now. :mrgreen:

Let me know if your Rpi makes smoke. Then I will think again. :mrgreen:

PS - Also look at R1. Instead of R1, your board has 4 PRn with a total of 16 LED current limiting resistors. I will talk about them later.
...
Attachments
sain_smart_4ch_relay_2018jun0501.jpg
sain_smart_4ch_relay_2018jun0501.jpg (163.13 KiB) Viewed 799 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 7:03 am

jadel wrote:
Sun Mar 03, 2019 3:41 pm
I'll have to test it and see. Fingers crossed it works

Problem Based Learning (PBP)

Finger crossed it doesn't work. Then you have a problem to solve and can start doing Problem Based Learning (PBL).

As I said earlier, you relay board has a couple of quad SMD resistor arrays. If you Rpi can switch on but not switch off the relay, chances are the resistor values are for Arduino only. Then you have the necessity to invent a new resistor value for Rpi (yes, scarily desoldering and soldering ridiculously tiny SMD chips).

By the way, the new generation of Arduino guys are using 3V3 versions (Pro Mini etc) and they have the same common problem of 3V3 Arduino High signal not high enough to switch off 5V Arduino compatible relays (or switching on Vgs(th) = 4V power MOSFETs).

Don't tell those Arduino Pro Mini guys the trick, let them weep in the dark, and the Rpi guy who laughs last, laughs best. :mrgreen:

Problem-based learning (PBL) - Wikipedia
https://en.wikipedia.org/wiki/Problem-based_learning

Problem-based learning (PBL) is a student-centered pedagogy in which students learn about a subject through the experience of solving an open-ended problem found in trigger material.

The PBL process does not focus on problem solving with a defined solution, but it allows for the development of other desirable skills and attributes.

This includes knowledge acquisition, enhanced group collaboration and communication. The PBL process was developed for medical education and has since been broadened in applications for other programs of learning. The process allows for learners to develop skills used for their future practice. It enhances critical appraisal, literature retrieval and encourages ongoing learning within a team environment.

The PBL tutorial process involves working in small groups of learners. Each student takes on a role within the group that may be formal or informal and the role often alternates. It is focused on the student's reflection and reasoning to construct their own learning. The Maastricht seven-jump process involves clarifying terms, defining problem(s), brainstorming, structuring and hypothesis, learning objectives, independent study and synthesis.[1] In short, it is identifying what they already know, what they need to know, and how and where to access new information that may lead to the resolution of the problem. The role of the tutor is to facilitate learning by supporting, guiding, and monitoring the learning process.[2] The tutor aims to build students' confidence when addressing problems, while also expanding their understanding. This process is based on constructivism. PBL represents a paradigm shift from traditional teaching and learning philosophy, which is more often lecture-based. The constructs for teaching PBL are very different from traditional classroom or lecture teaching and often require more preparation time and resources to support small group learning.

...
Attachments
quad_smd_resistor_array_2019mar0401.jpg
quad_smd_resistor_array_2019mar0401.jpg (198.56 KiB) Viewed 772 times
Last edited by tlfong01 on Tue Mar 05, 2019 12:52 am, edited 2 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 8:10 am

tlfong01 wrote:
Mon Mar 04, 2019 4:53 am
Inductance Measurement - 100uH Second Trial
Now I have got a pretty picture.

Inductance Measurement - 200uH First Trial

The 100uH picture does not look very good. So I connect another 100uH in series to make a 200uH inductance to measure. The results is displayed below.

Below is a summary.

-----------------------------------------------------------------------------------------
Value Period Freq Vs Vr Vr/Vs lag time lag degrees
-----------------------------------------------------------------------------------------
100uH 2500nS 400kHz 1.75V 1.20V 0.69 250nS 36 deg
200uH 5500nS 182kHz 1.70V 1.25V 0.74 500nS 33 deg

-----------------------------------------------------------------------------------------

Now I don't know how to calculate the inductance. I need to watch the Rose Hullman video again, and also quickly read again the All-About-Circuits free eBook chapters on AC Circuits and Inductance (Chapters 2, 3). :mrgreen:
...
Attachments
inductance_200uh_2019mar0401.jpg
inductance_200uh_2019mar0401.jpg (244.99 KiB) Viewed 758 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 9:19 am

tlfong01 wrote:
Mon Mar 04, 2019 8:10 am
Now I don't know how to calculate the inductance. I need to watch the Rose Hullman video again, and also quickly read again the All-About-Circuits free eBook chapters on AC Circuits and Inductance (Chapters 2, 3).

Inductance Calculation Results - Winner Winner Chicken Dinner!

I fast forwarded the Rose Hulman lecture and used my fake TI Scientific Calculator (a cheapy Casio MS-100TM 10 Digits Two Way Power) to calculate the inductance.

To my pleasant surprise, I got "perfect" results.

Now I have regained my confidence in AC circuits. Imaginary / complex numbers is a piece of cake! :mrgreen:

For sure I can pass the Rose Hullman final exam with flying colours. Perhaps I should apply for a tutor job at Rose Hullman! :mrgreen:

...
Attachments
inductance_calc_2019mar0402s.jpg
inductance_calc_2019mar0402s.jpg (165.58 KiB) Viewed 746 times
Last edited by tlfong01 on Tue Mar 05, 2019 5:19 am, edited 1 time in total.
I am an electronics and smart home hobbyist.

jadel
Posts: 18
Joined: Tue Feb 26, 2019 2:33 pm

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 10:59 am

Just confirming before I miss anything up, this circuit should work with the relay connected at the NO end and the middle. Correct?
Note: I couldn't find a relay board on the circuit making website, so I am using a single relay which will be part of a relay board. The relay board will be connected to the Rpi through the GPIO pins.
Attachments
Capture3.PNG
Capture3.PNG (9.95 KiB) Viewed 708 times

pcmanbob
Posts: 7138
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 11:04 am

jadel wrote:
Mon Mar 04, 2019 10:59 am
Just confirming before I miss anything up, this circuit should work with the relay connected at the NO end and the middle. Correct?
Yes contact will close on relay activation
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 2:26 pm

tlfong01 wrote:
Mon Mar 04, 2019 9:19 am

Inductance of Electromagnet ZYE1-P20/15 DC6V 0.5A = 3400uH

Now I have measured the electromagnet to be 3400uH.

Next step is to calculate the energy stored in the inductor and selection of the flyback diode which can swallow this energy when flyback. I am not sure if I need to calculate things including thermal resistance etc.

...

Code: Select all

---------------------------------------------------------------------------------------------------------------
Sample    R   Period    Freq       Vs      Vr  Vr/Vs lag time  lag deg  L = R / (6.28 * f)  
---------------------------------------------------------------------------------------------------------------
100uH   220   2.50uS   400kHz   1.75V   1.20V   0.69   0.25uS    36deg    ( 220 / (6.28 * 400k)) * 1m =   88 uH  
200uH   220   5.50uS   182kHz   1.70V   1.25V   0.74   0.50uS    33deg    ( 220 / (6.28 * 182k)) * 1m =  193 uH
300uH   220   3.75uS   267kHz   2.60V   1.80V   0.69   0.25uS    24deg    ( 560 / (6.28 * 267k)) * 1m =  330 uH
400uH   220   3.85uS   260kHz   2.70V   1.75V   0.65   0.25uS    23deg    ( 560 / (6.28 * 260k)) * 1m =  343 uH
500uH   220   4.00uS   250kHz   2.70V   1.80V   0.67   0.25uS    23deg    ( 560 / (6.28 * 250k)) * 1m =  356 uH
500uH   220   4.00uS   250kHz   2.75V   1.90V   0.69   0.25uS    23deg    (1200 / (6.28 * 250k)) * 1m =  760 uH
ZYE-1  1200  18.00uS    56kHz   2.65V   1.85V   0.70   2.00us    40deg    (1200 / (6.28 *  56k)) * 1m = 3400 uH  
---------------------------------------------------------------------------------------------------------------
...
Attachments
zye1_inductance_2019mar0401s.jpg
zye1_inductance_2019mar0401s.jpg (184.14 KiB) Viewed 683 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Mon Mar 04, 2019 2:52 pm

tlfong01 wrote:
Mon Mar 04, 2019 2:26 pm

Energy stored in the electromagnet ZYE1

I have found the formula for energy stored in an inductor.

http://hyperphysics.phy-astr.gsu.edu/hb ... ndeng.html
...
Attachments
energy_in_inductor_2019mar0402.jpg
energy_in_inductor_2019mar0402.jpg (115.81 KiB) Viewed 679 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Tue Mar 05, 2019 1:10 am

tlfong01 wrote:
Mon Mar 04, 2019 6:18 am
jadel wrote:
Sun Mar 03, 2019 3:41 pm
tlfong01 wrote:
Sun Mar 03, 2019 2:26 pm
I am 90% sure that you don't need any flyback diodes for the relays, because the relays are driven by ULN2803 octal darlingtons with built in flyback diodes.
Just checking you mean I don't need it across the relay not the whole circuit, right?[/color]
No flyback diodes across relay switch
I am only 90% sure. The picture below shows the flyback D1 across the relay switch. Now Q1 is replaced by 1/8 ULN2803 darlington with built in flyback. You may like to tell me where the scary flyback goes now.
Let me know if your Rpi makes smoke. Then I will think again.

Adding Extra Flyback Diodes On The B Side of The Relay PCB

In case you don't wish your Rpi catching fire, you can add 16 extra flyback diodes (I recommend 1N5822, the same thing used in your SS16ch12Vopto board) on the back side of the PCB, as shown below. Your high class SaintSmart PCB has 14K gold plated solder pads which are very solder friendly, and there is ample space for the newbie to practise soldering and messing around. :mrgreen:
...
Attachments
ss_16ch_12v_relay_pcb_2019mar0401.jpg
ss_16ch_12v_relay_pcb_2019mar0401.jpg (163.86 KiB) Viewed 660 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Connecting electromagnet to pi

Tue Mar 05, 2019 4:06 am

jadel wrote:
Mon Mar 04, 2019 10:59 am
CONNECTING ELECTROMAGNET TO PI Postby jadel » 2019-Feb-26 Tue 10:50 pm
1. I want to control an electromagnet that I built with my rpi. I built the magnet myself and want to run 12V into it, it has 2 ohm resistance so the current will be 6A.
2. I couldn't find a relay board on the circuit making website, so I am using a single relay which will be part of a relay board.

Huge Magnet of 1H

1. The magnet shown in your picture is 1H. Is it a huge magnet, not the same 2 Ohm 6 Amp you mentioned in your original post?

2. Is the "circuit making site” using a huge relay for the huge magnet? And your are now instead using one of the sixteen smaller relays of your SaintSmart 16 channel relay board?

I am playing with DC6V 500mA electromagnets, they are only 3.7mH, thousands of times weaker than your stronger guy! :(


I measured 1, 2, 3, and 4 magnets and found it very tiring to do the measurements, perhaps because (1) the magnet has a big range of values, so the values for 1, 2, 3, and 4 magnets do not add up proportionally, (2) My visual measurements are not accurate at all (I should have used the scope's digital ruler to do the measurements, but I am too lazy to learn). My conclusion is that my results are not reliable and not repeatable.

I can only said that the average inductance is very very roughly 5mH.
...

Code: Select all

---------------------------------------------------------------------------------------------------------
Sample       R    Period        Freq     Vs       Vr  Vr/Vs  lag time     lag deg  L = R/(6.28*f) 
---------------------------------------------------------------------------------------------------------
100uH      220    2.50uS   400.00kHz   1.75V   1.20V   0.69    0.25uS    36.00deg       88 uH  
200uH      220    5.50uS   182.00kHz   1.70V   1.25V   0.74    0.50uS    33.00deg      193 uH
300uH      220    3.75uS   267.00kHz   2.60V   1.80V   0.69    0.25uS    24.00deg      330 uH
400uH      220    3.85uS   260.00kHz   2.70V   1.75V   0.65    0.25uS    23.00deg      343 uH
500uH      220    4.00uS   250.00kHz   2.70V   1.80V   0.67    0.25uS    23.00deg      356 uH
500uH      220    4.00uS   250.00kHz   2.75V   1.90V   0.69    0.25uS    23.00deg      760 uH
ZYE-1 x 1 1200   12.00uS    83.00kHz   2.70V   1.70V   0.70    1.00uS    36.00deg    2,302 uH   2.3 mH
ZYE-1 x 2 1200   35.00uS    28.57kHz   2.70V   1.60V   0.59    1.00uS    38.00deg    8,607 uH   8.6 mH
ZYE-1 x 3 1200   75.50uS    13.00kHz   2.70V   1.75V   0.65    1.00uS    38.00deg   14,367 uH  14.4 mH
ZYE-1 x 4 1200  160.00uS     6.25kHz   2.60V   1.80V   0.69   10.00uS    22.50deg   30,574 uH  30.6 mH
---------------------------------------------------------------------------------------------------------
Avg = 5.5mH
...
Attachments
quad_dc6v_05a_magnet_brd_2019mar0501.jpg
quad_dc6v_05a_magnet_brd_2019mar0501.jpg (163.96 KiB) Viewed 649 times
Last edited by tlfong01 on Tue Mar 05, 2019 9:18 am, edited 3 times in total.
I am an electronics and smart home hobbyist.

Return to “Automation, sensing and robotics”