Lab 3: Whack-a-Mole

Sample program (TEMT6000): svn://mvnl.csie.ntu.edu.tw/wn11fall/lab/lab3

Description

In this project, you will program several Zigduino boards to become a whack-a-mole game set. Utilizing the light sensor on each device, when a hand covers the device, it will detect the “whacking” action. Your job is to design the communication protocols between different devices and count the number of times the moles are whacked.

TEMT6000

TEMT6000 is an ambient light sensor. We will provide each team with several TEMT6000 breakout boards. Please see its specifications and details here. The sample program we provide shows how to obtain measurements from the TEMP6000 sensor.

BMAC

We suggest you to use the BMAC library for communications. Look for its API here.

Requirements

  1. One of the boards should be connected to your computer via the USB cable. On your computer there should be a simple user interface to perform various operations (some listed below). The simplest way to do this is to utilize printf/scanf on your zigduino and use a terminal program on your computer to communicate with the zigduino board connected to your computer (let's call this node the master node in the following).
  2. We can register new “moles” (zigduino boards) to your game set. (Of course, after you program the board with your firmware) One way to do this is, when you first turn on a board, it will enter a “ready-to-be-registered” mode, and you use the user interface to instruct the master node to look for these boards.
  3. The game set should display the current score and keep the highest score in the user interface.
  4. Your game should contain at least 3 different levels. It should get harder and harder (and fun to play with!).
  5. At any time, we should be able to stop the game via user interface and come back to the “main menu”. Then, we can start the game again if we want.
  6. The detection of hand-covering action (whacking) should work in most of light conditions, or, in other words, adaptive.
  7. Feel free to develop any other features so that the game is more interesting! (we'll give you bonus score for this)

Ask any question about this Lab here.

zxm20243, 2011/12/01 04:18
有個很大的問題...
我參考http://www.nanork.org/wiki/nrk-api-uart
利用上面的API來實作從serial port讀資料的部分
可是我發覺大多數的時候都讀不到資料

然後我也利用了example中serial的部分來實驗
雖然是firefly的,但是有稍微改過裡面的內容,
發覺有一樣的情形,大概每讀16次才會跑出一個字元,
偶爾還會有亂碼的情況

助教請救救我們Q口Q
zxm20243, 2011/12/01 06:51
後來我們應該找到解決方法了...提供給大家做參考
http://www.nanork.org/browser/nano-RK/src/platform/zigduino/source/ulib.c?rev=1182
Kuang-Shih Huang, 2011/12/01 08:49
謝謝反應這個問題,也辛苦你自行解決了

會有這個問題
主要是因為下載的nano-rk版本太舊
或者不完整

如果不確定自己版本是否正確
請愛用我們架的svn server直接抓現在版本
svn co svn://mvnl.csie.ntu.edu.tw/wn11fall/nano-RK

WNFA TA
Kuang-Shih Huang, 2011/11/30 15:51
開放登記demo時間
請到以下連結登記
https://docs.google.com/spreadsheet/ccc?key=0AiwnDQMlIKGfdDR2d3J6c2pMZFRNdGRzdUpuemUtekE

WNFA TA
Ting-Yao Chang, 2011/11/30 22:33
請問這次Lab要上傳報告和code嗎?
還是只要上傳code就好
謝謝

另外想問有關於nrk_timer_int的問題
如果call nrk_timer_int_start後 再call stop 之後reset再start
雖然timer的count會歸零,可是call start之後會馬上interrupt進入callback function
照理說call完reset再call start, timer歸零後會等到timer到threshold再interrupt進callback function
但是卻馬上進去,不知道是哪裡的問題?
Kuang-Shih Huang, 2011/11/30 23:22
一樣請上傳report與code
report重點請放在你們實做內容
有助於助教快速了解你們所實做

另外 nrk_timer_int部份
助教之前沒有碰過,現在正在看
不知道你想做的功能是什麼?
Kuang-Shih Huang, 2011/11/30 23:55
助教測試
nrk_timer_int
reset->start之後
callback function並沒有馬上進去
不知道是不是其他地方有問題?

(如果有不合邏輯的狀況發生,建議回到最基本的測試,
如果測試仍然沒問題,請確定nrk_cfg等相關設定,或者是
記憶體有無使用超過等,記憶體控管在這種embedded system
上不如pc嚴謹,錯了通常也不會叫警告,而是行為亂七八糟難估計)
Peer, 2011/11/29 19:00
請問關於這次的lab3:
1.Master node是否也要當一個地鼠接light sensor亮LED?
2.最高分紀錄要留到程式重開會還在或是關閉之前就好?
3.這次的demo時間會是在什麼時候?
4.deadline可不可以延期? QAQ
寫不完+1, 2011/11/30 01:39
第4點 +1
jiaci, 2011/11/30 01:41
延期吧...!!!
asdfghjkl20203, 2011/11/30 01:41
跟 OS 作業卡在一起惹!
拜託第四點++ QAQ
Kuang-Shih Huang, 2011/11/30 08:56
1.不用
2.關閉之前就好
3.預定禮拜四晚上和禮拜一晚上,會開放登記。
4.我會跟老師講看看,不過三個禮拜的期限,我個人覺得希望不大。
(大家多問一點具體問題,讓老師看到你們遇到的困難,
跟你們的血汗,才不會讓老師懷疑你們這禮拜才開始寫XD)。

WNFA TA
wizhao, 2011/12/01 00:02
雖然有三個禮拜
不過大部份時間都跟期中考疊在一起QQ

想問助教我們用ReadFile讀的到master傳到serial port的訊息
但是用WriteFile寫的東西 master用getchar讀到的都是些空格 助教能不能指點一下><
Kuang-Shih Huang, 2011/12/01 00:43
那如果直接用serial terminal輸入的話master會成功getchar得到東西嗎?
(ex. minicom, tera-term, putty, pietty 等軟體)
software/hardware flowcontrol有關掉嗎?

至少先縮小範圍確定問題在哪裡,這樣才有辦法解決問題。

加油囉!!

WNFA TA
wizhao, 2011/12/01 01:04
用serial port開的話會沒辦法輸入東西耶
Kuang-Shih Huang, 2011/12/01 08:57
有確定software/hardware flowcontrol有關掉嗎?
或者請確定一下nano-RK的版本問題
(看最新回覆那篇 你有沒有那個檔案
nano-RK/src/platform/zigduino/source/ulib.c)

WNFA TA
Ting-Yao Chang, 2011/11/28 21:25
想請問一下 關於怎麼可以使外接的led燈閃爍
已經有看example裡面的led_bink檔
還是跟接的pin腳有關係 call nrk_led_toggle()裡面 參數放0是亮RFTX 1是亮RFRX
有辦法設定接的pin角的led燈設定他的led number嗎

謝謝
不才, 2011/11/29 02:36
nrk_led_toggle( ~ ) ~放的參數就是pin 腳的編號
該編號pin腳就會由 0->1 | 1->0
比如說call一次
nrk_led_toggle(NRK_GPIO_6) pin 6 就會由 0->1
再做一次就 1->0
應該是這樣吧~ 在main那邊要先註冊的樣子

不知道你的問題是不是這個
希望有幫忙
Ting-Yao Chang, 2011/11/29 16:26
謝謝解答,不過想再請問一下那註冊是在main call nrk_led_set()這個function嗎?
外接的led燈 一個pin角接POWER的3V3 一個假設接digital pin6 然後 call
nrk_led_set(NRK_GPIO6) 和 nrk_led_toggle(NRK_GPIO6)
還是依然不會亮 一個接3V3一個接GND就會亮
Kuang-Shih Huang, 2011/11/30 09:02
要先指定gpio方向(input/output)
ex. nrk_gpio_direction(NRK_GPIO_6, NRK_PIN_OUTPUT);
再使用
nrk_gpio_set(NRK_GPIO_6); //設成high
nrk_gpio_clr(NRK_GPIO_6); //設成low
nrk_gpio_toggle(NRK_GPIO_6); //high變low, low變high
來控制

這邊比較混淆的可能是 其實你控制的是gpio
所以請看gpio的api如何使用
http://www.nanork.org/wiki/nrk-api-leds-gpio

其他有的沒的範例也可以多看一下當初助教課提供的examples
svn co svn://mvnl.csie.ntu.edu.tw/wn11fall/lab/examples

大家加油!!

WNFA TA
Hakki, 2011/11/26 18:38
Is there a way to buffer more than one character from serial port for device? Current UART API only supports for buffering one character and we need more in order to supply a communication channel between GUI and master node.

We tried to buffer each character read from serial port into a string, but somehow we are still unsuccessful.
Kuang-Shih Huang, 2011/11/26 19:13
As i know, the uart api support buffering more then one character.
There is an example in http://www.nano-rk.org/wiki/nrk-api-uart
May this give you some help.

WNFA TA
Hakki, 2011/11/26 20:20
Well, as you can see from the API:

nrk_uart_set_trig_thresh
[TO BE IMPLEMENTED] It will allow setting the number of characters buffered required before a signal is sent to a task.

If you mean 'scanf' would work, we've already tried it - but, still doesn't work.
Kuang-Shih Huang, 2011/11/26 21:04
Sorry I didn't understand what problem you meet exactly.

Can you tell me more about your question?

Did you mean that you can't read anything from the input?
If this is the problem, maybe you forgot to turn off the software flow control
(the way to turn off in minicom is ctrl+a -> o -> g)

WNFA TA
You could leave a comment if you were logged in.
 
wn_11fall_lab3.txt · Last modified: 2011/10/01 10:48 by hikaru4 · [Old revisions]
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki