Moderators: TomKerekes, dynomotion
-
AmitKumar171
- Posts: 134
- Joined: Tue Feb 20, 2018 7:35 am
- Location: India
Post
by AmitKumar171 » Thu Nov 14, 2019 5:15 am
Hi tom,
I have checked the link that you have sent.
Bipolar (BJT) Transistor NPN 45V 2A 150MHz 2W Surface Mount SOT-89-3
In the description of the item it is showing that, this transistor has 2w maximum power but what i need here is 4w (12V * 0.300A).
Will the above item will work with this fan. ?
Waiting for your kind reply.
Thank You
AMIT KUMAR
-
TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Post
by TomKerekes » Thu Nov 14, 2019 8:12 pm
Hi Amit,
I asked you before to determine the voltage / current relationship for your fan but you did not post the results.
The power to the fan and the power dissipation in the transistor are two different things. At full power (12V and 4W) to the fan there will be zero power dissipation in the Transistor because there will be zero voltage across it.
Transistor Voltage = 12V - Fan Voltage
Without knowing the voltage / current relationship of the fan, we might assume it will draw half current (0.15A) at half voltage (6V). The transistor's power dissipation would then be:
(12V - 6V) x 0.15A = 0.9W
This should work but is a significant amount of power. The transistor will need some circuit board area as a heat sink to dissipate this heat. Otherwise search for a bigger transistor.
Note using this type of analog linear circuitry will have less efficiency and more transistor power dissipation than a digital switching circuit. With a switching circuit the transistor is always fully on or fully off. In both cases the transistor power dissipation is theoretically zero (either no current or no voltage).
Regards,
Tom Kerekes
Dynomotion, Inc.
-
AmitKumar171
- Posts: 134
- Joined: Tue Feb 20, 2018 7:35 am
- Location: India
Post
by AmitKumar171 » Fri Nov 15, 2019 5:29 am
Hi tom,
Thanks for your reply.
I have checked the relationship of fan with voltage and current, its linear.
You have said earlier that
With a switching circuit the transistor is always fully on or fully off
What does it mean ?
Can i use this circuit to control the fan and on off also using analog out from Knozz. ?
If yes then how ?
Waiting for your kind reply.
Thank You
AMIT KUMAR
-
TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Post
by TomKerekes » Sat Nov 16, 2019 7:00 pm
Hi Amit,
I have checked the relationship of fan with voltage and current, its linear.
Good
You have said earlier that
With a switching circuit the transistor is always fully on or fully off
What does it mean ?
A switching circuit is digital and switches on and off like a switch. An analog circuit varies the voltage and current like a potentiometer.
Here is a Resistor+Transistor circuit connected to a KFLOP 3.3V Digital Output to turn the Fan on and off. If the Transistor has a gain (hfe) of 100 then only 3ma of base current is needed to fully turn on the Fan of 300ma. To control Fan speed you will need to pulse the fan on and off at some frequency and vary the duty cycle (% of time on) this is called PWM (pulse Width Modulation). If you have JP6 pins available a KFLOP Hardware PWM can be used to make things easy. Otherwise you will need to write software to pulse the output on and off.
Note this circuit is not optically isolated like the Analog Output is. The 12V supply GND must be common GND with KFLOP +5V GND. This means any noise picked up in the fan wiring or 12V supply might possibly cause problems. If so you should add some opto isolation.
HTH
Regards,
Tom Kerekes
Dynomotion, Inc.
-
AmitKumar171
- Posts: 134
- Joined: Tue Feb 20, 2018 7:35 am
- Location: India
Post
by AmitKumar171 » Mon Nov 18, 2019 5:46 am
Hi tom,
Thanks for the earlier reply.
To control Fan speed you will need to pulse the fan on and off at some frequency and vary the duty cycle (% of time on) this is called PWM (pulse Width Modulation). If you have JP6 pins available a KFLOP Hardware PWM can be used to make things easy.
How to do that ?
As i have checked that i have 3 out of 10 I/O available for Fan control Kflop hardware PWM. I have JP6 - IO 27,28,29 available.
How to give command as you have said earlier pulse the fan on and off ?
Please explain how to pulse the fan on and off at some frequency and vary the duty cycle ?
If possible can you send the C program as well as G code to do that.
Waiting for your kind reply.
Thank You
AMIT KUMAR
-
TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Post
by TomKerekes » Mon Nov 18, 2019 6:44 pm
Hi Amit,
Here is code to control PWM #1 on IO27 based on persist variable 20
Code: Select all
#include "KMotionDef.h"
#define FVAR 20 // desired fan speed MCode P word is passed as float % in FVAR
#define PWMN 1 // use PWM #1 on JP6 Pin6 IO27
void main()
{
float speed = *(float *)&persist.UserData[FVAR]; // value stored is actually a float
// printf("Fans speed = %f\n",speed);
if (speed > 100.0f) speed = 100.0f; // limit from 0-100%
if (speed < 0.0f) speed = 0.0f;
SetBitDirection(26+PWMN,1); // define bit as an output
FPGA(IO_PWMS_PRESCALE) = 65; // divide clock by 65 (1 KHz)
FPGA(IO_PWMS+2*PWMN) = (int)(speed * (255.0f/100.0f)); // duty cycle
FPGA(IO_PWMS+2*PWMN+1) = 1; // Enable
}
KMotionCNC configured for M100 to execute above program in Thread #4 and pass P parameter in persist variable 20
- M100 executes PWM1.png (6.55 KiB) Viewed 3352 times
GCode to set fan to 50% duty cycle
M100 P50 (set Fan to 50%)
Note it isn't clear if your fan will have any problem or issue with being switched on and off to control the speed or what switching frequency would be best. You would need to ask the fan manufacturer or run experiments.
Also note the above code sets the PWM frequency to 1KHz (PRESCALE). All PWMs must run at the same frequency. It isn't clear whether you are using any other PWMs and at what frequency.
-
Attachments
-
- PWM1_from_PVAR.c
- (636 Bytes) Downloaded 137 times
Regards,
Tom Kerekes
Dynomotion, Inc.
-
AmitKumar171
- Posts: 134
- Joined: Tue Feb 20, 2018 7:35 am
- Location: India
Post
by AmitKumar171 » Thu Nov 21, 2019 11:18 am
TomKerekes wrote: ↑Sat Nov 16, 2019 7:00 pm
Hi Amit,
I have checked the relationship of fan with voltage and current, its linear.
Good
You have said earlier that
With a switching circuit the transistor is always fully on or fully off
What does it mean ?
A switching circuit is digital and switches on and off like a switch. An analog circuit varies the voltage and current like a potentiometer.
Here is a Resistor+Transistor circuit connected to a KFLOP 3.3V Digital Output to turn the Fan on and off. If the Transistor has a gain (hfe) of 100 then only 3ma of base current is needed to fully turn on the Fan of 300ma. To control Fan speed you will need to pulse the fan on and off at some frequency and vary the duty cycle (% of time on) this is called PWM (pulse Width Modulation). If you have JP6 pins available a KFLOP Hardware PWM can be used to make things easy. Otherwise you will need to write software to pulse the output on and off.
Note this circuit is not optically isolated like the Analog Output is. The 12V supply GND must be common GND with KFLOP +5V GND. This means any noise picked up in the fan wiring or 12V supply might possibly cause problems. If so you should add some opto isolation.
FanSwitch.png
HTH
Hi tom,
Thanks for the earlier reply.
As i have told you earlier that , transistor that i am using is BC547B. Here is the specification sheet attached in the link.
Code: Select all
https://www.farnell.com/datasheets/410427.pdf
Please suggest the resistor amount for the 12V 300ma fan.
Waiting for your kind reply.
Thank You
AMIT KUMAR
-
TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Post
by TomKerekes » Thu Nov 21, 2019 4:49 pm
Hi Amit,
That transistor is only rated for 100ma.
The resistor symbol marked "Fan" is the Fan not a resistor.
Regards,
Tom Kerekes
Dynomotion, Inc.
-
AmitKumar171
- Posts: 134
- Joined: Tue Feb 20, 2018 7:35 am
- Location: India
Post
by AmitKumar171 » Fri Nov 22, 2019 6:00 am
Hi tom,
Thanks for the earlier replies.
That transistor is only rated for 100ma.
Ok got it i will get transistor that you told earlier for the connection of PWM.
The resistor symbol marked "Fan" is the Fan not a resistor.
I was talking about Rb. How to calculate it and in my case which one should i use. ?
Waiting for your kind reply.
Thank You
AMIT KUMAR
-
TomKerekes
- Posts: 2677
- Joined: Mon Dec 04, 2017 1:49 am
Post
by TomKerekes » Fri Nov 22, 2019 9:45 pm
Hi Amit,
I was talking about Rb. How to calculate it and in my case which one should i use. ?
See the calculation in previous posted diagram for Rb.
It depends on the current gain of your transistor (hfe). If the transistor gain is > 80 then 270 Ohms should work.
Regards,
Tom Kerekes
Dynomotion, Inc.