Hello everyone, I'm working on a small project where I can control the height of a height-adjustable desk using a microcontroller, MOSFET transistors, and an ultrasonic sensor. Essentially I want the user to input a height and the desk to automatically adjust to that height.
This is the desk I am using. It only has up/down buttons and has no "memory" features.
I was trying to use this tutorial, but because I did not have an easy access to the motor itself, I decided to "replace" the up/down buttons with MOSFET transistors.
This is a MOSFET I am using. It has a Vgs threshold voltage between 2-4 volt, which will work for my 5v microcontroller.
I opened up the button box and here is what it looks like.
There are four wires going in the JST connector.
- Red : 30V
- Black : GND
- Green : Down
- White : Up
This is an active-high switch where connecting either Green or White to Red will move the desk down and up, respectively. See below diagram for how the switch (Omron SS-5) does in the schematic.
What I did so far
I pulled out the JST connector and connected jumper wires directly to the female pins to create the following circuit for raising the desk.
The voltage source on the left-side is the digital-out pin of a microcontroller. I was successfully able to raise the desk when the pin was high and stop raising the desk when the pin was low.
Edit(August 16th 2020): I measured the current from the source of the transistor to the white wire, and it spiked to ~3A for a brief moment, and while the desk is rising(i.e. when the motor is operating), it outputted ~300mA.
I was also able to do the same for lowering the desk, except that the source of MOSFET was connected to the Green wire instead.
My problem is:
I placed another transistor as such to do both raising and lowering:
Edit(Aug 15th 2020): Sorry about the confusing diagram. This diagram DOES use two digital output pins. The voltage source on the left side is D2 of MCU and the one on the right is D3 of MCU. The pins share a common ground, which is responsible for the following problem.
This obviously created a problem because the source of both transistors are connected to both White and Green wire, meaning that every time one transistor is on, both White/Green wires are HIGH. This is equivalent of pressing both buttons at the same time, which doesn't move the desk at all. I tried putting 10k resistor between the two sources of the transistors, but that did not solve the problem.
- How should I edit my circuit to fulfill what I am trying to do?
- Is this something I can even create just by using transistors? or
- Do I need to open the motor to follow the typical use cases of transistor-as-switch?
I would greatly appreciate if anyone can give advice on my situation :)
I am more than happy to clarify any confusion.