2016年7月5日 星期二

艾鍗ARM MCU Board



艾鍗ARM MCU  實驗套件規格採用的是新唐科技的NANO130低功耗系列晶片





MCU:

  • 新唐 NANO130KE3BN (NANO130低功耗系列晶)
  • ARM® CortexTM-M0 核心最高運行到 42 MHz
  • 128K bytes Flash EPROM Memory
  • 16K bytes SRAM Memory
電源: USB 輸入電源 5V,500mA 自復型保險絲限流保護,系統穩壓 3.3V

燒錄除錯器:  JLink

USB:  

  • 一組 USB 2.0 FS 設備 12Mbps
  • 提供 8 個可程式設計的端點
  • 包含 512 位元組的內部 SRAM 作為 USB 緩衝區

GPIO:

  • 一組 1602 文字型 LCD
  • 一個 4x4 KeyPad 模組
  • on board 輸入按鍵 x1
  • 一組步進馬達及控制器模組

12bits SAR ADC:

  • AD 通道 0:100K 熱敏電阻(on board)
  • AD 通道 1:100K VR(on board)
  • AD 外接通道 x 6

12bits DAC: 2 組 DAC 輸出通道

16bits PWM x8:

  • PWM0-0~2 控制全彩 LED(on board)
  • PWM1_3:Capture mode 紅外線收發模組(on board)

RTC:on board 32.768KHz 石英振盪器
UART:

  • USB 模組 (UART0)
  • ESP8266 WiFi 模組 (UART1)

I2C: BH1750 照度計
SPI: NRF24L01P 2.4G 無線通訊模組


PCB 外觀

NANO130KE3BN規格資料:

• 内核(Core)
- ARM® Cortex™-M0
- 最高運行頻率可達 42 MHz
- 工作電壓:1.8V to 3.6V
- 工作溫度:-40℃ ~ 85℃
• 超低功耗(Ultra-Low power consumption)
- 200 uA/MHz(Normal)
- 75 uA/MHz(Idle)
- 2.5 uA(Power down, RTC on, RAM retention)
- 1 uA (Power down, RAM retention)
- Fast wake-up:less than 7 us
• 記憶體(Memory)
- 32 KB 應用程式Flash
- 內嵌8 KB SRAM
- 可編程Data Flash
- 支援線上系統更新ISP(In-System Programming)
- 支援線上電路更新ICP(In-Circuit Programming)
• 類比轉數位轉換器(ADC)
- 提供12通道
- 12位解析度
- 可達2 MSPS(每秒取樣速率)
- ±1℃ 準確度溫感計



• 脈寬調變(PWM)
- 內建4個16位PWM產生器,可輸出
8 路PWM或4組互補配對PWM
- 捕捉ADC功能
• LCD 控制器
- 4x40 & 6x38 COM/SEG LCD
• 通訊介面(Connectivity)
- USB 2.0全速裝置
- 3 組SPI(可達 32 MHz)
- 2 組I²C(可達 1 MHz)
- 5 組UART(2 組可達 1 Mbps)
- 16/8 位EBI介面
• 時鐘控制(Clock control)
- 外部4 to 24 MHz高速晶振
- 內部12 MHz振盪器(1% 精準度)
- 內部10 kHz振盪器用於低功耗操作

資源連結:

  1. NANO130SC2BN晶片規格
  2. 艾鍗ARM Cortex M0 板電路圖



2016年6月28日 星期二

mbed client using Raspberry Pi with IT-Pi Shield



介紹如何利用yotta 工具進行編譯 linux mbed client

what is yotta ? 

  • mbed OS applications as yotta executables 
  • yotta - to build the mbed example programs
  • yotta is a module management system for C++ and C designed to make it easier to build better software by re-using code.
  • yotta uses the CMake build system, and targets describe how the compiler should be run by providing a CMake
  • yotta is written in python, and distributed using pip, the python package manager
  • 利用yotta 可以到yotta 公開的 module registry (http://yotta.mbed.com/)下載 module (即library)來使用. 另外, yotta 目標希望可以用同一份原始碼來編譯出不同平台上的code
     (yotta target <target_name>)  

yottta 工具安裝

成功安裝完必要的dependency後 , 接著進行安裝 yotta

1.) Installing Package Dependencies

