Tuesday, October 27, 2009

مرض الشيزوفرنيا !

لا تتعجب من مهندس و هو يتكلم عن الطب ، فاغلب المهندسين يحبون معرفه ما يسمونه بالميكانيزم و معرفه كيف يعمل الجسم ..إلخ من الهرطقات :) .
كثير من الناس في المجتمعات العربية يضحكون علي كلمة شيزوفرنيا و كأنها كلمة تعني انك مجنون رسمياً او انك تعاني من مرض فزيع ! و كما آثار الممثل احمد حلمي في فيلمه اسف علي الازعاج و هو يعاني من هذا المرض و جميع النقاد يقولوا انه اول من اثار هذا الموضوع في السينما المصرية ، و هم لا يعلمون ان فؤاد المهندس في افلامه لا اتذكر اسمها ذكرت الكلمة بين دكتورين اجانب ، يقول واحد للاخر ، شيزوفرنيا ،و الاثنين يختلفوا !
الشيزوفرنيا هو مرض الفصام ، و هو مرض يصيب اي شخص و هو يتوهم بأن هناك شخصيات تتحدث معه و تسمي هذه الاشياء بالضلالات delusion .
النقطه التي ارجحها هو سبب خلل كيميائي في المخ ، حتي ان بعض الادوية توصف عقارات تقلل نسبة الدوبامين في المخ و هذه الادوية تسمي مضادات الذهان Antipsychotic .
و انا اعرف بعض العقارات الناجحه في هذا الامر و الجرعه منها مثل الدوجماتيل 200 قرص يومي ، و عقار البيبريكس و لكنه غالي الثمن ، لا تستغرب كيف اعرف هذه الادوية ؟ لقد قابلت للاسف في حياتي حوالي ثلاث حالات منهم اصدقاء غير قريبين و جيران و هذا ما جعلني ابحث عن المرض و تفاصيله .

النقطة الغريبة في الموضوع هو ان هذه المعلومات تعتبر معلومات هامه ، فالمجتمع الامريكي معظمهم يكونوا عارفين بالمصطلحات الطبية و حتي انواع الامراض ، و لديهم معرفه ليست بكثير ، علي عكس المجتمع العربي ، و المصري بالخصوص ، الذي يفتي كثيراً حتي تجد في العيادات إناس يفتون في مرضهم و هذا ما يجعل الاطباء ضعاف النفوس في استغلالهم ، يجب ان تعرف ما هو مرضك و ما هي الادوية المرجحه له و هذا متوافر علي الانترنت .
Many people just laugh at the word schizophrenia , and they think that your totaly a crazy person when they describe you that ur a schizphornic ! . This sickness has been filmed in a movie called " Asef ala el ez'ag" by ahmed helmy , however the criticizers of the movie said its the first movie in the egyptian cinema which described that sickness , its not true ! . That word has been said in Fouad el mohanes movies , by a Comedy thing . This word is spread in the egyptian community and many people dont know what it really means , and as you know , egyptians like to talk too much and never say the word I DONT KNOW THIS .
Schizophrenia is sickness in the brain , In my humble opinion its a problem in the chemics of the brain , especially the increase in the dopamin , the patient feels or sees some delusions something like that he /she talks with persons that aren't actually there . Medicines are called Antipsychotic are usually described for the treatment of that sickness , which decreases the dopamin in the brain . Something like Dogmatil or Alpiprix which is really an expensive medicine .
The strange point in this topic is that information are really important , and most people in the usa community whatever patients or healty people really know about that sickness or the symptoms , and that's really a good point , unlike here in the egyptian community where patines just take the medicine and they dont know what they actually take or from what they suffer , althought understanding the sickness is the FIRST step to be able to be cured !.

Monday, October 26, 2009

Monday, October 19, 2009

Line Tracking using PID using 89S52

First I'd like to thank So ChikMan From Hong kong HKU, he is a pioneer in control engineering besides, he has repersented his country many times in Robocon contest, he has a great impact on teaching me the theory and operation of PID Control.

Hi, In robocon 2008, i've tried to implement the well-known algorithm in Control engineering the PID ( Proportional -integeral -derivative), I was having a great experience using the microcontroller from ATMEL 89S52 , plus I've already designed a complete board using it at the past years of the contests , and due to low fund, I've used it again. The problem is that uC doesnt have a PWM Hardware module so you've to write your own Software PWM, also it doesnt have an ADC ( anlogue to digital converter), and i've solved this by using a crude way of doing an ADC which is using a compartor like LM324.

The idea is there are 6 sensors (some people uses 8 or 16,or 32! depends on your complexity of design and speed you want to achieve), These sensors will give you the position of the robot from the line which it follows considring that the output from the sensors are Digital , so you've to define some numeric values to enumrate for the posssibilites of the position of the robot on the line to be tracked.

Consider that 1 is the value on white which means your on the line, and 0 is the value when your away from the line. Consider The sensor arrangement as this xxxxxx, let it be L1L2L3R3R2R1
Consider that L3, R3 have been positioned to be on the line , and the other sensors are seprated by 10mm.
The Pid algorithm calculates the error from the feedback element which is our 6 line sensors , when L3,R3 are on the white line, which means the robot is going straight and it also means the the Error is 0, which is our desired value or what's always called in control engineering text books ( Set Point ).
pseudo code :
error = setpoint- measured value .
If you've a control engineering textbook, you will see many figures of the well-known control loop which is familiar to many engineers.
The measured value should be a predfined numeric values because we dont have an ADC here.
We will define it like in the code.

