Friday, October 25, 2013

Counting Sort Uva Example

For counting sort we assume that the numbers are in the range [0,k]. We set up a counter array which counts how many duplicates inside the input , and then reorder the output accordingly without any comparison at all.
Complexity O(n+k).

UVA problem:Age Sorting

Solution:

#include<iostream>
#include<stdio.h>

using namespace std;

int main(){

unsigned long long N,i,printnum;
int age,np[102];
while((scanf("%llu",&N))&&N){
    for(i=0;i<=100;i++){
        np[i]=0;
    }
    for(i=0;i<N;i++){
        cin>>age;
        np[age]++;
    }
    printnum=0;
    for(i=0;i<=100;i++){
    if(np[i]>0){
        for(int j=1;j<=np[i];j++){
            printf("%llu",i);
            printnum++;
            if(printnum<N) printf(" ");
        }

    }
    }
    printf("\n");

}
return 0;
}

Saturday, July 27, 2013

Robot Actuators



 An actuator is a mechanism for activating process control equipment by use of pneumatic, hydraulic, or electronic signals. There are several types of actuators in robotic arms.


Types:
A hydraulic actuator consist of a cylinder or fluid motor that uses hydraulic power to facilitate mechanical operation. The mechanical motion gives an output in terms of linear, rotary or oscillatory motion. Because liquid cannot be compressed, a hydraulic actuator can exert considerable force, but is limited in acceleration and speed.
A pneumatic actuator converts energy formed by compressed air at high pressure into either linear or rotary motion. Pneumatic energy is desirable for main engine controls because it can quickly respond in starting and stopping as the power source does not need to be stored in reserve for operation.
An electric actuator is powered by motor that converts electrical energy to mechanical torque. The electrical energy is used to actuate equipment such as multi-turn valves. It one of the cleanest and most readily available forms of actuator because it does not involve oil.
A mechanical actuator functions by converting rotary motion into linear motion to execute movement. It involves gears, rails, pulleys, chains and other devices to operate.

Examples of Rotating Actuators : 

1. DC Motor
2.DC geared motor
3.Servo motor
4.Stepper Motor
5.BLDC motor
6. AC Servo Motors



Examples of Linear Actuators :

1. Solenoid
2. Linear Servo Motors
3.Linear Stepper Motors








You can convert linear motion into rotating motion or rotation motion into linear motion in many different ways.








Criteria for RUET ROBO RUN

Task : 
Each team has to build one autonomous bot which is able to go following the line
given in the arena.



Bot specification:
The bot must fit within 25cm * 25cm square. The power supply must be
dc(<=24V) installed in the bot. The bot must not do any harm to the arena or any
human being.



Arena Speciation:
As  specified in the figure (Black line on white background) .Run will start in the
start position and will end in end position as specified. In the path there are some
check points.



Rules for selecting winner:
Winner will be selected according to point earned. Earning the higher point will
get a higher rank. In the final round speed will be considered.
 




Fig1: Full Arena (Red mark text will not be present in original arena)









Fig2: Specification of dimensions of the arena 

Rules for points:
1.  Crossing every check point will be awarded with 3 points.
2.  Stopping at the end point will be awarded with 3 points.
3.  If the bot go outside the arena or stop or any other inconvenience occurs it
must take a restart.
4.  A team can take at most 5 restarts.
5.  A penalty of 1 point will be deducted from the score for every restart.
6.  While restarting the bot will be placed in the last check point it passed.
7.  Before restarting a team cannot do any major hardware change or any kind
of software change.


Rules for game play:
1.  One bot at a time will run in the arena.
2.  A team will have total 10 minutes to complete its run.
3.  Two rounds will be played among all team.
4.  A final round will be played between first, second and third according to
total point earned in the first two rounds.
5.  A team will be fully responsible for the safety of their bot.
6.  Judges have all the rights to take decision during the game play.

Rules for disqualification:
1.  A team will be disqualified if the bot does not fulfill the bot specification
criteria.
2.  A team will be disqualified if any attempt of cheating is made.
3. A team will be disqualified if any unfair behavior is seen.

Choice of Battery for Line Follower Robots

As normally line follower robot is small in size and need to accelerate quickly the choice of battery is very important . The size of the battery need to be small and the weight need to be very low. The power storage of the battery needs to be high.

Rechargable Battery :

 As the bot needs to run again and again choosing a rechargeable battery will be sensible. Two types of rechargeable battery can be used.

