Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: MSMQ: Problem with qInfo->PathName setting Pin
Adam Roderick J22-Dec-09 21:42
Adam Roderick J22-Dec-09 21:42 
GeneralRe: MSMQ: Problem with qInfo->PathName setting Pin
PankajB22-Dec-09 22:08
PankajB22-Dec-09 22:08 
GeneralRe: MSMQ: Problem with qInfo->PathName setting Pin
Adam Roderick J22-Dec-09 22:12
Adam Roderick J22-Dec-09 22:12 
GeneralRe: MSMQ: Problem with qInfo->PathName setting Pin
PankajB22-Dec-09 22:23
PankajB22-Dec-09 22:23 
GeneralRe: MSMQ: Problem with qInfo->PathName setting Pin
Adam Roderick J22-Dec-09 23:25
Adam Roderick J22-Dec-09 23:25 
GeneralRe: MSMQ: Problem with qInfo->PathName setting Pin
PankajB23-Dec-09 0:08
PankajB23-Dec-09 0:08 
GeneralRe: MSMQ: Problem with qInfo->PathName setting [modified] Pin
Adam Roderick J23-Dec-09 1:34
Adam Roderick J23-Dec-09 1:34 
QuestionDetect Acceleration and Retrieve Cell ID [modified] Pin
0705646H22-Dec-09 19:46
0705646H22-Dec-09 19:46 
Hi all,

I am new to the C Programming. Currently, I am using the 3-axis accelerometer MMA7260QT, P18F2620 and GSM Module iWOW TR 900 for my project.

MMA7260QT
MMA7260QT is the accelerometer that detect the 3-axis: X, Y and Z-axis.

P18F2620
P18F2620 is used to detect the acceleration signal sent by MMA7260QT in 3-axis. Once there is a vibration, it will automatically retrieve the Cell-ID. Then, it will convert the Cell-ID into the decimal form and send out to GSM Module iWOW TR900.

iWOW TR 900
iWOW TR 900 is to get whatever info from P18F2620 and send out using GSM.


The objective of my project is to detect the acceleration in 3 axis.
Once there is the vibration, it will send the signal to the P18F2620. P18F2620 will then automatically retrieve the Cell ID, convert it into the decimal form, eg. 15322-32 to be send out via SMS.

I have write the simple C code to send the fixed Cell ID. I have tested my program. It is able to send the fixed Cell ID out. However, there is something wrong with my codes. Firstly, it is still unable to detect the acceleration. Secondly, I still unable to write the code to get the Cell ID automatically. The iWOW module is only recognised AT command.

I am using the AT+CREG=2 and AT+CREG? in order to get the Cell ID. The reply on the hyper terminal is like this.

AT+CREG=2
OK
AT+CREG?
+CREG: 2,1,"0020","DB27"

I will need to store the 0020 and DB20 (Hex form) and convert it into decimal form 56103-32 to be sent out using the GSM module. All these have to be done using C program.

Here is my code snippet. Please correct me if anything I wrote wrongly in my code. Thanks Smile | :)

#include <P18f2620.h>
#include <delays.h>
#include <adc.h>

#define PWON PORTCbits.RC0 
#define RESET PORTCbits.RC1 

void InterruptHandlerHigh(void);
void adc_accelerometer(void);

char MESS[12] = {"AT+CREG=2\r\n"}; //Detect CellID
char MESS1[11] = {"AT+CREG?\r\n"}; //Detect CellID
char MESS2[12] = {"AT+CMGF=1\r\n"}; // Set the SMS form in text mode
char MESS3[22] = {"AT+CMGS=+6512345678\r\n"}; // Set the mobile phone to send SMS
char MESS4[21] = {"CellID | 15831-32\n\x1A"}; //Example of sending CellID
         
                                                                  
unsigned char a,b,i,j,k,l,m,x;
int X,Y,Z,X1,Y1,Z1;


#pragma code InterruptVectorHigh = 0x08
void InterruptVectorHigh(void){
_asm
goto InterruptHandlerHigh			//jump to interrupt routine
_endasm
}
#pragma code

