2009年4月13日 星期一

Test: floor

1. 每一塊地磚發送自身的訊息至地磚表面
2. 當地磚上方有障礙物,地磚身份由生轉為死。終止訊息的處理。
3. 每塊地磚可以獨立設定成為任一種訊息的源頭。

因此:
機器車或智慧的物件能行走在地磚皮層上,應用環境皮層的資訊執行任務。
牆、障礙物(具相當重量)滯留在地磚上,傳達出障礙的訊息到地磚。

method
透過基因演算的模擬演化後,
我們可以獲得一套有效的設定方式。將最有效的資訊源頭的位置設定至空間中; 將最有效的訊息處理邏輯寫入進智慧物件中。
利用縮尺可互動模型實驗,已驗證假設。

實作功能:
1. 讓每一塊地磚能同時傳輸銲接收來自四個面向的3種訊息。
2. 每塊地磚針對四周與自身的同組訊息找出最大的遞減1,以此為傳遞訊息的邏輯。
3. 每塊地磚能即時將運作中的3組訊息由紅外線散佈到地磚表面,以供智慧物件讀取使用。
4. 每塊地磚可以由重量感測障礙物,當出現障礙時切換自身為死的狀態。
5. 每塊地磚可以各別的設定其成為訊號來源的角色

7 則留言:

Scottie Chih- Chieh Huang 提到...

// LED connected to digital pin 9
int rceivePWM_rt = 0;
int rceivePWM_dn = 2;
int rceivePWM_lt = 4;
int rceivePWM_up = 7;
int selfPWM_R = 3;//self
int selfPWM_G = 5;//self
int selfPWM_B = 6;//self
int channel_R=8;
int channel_G=9;
int channel_B=10;
int IRin=12;
int dc=1;
int buttonR=0;
int buttonG=1;
int buttonB=2;
int button_obstacle=3;
int valueR, valueG, valueB, value_obstacle;
int life;

unsigned long duration_rt, duration_dn, duration_lt, duration_up;//row data
int status_rt, status_dn, status_lt, status_up ;//make sense
unsigned long timeout=5000;

int statusR=84, statusG, statusB;//1-84 result value(for process used)

int count=0, selfPWM, status, channel;
unsigned long durationR, durationG, durationB;

void setup()
{
pinMode(selfPWM_R, OUTPUT); // sets the pin as output
pinMode(selfPWM_G, OUTPUT); // sets the pin as output
pinMode(selfPWM_B, OUTPUT); // sets the pin as output
pinMode(rceivePWM_rt, INPUT);
pinMode(rceivePWM_dn, INPUT);
pinMode(rceivePWM_lt, INPUT);
pinMode(rceivePWM_up, INPUT);
pinMode(channel_R, OUTPUT); // sets the digital pin as output
pinMode(channel_G, OUTPUT); // sets the digital pin as output
pinMode(channel_B, OUTPUT); // sets the digital pin as output

Serial.begin(9600);
}

