magnetic door cct chat

Apr 26, 9:37Your 2 channel relay seems not having any optical coupler to isolator to reduce/prevent back EMF spikes going back to the Rpi’s power supply and thus mess up the python program. Perhaps you should replace it with a relay with the following features: (JD-Vcc jumper, for total optical isolation, (2) Optical couplers.  4 hours later… Ahtisham AshrafApr 26, 13:17If i turn on the 12 V first in that case the Raspberry Boots up , the RFID scans for the first time and then stop working for the second time. For this one i had a plan to restart the script each time someone scans the RFID but in that case it says that the GPIO Pins are in use  1 hour later… Ahtisham Ashraf182Apr 26, 14:33I have found something exactly similar to my question
forum.arduino.cc/t/…I am not a fully Raspberry Expert but i am a developer and for me it is a little bit hard to understand the Electrical things and the terms  1 day later… tlfong015891Tue 15:29@AhtishamAshraf (1) If you click my comment to reply, then I would be notified, just as your address to @tlfong01. Otherwise I would only see your comment when I revisit the chat room again. (2) You plan of restarting the script after every RFID read sounds stupid, and would very likely damage Rpi SE’s reputation! 🙂 tlfong015891Tue 15:40@AhtishamAshraf (1) Your project is a bit advanced, because it involves three things, RFID, Relay, and Door Lock. I guess only less than 1% of the readers in this Rpi SE and EE SE know what is going on! BTW, our comments in your question section got too long and so the Mod set up a chat room for us, so other readers might us too long winded. Now we have already an answer, I think it is OK for us to comment below my answer, until our comments get too long, and the mod would act again. Cheers.  2 hours later… Ahtisham Ashraf182Tue 17:55I have ordered all the relay types , let me share the links for you to check and none of them worked.amazon.ae/gp/product/…this one is a low level trigger and it also didn’t work as expected(removed)@tlfong01  5 hours later… tlfong015891Tue 22:35@AhtishamAshraf Ah, perhaps I have missed some other important thing. I would suggest a simple test to verify that my guess. (1) What you need is a a LED with a series current limiting resistor to replace the 12V powered lock. (2) Let me first calculate the resistance value of the series resistor. Normally a simple LED will light up if current passing through it is around 10mA. The voltage drop across the resistor when lighted up should be (12V – 0.6V) / 10mA ~= 11V / 20mA ~= 10/10 ~= 1kΩ.(3) Now you replace the lock by the LED in series with this 1kΩ. (4) And if you now try to use the RFID card to lock the lock (replaced by LED now), the LED would light up. And if you try the RFID card to lock again, ie, second time, without any problem, then the lock is the trouble maker. I have not thought thoroughly, so never mind if you don’t know what I am saying, or just ask me to clarify. Ah, bed time, see you later.  12 hours later… tlfong015891Wed 10:47@AhtishamAshraf This morning I read a question similar to yours. Perhaps we can compile a FAQ! 🙂My rfid-rc522 reader stops reading after some time, how can I debug it? – EESE 2021apr28
raspberrypi.stackexchange.com/…  1 hour later… tlfong01Wed 12:03@AhtishamAshraf My last link seems broken. raspberrypi.stackexchange.com/…  1 hour later… Ahtisham Ashraf182Wed 13:13@tlfong01 one more thing to mention i have the same model of raspberry pi in the above link Pi 3 Model B+(2017)and the thing is that i have tested the relay with the light bulb powering with 3.3 V and the card seems working perfectly every time without any issue. There must be some issue related with the 12 V and the Relay, with 3.3 V it works like a charmtlfong015891Wed 14:13@AhtishamAshraf Ha, firstly one important thing to confirm. When you said: “I have tested the relay with the light bulb powering with 3.3 V…“, did you mean that (1) You did test the relay with a 3.3V power light bulb (***Question:***Is this “light bulb” just an ordinary LED?). Did you test the light bulb as a fake electromagnetic lock?I mean, before you tested the real electromagnetic lock, you tested the waters by first testing a light bulb. Actually this is almost the same thing I suggested earlier: (1) Put aside the lock, (2) Instead of the real lock, use a 12V powered LED with a 1kΩ as a “fake lock”, and see if the RFID card can operate on this fake lock smoothly, many many times as you like, not just “You can only live once”?@AhtishamAshraf (1) I am 95% sure that Rpi model does not matter. (2) If you said testing the light bulb was like a charm, I am 80% sure that the relay (and Rpi and software) does not matter. (3) What remains is the 12V power supply unit (PSU). (4) BTW, I am still waiting for the link to your lock.I must know exactly if your lock is (a) “locking the door” is activated when 12V power is switched on, or (b) “unlocking the door” is activated when power is on? No hurry though. I am feeling that we are almost there (one last mile!)  3 hours later… Ahtisham Ashraf182Wed 16:58I tested with the ordinary LED using the raspberry 3.3 V Power and the RFID and about the Second one i am implementing the (b) unlocking the door, the Power cable is connected to the Closed Relay and it is passing the current constantly and as soon as i scan the RFID it opens the Circuit and the Current Stops and the Door Opens. I have tried either Ways using NO and NC but still the same. @tlfong01 tlfong015891Wed 17:18@AhtishamAshraf Ha, so you seem to have explored almost all the possibilities. So let me confirm: (1) You used the fake door lock (ordinary status/indicator/hobbyist LED, in series with current limiting resistor (perhaps 470Ω, but not important/relevant). powered by Rpi’s 3V3 rail.(2) And you confirmed the following: “… the Power cable is connected to the Closed Relay and it is passing the current constantly and as soon as i scan the RFID it opens the Circuit and the Current Stops and the Door Opens….I think I understand 90% of what you say in (1) and (2) above. Now I think there are at least two possibilities: (1) 12V powered door lock in “door closed” state, current passing from 12V+ through relay’s COM and NC to door lock, … , then when RFID reader caused Rpi to switch off relay and lock, creates Back EMF which corrupts Rpi’s software, therefore need to reset to restart program.I am thinking aloud, so not that organized, and I am slow in writing and thinking, so any casual errors and typos could not meet this chatroom’s no more editing after 3/5 minutes limit. In other words, many of my errors stay permanent, … 😦PS – I know very little about the door lock you are using. My experience is only with plain, bare bone solenoid type lock. So I might miss something important. You might like to skim my new references on locks and let me know if your lock looks like any of them. No hurry though. Ah, locking down jogging/supper time. I need to go. See you later. Cheers. PS – You might like to skim my other answer on Back EMF to get a rough idea of what might be going on inside your lock.What is Back EMF?: EESE Q&A, electronics.stackexchange.com/….  2 hours later… Ahtisham AshrafWed 19:37I was aware of the Back EMF and i found it on the first place , i wanted to know if there is any solution for this one to fix? like anything i need to add in the diagram @tlfong01  1 hour later… tlfong015891Wed 21:02@AhtishamAshraf (1) For Back EMF, as I suggested in the very beginning, use total optical isolation wiring, as described in my answer in “How to use JD-Vcc jumpered relays”””. (2) A related trouble maker is EMI, and you might like to try the four methods described in Appendix C of my answer to “What is Back EMF?”.Ref 15 suggests how to reduce noise (Back EMF and EMI) has more references, especially Ref 8, 9 in grounding using decoupling capacitors.I have more troubleshooting suggestions: (1) (a) Instead of the RFID Lock program, write a small python program to test if disconnecting 12V lock power can disturb python program, (1) the small test program does the following: loop indefinitely, every 0.5 sec, print time at Thonny output shell.(ii) Instead of using sofware control, use a manual switch to power lock, then switch off power, to see if Back EMF and/or EMI would disturb or reset the loop printing program. You might like to suggest other troubleshooting little programs.@AhtishamAshraf Yet another suggestion: (1) Insert Thonny console log/loop indefinitely print statements in the Appendix A LX230 RFID Rpi python program. Good luck. See you tomorrow. Cheers.  1 hour later… tlfong015891Wed 22:39@AhtishamAshraf I read the spec of the lock I referenced and found something that I didn’t know that I didn’t know. As I said earlier, I only knew about simple, plain, bare bone, solenoid that door lock, and the moving part, a stick like thing is not powerful at all, and I can use a finger to stop the movement. But for the lock, There is no moving part at all, all magnetic, and the lock force is 1,200 lbs!So my wild guess is that only 12V, 250mA might have built a very strong magnetic field. And when Rpi and RFID reader read the RFID card, they switch off the lock current, and so the big magnetic collapsed suddenly, cause big Back EMF and EMI, therefore disturbed. One more suggestion is this: move the lock 10 ft from Rpi and see if there is any improvement, or problem disappeared..  11 hours later… tlfong015891Thu 9:52I just found a must read tutorial for magnetic door lock users. You might like to read and give your comments.Back EMF Suppression (For Magnetic Door Locks) – Progeny
progeny.co.uk/…Just a quick suggestion, after reading Progeny’s article: (1) Use 30+V MOV, (2) Use a couple of high power Schottky flybacks in parallel. (2) It might not easy to find low voltage MOVs, but 110V MOV might also work, because the Back EMF voltage in your case might be much higher than 100+V. Good luck and cheers. tlfong015891Thu 10:34@AhtishamAshraf Talk is cheap, if all my talkshop suggestions fail, in order not to damage EESE’s reputation, I might consider getting a real cheapy magnetic lock, tear it down, measure the magnetic field etc (I do have a RF meter! :), and see why the little yellow duck’s suggestions are so crappy!CY-180 12V 180kG Single Door Magnetic Door Lock – TaoBao, ¥45
item.taobao.com/…  3 hours later… Ahtisham Ashraf182Thu 13:52move the lock 10 ft from Rpi and see if there is any improvement, or problem disappeared..
I have tried this one as well and it didn’t work and thanks for all of your time i will try different methods as well and will update you if i find a solution for this one @tlfong01  2 hours later… tlfong015891Thu 15:40@AhtishamAshraf You are welcome. Actually smart home and building automation has been one of my electronics hobbies in the last couple of years. My place is promoting smart city, so it is easy for me to find maker friends doing similar projects. You might like to skim old posts on solenoid door lock in rpi.org.forum:How to use 12VDC Solenoid Door Lock – rpi.org.forum 2019jan13
raspberrypi.org/forums/…Ahtisham AshrafYeah if you have any group of Whatsapp or any other platform you can add me there @tlfong01I have ordered 3 solenoid locks as well to test them tlfong015891As I said earlier, I know quite a lot about relays, solenoids, and solenoid door lock, but very little about magnetic lock. So it is a good opportunity to add this part of knowledge to my knowledge/skills set, hoping that one day I might find a freelance job, in doing or teaching about home automation.I am finding fun in doing pair programming/development with you, in this seemingly more and more challenging problem solving exercise. I also hoping to upgrade myself to hobbyist developer, from hobbyist programmer. But I am in no hurry at all, because electronics is still a hobby for me, and all my electronics projects so far are for charity work. Cheers.@AhtishamAshraf Ha, glad to hear that “I have ordered 3 solenoid locks as well to test them“. It is enjoyable doing pairing work with you, because we are learning new things from each other, and most important of all not seem to work under pressure or with a tight deadline. Often many of the OPs in this forum under pressure to complete an assignment for their school or work place. I was once in such an occasion and appreciate the pressure of meeting a tight deadline. Cheers. Ahtisham Ashraf182Thu 15:56I am a programmer myself but i don’t have quite good knowledge about the Electronic Circuits and stuff @tlfong01I have to deliver it for the company i am working in LOL as i am the manager so there is no time restriction one me @tlfong01 tlfong01Ha, I am jealous of the luck guy learning and working for fun, and get paid at the same time. Ah, I and missing the locking down afternoon. Need to go. Chat later. Ahtisham AshrafSure and thanks for the help @tlfong01  5 hours later… tlfong01Thu 20:48@AhtishamAshraf Ah, I always use …@gmail.com. The “…” is the last line of my profile.  19 hours later… tlfong015891Fri 15:35@AhtishamAshraf I have also ordered the magnetic locks for testing. So you test solenoid locks on your side, me mag locks this side.I placed my order yesterday morning, and the toys arrived this afternoon, a little longer than 1 working day. (Ordered 0429:1054 arrived 0430:1349).

user image

Mag lock spec: I used a multi-meter to check out the following.(1) The 180kg lock is 35Ω, therefore I = V/R = 12V/35Ω ~= 350 mA,(2) 60kg lock is 50Ω, therefore I = 12/50 ~= 240 mA.Power P = V * I, so(1) for 180kg lock, P = 12 * 0.35 = 3.84W ~= 4W(2) for 60kg lock, P = 12 * 0.24 = 2.88W ~= 3WNow I will start testing the smaller lock:12V, 50Ω, 240mA, 3W, 60kg  6 hours later… tlfong015891Fri 22:11@Feeds Now I have assembled a magnetic lock test rig. Hope to test it tomorrow.

user image

  15 hours later… Ahtisham Ashraf182Sat 13:37It was off yesterday so i couldn’t reply , i will check and debug it today. Do you have any code for the Solenoid RFID in Python? I will check that code and will compare it with the code i am currently using @tlfong01 and thanks a lot for putting this effort and debugging the issue.  1 hour later… tlfong015891Sat 15:02@AhtishamAshraf As I said earlier, take it easy and no hurry at all. Actually I have not been doing RFID and relay programming for more than a year, so I need to read my old post to freash my memory. Below is a short YouTube list I am now watching.(1) back emf test 2019mar3101
youtube.com/…(2) rpi GPIO signal toggling 5V low level trigger relay
youtube.com/…(3) mosfet test 2019feb1801
youtube.com/…(4) rpi switching zye1 2019jan01
youtube.com/…(5) Solenoid Test
youtube.com/…tlfong015891Sat 15:14@AhtishamAshraf This particular YT is on solenoid. You can find some references in my reply to the YT.Youtube rpi switching zye1 solenoid – 2019jan01
youtube.com/…rpi.org.forum Search “solenoid tlfong01” found 149 matches:
raspberrypi.org/forums/…  2 hours later… Ahtisham AshrafSat 17:01Thanks i will look into this as well  1 hour later… tlfong015891Sat 18:11@AhtishamAshraf Take your time. Ah, my time for lock down jogging and supper. See you later. Cheers.Ah, I forgot I let you know that my “solenoid door lock” is using the solenoid core to pull a string to open the door for my cat, wearing a RFID tag, can come in.  19 hours later… Ahtisham Ashrafyst 13:34amazon.com/…
This is the one i ordered. @tlfong01  1 hour later… tlfong015891yst 14:50@AhtishamAshraf Ah, you solenoid door lock looks nice, and I have appended your link to my reference list. Question: Did you have a choice of 6V or 12V? And you prefer 6V? I am asking because your magnetic lock is 12V, so we might not be easy to compare and contrast the back their corresponding back EMF and EMI. Anyway, this is not a problems at all, perhaps this way we might find that 6V is better than 12V! 🙂  4 hours later… Ahtisham Ashrafyst 19:02I am using 12 V because it is universal and i am still debugging about the back emf or coding issue @tlfong01  1 hour later… tlfong015891yst 20:12@AhtishamAshraf Yes, I very much agree with you that 12V is universal. It is industrial standard for hundreds of years, even before 5V TTL. Of course I have been using 6V for most of my Arduino and Rpi years, because I have been doing Mickey Mouse toy projects. One thing I always remember is that 12V has less noise than 5V, and 5V is less noisy that 3V3. tlfong015891yst 20:30@AhtishamAshraf I am also reading my and others’ old posts on using MFRC522, to refresh my memory. I will be adding those post links later to the reference list. One important thing I still remember is as I said earlier, about the package/library called SPI-py. Do you remember if you did install this SPI-pi when using MFRC522 programs. I always suspect it is this library that causes all the trouble, but I am only 80% sure. Anyway, you can search MFRC522 or RC522 in this forum for more info. tlfong015891yst 20:58@AhtishamAshraf I might be buying this 12V/24V lock (TaoBao price only CNY10) to compare your 6V version. I am 50% sure of the following: (1) 12V lock draw less current, (2) Energy stored in a solenoid is proportional the the square of current, (3) Therefore 12V lock, compared to 6V version, when current is switched off has less back EMF.  14 hours later… tlfong01589110:36@AhtishamAshraf I read the door lock ad again and found it saying that it uses magnetic force which seems not solenoid at all. My old solenoid lock using a string to pull a hinged door for my cat (wearing a RFID tag on her neck) food dispenser is too weak to pull something. So I have ordered 4 hopefully strong locks for my and my neighbour’s cat food feeders. Below is the order I placed this mroning.

user image

I am ordering two versions: 12V 350mA, and 12V 600mA. Now I can use my scope to display corresponding Back EMF pulses! 🙂  3 hours later… Ahtisham Ashraf13:16@tlfong01 I have installed the SPI-py package as well. Like in the start of discussion it worked perfectly without any issue until the Electromagnet Module is given 12 V Current.  2 hours later… tlfong01589114:51@AhtishamAshraf (1) Thanks a lot for your confirmation on SPI-py. So I still think we are almost there, or walking the last mile. (2) By the principle of “if it ain’t brike, don’t fix it”, we should not change anything on your almost working hardware/software configuartaion. (3) I would suggest the following cross checking procedure: (a) You backup your working programs, and try to install a copy of the same code to test your new 6V solenoid door lock,(b) I will also use the old package, install SPI-py, MFRC522 programs and test my 12V 350mA, and 12V 600mA door locks. (4) If we have bad luck that both of us have the same “You only live once” fate, then we can start debugging, perhaps me trying to replace the third party SPI-py by the Rpi builtin SPI package, and see if I can then add Rpi Thonny python console debug print statements, to narrow down where is the cause of trouble.You can, on your side, at the same time debug any way you think good.Question: Are you using Rpi Thonny python IDE, or all CLI commands?  3 hours later… tlfong01589117:35@AhtishamAshraf Now I have new idea. Part 1: (1) I know now you are using Rpi to control a 2 channel JD-Vcc jumper low level trigger relay. The relay’s COM is connected to +12V and NC is connected to door lock +, and 12V ground is connected to door lock -. (2) (a) So now when you supply 12V power, and there is no 3V3 input signal to the relay input, (b) so COM and NC is connected/shorted, (c) so +12V passes through COM, to NC to door lock +, switching on door lock, then current goes to ground.(3) So now if Rpi sends Low signal to relay, NC is now open, the +12V at COM is no longer connected to NC. In other words, current is switch off. Therefore door lock is unlocked.Now, Part 2 is my new idea. The new idea is to replace the relay which acts as a current switch by a N-channel Power MOSFET IRL540N which can also acts as a switch.Some two years ago I already tried to use the above IRL/IRN540N to switch on off a 350mA current motor. This time I am instead switching on/off the door lock which like the motor, is inductive, and so needs flyback diodes to prevent back EMF. Now I am showing two schematics, (1) Using relay, (2) Using IRL540N.

user image

@AhtishamAshraf Now the IRL540N not a relay switches on/off current to the motor. (1) The left diode is just status diode indicating current is on, (2) The right diode is the flyback idode. Now let me show you the schematic of magnetic door using IRL540N to switch on/off the current.

user image

You might have noticed that there is no flyback diode for the magnetic door lock. The reason is that the IRL540N already has a built in flyback diode. I am only 60% sure that my circuit using IRL540N works. So I need to study the datasheet and then do the experiment. Stay tuned. 🙂 


Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.