#pragma interrupt InterruptHandlerHigh
void InterruptHandlerHigh()
{
	if(INTCON3bits.INT1IF==1)
	{	
					if((X1+15<X<X1-15) | (Y1+15<Y<Y1-15) | (Z1+15<Z<Z1-15))
					{
					Delay10KTCYx(200);
					i=0, j=0, k=0, l=0, m=0;
			
					while (MESS[i])
					{				
						while(!TXSTAbits.TRMT);
						TXREG=MESS[i];
						i++;
					}

					Delay10KTCYx(200);
					while (MESS1[j])
					{
						while(!TXSTAbits.TRMT);
						TXREG=MESS1[j];
						j++;
					}
			
					Delay10KTCYx(200);
					while (MESS2[k])
					{
						while(!TXSTAbits.TRMT);
						TXREG=MESS2[k];
						k++;
					}
			
						Delay10KTCYx(200);
						while (MESS3[l])
					{
						while(!TXSTAbits.TRMT);
						TXREG=MESS3[l];
						l++;
					}
				
					Delay10KTCYx(200);
					while (MESS4[m])
					{
						while(!TXSTAbits.TRMT);
						TXREG=MESS4[m];
						m++;
					}
		}
}
}


void main(void)
{
	PWON = 1;
	RESET = 1;
	INTCONbits.GIEH = 0;			// disable global and enable external interrupt 0
	ADCON0=0b00000001;
	ADCON1 = 0b00001100;			// AN0,AN1,AN2 channel and internal voltage referencing
	ADCON2 = 0b10000100;			// right justified, manual acquistion time
	TRISA = 0b00000111;
	TRISC = 0b10111100;				// RC7(RX) as input & RC6(TX) as output 
	SPBRG = 10;						// baud rate = 115200
	TXSTA = 0b00100100;				// asynchronous mode, 8-bit data
									// transmit enable, high baud rate select bit
	RCSTA = 0b10010000;				// serial port enable, 8-bit data
									// continuous reception
	RCONbits.IPEN =1;				// IPEN
	INTCON3bits.INT1IP;				// IP = High
	INTCON2bits.INTEDG2=1;			// EDGE: raising
	INTCON3bits.INT1IF=0;			// clear IF
	INTCON3bits.INT1IE=1;			// enable IE
	INTCONbits.GIE = 1;				// enable Global Interrupt


				for(x=0;x<1;x++)
				{
					Delay10KTCYx(200);
					i=0, j=0, k=0, l=0, m=0;
			
					while (MESS[i])
					{				
						while(!TXSTAbits.TRMT);
						TXREG=MESS[i];
						i++;
					}

					Delay10KTCYx(200);
					while (MESS1[j])
					{
						while(!TXSTAbits.TRMT);
						TXREG=MESS1[j];
						j++;
					}
			
					Delay10KTCYx(200);
					while (MESS2[k])
					{
						while(!TXSTAbits.TRMT);
						TXREG=MESS2[k];
						k++;
					}
			
						Delay10KTCYx(200);
						while (MESS3[l])
					{
						while(!TXSTAbits.TRMT);
						TXREG=MESS3[l];
						l++;
					}
				
					Delay10KTCYx(200);
					while (MESS4[m])
					{
						while(!TXSTAbits.TRMT);
						TXREG=MESS4[m];
						m++;
					}
				}
	
	while(1)
	{
		PORTA=~PORTA;
		for(i=0;i<5;i++)
		Delay10KTCYx(100);
		
		
		Delay10TCYx( 5 ); // Delay for 50TCY
		ADCON0bits.GO=1; // Start conversion
		while(ADCON0bits.DONE); // Wait for completion
		X1 = ADRESH*256+ADRESL;  // Read result
		ADCON0bits.ADON=0; // Disable A/D converter
		
		 
		ADCON0=0b00000101;
		Delay10TCYx( 5 ); // Delay for 50TCY
		ADCON0bits.GO=1; // Start conversion
		while(ADCON0bits.DONE); // Wait for completion
		Y1 = ADRESH*256+ADRESL;  // Read result
		ADCON0bits.ADON=0; // Disable A/D converter
		
		
		ADCON0=0b00001001;
		Delay10TCYx( 5 ); // Delay for 50TCY
		ADCON0bits.GO=1;// Start conversion
		while(ADCON0bits.DONE); // Wait for completion
		Z1 = ADRESH*256+ADRESL; // Read result
		ADCON0bits.ADON=0; // Disable A/D converter 
		
		
	}
	
}

