Forum Replies Created
-
AuthorPosts
-
SOUBHIK KUMAR DEYParticipant
WE HAVE TO BREAK THE RECEIVED SMS in variable s INTO CORRESPONDING DIGITS of 0 & 1 and STORE them in the array s[ ]. But I don’t know how to do so.
Can anyone please help me?
SOUBHIK KUMAR DEYParticipantThis is the at8ports.h HEADER FILE to define the Input and Output ports.
#include <avr/io.h>
#include <avr/inttypes.h>
#define DDRB_OUT(x) DDRB = DDRB | 0x01<<x
#define DDRB_IN(x) DDRB = DDRB & ~(0x01<<x)
#define DDRC_OUT(x) DDRC = DDRC | 0x01<<x
#define DDRC_IN(x) DDRC = DDRC & ~(0x01<<x)
#define DDRD_OUT(x) DDRD = DDRD | 0x01<<x
#define DDRD_IN(x) DDRD = DDRD & ~(0x01<<x)
#define PB_ON(x) PORTB = PORTB | 0x01<<x
#define PB_OFF(x) PORTB = PORTB & ~(0x01<<x)
#define PC_ON(x) PORTC = PORTC | 0x01<<x
#define PC_OFF(x) PORTC = PORTC & ~(0x01<<x)
#define PD_ON(x) PORTD = PORTD | 0x01<<x
#define PD_OFF(x) PORTD = PORTD & ~(0x01<<x)
uint8_t PB_IN(uint8_t pin)
{
if((PINB & (0x01<<pin))==0)
return 0;
else
return 1;
}
uint8_t PC_IN(uint8_t pin)
{
if((PINC & (0x01<<pin))==0)
return 0;
else
return 1;
}
uint8_t PD_IN(uint8_t pin)
{
if((PIND & (0x01<<pin))==0)
return 0;
else
return 1;
}
void init_pwm()
{
TCCR1A|=(1<<WGM10)|(1<<COM1A1)|(1<<COM1B1);
TCCR1B=0x04;
DDRB = DDRB | 0x06;
}
SOUBHIK KUMAR DEYParticipant/*SOMEHOW WE HAVE TO BREAK THE DIGITS RECEIVED BY SMS SO THAT EACH DIGIT GETS STORED AS AN ELEMENT OF ARRAY s[ ] AND WE CAN THEN MANIPULATE TO OUR WISH. THIS I AM NOT UNABLE TO DO SO. AS OF NOW LET’S ASSUME OUR INCOMING sms IS A 2-DIGIT NO. CONSISTING OG 1 & 0. THESE DIGITS ARE ASSUMED TO BE STORED IN ARRAY FORMAT IN s[ ] in exactly same order*/
SOUBHIK KUMAR DEYParticipantA program that I have written for the SMS ROBOT –
/* Header files */
#include<avr/io.h>
#include<avr/delay.h>
#include”at8ports.h”
int s[10]; /*GLOBAL VARIABLE to store INPUT in an array format*/
int sms; /*GLOBAL VARIABLE to receive incoming sms*/
/* Initialise input & output pins */
/*
PD0 is the sensor input pin
PB1 and PB2 are the motor speed control pins
PC0 to PC3 are the motor direction control pins
*/
void init_settings()
{
DDRD_IN(0); /* PD0 = Input */
DDRB_OUT(1); /* PB1 = Output */
DDRB_OUT(2); /* PB2 = Output */
DDRC_OUT(0); /* PC0 = Output */
DDRC_OUT(1); /* PC1 = Output */
DDRC_OUT(2); /* PC2 = Output */
DDRC_OUT(3); /* PC3 = Output */
}
/* Functions for different directions */
/* Direction is determined from PC0 to PC3 */
/*PB_ON(x) implies to turn ON PULL UP resistor of PBx i.e. set the Output of PBx as LOGIC 1*/
/*PB_OFF(x) implies to turn OFF PULL UP resistor of PBx i.e. set the Output of PBx as LOGIC 0*/
/*same concept applies to all other pins*/
void forward()
{
/* PB1 and PB2 will always be high */
PB_ON(1);
PB_ON(2);
/* PC0 to PC3 = 1010 */
/*This is the ideal forward condition i.e. Logic 1:Logic 0:Logic 1:Logic 0*/
PC_ON(0);
PC_OFF(1);
PC_ON(2);
PC_OFF(3);
}
void left()
{
/* PB1 and PB2 will always be high */
PB_ON(1);
PB_ON(2);
/* PC0 to PC3 = 0110 */
/* Left motor backward (so opposite LOGIC to FORWARD), Right motor forward*/
PC_OFF(0);
PC_ON(1);
PC_ON(2);
PC_OFF(3);
}
void right()
{
/* PB1 and PB2 will always be high */
PB_ON(1);
PB_ON(2);
/* PC0 to PC3 = 1001 */
/* Left motor forward, Right motor backward (so opposite LOGIC to FORWARD)*/
PC_ON(0);
PC_OFF(1);
PC_OFF(2);
PC_ON(3);
}
void backward()
{
/* PB1 and PB2 will always be high */
PB_ON(1);
PB_ON(2);
/* PC0 to PC3 = 0101 */
/*Both motors in Backward direction, exactly opposite to Forward*/
PC_OFF(0);
PC_ON(1);
PC_OFF(2);
PC_ON(3);
}
/* To take input from the sensors [PD0 to PD4] */
void sensors()
{
sms = PD_IN(0);
}
/*SOMEHOW WE HAVE TO BREAK THE DIGITS RECEIVED BY SMS SO THAT EACH DIGIT GETS STORED AS AN ELEMENT OF ARRAY s[ ] AND WE CAN THEN MANIPULATE TO OUR WISH. THIS I AM NOT UNABLE TO DO SO. AS OF NOW LET’S ASSUME OUR INCOMING sms IS A 2-DIGIT NO. CONSISTING OG 1 & 0. THESE DIGITS ARE ASSUMED TO BE STORED IN ARRAY FORMAT IN s[ ] in exactly same order*/
void main()
{
init_settings(); /* To initialise all input and output pins */
while(1) /* Infinite loop */
{
sensors(); /* To take sensor values and store them */
if(s[0] == 0 && s[1] == 1)
{A
left(); /* Take a left turn */
}
else if(s[0] == 1 && s[1] == 0) /* Rightmost sensor */
{
right(); /* Take a right turn */
}
else if(s[0] == 0 && s[1] == 0) /* No sensor on the line */
{
PB_OFF(1); /*Motors stopped
PB_OFF(2);
}
else /* Zero error condition [Move forward] */
{
forward(); /* Go straight ahead */
}
} /* End of while loop */
} /* End of the program */
SOUBHIK KUMAR DEYParticipantSOUBHIK KUMAR DEYParticipantL293D IC LAYOUT –
SOUBHIK KUMAR DEYParticipantI have connected PIN RxD (PD0) of Atmega 8 to TxD of SIM900 and PIN TxD (PD1) of Atmega 8 to RxD of SIM900. Pins PB and PC are OUTPUT PINS connected via switches to L293D IC.
SOUBHIK KUMAR DEYParticipantMy Atmega 8 DEVELOPMENT BOARD –
SOUBHIK KUMAR DEYParticipantI have connected PIN RxD (PD0) of Atmega 8 to TxD of SIM900 and PIN TxD (PD1) of Atmega 8 to
RxD of SIM900. Pins PB and PC are OUTPUT PINS connected via switches to L293D IC.
SOUBHIK KUMAR DEYParticipantMy Atmega 8 DEVELOPMENT BOARD –
SOUBHIK KUMAR DEYParticipantI have connected PIN RxD (PD0) of Atmega 8 to TxD of SIM900 and PIN TxD (PD1) of Atmega 8 to RxD of SIM900. Pins PB and PC are OUTPUT PINS connected via switches to L293D IC.
SOUBHIK KUMAR DEYParticipantSOUBHIK KUMAR DEYParticipantThanx Shashsank,Can u please provide me the code in C? And what ports should I use from Atmega 8?Thnx………SOUBHIK KUMAR DEYParticipantMy robot shall move according to the sms I send. It’s steering is based on Differential drive.
It has 4 motors (2 on each side parallely connected). The robot will perform the following
action based on sms sent. The SMS shall be a 2-digit no. consisting of only ‘0’ or ‘1’. The
1st digit controls left side motors & 2nd digit controls right sidemotors.
SMS ACTION
11 FORWARD (switches ON both side motors)
01 LEFT (switches OFF left motor OR rotates LEFT motor in OPPOSITE direction and RIGHT motor ON)
10 RIGHT (switches ON LEFT motor and RIGHT motor OFF OR rotates RIGHT motor in OPPOSITE direction )
00 STOP (switches OFF both side motors)
‘1’ should send a high signal and ‘0’ should send a low signal so that AVR Atmega 8 can prepare the
output according to HIGH/LOW signal and send it to L293D IC. Sending ‘0’ switches OFF
corresponding motor or makes it rotate in opposite direction, sending ‘1’ switches ON corresponding
motor to allow Differential Drive steering method. Also if it may be possible to send inputs of more digits,
each digit controlling a particular function like switching on robot lights etc.(in that case sending a 3-digit no.).
But I am not getting how to make SIM900 interpret my sms commands and make the Atmega8 or 16 perform the required action on I/O pins. Can you please give me the complete circuit
diagram and PCB diagram with the connections of SIM900, Atmega 8 and L293D IC and other components which I may need?Please Sir help me for this college project.
SOUBHIK KUMAR DEYParticipantMy robot shall move according to the sms I send. It’s steering is based on Differential drive.
It has 4 motors (2 on each side parallely connected). The robot will perform the following
action based on sms sent. The SMS shall be a 2-digit no. consisting of only ‘0’ or ‘1’. The
1st digit controls left side motors & 2nd digit controls right sidemotors.
SMS ACTION
11 FORWARD (switches ON both side motors)
01 LEFT (switches OFF left motor OR rotates LEFT motor in OPPOSITE direction and RIGHT motor ON)
10 RIGHT (switches ON LEFT motor and RIGHT motor OFF OR rotates RIGHT motor in OPPOSITE direction )
00 STOP (switches OFF both side motors)
‘1’ should send a high signal and ‘0’ should send a low signal so that AVR Atmega 8 can prepare the
output according to HIGH/LOW signal and send it to L293D IC. Sending ‘0’ switches OFF
corresponding motor or makes it rotate in opposite direction, sending ‘1’ switches on corresponding
motor to allow Differential Drive steering method. Also if it may be possible to send inputs of more digits,
each digit controlling a particular function like switching on robot lights etc.(in that case sending a 3-digit no.).
But I am not getting how to make SIM900 interpret my sms commands and make the Atmega8 or 16 perform the required action on I/O pins. Can you please give me the complete circuit
diagram and PCB diagram with the connections of SIM900, Atmega 8 and L293D IC and other components which I may need?Please Sir help me for this college project.
-
AuthorPosts