-1

this is the picture i have referd to

this is my circuit i have connected but when iam trying to get the o/p across the drain the p-mosfet is acting as a on switch and not able to turn off the circuit if my circuit has mistake please refer me the proper image.

#define pwm 6
void setup() {
  // initialize serial communication at 9600 bits per second:
  pinMode(6,OUTPUT);
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  //Serial.println(sensorValue);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  //Serial.println(voltage);
  float vol1=voltage*11;
  Serial.print("convertd voltageg ");
  Serial.println(vol1);
  int s=0;
  if (vol1>24){
  float duty=(24)/(vol1);
  Serial.print("Duty cycle ");
  duty=duty*100;
  Serial.println(duty);
   s=map(duty,0,100,0,255);
  Serial.print("maped values");
  Serial.println(s);
    analogWrite(6,s);}
  else if(vol1>18 && vol1<25){
    s=255;
    analogWrite(6,s);
    Serial.println(s);
  }
  //Serial.println(x);
}
3
  • Read MOSFET as a switch.
    – hcheung
    Feb 26 at 13:43
  • DV & VTC. Your question is not about Arduino, and should be moved to EE.
    – VE7JRO
    Feb 27 at 4:57
  • Is it standard practice here to down vote an answer simply because it is deemed that the question belongs elsewhere? I'd have thought that any down voting of an answer should be accompanied by a specific comment stating how the answer is factually, or otherwise, incorrect.
    – 6v6gt
    Mar 4 at 3:34

2 Answers 2

-1

You have to be careful with such a circuit because you risk applying 12 volts to an arduino pin. To switch that P channel mosfet off, 12 volts has to be applied to the gate. Search for "mosfet high side switch". Usual solutions use both a P channel mosfet and either an npn transistor or an N channel mosfet. A simpler alternative is to switch the motor using an N channel mosfet (low side switch). See https://gammon.com.au/motors for a full description.

Note: that circuit you have used appears to have come from here https://circuitjournal.com/how-to-use-a-p-channel-mosfet-with-an-arduino and is particularly risky because it relies on the grounds between the 5 volt and 12 volt circuits not being interconnected. It may work as shown, however not recommended for the reasons stated above, but your simulation does not appear to have the 12 volt power supply sharing a common positive rail with the 5 volt supply.

-1

The Arduino when the output is High is ~5V referencing. The MOSFET gate sees it as -7V referencing the source. It is always best to use the source as the reference point for a MOSFET. Look at the data sheet and it shows it is doing what it is doing. The gate needs to about 0V referencing the source to be off. The exact value is dependent on the MOSFET used.You will need to add a transistor or mosfet to drive the P-Channel MOSFET with the Arduino. You could also use a opto isolator to switch the mosfet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.