Hello, i am working on this project called temperature based ac fan speed control .i have also made the circuitary required but i stuck at coding part not able to proceed in my project .please help.
Program should generate pwm signal according to the changes in the tempearture and also display same using lcd.
Welcome to the forum
Where did you get the circuit from ? Are you prepared to pay for someone to write the sketch for you ?
So how would you fill this bit out? What temp gives what PWM?
-jim lee
had made the circuitary by own .Even i had tried the code for it but it doesnot work at all.In my case lcd display fines in accordance to change in temperature all that doesnot work is pwm pin output that remain zero always everytime .![]()
I am student ,unfortunately i cant pay ![]()
well i am confused ,i take help of chatgpt he helped out a bit but pwm signal output is showing zero lol .if you need sample code i can provide you
I'm not looking for code, YOU are looking for code. You said you designed the circuits, what PWM do you want for what temp?
-jim lee
can it possible to generate pwm range dynamically for the given range of temperature?
for ex: if take temp range of 20 to 50degree celsius , so for 20 fan should be at zero and for 50 at max speed and for in between it varies within the range say in terms of some stepvalues.
i do not know whether it is feasible for you or not .
please suggest what you thought in that case
What I'm saying is. Write down what you WANT. Then we can see if that's possible.
-jim lee
see let say min temp value is 20 and max is 60 ,so range is 40 .At 20= off(0%) ,60=max(100% speed) .For given range of 40 ,at every inc in 2.5 degree temperature there is inc in fan speed say if temp changes from 20 to 25 fan speed should be 5% .
So code should capable to calculate this automaticaally depending upon the range that is to be specified by the user acc to the need.
Well not sure if it possible or not .
OK let's try it another way. I have an analog pin on the processor. 0..5V input. I assume this is where your are inputting your temp. signal.
I have a digital output pin on my processor. 0 or 5V. This is where we output the digital PWM.
What voltage, 0..5V input, maps to what PWM on the output pulse width , period of pulse wave in ms.?
-jim lee
what are the components you are using in the circuit could you share the detials
For writing code, I am one of the lowest experience programmers on this forum. Completing this code task for myself on an Arduino would require about 5-10 minutes of coding time to get a DS18B20 Temperature Sensor on pin 11 and a MOSFET on A0 to function exactly as you described.
Unfortunately, there is a communication error that prevents all of us from producing any meaningful code for your project, @needhelp22902 . There are way too many things that must be clearly defined in the code to make something work that you must explain to us before you can get any code from us. Until you explain how you wired your project and what parts you used, folks here will repeat their same questions in different ways until they either get the required information or they give up on helping you.
This link explains better how the helpers here need information for helping you and the best ways to provide them with the information.
Please note that in my first paragraph of this post, I clearly defined exactly what parts are used and exactly how they are wired to the Arduino board pins. Right now, I have several different projects not working yet because I am not sure what parts to use and how to connect them. Once I know those things, the code part is usually quick and easy. Same thing with helping you with your code.
Even if it is chatGPT code, if you have code that functions but does things you don't want it to, or doesn't do things that are required, post it here.
You could also try spending some time with any code that functions and see if you can start to,learn how to program,.
You could also start with the examples in the IDE.
@jeremy97469, self professed of lesser experience gives an estimate of the time it would take to write this from scratch - the truth is that no one could do it much faster, no matter what they eat for breakfast.
I'd probably code it maybe a few milliseconds faster, then spend about as long fixing all my typos trying to get it to compile. ![]()
This is a trivial program and even chatGPT probably got the major strokes correctly drawn. You have to meet AI (and us) more than halfway. With no money, you are stuck here with the general idea that we are not a code wiring to order service. We want to help you become a better programmer.
a7
This means there is some code. You should post this code each and every line
Without seeing your code there are billions of possabilities what causes the PWM-pin to always create 0,0V
there is a function called
map()
google for arduino reference map()
this is a function that can transform an input-range your 20 to 60 degrees
to an output-range 0% to 100% duty-cycle
Though without knowing what ADC-value do you get for 20°C and what ADC-value you get at 60°C
the code can't be finsihed
So what is your main subject that you are studying?
- technical design?
- mechanical engineering?
- electronics engineering
- informatic?
looks like you're driving a line powered fan with a Triac as well as having a AC line ~zero crossing sensor. this combination of devices suggests you need to control the fan speed by controlling when during the ~60 Hz half cycle the triac is triggered to turn on (and which turns off when the AC voltage reaches zero)
so the fan speed is determined by a pulse the MOC3021 opto isolated triac used to control the AC line triac.
that pulse needs to be generated from 0-8.3 msec after the signal from the 4n25 used as a "pseudo" zero crossing detector on pin 10 goes LOW HIGH (i don't believe the R6 serves any purpose, pin 10 needs to be configured with its internal pull-up resistor enabled)
triggering the moc3021 by making pin 11 HIGH immediately after the zero-detector on pin 10 goes LOW will turn the fan on for the whole AC half-cycle and max speed. turning it on up to 8.3 msec later will drive the fan with less power and at a lower speed. doubt there is a linear relationship between time and speed
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.


