力学与“光华妖风”

2011-07-13 来自 · 留下评论 

这是本学期【力学思维与现代工程】期中小论文

在经过复旦大学光华楼前,尤其是主楼与辅楼“门洞”附近,常能感受到强烈的风。这个现象可以用一些力学定律解释。

门洞内部及其附近的风

刮起东西方向的风时

力学思维课上提到伯努利定律,其数学表达式为1/2 ρv^2+ρgh+p=常数,其适用条件为非粘滞不可压缩稳定流体。在联通环境下,气体没有被压缩,而边缘效应也可以被忽略,在短时间内“光华妖风”是稳定的,适用伯努利定律。刮起东西方向的风时,光华楼两侧的风速不一样,即v不一样:上式v不同,上式第一项不同;考虑到高度几乎相同,上式第二项相同。由伯努利定律,即可导出两侧压强不同,即产生风。

刮起南北方向的风时

由流体连续性方程S_1 v_1=S_2 v_2,气流在经过门洞时,面积突然减少,导致流速增加。

光华楼南北两侧的风

当有东西方向的风时,由流体连续性方程S_1 v_1=S_2 v_2,因为光华楼的存在,空气被向两侧“挤压”,流体的流场发生变化,导致在光华楼附近风特别大。

由于门洞附近存在着这两种方向正交的风叠加,而行人一般是东西方向行走的,所以会有“无论朝什么方向走都是逆风”的错觉。

2011-05-15 来自 · 3 评论 

这个学期已经过了大半,博客也有大半个学期没有更新了。写点什么吧。

“我又何尝不想去做那些自己喜欢做的事,去码想码的代码,去折腾想折腾的电路,去学想学的技术,去读想读的书,去写想写的文章。到底是什么枷锁将我栓住,让我主动放弃了这些自由。”前几天写下这条微博,是多么的无奈。这半个学期来匆匆地度过,有TOEFL,有新东方,没有周末。细细数来,有太多的不满。每周大部分的时间都在做高数题中度过,为了上学期的那个信念。还有29学分。还有一些苦逼的课。

寒假买的示波器、电烙铁、开发板就在我的面前。学术启航的需求分析和设计文档就在右手边。但是示波器已经覆上了一层薄薄的灰尘,学术启航也没有开始做。我多么想去做那些事呢,那些喜欢做的事,那些想象中的生活。卢梭说人生而平等,却生活在无望不至的枷锁之中。这所谓的奋斗史,为了绩点放弃了那些喜欢的事情,不就是堕落么?可是我却跳不出来。

可是上面这些不过是点小牢骚罢了。当初选择这样做的时候,是考虑清楚的。因为现在学的是基础,是为了以后更快上手喜欢做的事。否则以后意气风发打算做个什么大东西的时候,却发现受制于以前的知识,这多么可悲。至于绩点,不过是在与别人的比较中产生的影响。当初的考虑,还不是关注于绝对学得如何,而非那一个数字么。尽管它是有用的,而且是非常有用的。

我多么羡慕寝室里那些人儿呢。有人能放心地几个星期不写作业为学生网竭尽全力,连续几天两三点才睡。有人能每天和小女友打上几个小时的电话。有人能三国杀到四五点然后翘掉整个早上课却照样在考试中发挥出色。

可是我不是这样的人。我期待有一个规律的生活,信奉日事日毕。也许到了期末后成绩仍然比不上他们,但至少能让自己满意。

所以还是这样继续下去,做自己。

小微博

2011-04-9 来自 · 3 评论 

2011年6月24日 09:42

记得要做自己。抛开那些功利因素,过完四年让自己满意的生活。

2011年6月12日 23:13

二十岁,记得要成为一个道德高尚、意志坚强的男人,记得“自信、自知、自立”,记得自我控制,自我规划,记得富有爱心、懂得感恩,记得保持一个平常心。记得父母的教诲,记得要做一个善良、勇敢、坚强的男人!

2011年6月11日 10:41

一手握着生命,一手举着理想。

2011年6月3日 23:01

I must tell you how ardently I admire and love you.

2011年5月18日 22:41

赵老师真是个好老师!上学期选他的课真是太幸运了!

2011年4月28日 19:36

我又何尝不想去做那些自己喜欢做的事,去码想码的代码,去折腾想折腾的电路,去学想学的技术,去读想读的书,去写想写的文章。到底是什么枷锁将我栓住,让我主动放弃了这些自由。

2011年4月13日 00:26

@3108,辛苦地写完了学术启航项目需求分析的草稿。

2011年4月9日 23:24

这是第一篇微博。

关于LPC17xx固件库定时器的Bug

2011-02-16 来自 · 5 评论 

