wdtz Posted January 18 Share Posted January 18 (edited) and, BTW, this will probably work on any SBC that has pwm and working port of wiringPi (wiringOP is much simpler than the dtbo method, IMO) WHY: I don't like fans that run full speed ALL the time pwm fans are a bit limited on the ground in small size, and expensive The SBC has pwm pins, so why not use them none of the examples I have found are adequate, either gpio off/full or excessive python scripts, 40 lines or more,, the bash script is ~ 10 lines Some of the wiringOP/gpio packages don't work (ubuntu-full desktop) try the commands in rc.local, if they don't work, then,,, dpkg -l |grep wiring; apt remove ..... git clone https://github.com/orangepi-xunlong/wiringOP.git,, also install lm-sensors (you may have to make link, this puts gpio in /usr/local/bin, this is branch next) in rc.local: gpio mode 0 pwm #using wPi pin #'s, from gpio readall sleep 500e-3 #pause needed gpio pwm 0 900 #starts for sure gpio pwm 0 380 #slow to MIN until cron adjusts ----- gpio pwm <pin> NNN ,,,, NNN is what I will call PWR, to get range give a PWR too large, the error will give range If the PWR is too low the the fan won't start, even 800 is only 90% start The fan turns all the time, but not at full speed, at MIN you can almost count the turns (maybe 150 rpm) You have to find the PWR number for MIN for your fan, start at 300, it should run for hours, if not add 20, retest When you get some #, then add 10%. With this number, fan should run forever the script that cron calls every minute or 2 #!/usr/bin/bash TEMP=`sensors|grep bigcore0 -A3 |grep temp1 |tr -s ' '| cut -d ' ' -f 2|cut -c 2-3` #adjust grep as suitable, fails >99 echo $TEMP #TEMP=$1 #for testing, will error if $1 is blank PWR=$(("$TEMP" * 11)) #or any other number you choose echo $PWR if [ "$PWR" -gt 999 ]; then #check to see if PWR is in 'correct' range PWR=999 elif [ "$PWR" -lt 380 ] ; then #if this number is suitable for YOUR fan PWR=380 fi gpio pwm 0 $PWR ----- obviously comment out echo lines when debugging finished And now the wiring, it is stupid simple (arrows are both connections AND current flow) (-ve) <-- E pwm --> R --> B (+ve) --> Fan --> C if R is 1k, not enough drive to turn on transistor, 330 is 'iffy', 220 is OK, I have 180, depends on transistor Oh, BTW, scope told me pulses are +, so transistor is NPN, if you couldn't follow circuit logic (TO92 OK, unless fan huge) ---- and now pwmTone,,, absolutely nothing on web gpio pwmTone <pin> <frequency> ,, sounds good, right. well range likely changes, neutral as long as you know plus: fan starts MUCH better, even 1/2 PWR minus: fan barely slows down even with very low PWR If anyone knows more, please reply..... maybe there should be 5-10k pwm --> (-ve) to ensure pwm turn-off??? ---- I guess if you don't have a scope you could feed a LED + R, see if it dims (? R=100?) as you change PWR PS I would suggest this be pinned, if it is considered suitable --------- And a better debugged script, better than off the top (of my head) paying more attention to the hw side and not forgetting anything ----- #!/usr/bin/bash TEMP=`sensors|grep bigcore0 -A3 |grep temp1 |tr -s ' '| cut -d ' ' -f 2|cut -c 2-3` #adjust grep as suitable, fails >9 echo $TEMP if [ $# -gt 0 ]; then TEMP=$1 #for testing fi PWR=$(($TEMP * 11)) #or any other number you choose if [ "$TEMP" -lt 50 ]; then PWR=$(($TEMP * 8)) elif [ "$TEMP" -lt 60 ]; then PWR=$(($TEMP * 9)) elif [ "$TEMP" -lt 70 ]; then PWR=$(($TEMP * 10)) fi echo $PWR if [ "$PWR" -gt 999 ]; then #check to see if PWR is in 'correct' range PWR=999 elif [ "$PWR" -lt 380 ]; then #if this number is suitable for YOUR fan PWR=380 fi echo $PWR gpio pwm 0 $PWR Edited January 18 by wdtz syntax 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.