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

Re: How to use Solenoid Lock 12V DC

Tue Jan 08, 2019 7:13 am

tlfong01 wrote:
Tue Jan 08, 2019 3:31 am
ZYE1 Solenoid Max Frequency is about 20Hz

Solenoid would be damaged if switched too often


I read solenoid lock ad saying that solenoid is designed for momentarily activated, otherwise the it would be damaged.

I have now secured the solenoid on a acrylic board, ready for hold weight testing and also Rpi software testing.

LY-031 12VDC Solenoid Cabinet Lock
https://item.taobao.com/item.htm?spm=a2 ... t=6#detail

...
Attachments
zye1_on_acrylic_brd_2019jan0801.jpg
zye1_on_acrylic_brd_2019jan0801.jpg (162.93 KiB) Viewed 2439 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: How to use Solenoid Lock 12V DC

Tue Jan 08, 2019 9:24 am

tlfong01 wrote:
Tue Jan 08, 2019 7:13 am

Rpi3B+ + ESP8266-12 + HX711 based auto cat feeder design notes
...
Attachments
cat_feeder_2019jan0803.jpg
cat_feeder_2019jan0803.jpg (189.88 KiB) Viewed 2430 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: How to use Solenoid Lock 12V DC

Tue Jan 08, 2019 9:40 am

davidcoton wrote:
Sat Jan 05, 2019 2:50 pm
In rating the fuse, it is only the cable that is considered. If the current using device (in this case the PSU) needs protection on its input, this should be provided at the equipment.

Looking at the photos, the cable is made of conductors with 0.75mm2 cross section, which is normally rated at 6A.

But since the current required is much less (~100mA), a standard 3A fuse is suitable.

1A, 2A or 5A could also be used but are less well accepted than the primary standard values of 3A and 13A. Of course I may have mis-identified the cable....

For your eyes only

Your eyes are almost as good as Sheena Easton!

Your very detailed explanation and advice on fuse selection is also professional and considerate to hobbyists! :mrgreen:


For Your Eyes Only - Sheena Easton - 14,015,699 views
https://www.youtube.com/watch?v=JP4xXjW97ko

...
Attachments
mains_cable_thickness_2019jan0803.jpg
mains_cable_thickness_2019jan0803.jpg (156.54 KiB) Viewed 2430 times
I am an electronics and smart home hobbyist.

User avatar
davidcoton
Posts: 6584
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: How to use Solenoid Lock 12V DC

Tue Jan 08, 2019 11:05 am

tlfong01 wrote:
Tue Jan 08, 2019 9:40 am

For your eyes only

Your eyes are almost as good as Sheena Easton!

Your very detailed explanation and advice on fuse selection is also professional and considerate to hobbyists! :mrgreen:

Looks right. The overall diameter of a 3-core 0.75mm2 flexible cable should be about 6.5mm.
Location: 345th cell on the right of the 210th row of L2 cache

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

Re: How to use Solenoid Lock 12V DC

Tue Jan 08, 2019 12:14 pm

tlfong01 wrote:
Sun Jan 06, 2019 8:38 am
Now I found the following good tutorial clarifying three things in one go. This century I have been playing only with digital circuits, and miserably helpless me don't have Maple or MathLab, so I have a big excuse to mess up things! :mrgreen:
Analog Electronics Tutorial
http://physics.wm.edu/~evmik/classes/Ph ... slides.pdf

Noether Theorem

Just now I skimmed through the 3 in 1 tutorial. Now I understand why I have forgotten them but don't seem to worry. The reason is that I never use them in my day to day electronics hobbyist projects.

Of course I use the common laws such as Ohm's Law, equivalent parallel and serial resistors and capacitors (almost never inductors), voltage sources but almost never current source. I know the exponential curve of capacitor charging and discharging, but almost never the corresponding inductor current characteristics.

So I conclude that it is NOT necessary to understand the three laws or theorems.

But to consider what value of fuse to use in the mains plug or the 12V to 5V PSU, I do need to consider one theorem, the Noether's Theorem, which I think I have been using when calculating the currents on both sides of a transformer, ie, power on both sides should be equal, or Vsecondary * Isecondary = Vprimary * Iprimary.

