Search This Blog

Tuesday, November 24, 2015

Wireless Communication using CC2530 Zigbee Wireless MCU

CC2530 က IEEE 802.15.4 နဲ့ Zigbee တွေအတွက် RF transceiver နဲ့ 8051 MCU ကို ပေါင်းစပ်ထားတဲ့ system-on-chip (SoC) solution တခုပါ။ သူ့ကို သုံးပြီး wireless module စမ်းလုပ်ဖို့ အတွက် CC2530EM Evaluation Modules နှစ်ခု၊ SmartRF05EB Evaluation Boards နှစ်ခု၊ နဲ့ CC2531 USB Dongle တခုပါတဲ့ CC2530DK devolopment kit ကို ဝယ်တာ USD 400 လောက်ပေးရပါတယ်။ သူတို့နဲ့ သုံးဖို့အတွက် TI ရဲ့ ဝက်ဘ်ဆိုက်မှာ အလကားပေးတဲ့ SmartRF Studio ကို စက်ထဲမှာ install လုပ်ပါတယ်။

CC2530DK

Tuesday, November 17, 2015

Driving 28BYJ-48-5V Stepper Motor with ULN2003A Transistor Arrays on Arduino

28BYJ-48-5V Stepper Motor နဲ့ ULN2003A driver တွေက တော်တော် အသုံးများပုံရပြီး အလွယ်တကူ ဝယ်နိုင်ရုံတင်မက စျေးလည်း တော်တော်ပေါ ပါတယ်။ Stepper Library ကို မသုံးပဲ Arduino ရဲ့ Port B ကို သုံးပြီး Stepper motor ကို ထိန်းတဲ့ ရိုးရှင်းတဲ့ နမူနာလေး ဖော်ပြချင်ပါတယ်။


Figure. Driving 28BYJ-48-5V Stepper Motor with Arduino UNO using USB power.


28BYJ-48-5V Stepper Motor က 5V နဲ့ တိုက်ရိုက်မောင်းနိုင်ပြီး၊ unipolar stepper motor အမျိုးအစားပါ။ သူ့ရဲ့ schematic ကို အောက်မှာပြထားပါတယ်။


Figure. 28BYJ-48-5V Stepper Motor.


ULN2003A Transistor Arrays ကတော့ inductive load တွေကို drive လုပ်ဖို့ ဒီဇိုင်းလုပ်ထားတာမို့ အထဲမှာ free wheeling diode ပါ ပါ ပါတယ်။ Darlington pair သုံးထားတာမို့ အဝင် ဗို့ 1.4V လောက်ကနေ 30V အထိ ကြိုက်တဲ့ ဗို့နဲ့ တိုက်ရိုက်ဆက်ပြီး ထိန်းနိုင်ပါတယ်။


Figure. ULN2003A.


Wave drive, Full step drive နဲ့ Half step drive တွေကို သုံးပြထားတဲ့ နမူနာ ပရိုဂရမ် လေးကို အောက်မှာ ပြထားပါတယ်။


//Driving 28BYJ-48-5V Stepper Motor using ULN2003A Transistor Arrays
//Author: Yan Naing Aye
//Website: http://www.cool-emerald.com/

#include "StepperPortB.h"
//----------------------------------------------------------
void setup() {    
  StepperInit();//setup pins
  //StepperMode(WAVE);
  //StepperMode(FULL);
  StepperMode(HALF);
  //Serial.begin(9600);
}
void loop() {
  Step(4096,2500); //turn 4096 steps forward with 2500 us period for each step
  Step(-4096,2500);//turn 4096 steps backward with 2500 us period for each step
  //Serial.println(CS);
}


//File: StepperPortB.h
//Author: Yan Naing Aye
//Website: http://www.cool-emerald.com/

//Driving 28BYJ-48 – 5V Stepper Motor using ULN2003A Transistor Arrays
//----------------------------------------------------------
#ifndef StepperPortB_h
  #define StepperPortB_h
  #include "Arduino.h"
byte* S; //Stepping sequence

//Wave drive
//Step          0 | 1 | 2 | 3 | 0 |...

//Blue   = A :  1 | 0 | 0 | 0 | 1 | ...
//Pink   = B :  0 | 1 | 0 | 0 | 0 | ...
//Yellow = C :  0 | 0 | 1 | 0 | 0 | ...
//Orange = D :  0 | 0 | 0 | 1 | 0 | ...
byte Wave[4] = {0x01,0x02,0x04,0x08};

//Full Step drive
//Step          0 | 1 | 2 | 3 | 0 |...

