This week
As a recap of what I touched on last week already: An STM32’s GPIO pins have a 3.3V output, but a push-pull solenoid may need 12V. Therefore, we will need to have the STM32’s GPIO pin output of 3.3V function as an enable line to control whether a solenoid is on/off, rather than serve the purpose of a supply voltage. We can feed the 3.3V into the gate of a MOSFET to do this.
We had always agreed on the circuit diagram. However, Peter assumed we would use a PMOS, and I assumed we would use an NMOS. An update from this week is that we resolved this confusion. In our circuit diagrams we had placed the MOSFET between the solenoid and ground. In this case, it is correct to use an NMOS as an NMOS gate-source voltage being higher than the threshold voltage enables the device, and the NMOS acts as a low-side switch since it completes the rest of the circuit’s connection to ground. A PMOS would work in a similar way as a high-side switch if it was placed immediately below the power supply, because a PMOS turns on when the gate-source voltage is more negative than the threshold voltage (Vth). It was easier to keep the circuit diagram drawing we already did (with the MOSFET connecting the solenoid to ground) as is, and we simply made sure the MOSFET icon was an NMOS not a PMOS.
According to the schedule, this week I was supposed to run Cadence simulations regarding the circuit, and so I did.
I had to conduct (refer to plots):
- Transient Analysis/time-domain simulation:
- Verify the voltage across the solenoid is 12V when the NMOS is fully on.
- When the NMOS turns off, ensure the flyback diode handles the transient current spike from the solenoid without issues.
2. DC operating point analysis:
- Apply a 3.3V GPIO signal to the NMOS gate, verify it turns on and off correctly. Measure the current through the solenoid (it should reach 250mA).
On an aside, I am curious to understand why, fundamentally, there is a transient current spike when solenoids turn off. Not that this is too important for the project, but I want to know more for my own general ECE knowledge.
Next week
I will start familiarising myself with Python’s MIDO library to parse + convert MIDI file data into a bit-packet format that is suitable to feed into the STM32 for solenoid actuation.