PCEVA,PC绝对领域,探寻真正的电脑知识
开启左侧

【原创】巧用主板speaker接口实现PWM风扇调速

  [复制链接]
xihuanttt 发表于 2012-6-3 23:09 | 显示全部楼层
太牛B了,这软硬都的精通,,,

点评

不敢当啊,都是现学现用的,知道点皮毛...  发表于 2012-6-3 23:31
月落 发表于 2012-6-3 23:36 | 显示全部楼层
果断顶。。只恨当初为何没有选电子专业!

点评

没选电子可以把电子当业余爱好嘛,我也不是学电子的,只是个爱好  发表于 2012-6-3 23:42
killua1109 发表于 2012-6-3 23:43 | 显示全部楼层
超级好的技术文 现在很缺少LZ你这样的人了 感谢分享
kinno 发表于 2012-6-3 23:50 | 显示全部楼层
砖家级啊
neoalex 发表于 2012-6-4 00:23 | 显示全部楼层
为了一个pwn,硬是把speaker折腾成了风扇测速,强人啊~
Tommy1992 发表于 2012-6-4 04:35 | 显示全部楼层
大开眼界,小白见识了
changchar 发表于 2012-6-4 07:45 | 显示全部楼层
技术宅果然是王道
joshu 发表于 2012-6-4 09:29 | 显示全部楼层
牛人啊!!!
观摩~~~
eraser666 发表于 2012-6-4 10:14 | 显示全部楼层
这才是技术贴
aaaaaa889 发表于 2012-6-4 11:17 | 显示全部楼层
很佩服LZ的精神,我个人也很喜欢业余时候捣鼓这些东西。根据LZ的描述,我想到一个东西,现在的电脑里都有个精确计时器,叫做HPET(High Precision Event Timer),XP SP3以上的系统均可支持,不知道对楼主实现Windows下更精确的控制转速有用否?另外查到微软对系统精确计时推荐使用QueryPerformanceCounter function()和QueryPerformanceFrequency()这两个Win32API,据说计时能精确到微秒。希望对LZ改进软件有所帮助。呵呵。
wsy2220  楼主| 发表于 2012-6-4 11:36 发自PCEVA移动客户端 | 显示全部楼层
aaaaaa889 发表于 2012-6-4 11:17
很佩服LZ的精神,我个人也很喜欢业余时候捣鼓这些东西。根据LZ的描述,我想到一个东西,现在的电脑里都有个 ...

我试过了,这两个函数只能做到精确计时,无法做到定时触发,要使用它来生成pwm信号,只能不断查询 QueryPerformanceCounter ,导致一个核心满载,有点杀鸡用牛刀的感觉,呵呵
aaaaaa889 发表于 2012-6-4 11:42 | 显示全部楼层
本帖最后由 aaaaaa889 于 2012-6-4 11:53 编辑
wsy2220 发表于 2012-6-4 11:36
我试过了,这两个函数只能做到精确计时,无法做到定时触发,要使用它来生成pwm信号,只能不断查询 QueryP ...


哦,Windows下看来只能通过写驱动来取得superIO芯片的控制权了,还要相关芯片厂商的datasheet,如果驱动未经签名,还要F8。Windows下面这些保护系统安全的措施真严密啊。貌似speedfan也是通过收集superIO芯片控制信息实现风扇控制的。
wsy2220  楼主| 发表于 2012-6-4 12:02 | 显示全部楼层
aaaaaa889 发表于 2012-6-4 11:42
哦,Windows下看来只能通过写驱动来取得superIO芯片的控制权了,还要相关芯片厂商的datasheet,如果驱动 ...

嗯,我的下一步打算就是直接对F71863编程,让它工作在PWM输出方式下.另外8253就是个定时器,工作频率1.19318MHZ,但是它的6种工作方式都不适合输出PWM信号,如果用它产生硬件中断或许可以,但是我还不知道怎么在Windows下写中断服务程序...
aaaaaa889 发表于 2012-6-4 12:14 | 显示全部楼层
本帖最后由 aaaaaa889 于 2012-6-4 12:16 编辑
wsy2220 发表于 2012-6-4 12:02
嗯,我的下一步打算就是直接对F71863编程,让它工作在PWM输出方式下.另外8253就是个定时器,工作频率1.19318 ...


恩,加油哈,呵呵。我搜到国外网站上一个开发风扇控制软件的人的一段话,贴上来供你参考:
I am at the moment working on a project that, among other things, controls the computer fans. Basically, the fans are controlled by the superIO chip of your computer. We access the chip directly using port-mapped IO, and from there we can get to the logical fan device. Using port-mapped IO requires the code to run in kernel mode, but windows does not supply any drivers for generic port IO (with good reason, since it is a very powerful tool), so we wrote our own driver, and used that.

If you want to go down this route, you basically need knowledge in two areas: driver development and how to access and interpret superIO chip information. When we started the project, we didn't know anything in either of these areas, so it has been learning by browsing, reading and finally doing. To gain the knowledge, we have been especially helped by looking at these links:

The WDK, which is the Windows Driver Kit. You need this to compile any driver you write for windows, With it comes a whole lot of source code for example drivers, including a driver for general port-mapped IO, called portio.
WinIO has source code for a driver in C, a dll in C that programmatically installs and loads that driver, and some C# code for a GUI, that loads the dll and reads/writes to the ports. The driver is very similar to the one in portio.
lm-sensors is a linux project, that, among other things, detects your superIO chip. /prog/detect/sensors-detect is the perl program, that does the detecting, and we have spent some time going through the code to see how to interface with a superIO chip.
When we were going through the lm-sensors code, it was very nice to have tools like RapidDriver and RW-everything, since they allowed us to simulate a run of sensors-detect. The latter is the more powerful, and is very helpful in visualising the IO space, while the former provides easier access to some operations which map better to the ones in sensors-detect (read/write byte to port)
Finally, you need to find the datasheet of your superIO chip. From the examples, that I have seen, the environment controllers of each chip provide similar functionality (r/w fan speed, read temperature, read chip voltage), but vary in what registers you have to write to in order to get to this functionality. This place has had all the datasheets, we have needed so far.
aaaaaa889 发表于 2012-6-4 12:20 | 显示全部楼层
另外我顺便帮你找了个F71863的datasheet。- -

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
wsy2220  楼主| 发表于 2012-6-4 12:22 | 显示全部楼层
aaaaaa889 发表于 2012-6-4 12:14
恩,加油哈,呵呵。我搜到国外网站上一个开发风扇控制软件的人的一段话,贴上来供你参考:
I am at the m ...

谢谢,datasheet我找到了,IO端口地址在AIDA64里能看到,剩下的就是怎么对F71863编程了,这个我还在研究
幻目之童 发表于 2012-6-4 12:42 | 显示全部楼层
看来中国教育还是有希望的
panyu119 发表于 2012-6-4 13:08 | 显示全部楼层
这不是一般人能弄的
3332243 发表于 2012-6-4 14:12 | 显示全部楼层
3332243 发表于 2012-6-3 23:08
哇哇,LZ数电不错。。我也是学电子的,一窍不通。。。看了要多请教你

目前还谈不上吧,你这个方案我都没看懂
luckissy 发表于 2012-6-4 14:39 | 显示全部楼层
生命在于折腾
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部