Anki LaTeX error with TeXLive on Windows

According to Anki user manual, the default configuration generating a LaTeX formula is by MikTeX on Windows, but I’m sure that some people may use TexLive instead, however, there is no solution online showing how to display a LaTeX formula with TeXLive on Windows.

Inspired by this post , I managed to get the solution:
1, Download and install the Anki Add-On ( check how to download and install Add-On in Anki ) Edit LaTeX build process (check it here, if invalid, search the name to get a new ULR for this Add-On)
2, Open Anki, and click on Tool -> Add On -> Find  Edit LaTeX build process -> Edit. Here we need to change two scripts to let Anki know where is the driver it need to render the LaTeX scripts. But before this, you need to know where are the `latex.exe’ and `dvipng.exe’ path in your directory. For my case, I install them in the path `C:\texlive\2016\bin\win32′, so I just need to:
(1), replace `latex’ with ”C:\\texlive\\2016\\bin\\win32\\latex”
(2), replace `dvipng’ with ”C:\\texlive\\2016\\bin\\win32\\dvipng”
Note that according to the instruction, the path should be divided by \\ instead of \, that’s why I red the \\ above.

 

基于Matlab的butterworth滤波器设计 – 1

用这个参加了一个小比赛,整个滤波器由一个关键词的提出,到设计,再到成型,遇到了很多问题,但也解决了很多问题,学到了不少东西。

程序涉及的wav文件
http://cid-c9a008b70a75b1fd.skydrive.live.com/browse.aspx/Butterworth%20Filter

[a,fs,bits] = wavread(‘give_money.wav’); % 1.wav is the original audio file
give_money = fft(a,262144); % length(a) = 142884,thus we use a larger value 262144 which is the value of 2^18
subplot(2,2,1);
plot(0:length(give_money)-1,abs(give_money));
xlabel(‘Original Singnal FFT’)

[b,fs,bits] = wavread(‘give_money_noised.wav’); % 2.wav is an audio file with noise
give_money_noised = fft(b,131072); % length(b) = 107604,thus we use a larger value 131072 which is the value of 2^17
subplot(2,2,2);
plot(0:length(give_money_noised)-1,abs(give_money_noised));
xlabel(‘Noised Signal FFT’)
rp = 1;
rs = 15;
wp = 0.0211;
ws = 0.1093; % check this parameter descriptions below
[N,wc] = buttord(wp,ws,rp,rs);
[B,A] = butter(N,wc);
give_money_export = filter(B,A,b);
subplot(2,2,3);
n = 0:length(give_money_export)-1;
stem(n,give_money_export,’.’);
xlabel(‘Filtered Signal In Time-Domain’);
subplot(2,2,4);
give_money_ex = fft(give_money_export,131072); % length(give_money_export) = 97902,thus we use a larger value 131072 which is the value of 2^17
subplot(2,2,4);
plot(0:length(give_money_ex)-1,abs(give_money_ex));
xlabel(‘Export Signal FFT’)

wavwrite(give_money_export,fs,bits,’give_money_filtered.wav’) % create a filtered file,so that we can compare with the original one

无法安装Protel DXP2004 简体中文破解版

从迅雷下载了 Protel DXP2004 简体中文破解版 .iso 解压后发现无法安装,出错提示为无法找到cab1.dat ,可是这个文件我自己都找到到,为什么程序安装的时候却找不到?
原来是文件路径除了问题
解压时我把所有程序都放在文件名为Protel DXP2004 简体中文破解版的文件夹下,而整个程序是全西文的编码,所以在安装过程中所有的路径都出现了字符编码错乱。

解决方法:
把存放安装文件的文件夹名字改成全英文:Protel DXP2004 就可以了。

平时经常要安装一些国外的软件,而外国人在做软件的时候有可能不大注意字符编码的问题,所以以后再用类似软件的时候要在全英文才行了

The C Programming Language 1-9

 

The C Programming Language 1-9 — Windows Live

我用了位置标识的方法,虽然有点臃肿,不过道理还是很明显的

#include <stdio.h>

#define WAIT 0   //an initial place
#define FIRST 1  //a place in the first blank
#define OTHER 2  //a place in the balnk that follows
#define WORD 3   //a place in a word
#define FIRST_OVER 4

main()
{
    long state,c;
    state = WAIT;
    c = getchar();
    while (c != EOF)
    {
    //make state into different value
        if ((state == WAIT) && (c == ‘ ‘)){
                state = FIRST;
                }
        if ((state == FIRST_OVER) && (c == ‘ ‘)){
                state = OTHER;
                }
        if ((state == OTHER) && (c != ‘ ‘)){
                state = WORD;
                }
        if ((state == WAIT) && (c != ‘ ‘)){
                state = WORD;
                }
     //process the character string by different value of state          
        if (state == FIRST){
                putchar(c);
                state = FIRST_OVER;
                }
        if (state == WORD){
                putchar(c);
                state = WAIT;
                }
        c = getchar();
    }
    system("pause");
}

1.5.2 character counting

Nothing is odd with the program here but if you don’t take care of two points here,you may get puzzled with the output display.

//1.5.2 character counting

#include <stdio.h>
main()
{
    long cn;
    cn = 0;
    while (getchar() != EOF){
        ++cn;
        }
    printf("%1d\n",cn);
    system("pause");
}

image 
I can’t get the result at first,for that time,I directly enter a string with an ENTER,but find nothing given,that is,it don’t seem to work properly but the code is properly written,what’s wrong?
Asking a friends,I get the result,there’s nothing wrong with the code,but something not properly with the output.Check with the DOS blank like this:
type in a string that you want to test,and then turn to a new line type in ctrl and z,at last you will get a properly displayed answer.

ctrl+Z在控制台中就是EOF,输入的字符串末尾没有EOF,所以while循环会无限执行下去,以致无法执行printf部分,所以在控制台中输入zrtl+Z,给定一个EOF使得输入的string有这个结束符,就能跳到下一个printf了

1.5.1 file copying

Get inputs from related service,like keyboard,and then copy what you get to the output,like screen.

/*1.5.1 file copying – original version*/

#include <stdio.h>
main()
{
    int c = 0;
    c = getchar();
    while (c != EOF)
    {
        putchar(c);
        c = getchar();
    }
}

There’s something interesting here,we’ve learned printf() before,if we use it here,what will happen?

/*1.5.1 file copying*/

#include <stdio.h>
main()
{
    int c = 0;
    c = getchar();
    while (c != EOF)
    {
        c = getchar();
        printf("%d\n",c);
    }
}

The output of this program display input characters’ ASCII code instead of its original value and this is something different from putchar().
But I still have a question about it.It works alright but I’m afraid at the first input,it will return something,as far as I’m concerned,not properly designed.
If I type in one character,’1’ or ‘a’ for example,it will eventually give me a ‘10’,which,in the ASCII code,stands for Null;
11

and if I type in a string,’abcdef’ for instance,it will feedback every character’s ASCII code properly but lacks the last one’s own ASCII code instead of 10,which stands for a Null character;
1

if I type in nothing but only give an ‘Enter’,it will feedback nothing at all.
 
All the phenomenon above only exist at the first typing in,while at the next that follow,it will feedback properly.
As far as I am concerned,every character,no matter one character or a string,is terminated with a ‘’ whose ASCII code  is 10,but why the program fail to give input’s own ASCII code instead of only showing a ‘’\o’ ‘s?

用printf()替代putchar()之后,运行程序出现了一个比较有趣的问题。
第一次出入的字符总会得到错误的结果:如果输入单个字符,则只会返回10,而10在ASCII码中代表的是空位符;如果输入一个字符串,则字符串中最后一位字符的ASCII码无法得到,取而代之的还是一个10;如果什么也不输入,而只回车的话,就会什么也不得到。
然而上面这些现象在第二次输入时就不再出现了,所有的输入都得到想要的结果,当然,第二次输入回车还是会返回一个10.

现在我所掌握掌握的知识是,一个字符串,无论是单个字符还是一连串的字符,都是以结尾的,所以上面显示的10正是这个字符,可是为什么第一次输入的时候会出现错误呢?

1.2 Variables and Arithmetic Expressions

The Fahrenheit to Celsius temperature convert is an epitome for beginner to know about variables and arithmetic expression
——————————————————-
/*Fahrenheit-Celsius convert #1 edition*/

# include <stdio.h>

main()
{
    int f,s;
    int low,high,step;
    low = 0;
    high = 200;
    step = 20;
    f = low;
    while(f <= high)
    {
        s = (5*(f -32))/9;
        f += step;
        printf("%d\t%d\n",f,s);
    }
    system("pause");
}
——————————————————-
for the system is lack of a pause command,I add a note in the end saying system("pause"); to pause the program when run,or it will be enclosed in a second.

 

Celsius temperature is not always in decimal but a floating number carrying with a dot and fractional part,thus this program need some modification to have a better display.
——————————————————-
/*Fahrenheit-Celsius convert #2 edition*/

# include <stdio.h>

main()
{
    int f;
    float s;
    int low,high,step;
    low = 0;
    high = 200;
    step = 20;
    f = low;
    while(f <= high)
    {
        s = (5.0/9.0)*(f -32);
        f += step;
        printf("%3d\t%6.2f\n",f,s);
    }
    system("pause");
}
——————————————————-
Bold part above consists of two float value 5.0 and 9.0,if modified as 5/9.0 or 5.0/9,it also run all the same,that because in an arithmetic expression,lower character type could be converted into higher one automatically,float is higher than int,both expression are converted into float one as 5.0/9.0.
But if modified as 5/9,it will crash.Because in this expression,both value are performed in int,and their arithmetic result should also be in an int.But 5/9 = 0.xxxxx is less than 1,and its fractional part is discarded,leaving 0 behind.

2009_0412 – 74LS90功能测试

74LS90功能比较多,不过我只选用了十进制的计数功能。
连线规则如下:
1.QA连INB,就可以构成十进制计数。这个是根据该TTL集成模块内部逻辑结构判断出来的,可以作为一种经验,不用多说。
2.两个置零端R0和两个置九端R9均接地,不让置零或置九。其实这四个引脚是用来测试整个集成电路是否正常的时候用的,方法很简单,R0(1) = R0(2) = 1同时R9(1) =  R9(2) = 0数码管显示0,接着把置九端和置零端的电平互换,数码管显示9,则集成电路完好。
3.QA QB QC QD分别接入数码管的D C B A端口,检测计数
4.双踪示波器A端接时钟源,B端分别接QA QB QC QD,用以对比分频和占空比的情况。

整个连线图如下:
 1

经过Multisim10的仿真,数码管从0向上计数到9,再跳回到0,不断反复。
示波器观察到各端口和时钟源的分频情况如下
QA对时钟源进行了2分频,占空比为50%
未命名 

QB对时钟源进行了四分频,但占空比有变换,至于为什么会这样,我也不知道,但是上星期在实验室搭线时却没发生这样的现象
 未命名2

QC QD都是十分频,占空比50%

在仿真和实际搭线的过程中发现,把示波器接上四个端口之后,整个计数频率会降低,数字跳变速度变慢。询问过实验室老师后发现,其实示波器内部有电阻,接到四个输出端后会改变整个电路的输出电阻,这样反馈再反馈作用下,整个计数频率会有变换

2009_0326 – 简单调用timer2

timer2是52单片机比51型多出来的一个计时器(计数器),不过timer2的功能远不止是计时和计数这两个,所以之前一直弄不出来就是因为没注意到这点,而只将timer2认为是一个简单的16位资源,错误认为其调用也和timer0及timer1相同,其实不然,查看过datasheet后发现光是timer2的control寄存器T2CON的八个位的安排就与前面两个计数器(计时器)不相同。所以,花了点时间研究datasheet,学习了一下这个寄存器的设置,今天就弄了出来。

// use timer2 in an easy way

#include <reg52.h>
sbit P1_0 = P1^0;
sfr T2MOD = 0xC9;

main()
{
    T2MOD = 0x00;
    T2CON = 0x08;
    TH2 = 0xff00; TL2 = 0xff00;
    RCAP2H = 0xff00; RCAP2L = 0xff00;
    EA = 1; ET2 = 1;
    TR2 = 1;

    while(1);
}

void change(void) interrupt 5
{
    TF2 = 0;
    P1_0 = !P1_0;
}

程序中要三处加重的地方我之前一直没弄出来,经过datasheet的学习才发现其中的奥妙:
1.sfr T2MOD = 0xC9;
T2MOD
timer2的模式控制寄存器T2MOD其实没有多大的设置意义,顶多就是对其中DCEN位进行设置。DCEN全称decreasement enable即“递减使能”,设置为1的时候允许在计时时递减计时,相反,设置为0的时候就是递增计时。而出了这一个位,T2MOD的其它位都没有什么利用的价值(至少datasheet上没有说明其他位的具体用法,只是说允许用户自己设定),这个DCEN位又可以独立设置电平,所以整个T2MOD在reg51.h文件中都没有独立设置其地址。所以,如果在程序中要设置整个T2MOD的话,要在主程序之前给T2MOD设置全局变量的入口地址,就是0xc9,否则在主程序中调用会被编译器提醒没有T2MOD这个变量。

2.RCAP2H = 0xff00; RCAP2L = 0xff00;
之前我一直认为timer2的自动重装也就是给TH2和TL2重装原来的数罢了,所以写了两行这两个特殊功能寄存器的赋值,当然编译出来是错的。datasheet中讲到,要给timer2的TH2及TL2重新装入数值,必须把待装的数值存入RCAP2H以及RCAP2L这两个特殊功能寄存器,其实从电路图上可以更清楚地看出这样设置的原因:(图中红圈内)
auto_reload_mode 

3.TF2 = 0;
这点也是timer2与同样具有自动重装功能的timer0 timer1工作方式2不同的地方。0和1timer的工作方式2在计时满时相应的TF位会溢出,但进入中断处理后硬件会自动将其清零(当然如果使用查询的方式就得软件清零),但timer2的这个TF2位即使进入中断,也要软件清零,否则无法进入下一个计数周期。