[SOLVED] Need Review: DIY Calendar House - Page 1
Forum section: electronics / projects

author: TehoorMarjan
author_rank: Newbie
timestamp: November 22, 2024, 02:33:20 am
content: Hello all!New in electronics design, and also this forum. I hope I post in the right section. Short presentation: I'm from France, 38, engineer in IT automotive, embedded SW, had some education in electronics but without any practice in years, I'm mostly newbie.I though this project would be just plugging modules together and write some code, but it appears that it's a bit more complex than that, so I started with Fritzing and finally went to KiCAD because I did not trust Fritzing to help me enough in creating a PCB.The project is to pimp a wooden little advent calendar in the form of an house. With audio, lights and detection of when the drawers are opened.There is an ESP32 driving the whole, a PAM8403 mini-module to play sound from SD Card, some I2C IO expanders to fetch all the hall sensors that detect when drawers are pulled (I glued magnets on them), and a 24 channels PWM LED driver with a DC/DC converter (that I don't know yet if I need it) to push a bit the brightness of the 12V LEDs.I need a good review of the schematics. I'm not sure at all how I connected the MOSFETs. The first, in the ESP32 block, is to cut out the power for most of all external modules. The second, in the Hall Power Switch block, is to control the power on the hall sensors and io expanders. The reason is that I bought A3144 hall sensors, which means that they draw current when a magnet is close, which means the drawers are pulled in, which means almost always in my case. So I decided to poll them using the ESP32. The routine will be: Close the MOSFET to have power flowing, wait a bit, retrieve the state of all hall sensors and open the MOSFET to cut off power and save battery life. The last MOSFET is used in the KeepAlive block. This is because I use power banks and those may go to sleep when too few current is drawn for some time.So the idea is to drain a bit of current for 20ms every 1 to 5 seconds.The other big question is the wiring of the I2S bus. The board of the module already includes a capacitor and a 10k resistor in serie on the line. So I finally decided to wire them directly. Butin this blog post from the vendor, they use a 22k resistor in serie in addition and a 4.7k pull-down resistor, and I don't understand why. Besides, I'm afraid this would create a divider bridge that will very much lower the voltage in input of the module and the PAM may not see the signal at all. So... Resistor? Not resistors? I search a bit on the web, and I've never seen such a montage elsewhere, and the line resistors for such circuits are usually anyway much lower. I'm a bit lost...And then any other review tip, remarks, comments, questions, ... All very welcome.These are some illustration files, but beware that they are from previous versions, so they're just here to give you an idea, but the schematics are wrong.Thank you very much!TehoorPS: I posted on AAC too, I hope you don't mind...

author: TehoorMarjan
author_rank: Newbie
timestamp: November 22, 2024, 06:06:56 am
content: Well, I understood the issue with the "I2S" resistors. That's just not I2S at all. It's just the DAC. So these are actually analog lines and the resistors are here to adapt the audio signal strenght to the amplifier module.

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 22, 2024, 08:14:53 am
content: Quote from: TehoorMarjan on November 22, 2024, 06:06:56 amYes that is correct. I2S is a form of SPI and uses a system clock signal, a data signal and a left right select clock to transfer the digital stereo signal.Yours signals are labeled I2S_L and I2S_R, which indeed has nothing to do with I2S. The module you choose is indeed just and audio amplifier. Nothing digital about it.It looks like a fun project when done, but a bit more work is needed.A little bit about your schematics. They are hard to read. It seems to become more and more practice to use squares to block of sections and use net labels to connect things. I do use it from time to time to, depending on the size and complexity of the schematics. With a simple design as yours just use wires instead of these labels to directly connect the objects together.About the switching of the power for the separate parts it is not good practice to cut the ground connection, and even if you would like to do it this way, I don't think the 2N7000 is a good fit and I don't see it working in the way you wired it up. Why not the 2N7000, it might not be beefy enough to handle the currents and it might not turn on fully driven from a 3.3V IO pin. This will cause a voltage drop over the 2N7000 and with that lift the ground level of the modules. Might lead to not seeing proper logic levels on the modules.It is better to switch the power lead with a P channel mosfet, but this also needs taking care of the control signals not being high also. Otherwise these might still provide power to the modules and cause unwanted effects.Another thing is your PCF8575 part in your schematics. I'm guessing these are modules, because the pinout does not correspond to the datasheet. There is also no way of telling if the two have different addresses set. As you are making a PCB for it, you might just want to get the actual parts instead of a module. They are easy enough to solder and don't need much additional components. Just a decoupling cap on the power supply, and only one set of pullup resistors on the I2C lines.A bit of advice for the PCB make sure to create a solid as possible ground plane and try to keep the signals on the top layer as much as possible.

author: xvr
author_rank: Frequent Contributor
timestamp: November 22, 2024, 11:16:08 am
content: MOSFETs are connected in a very strange way. They all are controlled by signal on Source (instead of Gate)

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 22, 2024, 12:54:47 pm
content: Quote from: xvr on November 22, 2024, 11:16:08 amA bit like how level converters are wired. Not how it should be in this use case for sure.

author: TehoorMarjan
author_rank: Newbie
timestamp: November 22, 2024, 02:53:52 pm
content: Thank you very much for all your inputs.Sorry for the hard to read schematics, I thought it was good practice, and in my first attempt in Fritzing I connected everything directly before I discovered net labels, and it wasn't nice at all. I guess there is a proper sweet point between the two and I'm not very comfortable with it yet... I also still don't master the net classes of KiCAD and assignment of track thickness, I thought it would help later on.About the selected part, specifially the 2N7000, I have them lying around, so I just ensured that they would work in the situation but they are probably not the best suited. It would be more problematic if they are, as you think, not suitable for the job. I'll make some tests to ensure they are at least ok, despite not being perfect.The placement at GND level (e.g. after load) was suggested by some internet posts because the voltages are different. ESP32 is 3V3 and most modules (made for Arduino) operate better at 5V. I've watched some tutos on YouTube, but if you think the mosfets are improperly wired, please guide me. I'll do my researches on my side too, but any help is appreciated.Sure, now that I decided the PCB way, it's a bit stupid to have all these modules instead of the chips. But originally I hoped I would use a perfboard and I ordered the components. Next time, specially given the PCBWay prices (and other companies) I won't bother buying all these expansive modules (although very reasonably expansive, I must say). That's DIY... Lean from your mistakes