void loop()
{

valueR=analogRead(buttonR);
valueG=analogRead(buttonG);
valueB=analogRead(buttonB);
value_obstacle=analogRead(button_obstacle);

if(valueR==1023)
statusR=84;
if(valueG==1023)
statusG=84;
if(valueB==1023)
statusB=84;
if(value_obstacle==1023)
{
analogWrite(selfPWM_R, 0);
analogWrite(selfPWM_G, 0);
analogWrite(selfPWM_B, 0);
statusR=0;
statusG=0;
statusB=0;
life=0;
}
else
life=1;

//Serial.println(valueR);
if(life==1){
if(count==0)
{status=statusR;
selfPWM=selfPWM_R;
channel=channel_R;}
else if(count==1)
{status=statusG;
selfPWM=selfPWM_G;
channel=channel_G;}
else if(count==2)
{status=statusB;
selfPWM=selfPWM_B;
channel=channel_B;}

digitalWrite(channel, HIGH);
delay(10);

duration_rt = pulseIn(rceivePWM_rt, HIGH, timeout);
duration_dn = pulseIn(rceivePWM_dn, HIGH, timeout);
duration_lt = pulseIn(rceivePWM_lt, HIGH, timeout);
duration_up = pulseIn(rceivePWM_up, HIGH, timeout);

if(duration_rt>984 && duration_rt<2040)
status_rt=((duration_rt/7.94)-1)/3+1;
else if(duration_rt>0 && duration_rt<985)
status_rt=((duration_rt/8)-1)/3+1;
else
status_rt= 0;

if(duration_dn>984 && duration_dn<2040)
status_dn=((duration_dn/7.94)-1)/3+1;
else if(duration_dn>0 && duration_dn<985)
status_dn=((duration_dn/8)-1)/3+1;
else
status_dn= 0;

if(duration_lt>984 && duration_lt<2040)
status_lt=((duration_lt/7.94)-1)/3+1;
else if(duration_lt>0 && duration_lt<985)
status_lt=((duration_lt/8)-1)/3+1;
else
status_lt= 0;

if(duration_up>984 && duration_up<2040)
status_up=((duration_up/7.94)-1)/3+1;
else if(duration_up>0 && duration_up<985)
status_up=((duration_up/8)-1)/3+1;
else
status_up= 0;

status= max(status, status_rt);
status= max(status, status_dn);
status= max(status, status_lt);
status= max(status, status_up);

if(status>0)
status=status-dc;
else
status=0;

analogWrite(selfPWM, status*3); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
Serial.println(status);

count=count+1;

if(count==1)
statusR=status;
else if(count==2)
statusG=status;
else if(count==3)
{statusB=status;
count=0;}

digitalWrite(channel, LOW);
}
}

apin 提到...

這一個test有應用到無線的傳輸技術嗎?

Scottie Chih- Chieh Huang 提到...

Hello,
好久不見,看你網誌最近也作不少新東西:)
目前我一塊地磚用3個arduino晶片控制。
一個運算網絡中狀態的資訊
另外兩個分別讀取上方紅外線輸入資訊,以及散發自身資訊給上方。
目前此test只是運算網絡中資訊的功能。

apin 提到...

Hello 學長, 嗯對呀我最近也一直在做這個東西. 我只用單一個 Atmega168 做出四個有線的 communication ports, 但因為腳位不夠, 有階段性的腳位重新配置. 若是可像你用紅外線傳輸, 也不失為一個好方法. 另外我還想問的是, 三個Arduino晶片勢必也需要某種連接方式才能將它們整合成為一個,這個部份是怎麼處理的呢?

Scottie Chih- Chieh Huang 提到...

我使用 PWM訊號作晶片之間的資訊傳送。一方使用analogWrite(LEDpinn, 脈波寬度)。另一方使用Pulsein作接收。經過測試我可以整理出84個穩定的脈波數值(0-84)。那妳是用Serial通訊來同時接收四個方向的資訊嗎?正常運作嗎。我之前這樣試過但是沒有辦法同時於處理4個serial read(即使我用了AFserial、Newserail的模組)。對了,妳寫的paper可以跟你要嗎?謝謝

apin 提到...

我沒有用複雜的模組,只是將 Atmega168 的 pin 腳分為四組, 四個 ports 一共用了 16 支 pin, 每一組裡面有其中兩支pin用來控制資料的出和入,一支pin為 clock,另一支為 data. 在某些狀態下它們可以穩定輸入和輸出, 但是至於為什麼要在特定的狀態下才會穩定我也不曉得.而且不會同時傳遞,會有先後的時間差.paper寫好後,我會整理出一份文件,到時可以傳給你.paper本身也可以給你 XD

Scottie Chih- Chieh Huang 提到...

note: 2009/5/6
// LED connected to digital pin 9
int rceivePWM_rt = 0;
int rceivePWM_dn = 2;
int rceivePWM_lt = 4;
int rceivePWM_up = 7;
int selfPWM_B = 6;//self
int selfPWM_G = 5;//self
int selfPWM_R = 3;//self
int channel_B=8;
int channel_G=12;
int channel_R=13;
int dc=1;
int buttonR=0;
int buttonG=1;
int buttonB=2;
int button_obstacle=3;
int valueR, valueG, valueB, value_obstacle;
int life;

unsigned long duration_rt, duration_dn, duration_lt, duration_up;//row data
int status_rt, status_dn, status_lt, status_up ;//make sense
unsigned long timeout=5000;

int statusR, statusG, statusB;//1-84 result value(for process used)

int count=0, selfPWM, status, channel;
unsigned long durationR, durationG, durationB;