//Blue   = A :  1 | 1 | 0 | 0 | 1 | ...
//Pink   = B :  0 | 1 | 1 | 0 | 0 | ...
//Yellow = C :  0 | 0 | 1 | 1 | 0 | ...
//Orange = D :  1 | 0 | 0 | 1 | 1 | ...  
byte FullStep[4] = {0x09,0x03,0x06,0x0C};

//Half Step drive
//Step          0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 0 |...

//Blue   = A :  1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 |...
//Pink   = B :  0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |...
//Yellow = C :  0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |...
//Orange = D :  1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |...
byte HalfStep[8] = {0x09,0x01,0x03,0x02,0x06,0x04,0x0C,0x08};
int CS=0;//Current step
int N;
//----------------------------------------------------------
//Mode definition
#define HALF 0
#define FULL 1
#define WAVE 2
//Define the mode to drive the stepper motor
void StepperMode(int Mode) {  
  if(Mode==WAVE) {S=Wave; N=4;}
  else if(Mode==FULL) {S=FullStep; N=4;}
  else {S=HalfStep; N=8;}
}
//----------------------------------------------------------
//Turn stepper motor n steps
//with t microseconds period for each step
//positive n for forward dir and negative n for backward dir
void Step(int n,int t) {
  int CD=1; 
  if(n<0) {n*=-1; CD=-1;}
  for(int i=0;i<n;i++) {
    CS=(CS+(N+CD))%N;
    PORTB=S[CS];
    delayMicroseconds(t);
  }
}
//----------------------------------------------------------
//Initialize
void StepperInit() {
  //Setup port B (digital pin 8 to 13)
  //The two high bits (6 & 7) map to the crystal pins and are not usable
  //only 4 pins - 8 to 11 are used in this program
  //where Blue - pin 8 (LSB), Pink -pin 9, Yellow -pin 10, Orange -pin 11
  DDRB=0xff;
  PORTB = 0x00;  
}
//----------------------------------------------------------
#endif

Monday, November 16, 2015

Fitting a curve to a function

ပေးထားတဲ့ curve တခုနဲ့ အကိုက်ညီဆံုး piecewise linear function တခုကို ရှာတဲ့ နမူနာ MatLab code တခုပါ။



%Fitting a curve to a piecewise linear function using least square method
%with the fixed start and end points

%clear command windows
clc;

%clear workspace
clear all;
%--------------------------------------------------------------------------
%Read curves
load Curve.dat;

%find lower left and upper right corners 
xD=Curve(1,:);
yD=Curve(2,:);
x0=min(xD); x1=max(xD); 
y0=min(yD);  y1=max(yD);
n=5;%order n i.e, the number of segments
FS=x1-x0;
global xs;
global yB;
global yE;
xs=(0:FS/n:FS);
yB=y0;
yE=y1;
%initialize coefficients (y values) to find 
%excluding the first and the last one
ys_initial=xs(2:n);
% options = optimset('MaxFunEvals',1000,'MaxIter',1000);
% LowerBoundC=y0;
% UpperBoundC=y1;
% ys =lsqcurvefit(@LineSeg,ys_initial,xD,yD,LowerBoundC,UpperBoundC,options);
ys =lsqcurvefit(@LineSeg,ys_initial,xD,yD);
%fixed start and end points
ys=[y0 ys y1];
%--------------------------------------------------------------------------
%Plot 
hFig1 = figure(1);
set(hFig1, 'Position', [600 100 500 300])
plot(xD,yD,':g','LineWidth',3,...
                'MarkerEdgeColor','b',...
                'MarkerFaceColor','b',...
                'MarkerSize',2)
hold on;             
plot(xs,ys,'-rs','LineWidth',1,...
     'MarkerEdgeColor','r',...
     'MarkerFaceColor','r',...
     'MarkerSize',4)
hold off;        
grid on;
%--------------------------------------------------------------------------


LineSeg.m
function [y] = LineSeg(ys,x)

global xs
global yB
global yE
L=length(x);
y=zeros(1,L);
ys=[yB ys yE];
LS=length(ys);
for i=1:L
    xt=x(i);
    %--------------------------
    %find segment
    for j=2:LS
        if(xs(j)>=xt) 
            break;
        end
    end    
    %interpolate
    x2=xs(j);
    y2=ys(j);
    y1=ys(j-1);
    x1=xs(j-1);
    y(i)=y1+(y2-y1)/(x2-x1)*(xt-x1);
    %--------------------------
end 

Sunday, October 4, 2015

Photographing around NTU