1. Lithium-ion battery
Mobile phone battery can be used. One mobile phone battery gives 3.7 v. Connecting them is series gives higher voltage and connecting them in paraller gives higher backup. The energy capacity is rated in mAh rating . Higher the mAh rating higher is the storage capacity and higher is the backup.


2.Lithium polymer battery:
Lithium-ion polymer batteries, polymer lithium ion or more commonly lithium polymer batteries (abbreviated Li-poly, Li-Pol, LiPo, LIP, PLI or LiP) are rechargeable (secondary cell) batteries. LiPo batteries are usually composed of several identical secondary cells in parallel to increase the discharge current capability, and are often available in series "packs" to increase the total available voltage.
Before using them just learn the safety precaution. They explode in high temperature. They need to be charged using controlled charger.
 



Non Rechargeable Battery :
If some one wishes to use non rechargeable battery then 9v Duracell batteries can be used.



My experience:

I used mobile phone batteries in series in my robot. They gave good backup, low weight and seize make it convenient and also good life time.

 

Application of Capacitor



Energy storage
A  capacitor  can  store  electric  energy  when  disconnected  from  its  charging  circuit,  so  it  can  be  used  like  a  temporary battery.
Pulsed power and weapons
Groups of large, specially constructed, low-pulses of current for many pulsed power applications. These include lasers (especially TEA lasers), pulse forming networksLarge  capacitor  banks(Reservoir)  are  used  as  energy  sources  for  the detonators in nuclear weapons and other specialty weapons. Experimental work is under way using banks of capacitors as power sources for electromagnetic armor and electromagnetic
Power conditioning
Reservoir capacitors are used in power suppliesalso be used in charge pump circuits as the energy  storage element in the generation of higher voltages than the input voltage (such as stun gun). Capacitors are connected in parallel with the power circuits of most electronic devices and larger  systems  (such  as  factories)  to  shunt  away  and  conceal  current  fluctuations  from  the  primary  power  source  to pacitor  can  store  electric  energy  when  disconnected  from  its  charging  circuit,  so  it  can  be  used  like  a  temporary . Capacitors are commonly used in electronic devices to maintain power supply while batteries are being changed.
Power factor correction
In electric power distribution, capacitors are used for power factor correction.
Signal coupling
Because capacitors pass AC but block DC signals (when charged up to the applied dc voltage), they are often used to separate the AC and DC components of a signal. This method is known as AC coupling or "capacitive coupling".
Decoupling
A decoupling capacitor is a capacitor used to decouple one part of a circuit from another. Noise caused by other circuit elements is shunted through the capacitor, reducing the effect they have on the rest of the circuit. It is most commonly used between the power supply and ground. An alternative name is bypass capacitor as it is used to bypass the power supply or other high impedance component of a circuit.
Noise filters and snubbers
When an inductive circuit is opened, the current through the inductance collapses quickly, creating a large voltage across the open circuit of the switch or relay.  If the inductance is large enough, the energy will generate a spark, causing the contact points to oxidize, deteriorate, or sometimes weld together, or destroying a solid-state switch. A snubber capacitor across the newly opened circuit creates a path for this impulse to bypass the contact points, thereby preserving their life; these were commonly found in contact breaker ignition systems, for instance. Similarly, in smaller scale circuits, the spark may  not  be  enough  to damage  the  switch  but  will still radiate  undesirable  radio  frequency  interference  (RFI),  which a filter capacitor absorbs. Snubber capacitors are usually employed with a low-value resistor in series, to dissipate energy and minimize RFI. Such resistor-capacitor combinations are available in a single package.
Motor starters
In single phase squirrel cage motors, the primary winding within the motor housing isn't capable of starting a rotational motion on the rotor, but is capable of sustaining one. To start the motor, a secondary winding is used in series with a non-polarized starting capacitor to introduce a lag in the sinusoidal current through the starting winding. When the secondary winding is placed at an angle with respect to the primary winding, a rotating electric field is created. The force of the rotational field is not constant, but is sufficient to start the rotor spinning.
Signal processing
The energy stored in a capacitor can be used to represent information, either in binary form, as in DRAMs, or in analogue form, as in analog sampled filters and CCDs. Capacitors can be used in analog circuits as components of integrators or more complex filters and in negative feedback loop stabilization. Signal processing circuits also use capacitors to integrate a current signal.
Sensing
Most capacitors are designed to maintain a fixed physical structure. However, various factors can change the structure of the capacitor; the resulting change in capacitance can be used to sense those factors.
Changing the dielectric:
The effects of varying the physical and/or electrical characteristics of the dielectric can also be of use. Capacitors with an exposed and porous dielectric can be used to measure humidity in air. Capacitors are used to accurately measure the fuel level in airplanes; as the fuel covers more of a pair of plates, the circuit capacitance increases.
Changing the distance between the plates:
Capacitors with a flexible plate can be used to measure strain or pressure. Industrial pressure transmitters used for process control use pressure-sensing diagphragms, which form a capacitor plate of an oscillator circuit. Capacitors are used as the sensor in condenser microphones, where one plate is moved by air pressure, relative to the fixed position of the other plate. Some accelerometers use MEMS capacitors etched on a chip to measure the magnitude and direction of the acceleration vector. They are used to detect changes in acceleration, eg. as tilt sensors or to detect free fall, as sensors triggering airbag deployment, and in many other applications. Some fingerprint sensors use capacitors. Additionally, a user can adjust the pitch of a theremin musical instrument by moving his hand since this changes the effective capacitance between the user's hand and the antenna.
Changing the effective area of the plates:
Capacitive touch switches are now used on many consumer electronic products.