author: TehoorMarjan
author_rank: Newbie
timestamp: November 22, 2024, 03:08:13 pm
content: Would that be a better wiring ? (Taken fromhttps://www.electronics-tutorials.ws/transistor/tran_7.html)

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 22, 2024, 03:25:18 pm
content: Quote from: TehoorMarjan on November 22, 2024, 02:53:52 pmNo problem, but it is advice that is given here a lot. I received it myself too. Flow in drawing a circuit is from left to right, with inputs on the left and outputs on the right. With parts that have a lot of connections it becomes a bit harder, but it is still possible.An argument against the net labels is that it is easy to miss a connection when searching through a schematic. So yes one needs to find a balance in using them and also practice in drawing proper schematics. But with so many individuals out there, there will always be someone who thinks otherwise.I'm not familiar with Kicad at all. I use the free online EasyEDA website to draw my schematics and PCB's. For me it has all I need.Quote from: TehoorMarjan on November 22, 2024, 02:53:52 pmThat is also part of electronics, looking for the right component. Yes the 2N7000 might work in your tests, but will it work for long and within extended operational circumstances. What is the worst case scenario something still has to work under, etc.Quote from: TehoorMarjan on November 22, 2024, 02:53:52 pmWell then it was bad advice. It is better practice to use level converters when dealing with different logical voltage levels. The 2N7000 can be used as a level converter, but does have it's limitations, speed wise. Here is a thread about it:https://www.eevblog.com/forum/projects/using-a-mosfet-(2n7000)-as-a-logic-level-converter/You don't use it in the ground line, but in signal lines to bidirectionally go from a low voltage to a high voltage.There are also integrated level converters that work better at high speeds and have multiple converters in one package. Texas Instruments has lots of them:https://www.ti.com/logic-voltage-translation/voltage-translators-level-shifters/products.htmlThat is a big problem of the internet, there is so much information, that one needs a good understanding to filter out the bullshit that is published out there. Especially youtube is rather full with it. You came to the right place now though. Lots of good and helpful engineers to give proper advice. I have learned a lot since I joined.Quote from: TehoorMarjan on November 22, 2024, 02:53:52 pmJLCPCB is also very cheep if you don't mind a bit of a delay. I use them and it takes at most two weeks to have the result in your hands. That is mainly due to shipping. Production is two days and because I don't want to pay big bucks I use the cheapest shipping option. My last order was about 5 euro for 5 boards (the minimum they do) of 7*5 cm.Quote from: TehoorMarjan on November 22, 2024, 02:53:52 pmNot just for DIY, it is how probably all of us have learned in some way.

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 22, 2024, 03:35:30 pm
content: Quote from: TehoorMarjan on November 22, 2024, 03:08:13 pmYes it is, but easier to read when drawn as shown the page you linked. The gate needs to be driven by an output. There is no need for the pull down resistor. The way the fet works is that when the gate is charged with a positive voltage it starts conducting. When the gate source voltage is well above the threshold it will be fully on. So with a push pull output no resistor is needed, unless the gate capacitance is so big that the current on switching becomes to much for the push pull output. When it is an open collector or open drain output, you need a pull up resistor to the positive supply to get the needed gate voltage. But be aware of the max voltage allowed on the output of the MCU and of course the max gate source voltage of the fet.I'm sure the page you linked has al that information on it. Take a look at the datasheet of the 2N7000 and see what the Rdson is. With this information and the current drawn by your modules you can work out if it is a workable solution.

author: TehoorMarjan
author_rank: Newbie
timestamp: November 22, 2024, 03:58:56 pm
content: It's a bit more complicated for me here...(2N7000 datasheet)Rdson = 5.3 Ohmand the ESP32 can deliver up to 40mA (recommended < 20mA), it looks like the 2N7000 needs 1mA, switching voltage is 0.8V up to 3V. So maybe I need to insert a resistor to drop the voltage a bit (output is 3V3)?Here are the changes (page 2 didn't change except resistor references). But from what I understand I would need resistors in serie with the gate and output pin, but not in pull-down configuration (gate to GND)?

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 22, 2024, 05:05:32 pm
content: The specifications of the 2N7000 also list absolute maximum ratings. The max gate source voltage is +/-30V, which is a large range. This means the 3.3V from the ESP32 is no problem what so ever and no resistor in series is needed.The gate source threshold voltage is specified at a minimum drain source current and has a range due to spread in production. One batch can have a threshold of 0.8V while another batch has a threshold of 3V.When you look at 0n-state drain current you see it specified at Vgs 4.5V and Vds 10V with a drain current of 75mA. With these condition Rdson is 5.3 Ohm at max. This means a voltage drop of 0.4V over the 2N7000. With less current and a lower Vgs the Rdson can be higher.With your two fets in series to control the hal effect sensor interface the change is very high that it won't work.Best to do some study on how to read datasheets.

author: TehoorMarjan
author_rank: Newbie
timestamp: November 22, 2024, 05:41:31 pm
content: Is it possible to see it anether way ? The hall sensors when all on, drain 12mA. Which, through a resistor of 5 Ohm would give a drop of only 0.06V. This could be different for the EXT_GND however, specially the 24 LEDs and Audio could drain much more current, and the switch isn't really necessary, it just felt a good idea. But could totally be removed, specially as the LED PWM has a general "disable" pin.I tested the schema (only one MOSFET) using a VCC of 5V, the load is a LED (3.75V drop) + 47 Ohm (I expect 26mA of current ?), gate is driven by ESP32 IO (tested with and without pull-down of 1k). I works "well" (but how long? how hot?...).I'll give a go with my tester: Update: I measure 0.00V between source and drain when MOSFET is closed. 3.46V when opened (normal). My component tester gives a Rdson of 0.58 Ohm, but I cannot change the test voltages and it uses 1.86V Vds and 0.68V Vgs (I assume, it says "VT" and "VF" on the screen and I've never used it for such components so far...)(Sorry if I seem to insist, it's just that I prefer to explore all possibilities before having to buy new components instead of the ones I have lying around.)Would be stupid, but is it possible that another manufacturer makes 2N7000 MOSFETs with totally different characteristics? If so, how to find back the right manufacturer and datasheet? I've bought them so long ago, at Conrad in Germany (when I lived there). Probably 10 years or so...!

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 22, 2024, 06:43:28 pm
content: If this is just a one of project for your self it does not matter that much. In that case you can use what you have and build it. When it is for mass production it becomes a different story.But for turning of your separate sections don't use the 2N7000 in series, but use a single one per section that needs to be disconnected. That way there is less risk of to big of a ground level difference.Make sure to not pull up the I2C lines connected to the ESP32 to 5V. I2C is open drain and should work with just pull ups to 3.3V.