void adc_accelerometer(void)
{
	
		Delay10TCYx( 5 ); // Delay for 50TCY
		ADCON0bits.GO=1; // Start conversion
		while(ADCON0bits.DONE); // Wait for completion
		X = ADRESH*256+ADRESL;  // Read result
		ADCON0bits.ADON=0; // Disable A/D converter
		
		 
		ADCON0=0b00000101;
		Delay10TCYx( 5 ); // Delay for 50TCY
		ADCON0bits.GO=1; // Start conversion
		while(ADCON0bits.DONE); // Wait for completion
		Y = ADRESH*256+ADRESL;  // Read result
		ADCON0bits.ADON=0; // Disable A/D converter
		
		
		ADCON0=0b00001001;
		Delay10TCYx( 5 ); // Delay for 50TCY
		ADCON0bits.GO=1;// Start conversion
		while(ADCON0bits.DONE); // Wait for completion
		Z = ADRESH*256+ADRESL; // Read result
		ADCON0bits.ADON=0; // Disable A/D converter 
}


modified on Wednesday, December 23, 2009 6:39 AM

AnswerRe: Detect Acceleration and Retrieve Cell ID Pin
Nelek22-Dec-09 21:07
protectorNelek22-Dec-09 21:07 
GeneralRe: Detect Acceleration and Retrieve Cell ID Pin
0705646H22-Dec-09 21:37
0705646H22-Dec-09 21:37 
GeneralRe: Detect Acceleration and Retrieve Cell ID Pin
Cedric Moonen22-Dec-09 21:54
Cedric Moonen22-Dec-09 21:54 
GeneralRe: Detect Acceleration and Retrieve Cell ID Pin
0705646H23-Dec-09 0:02
0705646H23-Dec-09 0:02 
GeneralRe: Detect Acceleration and Retrieve Cell ID Pin
Nelek22-Dec-09 22:16
protectorNelek22-Dec-09 22:16 
GeneralRe: Detect Acceleration and Retrieve Cell ID Pin
0705646H22-Dec-09 22:23
0705646H22-Dec-09 22:23 
GeneralRe: Detect Acceleration and Retrieve Cell ID [modified] Pin
Nelek23-Dec-09 0:07
protectorNelek23-Dec-09 0:07 
AnswerRe: Detect Acceleration and Retrieve Cell ID Pin
Nelek23-Dec-09 0:26
protectorNelek23-Dec-09 0:26 
GeneralRe: Detect Acceleration and Retrieve Cell ID Pin
0705646H23-Dec-09 0:53
0705646H23-Dec-09 0:53 
GeneralRe: Detect Acceleration and Retrieve Cell ID Pin
Nelek23-Dec-09 1:42
protectorNelek23-Dec-09 1:42 
GeneralRe: Detect Acceleration and Retrieve Cell ID Pin
0705646H27-Dec-09 15:18
0705646H27-Dec-09 15:18 
GeneralRe: Detect Acceleration and Retrieve Cell ID Pin
Nelek27-Dec-09 22:39
protectorNelek27-Dec-09 22:39 
QuestionHow to send keyboard event to other program ? Pin
wangningyu22-Dec-09 18:53
wangningyu22-Dec-09 18:53 
AnswerRe: How to send keyboard event to other program ? Pin
Rajesh R Subramanian22-Dec-09 18:57
professionalRajesh R Subramanian22-Dec-09 18:57 
AnswerRe: How to send keyboard event to other program ? Pin
KingsGambit22-Dec-09 19:16
KingsGambit22-Dec-09 19:16 
GeneralRe: How to send keyboard event to other program ? Pin
wangningyu22-Dec-09 19:21
wangningyu22-Dec-09 19:21 
GeneralRe: How to send keyboard event to other program ? Pin
Rajesh R Subramanian22-Dec-09 19:23
professionalRajesh R Subramanian22-Dec-09 19:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.