Tuesday, July 9, 2013

Choice of Motor for line follower

There ate many different types of motor that can be used in a line follower robot. Choice of motor also depends on application. To chose a motor you have to look for important features . such as:
1.RPM
2.Torque
3.Voltage
4.Size
5.Weight
6.Power consumed
etc.

After looking for these features u have to chose a motor that matches your application.



         I shall recommend here some kind motors for student of Bangladesh considering availability and price. For a small size line follower u can use DC GEARED motor like the photo of rpm nearly about 200.
U can aslo use servo motor(sg5010) after modifying it for continuous rotation. (Price a bit higher)
Do not use motor that looks like following photo or motor with no gear head. It does not give good response (From experience):


Tuesday, July 2, 2013

Photos of Some Line Follower

These line follower participated in the global robotics challenge Bangladesh round 2013.
















AVR Project Ideas

Here I will share some simple project ideas that come into my head. No complicated and high standard project are to be shared I think.

1. Digital Room Lock
    A simple digital room can be made using your existing room lock. Place a LCD and keyboard outside the door and the circuit with micro controller and stepper motor inside the door. When it is requested from outside to open the door via keyboard the micro controller makes the stepper motor rotate and hence by some mechanical arrangement the door lock is opened. obviously the system will be password protected.

2. coming soon

Saturday, June 29, 2013

Simplified AVR USBasp Circuit Diagram

The circuit Mr. Fischl designed for avr usb asp cotains several jumpers. We can skip those if we do not want to use some features. So here comes the simplified circuit which works very well without any problem. Also the connections that goes to the target MCU is indicated. (Collected)



 
This is the same circuit with original pin configuration of atmega8 .







The farmware ,driver and details will be found in the following link



Friday, June 28, 2013

Dot matrix display

8*16 dot matix display using atmega8 and 74hc595


Proteus Design:


CODE:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/pgmspace.h>