void setup()
{
pinMode(selfPWM_R, OUTPUT); // sets the pin as output
pinMode(selfPWM_G, OUTPUT); // sets the pin as output
pinMode(selfPWM_B, OUTPUT); // sets the pin as output
pinMode(rceivePWM_rt, INPUT);
pinMode(rceivePWM_dn, INPUT);
pinMode(rceivePWM_lt, INPUT);
pinMode(rceivePWM_up, INPUT);
pinMode(channel_R, OUTPUT); // sets the digital pin as output
pinMode(channel_G, OUTPUT); // sets the digital pin as output
pinMode(channel_B, OUTPUT); // sets the digital pin as output

Serial.begin(9600);
}

void loop()
{

valueR=analogRead(buttonR);
delay(10);
valueG=analogRead(buttonG);
delay(10);
valueB=analogRead(buttonB);
delay(10);
value_obstacle=analogRead(button_obstacle);
delay(10);

if(valueR<10)
statusR=80;
else if(valueR>1000)
statusR=0;

if(valueG<10)
statusG=80;
else if(valueG>1000)
statusG=0;

if(valueB<10)
statusB=80;
else if(valueG>1000)
statusB=0;

if(value_obstacle<10)
{
analogWrite(selfPWM_R, 0);
analogWrite(selfPWM_G, 0);
analogWrite(selfPWM_B, 0);
statusR=0;
statusG=0;
statusB=0;
life=0;
}
else
life=1;

//Serial.println(valueR);
if(life==1){
if(count==0)
{status=statusR;
selfPWM=selfPWM_R;
channel=channel_R;}
else if(count==1)
{status=statusG;
selfPWM=selfPWM_G;
channel=channel_G;}
else if(count==2)
{status=statusB;
selfPWM=selfPWM_B;
channel=channel_B;}

digitalWrite(channel, HIGH);
delay(20);

duration_rt = pulseIn(rceivePWM_rt, HIGH, timeout);
duration_dn = pulseIn(rceivePWM_dn, HIGH, timeout);
duration_lt = pulseIn(rceivePWM_lt, HIGH, timeout);
duration_up = pulseIn(rceivePWM_up, HIGH, timeout);

if(duration_rt>984 && duration_rt<2040)
status_rt=((duration_rt/7.94)-1)/3+1;
else if(duration_rt>0 && duration_rt<985)
status_rt=((duration_rt/8)-1)/3+1;
else
status_rt= 0;
Serial.print("0==>");
Serial.println(status_rt);

if(duration_dn>984 && duration_dn<2040)
status_dn=((duration_dn/7.94)-1)/3+1;
else if(duration_dn>0 && duration_dn<985)
status_dn=((duration_dn/8)-1)/3+1;
else
status_dn= 0;
Serial.print("2==>");
Serial.println(status_dn);

if(duration_lt>984 && duration_lt<2040)
status_lt=((duration_lt/7.94)-1)/3+1;
else if(duration_lt>0 && duration_lt<985)
status_lt=((duration_lt/8)-1)/3+1;
else
status_lt= 0;
Serial.print("4==>");
Serial.println(status_lt);

if(duration_up>984 && duration_up<2040)
status_up=((duration_up/7.94)-1)/3+1;
else if(duration_up>0 && duration_up<985)
status_up=((duration_up/8)-1)/3+1;
else
status_up= 0;
Serial.print("7==>");
Serial.println(status_up);
//Serial.println(duration_up);

status= max(status, status_rt);
status= max(status, status_dn);
status= max(status, status_lt);
status= max(status, status_up);

//analogWrite(selfPWM, status*6); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
//Serial.println(status);

count=count+1;

if(count==1)
{
if(status>0)
status=status-dc;
else
status=0;

statusR=status;
Serial.print("R==>");
Serial.println(statusR);
analogWrite(selfPWM, statusR*3);}

else if(count==2)
{
if(status>0)
status=status-dc;
else
status=0;

statusG=status;
Serial.print("G==>");
Serial.println(status);
analogWrite(selfPWM, statusG*6);}

else if(count==3)
{
if(status>0)
status=status-dc;
else
status=0;

statusB=status;
count=0;
Serial.print("B==>");
Serial.println(status);
analogWrite(selfPWM, statusB*6);}

digitalWrite(channel, LOW);
delay(100);
}
}