Just thinking aloud. Nothing useful, but important in basic understanding of electronics circuits.

Emmy Noether - Wikipedia
https://en.wikipedia.org/wiki/Emmy_Noether

Emmy Noether - Famous Scientists
https://www.famousscientists.org/emmy-noether/

Physics is actually too hard for physicists. -- David Hilbert 1915

"She knows her stuff.” - Albert Einstein 1918
...
Attachments
emma_noether_2019jan0801.jpg
emma_noether_2019jan0801.jpg (120.31 KiB) Viewed 2411 times
Last edited by tlfong01 on Wed Jan 09, 2019 1:08 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: How to use Solenoid Lock 12V DC

Tue Jan 08, 2019 2:18 pm

tlfong01 wrote:
Tue Jan 08, 2019 7:13 am
ZYE1 Solenoid Max Frequency is about 20Hz
I have now secured the solenoid on a acrylic board, ready for ... Rpi software testing.

Rpi program testing ZY1 Solenoid OK

I wrote a minimal python program to switch on/off the solenoid and found it OK.

However, there is a small setup problem. I first tested the program without the solenoid, just to see if the relay status green light blinks and clicks.

But when I later tried to hot connect the solenoid, I saw sparks (I know this means my hands were trembling and did not connect properly and caused a couple of makes and breaks. And when the solenoid coil with current breaks, there is back EMF, and the Rpi resets itself (but not fried!)

(youtube) https://youtu.be/hov3hx7tpAE

...

Code: Select all

# zye1_test_2019jan0801.py tlfong01 2019jan09hkt2157 ***

import RPi.GPIO as GPIO
from   time import sleep

relayPin= 11

# *** GPIO Functions ***

def setGpioMode():
    GPIO.setwarnings(False) 
    GPIO.setmode(GPIO.BCM)
    return

# *** Set Gpio pin as output ***

def setGpioPinOutput(gpioPin):
    GPIO.setup(gpioPin, GPIO.OUT)
    return

# *** Set Gpoio pin High/Low ***

def setGpioPinHigh(gpioPin):  
    GPIO.output(gpioPin, GPIO.HIGH)
    return

def setGpioPinLow(gpioPin): 
    GPIO.output(gpioPin, GPIO.LOW)
    return

# *** Toggle Gpio pin ***

def toggleGpioPin(gpioPin, highSecond, lowSecond, count): 
    for i in range(count):
        setGpioPinHigh(gpioPin)
        sleep(1)
        setGpioPinLow(gpioPin)
        sleep(1)
    return

# *** Main ***

print('Begin togglePin(), ...')
setGpioMode()
setGpioPinOutput(relayPin)
toggleGpioPin(gpioPin = relayPin, highSecond = 1, lowSecond = 1, count = 4)
print('End   togglePin().')

# *** End ***
...
Attachments
rpi_zye1_test_2019jan0801.jpg
rpi_zye1_test_2019jan0801.jpg (157.7 KiB) Viewed 2403 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: How to use Solenoid Lock 12V DC

Wed Jan 09, 2019 3:15 am

tlfong01 wrote:
Mon Jan 07, 2019 2:03 pm
Another thing I would like to know if the current need to activate and deactivate the solenoid.
ZYE1 Solenoid Calibration Results
I increased Vin from around 3V to 10V, found the trigger level (pull) at round 5.5V 350mA. Then I decreased Vin to 0.5V and found deactivate level (release) at a very low level of 0.5V

ZYE1-0837ZP DC12V 0.8N Solenoid Hysteresis

There are too many things I don't know about the solenoid, like why my solenoid has a big hysteresis of 6V to 0.5V, and what is the meaning of pulling or holding 0.5N, so I am doing more research. :mrgreen:

Solenoid Basics - 628,681 views
https://www.youtube.com/watch?v=hsoggQOoG4s

Post-Apocalyptic Computing with Jeri Ellsworth’s Home-Brewed Chips - 25 Nov 2018
https://thenewstack.io/post-apocalyptic ... wed-chips/

Magnetic Logic - Forgotten Technology 387,479 views
https://www.youtube.com/watch?time_cont ... 7SkE5pERtA

Jeri Ellsworth -Wikipedia
https://en.wikipedia.org/wiki/Jeri_Ellsworth

A Toy With a Story - John Markoffdec NyTimes 2004dec20
https://www.nytimes.com/2004/12/20/tech ... story.html
...
Attachments
zye1_hysteresis_2019jan0901.jpg
zye1_hysteresis_2019jan0901.jpg (152.16 KiB) Viewed 2379 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: How to use Solenoid Lock 12V DC

Wed Jan 09, 2019 7:39 am

tlfong01 wrote:
Wed Jan 09, 2019 3:15 am
Solenoid Basics - 628,681 views
https://www.youtube.com/watch?v=hsoggQOoG4s
A Toy With a Story - NyTimes 2004dec20
https://www.nytimes.com/2004/12/20/tech ... story.html

ZYE1-0387ZP 12VDC 0.8N Solenoid Hold Strength Experiment

After watching Jeri Ellsworth's videos, I did the same experiment and summarize the following results.

1. When applying 12V DC to the solenoid, the holding force is about 1.5kg.

2. After a couple of minutes, the solenoid gets warm and runs out of steam, drops the 1.5kg load. But it can still hold 1kg for another 10 minutes.

I am surprised to find that the little solenoid so powerful. I need to do more research again! :mrgreen:
...
Attachments
zye1_solenoid_force_2019jan0901.jpg
zye1_solenoid_force_2019jan0901.jpg (170.63 KiB) Viewed 2379 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: How to use Solenoid Lock 12V DC

Wed Jan 09, 2019 8:15 am

tlfong01 wrote:
Wed Jan 09, 2019 7:39 am
ZYE1-0387ZP 12VDC 0.8N Solenoid Hold Strength Experiment
1. When applying 12V DC to the solenoid, the holding force is about 1.5kg.
2. After a couple of minutes, the solenoid gets warm and runs out of steam, drops the 1.5kg load. But it can still hold 1kg for another 10 minutes.

ZYE1 Spec

The ZYE1 spec I googled does not seem to match my experiment results. I guess my misunderstood something. :(

ZYE1 Spec
https://world.taobao.com/item/15241499702.htm

Hysteresis - Wikipedia
https://en.wikipedia.org/wiki/Hysteresis

Analyzing Magnetic and Mechanical Hysteresis in a Proportional Solenoid
- Solenoid Systems

https://www.google.com/search?q=solenoi ... e&ie=UTF-8
...
Attachments
zye1_spec_2019jan0902.jpg
zye1_spec_2019jan0902.jpg (185.81 KiB) Viewed 2371 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: How to use Solenoid Lock 12V DC

Wed Jan 09, 2019 12:07 pm

tlfong01 wrote:
Wed Jan 09, 2019 8:15 am

Electromagnet Lift Hold Solenoid

While searching my junk box for more solenoids to play, I found a round thing looking like a magnet. So I googled.

I surprisingly received an promotion email today about a coming exhibition in coil winding and transformer. I never registered in any of these kind of organization. I am a little bit worried how they got the email of those who googled searched solenoid, or discussed solenoids in a forum.

Amazon ZYE1-P25/20 5KG(50N) Electric Lifting Magnet Electromagnet Solenoid Lift Holding Waterproof US$10
https://www.amazon.com/ZYE1-P25-Electri ... B077TJD5DK

正永直流吸盘式电磁铁 ZYE1-P25/20 DC5V ¥20
https://item.taobao.com/item.htm?spm=a2 ... t=6#detail

CWIEME SHANGHAI is Asia-Pacific’s professional event dedicated to Coil Winding, Electric Motor and Transformer Manufacturing Exhibition. The fastest growing event within the CWIEME family.
http://cn.coilwindingexpo.com/en

Taking place from the 26-28 March 2019 and located in SWEECC, CWIEME Shanghai provides a platform for coil winding, electric motor and transformer suppliers to showcase their products to a high-profile audience, to keep on top of emerging trends, industry developments, and to help build long term, sustainable business relationships.

Every year, highly-specialized engineers and procurement professionals attend CWIEME to meet new and existing suppliers, invest in innovative products and solutions, network with their peers and stay up-to-date with the latest trends and industry developments. It is the ideal platform for companies to highlight their products and technologies to key buyers and decision makers who have real purchasing power.

If you desire to introduce your company, build up sales pipeline in China and APAC, if you want to connect with a greater spectrum of prospects, there is no other event where you can meet a concentrated customer base of coil, electric motor, generator and transformer manufacturers than CWIEME SHANGHAI.

Who will you meet onsite of CWIEME SHANGHAI Attendees by Company Sector
Motor manufacturers
Transformer manufacturers
Coil manufacturers
Generator manufacturers
OEMS – automotive/ energy/consumer electronics and appliances

With CWIEME SERIES‘ UNIQUE GLOBAL PROMOTION PLATFORM, CWIEME SHANGHAI delivers
Access to a global community of industry professionals 100,000+ purchasing and engineering professionals
Senior audience from across the ecosystem 13,800+ attendees of highly specialized engineers and procurement professionals
The newest and most innovative products, solutions & technologies 1,100+ quality exhibitors
Exceptional content 50+ hours of technical seminar content

...
Attachments
lift_hold_solenoid_2019jan0901.jpg
lift_hold_solenoid_2019jan0901.jpg (105.53 KiB) Viewed 2362 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: How to use Solenoid Lock 12V DC

Wed Jan 09, 2019 1:15 pm

davidcoton wrote:
Tue Jan 08, 2019 11:05 am
Looks right. The overall diameter of a 3-core 0.75mm2 flexible cable should be about 6.5mm.

AWG 26 Wire Current Limit

Ah, I never care about wire diameter, though I prefer thin wires because they are soft and flexible. For my Micky Mouse hobbyist projects, I almost always use AWG26 wires.
...
Attachments
awg_current_limit_2019jan0901.jpg
awg_current_limit_2019jan0901.jpg (176.96 KiB) Viewed 2358 times
I am an electronics and smart home hobbyist.

User avatar
davidcoton
Posts: 6584
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: How to use Solenoid Lock 12V DC

Wed Jan 09, 2019 2:07 pm

tlfong01 wrote:
Wed Jan 09, 2019 1:15 pm
davidcoton wrote:
Tue Jan 08, 2019 11:05 am
Looks right. The overall diameter of a 3-core 0.75mm2 flexible cable should be about 6.5mm.

AWG 26 Wire Current Limit

Ah, I never care about wire diameter, though I prefer thin wires because they are soft and flexible. For my Micky Mouse hobbyist projects, I almost always use AWG26 wires.
Internal wiring is a different matter. If you do use 26AWG for the incoming mains, that's when you need to consider whether an internal fuse is required at 2A or less, because the fuse in the plug won't provide appropriate protection. Even if you fit a 1A or 2A fuse in the plug, someone else couild look at the supply cable and change the fuse for a higher rating....
Location: 345th cell on the right of the 210th row of L2 cache

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

Re: How to use Solenoid Lock 12V DC

Wed Jan 09, 2019 2:52 pm

davidcoton wrote:
Wed Jan 09, 2019 2:07 pm
tlfong01 wrote:
Wed Jan 09, 2019 1:15 pm
davidcoton wrote:
Tue Jan 08, 2019 11:05 am
Looks right. The overall diameter of a 3-core 0.75mm2 flexible cable should be about 6.5mm.
AWG 26 Wire Current Limit
Ah, I never care about wire diameter, though I prefer thin wires because they are soft and flexible. For my Micky Mouse hobbyist projects, I almost always use AWG26 wires.
Internal wiring is a different matter. If you do use 26AWG for the incoming mains, that's when you need to consider whether an internal fuse is required at 2A or less, because the fuse in the plug won't provide appropriate protection. Even if you fit a 1A or 2A fuse in the plug, someone else couild look at the supply cable and change the fuse for a higher rating....

Main fuse and Internal Fuse Design

Ah, thank you. You said the thing I did not know how to express. Now let me summarize.

1. There are two places you need to fit a fuse: (a) the 220VAC mains plug, let us call it the "mains fuse", (b) the application end, in my case, output of the 12VDC PSU. Let us call it the "application fuse".

2. I was going to use the common sense "power should be the same both sides law " to find if the application fuse is 2A, say, then the mains fuse should be 2A * (12 / 220) ~= 0.05A = 50mA

3. So I will fit a application fuse of 50mA (or the nearest I can find, perhaps 100mA).

4. I did worry what you worry, so I already decided that if I did fit a 1A fuse in the main plug, I would stick a bright red warning label on the plug with a sign like "This plug is intentionally fit with a small fuse, do not change it, ..."
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: How to use Solenoid Lock 12V DC

Wed Jan 09, 2019 3:01 pm

tlfong01 wrote:
Wed Jan 09, 2019 12:07 pm

ZYE1 DC6V 10mm 0.8N Solenoid Calibration Notes

/to continue, ...
...
Attachments
zye1_dc6v_10mm_08n_2019jan0902.jpg
zye1_dc6v_10mm_08n_2019jan0902.jpg (138.45 KiB) Viewed 2344 times
I am an electronics and smart home hobbyist.

User avatar
davidcoton
Posts: 6584
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: How to use Solenoid Lock 12V DC

Wed Jan 09, 2019 3:42 pm

tlfong01 wrote:
Wed Jan 09, 2019 2:52 pm

Ah, thank you. You said the thing I did not know how to express. Now let me summarize.

1. There are two places you need to fit a fuse: (a) the 220VAC mains plug, let us call it the "mains fuse", (b) the application end, in my case, output of the 12VDC PSU. Let us call it the "application fuse".

2. I was going to use the common sense "power should be the same both sides law " to find if the application fuse is 2A, say, then the mains fuse should be 2A * (12 / 220) ~= 0.05A = 50mA

3. So I will fit a application fuse of 50mA (or the nearest I can find, perhaps 100mA).

...
Actually, there are three places.(a) mains fuse, correct. (b) INPUT to the 12VDC PSU "appliance fuse". (c) OUTPUT from the 12VDC PSU "12V fuse".

a) We have already determined this protects the external supply cable, rated 6A, so 3A is the most standard, but 1A, 2A, 5A are also suitable.

b) This protects the appliance itself from excessive damage (fire) under fault conditions, because the mains fuse will not adequately protect the internal mains wiring if it is 26AWG. This is also a mains fuse, 2A maximum. The minimum will be determined by the required 12V output current (translated by constant power calculation), plus some for losses, plus an "anti-surge" allowance for start-up conditions. So for 2A output at 12V, 100mA minimum (dodgy maths if you got 50mA). But a quick-blow 100mA fuse will probably blow every time you switch on. So 150mA Antisurge, or a 2A Quick blow will probably work (check "maximum inrush" current and time for given PSU).