const char dotmatrix[27][8] PROGMEM=
{

{
0b11000110,
0b11000110,
0b11111110,
0b11111110,          //A
0b10000010,
0b10000010,
0b01111100,
0b00111000,
},
{
0b11111110,
0b10000001,
0b10000001,
0b10000110,
0b11111110,            //B
0b10000001,
0b10000001,
0b11111110,
},
{
0b01111110,
0b10000001,
0b10000000,
0b10000000,            //C
0b10000000,
0b10000011,
0b10000001,
0b01111110,
},
{
0b11111000,
0b11000100,
0b11000110,
0b11000110,
0b11000110,              //D
0b11000110,
0b11000100,
0b11111000,
},
{
0b11111110,
0b11000000,
0b11000000,
0b11111000,            //E
0b11111000,
0b11000000,
0b11000000,
0b11111110,
},
{
0b10000000,
0b10000000,
0b10000000,
0b10000000,
0b11111000,                //F
0b10000000,
0b10000000,
0b11111111,
},
{
0b01111110,
0b10000010,
0b10001110,
0b10000000,                //G
0b10000000,
0b10000000,
0b10000001,
0b01111110,
},
{
0b10000001,
0b10000001,
0b10000001,
0b10000001,                //H
0b11111111,
0b10000001,
0b10000001,
0b10000001,
},
{
0b01111100,
0b00010000,
0b00010000,
0b00010000,                //I
0b00010000,
0b00010000,
0b00010000,
0b01111100,
},
{
0b00001100,
0b00010010,
0b00010010,
0b00010000,                //J
0b00010000,
0b00010000,
0b00010000,
0b01111110,
},
{
0b10001100,
0b10010000,
0b10100000,
0b11000000,                //K
0b11000000,
0b10100000,
0b10010000,
0b10001100,
},
{
0b11111110,
0b10000000,
0b10000000,                //L
0b10000000,
0b10000000,
0b10000000,
0b10000000,
0b10000000,
},
{
0b01000010,
0b01000010,
0b01000010,
0b01000010,
0b01000010,                //M
0b01011010,
0b01100110,
0b01000010,
},
{
0b10000001,
0b10000011,
0b10000101,
0b10001001,
0b10010001,                //N
0b10100001,
0b11000001,
0b10000001,
},
{
0b00111100,
0b01000010,
0b10000001,
0b10000001,                //O
0b10000001,
0b10000001,
0b01000010,
0b00111100,
},
{
0b10000000,
0b10000000,
0b10000000,
0b10000000,                //P
0b11111110,
0b10000001,
0b10000001,
0b11111110,
},
{
0b00000011,
0b10000100,
0b01111110,
0b10001001,            //Q
0b10010001,
0b10000001,
0b10000001,
0b01111110,
},
{
0b10000110,
0b10001000,
0b10010000,
0b10100000,
0b11111110,            //R
0b10000001,
0b10000001,
0b11111110,
},
{
0b01111100,
0b10000010,
0b00000010,
0b01111100,                //S
0b10000000,
0b10000000,
0b01000010,
0b00111100,
},
{
0b00010000,
0b00010000,
0b00010000,
0b00010000,                //T
0b00010000,
0b00010000,
0b00010000,
0b11111110,
},
{
0b00111100,
0b01000010,
0b10000001,
0b10000001,                //U
0b10000001,
0b10000001,
0b10000001,
0b10000001,
},
{
0b00011000,
0b00100100,
0b01000010,
0b01000010,                //v
0b10000001,
0b10000001,
0b10000001,
0b10000001,
},
{
0b11000011,
0b11000011,
0b10100101,
0b10011001,                //W
0b10000001,
0b10000001,
0b10000001,
0b10000001,
},
{
0b10000001,
0b10000001,
0b01000010,
0b00100100,            //X
0b00011000,
0b00100100,
0b01000010,
0b10000001,
},
{
0b00011000,
0b00011000,
0b00011000,
0b00011000,            //Y
0b00100100,
0b01000010,
0b10000001,
0b10000001,
},
{
0b11111111,
0b11000000,
0b01100000,
0b00110000,                //Z
0b00011000,
0b00001100,
0b00000110,
0b11111111,
},
{
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
},

};

int main(void){


DDRD=0xFF;
DDRC=0xFF;
PORTD=0xFF;
PORTC=0x00;
int k,j,l,q,i,s,t=1,sp=5,in,dec,array[]={18,0,4,4,3,26,26,26};
char A;
unsigned long   aaa,x;


while(1){t=1;
    for(s=0;s<=4;s++){
       for(q=7;q>=0;q--){
          if(t){q=32;t=0;}
          for(j=0;j<sp;j++){            //defines speed
            for(k=0;k<=7;k++){


            aaa=0x00;
            A=pgm_read_byte(&(dotmatrix[array[s]][k]));
            aaa=aaa|A;
            aaa=aaa<<8;
            A=pgm_read_byte(&(dotmatrix[array[s+1]][k]));
            aaa=aaa|A;
            aaa=aaa<<8;
            A=pgm_read_byte(&(dotmatrix[array[s+2]][k]));
            aaa=aaa|A;
            aaa=aaa<<8;
            A=pgm_read_byte(&(dotmatrix[array[s+3]][k]));
            aaa=aaa|A;


            aaa=(aaa>>q);




                    for(i=31;i>=0;i--){
                        PORTD=0b11111111;
                        PORTC=0b00000000;
                        x=aaa&(1<<i);
                        if(x)
                        PORTC=0b00000011;
                        //_delay_ms(1);}
                        else
                        PORTC=0b00000010;
                        //_delay_ms(1);}
                    }

                    PORTC=0b00000100;

                    PORTD=0b11111111^(1<<(k));

                    if(t==1)
                    _delay_ms(0.1);
                    else
                    _delay_ms(0.2);



                }
            }



        }
    }
}




return 0;
}


Tuesday, June 25, 2013

Bangladeshi Stores for Elcetonics and Robotics Spare Parts

Stores where u can find electronics and robotics parts at cheap rate by ordering by mobilephone.

1.Speedytron Electronics

Facebook Page: Speedytron Electronics
Mirpur, Dhaka.
Email: speedytron@asia.com