Code List using 89S52

void init_timer0(void)
{
EA=0; // disable gloabl interrupts

TMOD=0x02; // 0000 0010
TH0=0x9B; // Timer values
TL0=0x9B; //
PWM=0;
ET0=1; // Enable timer interrupt 0

EA=1;
}


The Software PWM Code
// Motor1_2 , is the enable pin of the motor for PWM
// pwm_l , r are the values of the PWM which be sent to the motor , from 0 > 11
void timer0(void) interrupt 1 using 0
{
TR0=0;
PWM++;
TL0=0x9B;TF0=0;
if (PWM==11) PWM=0
if (PWM <= pwm_l) Motor1_2=1; else Motor1_2=0; if (PWM <= pwm_r) Motor2_2=1; else Motor2_2=0; TR0=1; }



// Do this in a 20ms (sampling time) control loop

void Line_Track(void)
{
int mpos;
float error,Rate,Deriv,previous_error;
pwm_r_=11;
pwm_l_=11;
TR0=1;
Walk(1); // move forward
if((Sensor_1==0)&&(Sensor_2==0)&&(Sensor_3==0)&&(Sensor_4==0)&&(Sensor_5==0)&&(Sensor_6==0))
{
mpos=0;
}
if ((Sensor_1==1)&&(Sensor_2==1)&&(Sensor_3==1)&&(Sensor_4==1)&&(Sensor_5==1)&&(Sensor_6==1))
{
mpos=0;
}
if ((Sensor_1==0)&&(Sensor_2==0)&&(Sensor_3==1)&&(Sensor_4==0)&&(Sensor_5==0)&&(Sensor_6==0))
{
mpos=-1;
}
if((Sensor_1==0)&&(Sensor_2==0)&&(Sensor_3==0)&&(Sensor_4==1)&&(Sensor_5==0)&&(Sensor_6==0))
{
mpos=1;
}
if((Sensor_1==0)&&(Sensor_2==1)&&(Sensor_3==0)&&(Sensor_4==0)&&(Sensor_5==0)&&(Sensor_6==0))
{
mpos=-2;
}
if((Sensor_1==0)&&(Sensor_2==0)&&(Sensor_3==0)&&(Sensor_4==0)&&(Sensor_5==1)&&(Sensor_6==0))
{
mpos=2;
}
if((Sensor_1==1)&&(Sensor_2==0)&&(Sensor_3==0)&&(Sensor_4==0)&&(Sensor_5==0)&&(Sensor_6==0))
{
mpos=-5;
}
if((Sensor_1==0)&&(Sensor_2==0)&&(Sensor_3==0)&&(Sensor_4==0)&&(Sensor_5==0)&&(Sensor_6==1))
{
mpos=5;
}
if((Sensor_1==0)&&(Sensor_2==1)&&(Sensor_3==1)&&(Sensor_4==0)&&(Sensor_5==0)&&(Sensor_6==0))
{
mpos=-4;
}
if((Sensor_1==0)&&(Sensor_2==0)&&(Sensor_3==0)&&(Sensor_4==1)&&(Sensor_5==1)&&(Sensor_6==0))
{
mpos=-4;
}
if((Sensor_1==0)&&(Sensor_2==0)&&(Sensor_3==0)&&(Sensor_4==1)&&(Sensor_5==1)&&(Sensor_6==1))
{
mpos=3;
}
if((Sensor_1==1)&&(Sensor_2==1)&&(Sensor_3==1)&&(Sensor_4==0)&&(Sensor_5==0)&&(Sensor_6==0))
{
mpos=-3;
}
// PID Equations

error=-mpos; // error = 0 - feedback , 0 is the center
error=error*2.2; // KP*ERROR , Kp=2.2
Rate = error-previous_error;
Deriv = Rate * 2.0; // KD = 2.0
previous_error=error;
error=error+Deriv; // PD Terms

// CUT Terms
// error is negative , robot is going to right
if (error < pwm_r =" plus"> 0){
pwm_r_+= ABS(error);
pwm_l_-=ABS(error);
}
if(pwm_r_>11)pwm_r_=11;
if(pwm_l_>11)pwm_l_=11;


}


Videos

Fast line follower
http://www.youtube.com/watch?v=g2_9nDmEmPo

Doing a task
http://www.youtube.com/watch?v=kiqopmLjFjE



Eng.Ahmed Saleh Mohammed
El Shorouk Acadmey
Electronics and communications engineering department

My Quotes

Ahmed Saleh's Quotes
Written by Ahmed Saleh

1. Electronics Engineering + Computer Science + Mathematics == A Computer scientist
2. Both Gates and Einestien created an evoultion In software and physics, Although they had belived trinity ..etc .
3. Love is a Power measured in the number of pulses of your heart when you see her eyes,its unit is Watt

4. Engineering is the science which i love, but my love to you is another science which adore - Ahmed Saleh

5.My love to you is like blood flowing in my body, if its ended  ÷would die . - Ahmed Saleh

6. If u wanna "Feel" the real love, then "Watch" two blind couples - Ahmed Saleh

7. Physics concern with how things work, chemistery concerns with how things are constructed, mathematics concern with why things actually work. - Ahmed Saleh

8.If you wanna be a very talent designed engineer, Don't put your hands in your poket and design from used materials.

The Start

This blog is mainly about Electronics engineering, and Software Engineering, Also it reflects few viewpoints in my life.