sudo apt-get install python-setuptools cmake build-essential ninja-build python-dev 
sudo apt-get install libffi-dev 
sudo apt-get install libssl-dev
sudo easy_install pip

2) Installing yotta

sudo pip install yotta     //wait and pray......


問題排除 

如果按照上面步驟,安裝yotta, 套件找不到情況, 建立virtualenv , 解決python 相依套件的問題

Installing in a Virtualenv


Virtualenv is a way of separating different python programs installed on the same system from each other. If you have a complex python environment on your system it’s recommended that you install yotta inside a virtualenv. 

  1. Ensure you have virtualenv itself installed. It can be installed with:
    pip install virtualenv
    
    Check that your installation is succesful by running virtualenv --version.
  2. Create a directory to use for the yotta virtualenv:
    mkdir yotta-venv
    virtualenv ./yotta-venv
    
  3. activate the new virtualenv:
    source ./yotta-venv/bin/activate
    
  4. install yotta in the virtualenv:
    pip install yotta
    
  5. (optional) add the binary directory of your virtualenv to your PATH: (if you omit this step, you will need to run yotta as../path/to/yotta-venv/bin/yotta instead of simply yotta.
    export PATH="/path/to/yotta-venv/bin:$PATH"
    
Now yotta should work as normal. You will need to activate the virtualenv any time you want to run yotta commands (you can deactivate it afterwards, by simply running deactivate).

Yotta 成功安裝畫面

 編譯 mbed client linux Source 

 made sure you have installed yotta and all necessary toolchains.

  1. In the command prompt, go to mbed-client-linux-example.
  2. Set up the application with correct Certificate and Domain:
    B. Go to My devices -> Security credentials.
    C. Click GET MY DEVICE SECURITY CREDENTIALS. You will get the needed certificate information as well as the endpoint name and domain.
    D. Copy the security credentials to source/security.h.
  3. In the command prompt, type yotta target arm-linux-native to set up the target device., 這裡會產生出資料匣 build/arm-linux-native
  4. In the command prompt, type yotta build. The executable file will be created in the folder build/arm-linux-native/source/.

    (yotta build -d: 可加入debug 訊息輸出)
編譯code 時會去pubic repository 下載module , 故要求驗證身份

5. In the folder mbed-client-linux-example/build/arm-linux-native/source/, run the executable from the command line, type ./mbed-client-linux-example.

         6. 若要將整個project 清空: 執行 yotta clean


The build process (what is ninja?)



---------------------
參考文件

2016年6月18日 星期六

關於L293D馬達驅動模板


L293D馬達驅動板


The shield contains two L293D motor drivers and one 74HC595 shift register. The shift register expands 3 pins of the Arduino to 8 pins to control the direction for the motor drivers. The output enable of the L293D is directly connected to PWM outputs of the Arduino.

The Motor Shield is able to drive 2 servo motors, and has 8 half-bridge outputs for 2 stepper motors or 4 full H-bridge motor outputs or 8 half-bridge drivers, or a combination.

模組板規格

  • 2 connections for 5V 'hobby' servos connected to the Arduino's high-resolution dedicated timer - no jitter!
  • 4 H-Bridges: L293D chipset provides 0.6A per bridge (1.2A peak) with thermal shutdown protection, internal kickback protection diodes. Can run motors on 4.5VDC to 25VDC.
  • Up to 4 bi-directional DC motors with individual 8-bit speed selection (so, about 0.5% resolution)
  • Up to 2 stepper motors (unipolar or bipolar) with single coil, double coil or interleaved stepping.
  • Pull down resistors keep motors disabled during power-up
  • Big terminal block connectors to easily hook up wires (18-26AWG) and power
  • Arduino reset button brought up top
  • 2-pin terminal block and jumper to connect external power, for separate logic/motor supplies
  • Tested compatible with Arduino Mega 1280 & 2560, Diecimila, Duemilanove, and UNO
  • Download the easy-to-use Arduino software library, check out the examples and you're ready to go!




http://www.kidmakers.org/-for-the-galileo/
Motor shield Motor電源與Arduino Vin 關係

關於 74HC595 Shift Register


  74HC595 為一個位移暫存器: 8bit serial in, parallel out。主要可以透過控制 SER、RCLK, SRCLK 3個輸入接腳控制8個輸出(QA~QH), 這如同是一個3-to-8的Decoder。
  74HC595 位移暫存器可以作為I/O Expansion, 用3根GPIO獲得到8個輸出


  • Vcc
    Up to 6V (needs to be the same voltage as your microcontroller) – Usually 3.3 / 5v
  • QA to QH
    Shift Register Outputs.==> Register 輸出pin
  • SER.
    (Serial) Input for the next pin that gets shifted in.==> Register 輸入pin
  • SRCLK
    (Serial Clock) pulled high, 時 SER pin 狀態會丟入Register
  • RCLK
    (Register Clock) Needs to be pulled high to set the output to the new shift register values,  pulled high, 時 Register 內部8bit值會輸出到QA~QH. This must be pulled high directly after SRCLK has gone LOW again.
  • /SRCLR
    (Serial Clear) Will empty the whole Shift Register if pulled LOW, must be pulled High to enable.清除8bit register內容
  • /OE
    (Output Enable) This pin enables the output when tied to GND, & disabled when HIGH.=>控制輸出與否
  • OH' (pin 9) : You know how the last register just dumps its value when it is shifted over? 每次Shift Out 的值 (即bit 9的內容)

2016年6月16日 星期四

USB over IP (1)



The USB/IP Project aims to develop a general USB device sharing system over IP network. To share USB devices between computers with their full functionality, USB/IP encapsulates USB I/O requests into IP packets and transmits them between computers.


技術架構


  1. Server : 伺服端為USB Host Controller,實際和USB Device連接並分享 USB , 如分享USB 隨身碟、USB Webcam。對於VHCI Driver而言,Stub driver 即如同一個 usb device的driver,Stub Driver 還必須進行IP <-->USB 的封包處理
  2. Client : 客戶端用以連接伺服端並且進行遠端掛載/卸載 (attach/detach) USB。VHCI (Virtual Host Controller Interface)  Driver 為虛擬USB Host),讓SB device 好像直接插入到Host controller 中 (但此為虛擬的HCI)。Client端將IP封包 (其payload為USB 封包),送入VHCI,使系統以為真有USB插入。 


usbip-design


Linux  kernel 3.17.x 後內建支援 USB over IP的功能

[USB/IP Support ]
This enables pushing USB packets over IP to allow remote machines direct access to USB devices. It provides the USB/IP core that is required by both drivers.  

Linux 
root@server1:~# sudo modprobe usbip-host




root@server1:~# usbipd -D

you should see that the usbip daemon is listening on TCP port 3240



root@server1:~# sudo apt-get install usbip

root@raspberrypi:~# usbip list -l

 - busid 1-1.1 (0424:ec00)
   Standard Microsystems Corp. : unknown product (0424:ec00)

 - busid 1-1.4 (0781:5567)
   SanDisk Corp. : Cruzer Blade (0781:5567)

root@raspberrypi:~# usbip bind --busid=1-1.4

usbip: info: bind device on busid 1-1.4: complete


root@raspberrypi:~# lsusb

Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0781:5567 SanDisk Corp. Cruzer Blade


資源參考
http://usbip.sourceforge.net/
http://askubuntu.com/questions/612355/share-usb-drive-over-network