2.Telecom Spares
Facebook Page:Telecom Spares
Patuatuli,Puran Dhaka
Email: ahsan4141@yahoo.com



3.New Mitsu Electronics
Vasani Stadium, Dhaka
Cell:01710-846477



Bangladesh Online Stores (Rate is higher).

1. Techshop.com
2. store.roboticsbd.com
3.Facebool Page: hobbyshopbd (cheaper rate)
4.www.smrtechbd.com

Friday, June 21, 2013

How to make a line follower robot

Here u will find some information but no details is given. For details just google. U will find may sites and blogs with details.


What is line follower Robot?

A line follower robot is a robot that runs following a line in an arena and may be do some other staffs . 



What do I need to make one?

You will need five things.
1. A circuit which includes a micro controller (brain of the bot).
2.Motors to run the bot.
3.Sensors to follow the line.
4.A Chassis to make a structure.
5.Battery as power supply.

How can I make the circuit?

You can create the circuit from the schematic you designed by using vero board and soldering or u can design a PCB  then print it and then solder. For designing PCB u can use Preteus or Eagle Cad.

What about the Microcontroller?

I use atmega32. It has 8 ADC channel which can be used. It has enough memory and pins  and easy to use. C language can be used to program it.


What kind of motor do I use?

U can use small DC geared motor. U can use L293d as motor driver IC. Speed control can be done by PWM. But the problem of u this type of motor is u can  not stop the bot suddenly due to inertia and accurate speed control is possible only is a limited range.
U can also use stepper motor. They will give very accurate movement. U can add external gear for higher torque. But beginner may find them difficult in handling . I found the awesome.
U can also use modified servo motor for continuous rotation. They are then variable speed geared dc motor. They very easy to control by PWM also no driver IC is not needed. May be very handy for beginners but a little bit costly.

How do I make sensors?

Reflection of LED light is higher in white surface and lower in black surface. This phenomena is used to identify the position of the bot in the arena. Both LDR and photo diode give higher resistance if incident light is lower and lower Resistance if incident light is higher. This feature is used to make sensors.For making sensors u can use LDR and LED pair . But for black and white surface IR emitter and IR photo diode will be the best. In the circuit u can use voltage divider arrangement take input using microcontroller adc pin. For faster response Comparator arrangement with opamp is good. A pot must be kept for calibrating in comparator.

How do I make Chassis?

Chassis can be made in many different ways. Make sure that weight is as low as possible and the body is rigid enough. For that u can use plastic board.

What will be the arrangement of wheel?

The easiest arrangement is two wheel with two motors in the backside and one free moving wheel in the front side. This will allow you differential movement. Just google "differential movement". You can collect wheels from old toy or can buy a new toy and take the wheels from there. For the free moving wheel u can use ball caster or can use rubber ball caster.



Which battery do I use?

You can use rechargeable Lippo battery. You can also use rechargeable Li-ion battery. Two or three mobile phone battery in series is a good choice but a bit expensive. Battery with higher Ah rating will give  more backup.

What will be the algorithm?

 Simply saying when the bot is drifting off the line to the left then turn right a little bit and vice versa. Many adjustment and modification is needed for faster and smooth run. Many different algorithm can be used. Just google and learn. PID is a famous one for a continuous and smooth line.


Some special tips:
1. Keep the weight as low as possible for lower moment of inertia.

2. Use some kind of shield for the sensors to keep it out of external light.

3. Use at least three sensor on each side of the line and another one a bit in distance on each side  for crossing checking that means total of eight sensors.

4.Use rechargeable batteries with enough backup capability.


Some links: (U will find plenty of them in internet )

Photos of some line follower

Bangladeshi Stores for Elcetonics and Robotics Spare Parts 

Choice of Motor for line follower

http://futuredreamersrobotics.blogspot.com/2013/02/making-line-follower-robot.html

http://futuredreamersrobotics.blogspot.com/2013/01/making-light-sensor.html

http://extremeelectronics.co.in/robotics/making-a-line-sensor-using-ir-receiver/

http://extremeelectronics.co.in/avr-tutorials/line-following-robot-using-avr-atmega8/







Thursday, February 21, 2013

A Mobile Phone Controlled Robot

This is a robot which is able to pick an object carry it and drop it. It is remotely operated by cell phone. The idea of DTMF tone decoder is used here.

Saturday, February 16, 2013

A Line Follower Robot
















This is a line follower robot which follows a white line on a green background. We used LDR as sensor. ATMEGA 32 microcontroller as its brain. When it gets a black mark on the side of its path it takes the next turn on that side. The robot was prepare for GRC13 Bangladesh round.