c) Determined by the current carrying capability of the OUTPUT conductors and the PSU maximum current output. If the cables can safely carry more current than the supply can deliver, this fuse is probably unnecessary (Full answer depends on the failure modes of the PSU. Yuck.)
Location: 345th cell on the right of the 210th row of L2 cache

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

Re: How to use Solenoid Lock 12V DC

Thu Jan 10, 2019 5:58 am

tlfong01 wrote:
Wed Jan 09, 2019 3:01 pm
ZYE1 DC6V10mm 0.8N Solenoid Calibration Notes

Solenoid Valve 12DVC 4.8W Calibration Notes

/ to continue, ...
...
Attachments
solenoid_valve_12vdc_4w8_2019jan1001.jpg
solenoid_valve_12vdc_4w8_2019jan1001.jpg (160.84 KiB) Viewed 2310 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: How to use Solenoid Lock 12V DC

Thu Jan 10, 2019 6:49 am

tlfong01 wrote:
Thu Jan 10, 2019 5:58 am
tlfong01 wrote:
Wed Jan 09, 2019 3:01 pm
ZYE1 DC6V10mm 0.8N Solenoid Calibration Notes
Solenoid Valve 12DVC 4.8W Calibration Notes

Solenoid Valve 12DVC 4.8W Calibration Notes

Summary
1. Pull threshold = 4V 150mA,
2. Release threshold = 3.5V 140mA
3. 12V current = 460mA
4. 0.5V = 20mA

...
Attachments
solenoid_valve_hysteresis_2019jan1001.jpg
solenoid_valve_hysteresis_2019jan1001.jpg (160.26 KiB) Viewed 2302 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: How to use Solenoid Lock 12V DC

Thu Jan 10, 2019 9:05 am

tlfong01 wrote:
Thu Jan 10, 2019 6:49 am

Rpi3B+ program to control ZYE1 Version 2019jan10

Program tested OK.

# zye1_test_2019jan1001.py tlfong01 2019jan109hkt1625 ***

# ****************************************************************************************
# Program Documentation 2019jan10hkt1625
#
# System Config
# Rpi hardware = Rpi3B+
# Rpi software = $ hostnamectl = raspberrypi Raspbian GNU/Linux 9 (stretch) Linux 4.14.34-v7+ arm
# Python = >>> sys.version = 3.5.3 Jan 19 2017

# Program Description
# 1. Setup Rpi.GPIO BCM mode
# 2. Set GPIO11 as relayPin to control 5V rela KY019
# 3. Toggle 100 times relayPin at 1Hz

# Test Description
# 1. Rpi GPIO pin controls Relay KY019
# 2. Relay KY019 controls Solenoid ZTE1

