1

Comments

Long day for me to update my blog. I even don't know my blog was blocked by our Great Fire Wall.

Yesterday I passed my first time of GRE test. That's a f**k test. But during the day of preparing the GRE, I got a chance to attend our University's electronic design contest. In the contest, I fixed some problems of my power and add some now function into it.


This is the top layer of the power. You can see a black PCB which plug into the main board. That's a current detection module. I using TI's INA200A to detecting the current of power's output. Then using Arduino's ADC to check out the current if the current exceeds the threshold value. This threshold value could change during the runtime. If the power is overloaded, the relay (yellow thing) will cut off the output to protect the buck chip until manual reset the system.

The 1602 LCD could display the output voltage, output current and cut off thrshold current value. Using Arduino to control the LCD is very simple like using printf() function in C language.


This the bottom layer of the power. I using the surface mount package part to keep the system small.


This is the out put waveforms. About 15mV ripple voltage in 1A load, 10V output. Fantastic result by using Nichicon HD aluminium electrolytic capacitor.

That's all of the
This project is open-sourced, under the licence of BY-NC-SA. If you want the SCH, PCB file and Arduino file, leave the comment and I will mail you ASAP.
Thanks to Texas Instruments for offering me so many kind of chips free.

< ,, >
0

Comments

We use TI's TLC5615, 10-BIT DIGITAL-TO-ANALOG CONVERTERS as our DAC.
This chip has 3-Wire Serial Interface, so we can use Arduino to control it.
Arduino is an open-source physical computing platform based on the AVR MCU.
Now give the Arduino program.

//Arduino project http://arduino.cc
//by Mini Dragon at http://minidr.com/archives/687
//This program is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
#define CS 2 //chip enable
#define CLOCK 3
#define DATA  4
 
#define HALF_CLOCK_PERIOD 2 //2 uS of clock period 
float j=0;
void setup()
{
	pinMode(DATA, OUTPUT);
	pinMode(CLOCK,OUTPUT);
	pinMode(CS,OUTPUT);
	digitalWrite(CS,HIGH);
	digitalWrite(DATA,LOW);
	digitalWrite(CLOCK,LOW); 
}
 
void writeValue(uint16_t value)
{
	digitalWrite(CS,LOW);//start of 12 bit data sequence
	digitalWrite(CLOCK,LOW);
	data = data << 2; //Add 2 0 at the end of the data. A 10-bit data word should add 2 0 at the LSB bit (sub-LSB) since the DAC input latch is 12 bits wide.(SEE TLC5615C DATASHEET) 	
	for(int i=11; i>=0; i--)//send the 12 bit sample data
	{
		digitalWrite(DATA, (value & (1 << i) ) >> i );//DATA ready
		delayMicroseconds(HALF_CLOCK_PERIOD);
		digitalWrite(CLOCK,HIGH);//DAC get DATA at positive edge
		delayMicroseconds(HALF_CLOCK_PERIOD);
		digitalWrite(CLOCK,LOW);
	}
	digitalWrite(CS,HIGH);//end 12 bit data sequence
}
 
void loop()
{
	j=567; //in here, 567 is a example. DAC OUT=j*Vref/1024
	writeValue(floor(j));
}

Each DAC output voltage maps a main Vout.
To be continued.

[Update 2014/Tue/22] Code Opt

< ,, >
5

Comments

用开源硬件平台 Arduino 制作了一辆寻迹小车.

硬件非常简单, 几个5000型红外对管, 利用红外线在白板上反射, 光敏二极管呈低阻; 在黑线上被吸收, 光敏二极管呈高阻的原理探测轨迹, 再通过一个斯密特触发器修正波形, 输入信号到 Arduino 平台, 处理信息, 最后 Arduino 输出占空比可调的 PWM 波加上驱动电路改变两个轮子的速度来控制小车的方向.

程序: 只有参考意义. 最后还是要仔细调整占空比的. 否则会冲出跑道.

int left=10;//定义左电机PWM输出端口
int right=9;//右电机PWM输出端口
int l2=5;
int l1=4;
int r1=3;
int r2=2;//定义传感器输入端口
int l;
int r;//测试数据
 
void setup() {
	//Serial.begin(9600);//启动串口,用于调试
	pinMode(l2,INPUT);
	pinMode(l1,INPUT);
	pinMode(r1,INPUT);
	pinMode(r2,INPUT);//定义输出端口作用,PWM输出不需要定义
}
void loop() {
	int left2=digitalRead(l2);
	if(left2==HIGH)
		left2=1;
	else
		left2=0;
	int left1=digitalRead(l1);
	if(left1==HIGH)
		left1=1;
	else
		left1=0;
	int right1=digitalRead(r1);
	if(right1==HIGH)t
		right1=1;
	else
		right1=0;
	int right2=digitalRead(r2);
	if(right2==HIGH)
		right2=1;
	else
		right2=0;//将输入的高低电平转换成0或者1
 
	int data=left2*1000+left1*100+right1*10+right2;//转换全部数据到一个变量,方便计算
	switch(data)
	{
		case 111://0111,由于触发器反转,0表示检测到黑线,111表示白线,就是黑线在左边
			analogWrite(left,63);l=63;//左轮减速,模拟量用PWM输出,输出量为63/255就是1/4的占空比
			analogWrite(right,255);r=255;//右轮全速
			break;
		case 11://0011
			analogWrite(left,127);l=127;
			analogWrite(right,255);r=255;	
			break;
		case 1011:
			analogWrite(left,191);l=191;
			analogWrite(right,255);r=255;
			break;
		case 1001://在中间
			analogWrite(left,255);l=255;
			analogWrite(right,255);r=255;
			break;
		case 1101:
			analogWrite(left,255);l=255;
			analogWrite(right,191);r=191;
			break;
		case 1100:
			analogWrite(left,255);l=255;
			analogWrite(right,127);r=127;
			break;
		case 1110:
			analogWrite(left,255);l=255;
			analogWrite(right,63);r=63;
			break;
		default:
			analogWrite(left,0);l=0;
			analogWrite(right,0);r=0;
			break;
	} //end case
	delay(500);
/*用于串口调试数据,可以不用,这里将其注释
	Serial.print(left2);
	Serial.print(left1);
	Serial.print(right1);
        Serial.print(right2);
        Serial.print(" -> ");
	Serial.print(l);
	Serial.print(" ");
	Serial.println(r);*/
}

标准的 C 语言用法. 非常简单吧.
为了节省开发成本, 我自己买了 ATMEGA328P ,参考了 Arduino UNO 的电路图画了自己的电路板. 电机驱动电路用了 ULN2003 达林顿堆 ( 其实可以用 MOS 管的 ), 这样比较便宜. 供电用了航模电池, 单片机和传感器分开用 7805 供电, 节省干扰.

最后跑了下效果还不错.

< >
10

Comments

玩了一把 Arduino, 写了一个最简单的程序, 闪烁的灯, 只要14行, 还是算上空行和大括号的,这让学51连个流水灯也写不出来的同学情何以堪...

PCB

1
2
3
4
5
6
7
8
9
10
11
12
int flash = 2;	//设置端口名字
void setup()
{
	pinMode(flash , OUTPUT); 	// 定义端口用来输出
} 
void loop()
{
	digitalWrite(flash , HIGH);
	delay(500);
	digitalWrite(flash , LOW);
	delay(500);
}

开源的东西就是好, 简单好用, Linux 下也有 IDE, 安装居然 yum 下就解决问题了, 这让每天用着盗版的付费的 IDE 的同学情何以堪...

IDE

< >