ဒီနှစ်ပိုင်းတွေထဲ NTU ကျောင်းဝင်းထဲမှာ ကြုံရင် ကြုံသလို ရိုက်ဖြစ်ခဲ့တဲ့ ဓာတ်ပုံလေးတွေ စုပြီး တင်လိုက်ပါတယ်။ ဒီအောက်ကပုံကတော့ 1950s နှစ်ပိုင်းလောက်က တည်ဆောက်ခဲ့တဲ့ Chinese Heritage Centre (CHC) ရဲ့ပုံပါ။ သူ့ဘေးမှာက သာယာအေးချမ်းတဲ့ Nanyang Lake ရေကန်လေးရှိပြီး ရှေ့မှာက စိမ်းလန်းလှပတဲ့ Yunnan ပန်းခြံ ရှိပါတယ်။ အိမ်ပြန်ရင် နောက်ဖက်ကတောင်ကုန်းကနေဆင်းပြီး ပန်းခြံကို လမ်းဖြတ်လျှောက်ပြီး ပြန်နေကျပါ။ ဒီဓာတ်ပုံရိုက်တုန်းက ညနေ ၇ နာရီလောက် မှောင်ရီပျိုးစ သဘာဝ အလင်းရောင် နဲ့ လျှပ်စစ်မီးရောင် တွေကအဆင်ပြေပြေ လှနေတယ်ထင်တာနဲ့ handheld ပဲ ရိုက်လိုက်တာပါ။


Figure. Chinese Heritage Centre in NTU


Friday, September 25, 2015

Adafruit CC3000 WiFi for Arduino

WiFi သုံးပြီး microcontroller နဲ့ ဆက်သွယ်တဲ့ ဟာကို Arduino Uno နဲ့ Adafruit CC3000 WiFi Shield ကိုသုံးပြီး စမ်းကြည့်ထားတာပါ။ သူက Arduino ရဲ့ standard WiFi shield မဟုတ်တဲ့ အတွက် WiFi.h library ကို သုံးလို့မရပါဘူး။ ဒါ့ကြောင့် Adafruit CC3000 library ကို ဒေါင်းလုပ်လုပ်၊ un-zip လုပ်ပြီး C:\Program Files (x86)\Arduino\libraries folder ထဲမှာ ထည့်ဖို့လိုပါတယ်။


Figure. Adafruit CC3000 WiFi shield stacked with Arduino Uno.


Sunday, September 20, 2015

Our Kids 1 : Communication with children

တစ်လောက NTU ရဲ့ Campus Recreation and Wellness (CReW) ကလုပ်ပေးတဲ့ Communication with Children ဆိုတဲ့ talk လေးကို သွားနားထောင်ဖြစ်တယ်။ ပြောတဲ့သူက Employee Wellbeing Centre က Staff Counsellor တစ်ယောက်ဖြစ်တဲ့ Ms. Janet Phang ပါ။ နေရာက Campus Clubhouse ရဲ့ Orchid Room မှာပါ။ စင်ကာပူ ဒေါ်လာ ၅ ဒေါ်လာပေးရပါတယ်။ သူတို့ စီစဉ်ထားတဲ့ Fusion spoon က အစားအသောက် Potato Salad, Teriyaki Chicken, Sweet & Sour Fish,Braised Tofu with Mushroom, Curry mixed vegetable, Fried Bee Hoon, Chocolate Éclair, Coffee, Tea, Fruit Punch တွေနဲ့ တင်ကို တော်တော်တန်နေပါပြီ။ ပြီးတော့ free gift ပေးတဲ့ အပူအအေးခံတဲ့ mug ခွက်လေးကလည်း တော်တော်ကောင်းပါတယ်။ အဲ.. ပြောသွားတဲ့ အကြောင်းအရာတွေလဲ တော်တော် သဘောကျပါတယ်။


Figure. Communication with children.


Saturday, September 19, 2015

Controlling Your Hardware from the Web Using Arduino

Arduino Ethernet shield 2 ကိုသုံးပြီး အင်တာနက်ကနေ သင့်ရဲ့ hardware တွေကို လှမ်းပြီး ထိန်းတဲ့အကြောင်း ဆွေးနွေးချင်ပါတယ်။ Arduino Ethernet 2 Library ကိုသုံးပြီး server အနေနဲ့ နမူနာတခု၊ client အနေနဲ့ တမျိုး စမ်းကြည့်ပါမယ်။ နောက်ဆုံး version Arduino IDE ကို သုံးဖို့လိုပါတယ်။ ဒီနမူနာမှာတော့ Arduino IDE 1.7.6 ကိုသုံးထားပါတယ်။ Arduino Uno ကို Ethernet shield 2 တပ်ထားတဲ့ပုံကို အောက်မှာ ပြထားပါတယ်။