这篇日志里我提到了LPC17xx定时器部分的固件库有Bug,具体为作为计数器模式的时候固件库工作不正常,检查代码后发现有几处错误,此问题已反馈给NXP。这几天收到了NXP的答复,他们承认了这个错误并已将这个问题反馈给了相关的工程师。在报告Bug的过程中,我也尝试着修复这个Bug。下面是往来邮件和附件,包括问题的重现和我修改后的代码。

From: Case Notification [mailto:noreply@salesforce.com]
Sent: 2011 Feb 12 1:18 PM
To: Eric Wang
Subject: Case # 00001236: Bugs in LPC17xx Firmware library has been assigned to you.
*** New Case Assignment Notification ***
Following Case has been assigned to you:
Company:
Contact:
Case Number: 00001236
Subject: Bugs in LPC17xx Firmware library
Description: Related product: Microcontrollers, Cortex-M3 (32-bit), LPC1700
There might be a bug in LPC17xx Firmware library that when timer works in counter mode, the firmware library doesn’t work as expected. Some register names in the firmware code might be wrong(i.e. CCR and CTCR), and parameter check in the header files is also a mistake since it totally ignored counter falling mode etc.
bug fixed and update is expected.
Click on the link to access the Case: https://eu1.salesforce.com/500D000000E4byl
Hi Wang,
We just got a case from you.Thanks for your question.
Can you give more detail about your question?
How did you get the lib? From our website?
Lib can not work as expected, what are you expected?Is there any demo code?
You mean ” Some register names in the firmware code might be wrong(i.e. CCR and CTCR), and parameter check in the header files is also a mistake since it totally ignored counter falling mode etc.” Could you point it clearly?
If you provide more info, we could fix it asap.
Best Regards,
Eric Wang 王 超
PAE, MCU
NXP Semiconductor
Hi Wang,
Thank you for reply.
The lib is download from http://ics.nxp.com/support/documents/microcontrollers/?scope=LPC17xx , marked “LPC17xx CMSIS-Compliant Standard Peripheral Firmware Driver Library (GNU, Keil, IAR) “.
The user’s manual(UM10360) mentioned that timers in lpc17xx could be used as counters, which I think that on every certain edge on the certain pin would increase the counter by 1.
I’ll attach my demo project and you should extract the full library into it before run. I tested it with LPC1768.
I tried to correct the mistake and it’s also attached, I modified these lines
File lpc17xx_timer.h, Line 142
File lpc17xx_timer.c, Line 320, 321, 344, 346
I have comments on these lines and they begin with”//!!”
I’m not sure if there are more mistakes and you should have a double check on it.
Regards,
王盛业
复旦大学复旦学院克卿书院 10607班
复旦大学信息科学与工程学院 电子信息科学类
Hi,
Thanks for your info. I have a look and find following should be mistake. I will forward to related engineer to fix.
File lpc17xx_timer.h, Line 142
File lpc17xx_timer.c, Line 320, 321, 344, 346
For counter function, I will check and give you feedback at convenience.
Best Regards,
Eric Wang 王 超
PAE, MCU
NXP Semiconductor

补充:后来又收到了NXP的邮件,算是总结性的答复。大致内容和上面的类似,然而可能我表达不清他以为我报告器件有Bug。学好英语很重要……

Dear Shengye,
Your inquiry is resolved for your case 00001236: Bugs in LPC17xx Firmware library
Solution answer:
Hi Shengye,
Thanks for your mail.
I check the lib which can downlaod from link http://ics.nxp.com/support/documents/microcontrollers/zip/lpc17xx.cmsis.driver.library.zip .
For line 142 in lpc17xx_timer.h, #define PARAM_TIM_MODE_OPT(MODE) ((MODE == TIM_TIMER_MODE)||(MODE == TIM_COUNTER_RISING_MODE)\
|| (MODE == TIM_COUNTER_RISING_MODE)||(MODE == TIM_COUNTER_RISING_MODE)) should be
#define PARAM_TIM_MODE_OPT(MODE) ((MODE == TIM_TIMER_MODE)||(MODE == TIM_COUNTER_RISING_MODE)\
|| (MODE == TIM_COUNTER_FALLING_MODE)||(MODE == TIM_COUNTER_ANY_MODE)) .
For line 320, 344, 346 in lpc17xx_timer.c, TIMx->CCR should be TIMx->CTCR .
line 321 should beTIMx->CTCR |= TimerCounterMode;
I will forward to related engineer check and fix.
Btw, you refer that Counter register can not be incremented after related edge. Pls confirm that he frequency of the CAP input can not exceed one quarter of the PCLK clock. If exceed, count will not identify the edge.
Please let us know if this does not resolve your inquiry. Your ticket will remain closed if we do not hear from you.
Registration in my.NXP (www.nxp.com/my) is required for you to check your question status and/or submit a follow-up to your question. For any reference to this question, use the following number:
* Case# 00001236.
*** TIPS ***
- Please do not reply to this email, it has been sent automatically.
- Modify your junk or spam setting to allow incoming “nxp.com” e-mail addresses.
- Add the sender, “NXP Technical Support” to your list of known contacts.
Best Regards,
The NXP Technical Support Team
NXP Semiconductors
附件:bug demo
仅供大家参考,希望下一个固件库的更新版本中能修复这个问题。