author: TehoorMarjan
author_rank: Newbie
timestamp: November 22, 2024, 07:05:28 pm
content: Quote from: pcprogrammer on November 22, 2024, 06:43:28 pmYes, I'm just going to remove the "EXT_GND" switch and only have one for the polling logic of the hall sensors. I did some more testings using just a 150Ohm load to 5V, because the LED test didn't show the expected voltages on the pins. Under this simple load, I could really measure a current of 31mA and then the voltage drop between source and drain was of 0.2V, not 0 at all. I left it for some time, the resistor heats up a bit (it's a 250mW rated for 144mW, so that's mostly okay) and the mosfet doesn't heat up at all. In the end, once I checked that the hall sensor can possibly work with only 4.8V, I'll go that route.Update: DONE Minimum VCC is 4.5V (https://www.alldatasheet.fr/datasheet-pdf/view/55092/ALLEGRO/A3144.html)Quote from: pcprogrammer on November 22, 2024, 06:43:28 pmOkay, I though it was good the other way around, but it makes sense. Pity is that 3V3 is much harder to reach on the PCB

author: TehoorMarjan
author_rank: Newbie
timestamp: November 22, 2024, 07:33:44 pm
content: Hopefully the last version ?Changed pull-ups on 3V3 for I2CRemoved EXT GNDMoved IO33 from control of EXT GND to control of the OE (disable all) pin on the LED driverUsed "Generic Connectors" because a guy from university looked really convincing in saying so

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 22, 2024, 07:41:08 pm
content: Quote from: TehoorMarjan on November 22, 2024, 07:05:28 pmThe issue with MCU's running on 3.3V and 5V logic is that the the pin on the MCU has to be 5V tolerant, and this is not always the case. More normal is that the pins have protection diodes to ground and the supply of the MCU. This means that when a higher voltage is on such a pin it will be directed to the supply, and it depends on how good the supply can handle this, if the total voltage goes up or not. This of course also depends on the current as a result of this voltage. With a 2k7 resistor to 5V the current won't be that big, and it might work for a while or even for ever, but you can't be sure about it.As an example a while back there was a discussion on the forum about a youtuber directly connecting a LED to a GPIO pin of a 3.3V MCU stating it was fine due to current limiting in the MCU and the LED forward voltage being close to the supply voltage. Sure it worked, but only for a limited time, as reported by people who actually tried it in a project. And in most MCU's there is no real current limiting provided on GPIO pins. They have maximum current ratings on a single pin and also on the supply pin. Exceeding these limits leads to overheating and eventually destroying the part.The thing is specification are there for a reason.

author: TehoorMarjan
author_rank: Newbie
timestamp: December 08, 2024, 08:56:08 pm
content: Hello back !Just wanted to say thank you for your help. I managed to get the PCB printed and it was really thrilling as it was my first. The PAM module didn't help because the sound from the ESP32 is awful, whatever the filtering or the method, but the ESP8862Audio library is also not well maintained any more. I opted for a true I2C amplifier and this worked very well, just that I needed to scratch a PCB line and solder some ugly wires... Due to the deadline, I didn't do it on time from a code point of view, also because I bough some bad cables that get fragile when soldered, so I ended with broken cables that I had to solder INTO the small space of the wooden box! So I paused the project a bit, it will be ready for next year, with a version 2.0!! For now, this is probably the most complex circuit just to power some LEDsHere is the current state:https://github.com/TehoorMarjan/calendarhouse/tree/main