Figure. Arduino Uno paired with Arduino Ethernet shield 2.


Wednesday, September 16, 2015

Testing Dual-Core Microcontroller - LPC54102

LPC54102J512 MCU မှာ Cortex M4 Master တစ်ခုနဲ့ Cortex M0+ Slave ဆိုပြီး core နှစ်ခုပါပါတယ်။ LPCXpresso IDE v7.9.0 ကိုသုံးပြီး multicore systems တစ်ခုကို ဖန်တီးတာ၊ debug လုပ်တာတွေကို နမူနာ တစ်ခုရေးပြီး စမ်းကြည့်တဲ့ အတွေ့အကြုံကို ပြောချင်ပါတယ်။ LPCOpen ကို ဒေါင်းလုပ်လုပ်ထားပြီး Quickstart -> Import project(s) ကို နှိပ်ပြီး import လုပ် ထားဖို့လိုပါတယ်။


Thursday, September 10, 2015

Accelerometer LIS3DSH

LIS3DSH က STMicroelectronics ထုတ်တဲ့ 3-axis MEMS accelerometer တခု ဖြစ်ပါတယ်။ Full scale ကို &pm;2g ကနေ &pm;16g ထိ အမျိုးမျိုးရွေးလို့ ရပါတယ်။ အရွယ်အစားက လည်း 3mm x 3mm ပဲမို့ သေးသေးလေးပါ။ Digital output ကို SPI ဒါမှမဟုတ် I2C ကြိုက်တာသုံးလို့ရပါတယ်။ Supply voltage က 1.71 V ကနေ 3.6 V ထိပေးလို့ ရပါတယ်။ STEVAL-MKI134V1 adapter board လေး တခုဝယ်ပြီး စမ်းကြည့်ထားတဲ့ အတွေ့အကြုံ လေးအကြောင်း ပြောချင်ပါတယ်။


Figure. STEVAL-MKI134V1 - LIS3DSH adapter board for standard DIL24 socket.

Tuesday, September 8, 2015

A Holistic Approach to Vocal Freedom

NTU ရဲ့ Campus Recreation and Wellness (CReW) ကစီစဉ်တဲ့ A Holistic Approach to Vocal Freedom ဆိုတဲ့ သီချင်း အဆို သင်တန်း သွားတက်ကြည့်ဖြစ်တယ်။ သင်တဲ့သူက NIE က Visual and Performing Arts က lecturer တယောက်ဖြစ်တဲ့ Dr. Chia Wei Khuan ပါ။ ငယ်ငယ်ကတည်းက သီချင်းတွေ အိမ်နေရင်း အမြဲဆိုခဲ့ပေမယ့် အဲဒီအကြောင်းကို မလေ့လာဘူးတာ တပိုင်း၊ စိတ်ဝင်စားတာတပိုင်း ကြောင့် ကြုံကြိုက်တုန်း သွားတက်ဖြစ်ခဲ့တာပါ။ ခြောက်ပတ်စာ သင်တာတွေက

  • The McClosky Technique: Relaxation, Posture, Breathing and Breathy Sigh
  • Freeing the Tongue, Jaw, Facial Muscles and Neck
  • Phonation: On-set and Off-set, Flow vs Pressed
  • Resonance and Articulation
  • The Singer's Breath: Appoggio
  • Maintaining Vocal Freedom
ဆိုတဲ့ အကြောင်းတွေ ဖြစ်ပါတယ်။


Figure. ကြာတော့ ကြာပြီ အိမ်မှာ ကာရာအိုကေ ဆိုလို့ ရအောင်ဆိုပြီး မိုက်ခရိုဖုန်း လိုက်ရှာရင်း ကြိုးမဲ့မဟုတ်တာလည်း ဖြစ်တဲ့ Shure SM58 လေး သဘောကျတာနဲ့ ဝယ်ဖို့လုပ်တော့ ဘယ်မှာ ဝယ်ရမှန်း မသိဘူး။ အွန်လိုင်း မှလည်း Amazon မှာတော့ တွေ့ပေမယ့် စင်ကာပူ လိပ်စာနဲ့ ဝယ်မရဖြစ်နေတာ။ နောက်မှ သီရိကို အမှတ်မထင် ပြောပြဖြစ်တော့ သူက SingPost ကနေတဆင့် ပို့တဲ့ ဟာလုပ်ပြီး ရအောင် ရှာဝယ်ပေးတာနဲ့ အဆင်ပြေသွားတယ်။