# Program Developmenet Description
# 1.0 NE555 Timer Test
# 1.1 NE555 timer to generate 1Hz square wave, with red status LED blinking
# 1.2 NE555 output to control KY019, green LED blinks, relay clicks
# 2.0 Digital Signal Generator (DSG) Test
# 2.1 DSG 1Hz to 20Hz signal to control KY019
# 3.0 Rpi Test
# 3.1 Rpi GPIO toggles at 1Hz, 4 times to control KY019
# 4.0 Solenoid Test
# 4.1 Repeat 1.0 to 3.0 with Solenoid ZYE1 connected
#****************************************************************************************

...

Code: Select all

# zye1_test_2019jan1001.py tlfong01 2019jan109hkt1625 ***

# ***************************************************************************************************
# Program Documentation 2019jan10hkt1625
#
# System Config
# Rpi hardware = Rpi3B+
# Rpi software = $ hostnamectl = raspberrypi Raspbian GNU/Linux 9 (stretch) Linux 4.14.34-v7+ arm 
# Python = >>> sys.version = 3.5.3 Jan 19 2017

# Program Description
# 1. Setup Rpi.GPIO BCM mode
# 2. Set GPIO11 as relayPin to control 5V rela KY019
# 3. Toggle 100 times relayPin at 1Hz