学习LPC17xx – IIC

2011-02-12 来自 · 2 评论 

这是IIC操作EEPROM的例子。在调试过程中,误将从机地址写为0×01010000而导致出错,这是十六进制而非二进制!

  • 千万别傻傻地把从机地址弄错,0×01010000这种错误不能犯!这是十六进制,不是二进制!

代码如下:

#include <lpc17xx.h>
#include <stdint.h>
#include "lpc17xx_libcfg.h"
#include <debug_frmwrk.h>
#include <lpc17xx_pinsel.h>
#include <lpc17xx_i2c.h>
 
uint32_t _DGETNUM(uint8_t cnt)
{
	uint32_t rtn = 0;
	while(cnt--) {
		rtn = rtn * 10 + (_DG - '0');
	}
	return rtn;
}
 
uint8_t buf[100];
 
uint32_t writeEEPROM(uint32_t len)
{
	I2C_M_SETUP_Type i2ccfg;
	i2ccfg.sl_addr7bit = 0x50;
	i2ccfg.tx_data = buf;
	i2ccfg.tx_length = len;
	i2ccfg.tx_count = 0;
	i2ccfg.rx_data = NULL;
	i2ccfg.rx_length = 0;
	i2ccfg.rx_count = 0;
	i2ccfg.retransmissions_max = 1;
	i2ccfg.retransmissions_count = 0;
	i2ccfg.status = 0;
   	i2ccfg.callback = NULL;
	return I2C_MasterTransferData(LPC_I2C0, &i2ccfg, I2C_TRANSFER_POLLING) == SUCCESS;
}
 
uint32_t readEEPROM(uint32_t len)
{
	I2C_M_SETUP_Type i2ccfg;
	i2ccfg.sl_addr7bit = 0x50;
	i2ccfg.tx_data = buf;
	i2ccfg.tx_length = 1;
	i2ccfg.tx_count = 0;
	i2ccfg.rx_data = buf + 1;
	i2ccfg.rx_length = len;
	i2ccfg.rx_count = 0;
	i2ccfg.retransmissions_max = 3;
	i2ccfg.retransmissions_count = 0;
	i2ccfg.status = 0;
   	i2ccfg.callback = NULL;
	return I2C_MasterTransferData(LPC_I2C0, &i2ccfg, I2C_TRANSFER_POLLING) == SUCCESS;
}
 
int main(void)
{
	char cmd;
	int i;
	uint8_t cnt, addr; 
	PINSEL_CFG_Type pincfg;
	debug_frmwrk_init();
	_DBG_("I2C EEPROM Test(W to write and R to read)");
 
	pincfg.Portnum = PINSEL_PORT_0;
	pincfg.Pinnum = PINSEL_PIN_27;
	pincfg.Funcnum = PINSEL_FUNC_1;
	pincfg.Pinmode = 0;
	pincfg.OpenDrain = 0;
	PINSEL_ConfigPin(&pincfg);
 
	pincfg.Portnum = PINSEL_PORT_0;
	pincfg.Pinnum = PINSEL_PIN_28;
	pincfg.Funcnum = PINSEL_FUNC_1;
	pincfg.Pinmode = 0;
	pincfg.OpenDrain = 0;
	PINSEL_ConfigPin(&pincfg);
 
	I2C_Init(LPC_I2C0, 100000);
	I2C_Cmd(LPC_I2C0, ENABLE);
	while(1) {
		_DBG_("Command(C), Length(2), Address(3)");
		cmd = _DG;
		cnt = _DGETNUM(2);
		addr = _DGETNUM(3);
		buf[0] = addr;
		switch(cmd) {
			case 'R':
				if (!readEEPROM(cnt)) _DBG_("Failed");
				for(i = 1; i <= cnt; ++ i) _DBC(buf[i]);
				_DBG_("");
				break;
			case 'W':
				i = 0;
				while(cnt --) {
					buf[++ i] = _DG;
					_DBG_("");
					if (i == 8 || cnt == 0) {
						if (!writeEEPROM(i + 1)){
							_DBG_("Failed");
							i = -1;
							break;
						} else {
							buf[0] += 8;
							i = 0;
						}
					}
				}
				if (i != -1) _DBG_("Successed");
				break;
		}
	}
}

第 3 页 共 15 页12345...10...末页 »