# Test Description
# 1. Rpi GPIO pin controls Relay KY019
# 2. Relay KY019 controls Solenoid ZTE1

# Program Developmenet Description
# 1.0  NE555 Timer Test
# 1.1 NE555 timer to generate 1H square, with red status LED blingking
# 1.2 NE555 output to control KY019, green LED blinks, relay clicks
# 2.0 Digital Signal Generator (DSG) Test
# 2.1 DSG 1Hz to 20Hz signal to control KY019
# 3.0 Rpi Test
# 3.1 Rpi GPIO toggles at 1Hz, 4 times to control KY019
# 4.0 Solenoid Test
# 4.1 Repeat 1.0 to 3.0 with Solenoid ZYE1 connected
#******************************************************************************************************

import RPi.GPIO as GPIO
from   time import sleep

# *** GPIO Functions ***

def setGpioMode():
    GPIO.setwarnings(False) 
    GPIO.setmode(GPIO.BCM)
    return

# *** Set Gpio pin as output ***

def setGpioPinOutput(gpioPin):
    GPIO.setup(gpioPin, GPIO.OUT)
    return

# *** Set Gpoio pin High/Low ***

def setGpioPinHigh(gpioPin):  
    GPIO.output(gpioPin, GPIO.HIGH)
    return

def setGpioPinLow(gpioPin): 
    GPIO.output(gpioPin, GPIO.LOW)
    return

# *** Toggle Gpio pin ***

def toggleGpioPin(gpioPin, highSecond, lowSecond, count): 
    for i in range(count):
        setGpioPinHigh(gpioPin)
        sleep(highSecond)
        setGpioPinLow(gpioPin)
        sleep(lowSecond)
    return

# *** Main ***

print('Begin togglePin(), ...')

relayPin   = 11
highSecond = 1
lowSecond  = 1
count      = 100

setGpioMode()
setGpioPinOutput(relayPin)

toggleGpioPin(relayPin, highSecond, lowSecond, count)

print('End   togglePin().')

# *** End ***
Last edited by tlfong01 on Mon Jan 14, 2019 4:01 am, edited 3 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: How to use Solenoid Lock 12V DC

Thu Jan 10, 2019 1:49 pm

tlfong01 wrote:
Thu Jan 10, 2019 9:05 am
Rpi3B+ program to control ZYE1 Version 2019jan10
Program tested OK.
# zye1_test_2019jan1001.py tlfong01 2019jan109hkt1625 ***



Relay KY019 and Solenoid ZYE1 Back EMF Watching Notes

Now I am switching on/off the solenoid at 10Hz, and using my new CNY2,000 Rigol scope to watch the back EMFs.

When I ran the test program, Rpi desktop gui immediately went dark, I thought Rpi auto reset by the back EMF, but when I hit the keyboard, the screen came back, and nothing happened, ie, no back EMF triggered auto reset. I tried again and the same thing happen. I think this is not a pure coincidence. It is a bad sign that something goes wrong as soon as I toggle the solenoid too fast. This weird thing did not happen when last year I fast toggled only the relay.

I am worrying more scary things might happen. So I decided not to test the solenoid for now, but just the KY019 relay. :mrgreen:


def test02(): # *** Toggle 10Hz 100 times ***
print('Begin togglePin(), ...')
setup()
relayPin = 11
highSecond = 0.05
lowSecond = 0.05
count = 100
print(' relayPin =', relayPin, 'highSecond =', highSecond, \
'lowSecond =', lowSecond, 'count =', count)
print(' now toggling, hit <ctrl>C to abort this python program.')
setGpioPinOutput(relayPin)
toggleGpioPin(relayPin, highSecond, lowSecond, count)
print('End togglePin().')
return


...

Code: Select all

# zye1_test_2019jan1002.py tlfong01 2019jan10hkt2110 ***

# ***************************************************************************************************
# Program Documentation 2019jan10hkt2111
#
# System Config
# Rpi hardware = Rpi3B+
# Rpi software = $ hostnamectl = raspberrypi Raspbian GNU/Linux 9 (stretch) Linux 4.14.34-v7+ arm 
# Python = >>> sys.version = 3.5.3 Jan 19 2017

# Program Description
# 1. Setup Rpi.GPIO BCM mode
# 2. Set GPIO11 as relayPin to control 5V rela KY019
# 3. Toggle 100 times relayPin at 1Hz

# Test Description
# 1. Rpi GPIO pin controls Relay KY019
# 2. Relay KY019 controls Solenoid ZTE1

# Program Developmenet Description
# 1.0  NE555 Timer Test
# 1.1 NE555 timer to generate 1H square, with red status LED blingking
# 1.2 NE555 output to control KY019, green LED blinks, relay clicks
# 2.0 Digital Signal Generator (DSG) Test
# 2.1 DSG 1Hz to 20Hz signal to control KY019
# 3.0 Rpi Test
# 3.1 Rpi GPIO toggles at 1Hz, 4 times to control KY019
# 4.0 Solenoid Test
# 4.1 Repeat 1.0 to 3.0 with Solenoid ZYE1 connected
#******************************************************************************************************

import RPi.GPIO as GPIO
from   time import sleep

# *** GPIO Functions ***

def setRpiGpioModulePinNumberingMode():
    GPIO.setwarnings(False) 
    GPIO.setmode(GPIO.BCM)
    return

# *** Set Gpio pin as output ***

def setGpioPinOutput(gpioPin):
    GPIO.setup(gpioPin, GPIO.OUT)
    return

# *** Set Gpoio pin High/Low ***

def setGpioPinHigh(gpioPin):  
    GPIO.output(gpioPin, GPIO.HIGH)
    return

def setGpioPinLow(gpioPin): 
    GPIO.output(gpioPin, GPIO.LOW)
    return

# *** Toggle Gpio pin ***

def toggleGpioPin(gpioPin, highSecond, lowSecond, count): 
    for i in range(count):
        setGpioPinHigh(gpioPin)
        sleep(highSecond)
        setGpioPinLow(gpioPin)
        sleep(lowSecond)
    return

# *** Setup ***

def setup():
    setRpiGpioModulePinNumberingMode()
    return

#*** Test Functions ***

def test01(): # *** Toggle 1Hz 100 times ***
    print('Begin togglePin(), ...')
    setup()
    relayPin   = 11
    highSecond = 1
    lowSecond  = 1
    count      = 100
    print('  relayPin =', relayPin, 'highSecond =', highSecond, \
          'lowSecond =', lowSecond, 'count =', count)
    print('  now toggling, hit <ctrl>C to abort this python program.')
    setGpioPinOutput(relayPin)
    toggleGpioPin(relayPin, highSecond, lowSecond, count)
    print('End   togglePin().')
    return

def test02(): # *** Toggle 10Hz 100 times ***
    print('Begin togglePin(), ...')
    setup()
    relayPin   = 11
    highSecond = 0.05
    lowSecond  = 0.05
    count      = 100
    print('  relayPin =', relayPin, 'highSecond =', highSecond, \
          'lowSecond =', lowSecond, 'count =', count)
    print('  now toggling, hit <ctrl>C to abort this python program.')
    setGpioPinOutput(relayPin)
    toggleGpioPin(relayPin, highSecond, lowSecond, count)
    print('End   togglePin().')
    return

# *** Main ***

# test01() # *** Toggle  1Hz 100 times ***
test02() # *** Toggle 10Hz 100 times ***

# *** End ***
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: How to use Solenoid Lock 12V DC

Thu Jan 10, 2019 2:44 pm

tlfong01 wrote:
Thu Jan 10, 2019 1:49 pm
Relay KY019 and Solenoid ZYE1 Back EMF Watching Notes
Now I am switching on/off the solenoid at 10Hz, and using my new CNY2,000 Rigol scope to watch the back EMFs.
I am worrying more scary things might happen. So I decided not to test the solenoid for now, but just the KY019 relay. :mrgreen:

A Portrait of the Back EMF as a Wavelet

So I first toggled the KY019 relay at 10Hz, and used my scope to look at Rpi GPIO pin 11, which is sending (3V3 upshifed by TSX0104) 5V0 10Hz square wave to the input pin of KY019 relay. I found everything OK. KY019 clicks and green LED blinks happily. The GPIO pin 11 waveform is sharp and clear.

Now I was getting sleepy and forgot my own warning and took the big risk - connected the no fly-back diode connected 12V ZYE1 solenoid (without load) to 5V KY019 relay contacts! :shock:

Now the KY019 still clicks softly, but the new guy ZYE1 bangs loudly. I noticed very thin spikes shortly after every falling edge of the 10Hz square signal.

I zoomed in and in and finally saw the face of the infamous bad guy - BACK EMF! The ugly creature giggled, and wanted a selfie, so there you are,


A Portrait of the Back EMF as a Wavelet

I call it a day. :mrgreen:

...
Attachments
back_emf_2019jan1001.jpg
back_emf_2019jan1001.jpg (181.28 KiB) Viewed 2275 times
Last edited by tlfong01 on Mon Jan 14, 2019 12:48 pm, 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: How to use Solenoid Lock 12V DC

Fri Jan 11, 2019 2:15 pm

tlfong01 wrote:
Thu Jan 10, 2019 2:44 pm

More Solenoid Hold Strength Tests and Surprising Findings

I used a spring balance to check the hold strength of the solenoid. I found that before heated up, the solenoid can hold 0.8kg, but once heated up, it can only hold 0.5kg.

The other big problem is that a solenoid can hold 0.8kg does not mean that it can begin with pushing or pushing 0.8kg. In other words, when the piston begins pulling, it can pull very little weight, but as it pulls in further and further, its strength gets strong and stronger.

Why?
...
Attachments
solenoid_hold_test_2019jan1101.jpg
solenoid_hold_test_2019jan1101.jpg (169.26 KiB) Viewed 2254 times
I am an electronics and smart home hobbyist.

Return to “Beginners”