Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need some help in coding 16f877

Status
Not open for further replies.

sultan.al3lama

Junior Member level 1
Junior Member level 1
Joined
Mar 7, 2011
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,427
hi
i have a project to build a car that can move autonomously and it send its location to the base station through the XBEE to draw its path
could anyone help me in the codes that may help me or the way to build such system
regards,
 

in CCS there is easy steps in commands to send data via XBEE. You provide more details about your project & hardware. For what level you have promoting this project. In Studebts level? or???? Tell us what are the ideas you have collected for this project. if you have a circuit diagram proveide here... It may use all to help you...
 
hi
i will use gps and the model i will use is in the link
50 Channel GS407 Helical GPS Receiver - SparkFun Electronics
i need the code that will read the gps data and send them to the base station via XBEE
also, i need to know how to draw the path of the car depending on the gps reading that are coming from the car
i know that the gps is used the rs232 while the XBEE is also using rs232
in 16f877 i only have one rs232
how can solve this problem??
if you can help me please do
regards,
 

in xbee or pic there is no rs232. It contain only usart. In xbee, it is 3.3v standard. And in pic it is ttl. So you need to convert between these voltages. You may please send the currect ideas i'll send the code for you, my friend
 
hi sir,
thank you very much
i have to use the gps to send the position to the base station to draw the path that the robot is following
so i need to monitor it throw the gps reading
i use this gps
50 Channel GS407 Helical GPS Receiver - SparkFun Electronics
and i want to implement the code to get the position and then another code in VB to draw the path in the map such as google map or google earth
could you please help me??
regards,
 

gps modules are generaly using NMEA standards. The word GPGGA or GPRMC or GPGLL contain the position information. You just need to extract this from those sentences.
I need the explemations
1 . Microcontroller programming language (asm/c)
2. Are you using google map or VB
3. How the mobile device ( i mean the car) send data to pc , gsm, zigbee. etc ...
 
PIC16 have 1 UART module only. Your requirement extract GPS Receiver data, then send it using RF (zigbee or any other module). You can use PIC RX connect to GPS and PIC TX connect to RF. If you can get the idea, then see this video or coding (in C using Hi-Tech compiler)
1. Extract GPS data
2. Send and receive UART
 
hi sir,
thanks for your information
i use the CCS (C language)
i will embed the google earth in the VB
the communication is to be throw the XBEE

---------- Post added at 13:37 ---------- Previous post was at 13:35 ----------

hi sir (engshahrul)
i am using the CCS not the Hi-tech
so if you can provide me with the CCS code it will be great
regards,
 

CCS compiler allows you to define any digital IO as your software serial....
so you can use one hardware serial and one software serial just look at the CCS help..
 
hi sir,
so how can i define the software serial and then how to read from the gps
other thing is hoew to draw the path on the google earth by implementing it in the VB
please if you have any further information provide me with it
regards,
 

first you can define serial streams like this..

#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7,stream = hardware) // Hardware serial
#use rs232(baud=9600, xmit=PIN_C0,rcv=PIN_C1,stream = software) // Software serial

then you can receive the software serial as
data = fgetc(software); // Receive data from software serial

these are the basic commands for more specs you can consult CCS compiler help or have a look at the following link..
CCS :: View topic - Software UART baud rate problem
 
hi sir,
thank you for you useful information
but i just want to know
i have to use the kbhit or not
also how to program the gps and get the data from it?
could you please help me
regards,
 

hi sir,
thank you for you useful information
but i just want to know
i have to use the kbhit or not
also how to program the gps and get the data from it?
could you please help me
regards,

hai sultan
I told you that the gps is following NMEA protocol . You can read by serial port. Every sentence starting with the symbol $ and ends with a LF signal. You can check for these symbols in the program. I am using hi- tech picc . So if you need i'll send the code in picc.
 
This is sample code using Hi-Tech. If you understand this, should give you idea to convert into CCS
if(RCIF==1){
if(RCREG=='$') z=0;
if(z<=6) gps[z]=RCREG;
else if((gps[3]=='R')&(gps[4]=='M')&(gps[5]=='C')) gps[z]=RCREG;
if(z<89) z++;}
The result, you get the array of $GPRMC,....
 
This is sample code using Hi-Tech. If you understand this, should give you idea to convert into CCS

The result, you get the array of $GPRMC,....

Why you are not checking rcif, before reading each RCREG. I think it may be cause a logical error
 
Why you are not checking rcif, before reading each RCREG. I think it may be cause a logical error
That is RCIF interrupt. So, the code automatically run when UART signal comes in. Previous post, I have give link full source code.
 
hi sir,
thank you for you useful information
but i just want to know
i have to use the kbhit or not
also how to program the gps and get the data from it?
could you please help me
regards,

when you are using software serial i.e other than the hardware serial there is no interrupt so you can use kbhit to check if there is an incoming data at the soft serial other wise you can poll and wait for the receive....

and for GPS receiving you should search in the forum there are several previous post discussing that...
 
hi sir
thank you for help
i am not fully understand how to program the gps
could you please illustrate more
i need to write code in ccs
also i need to know how to use the gps output to draw the path of the robot on the google earth
best regards,
 

hi
could anyone check this code and tell me what the wrong with this code
it is to read from the gps

#include "C:\Users\student\Desktop\gps\gps.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7,stream = xbee,errors) // xbee serial
#use rs232(baud=9600, xmit=PIN_C0,rcv=PIN_C1,stream = gps,errors) // gps serial
char comandoGPR[7] = "$GPRMC";
int i;
char linea[75] = "";
int bien=0;
int indices[13];
int cont=0;
int j;
int conta=0;
int byteGPS=-1;
void main()
{
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_psp(PSP_DISABLED);
setup_counters(RTCC_INTERNAL,RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_1,0,1);

// byteGPS=Serial.read(); // Read a byte of the serial port
// if (byteGPS == -1) { // See if the port is empty yet
// delay(100);
// } else {
// if(kbhit(gps)==true)
//{
while(1)
{
if(kbhit(gps))
{
byteGPS = fgetc(gps);
// if (byteGPS == -1) { // See if the port is empty yet
// delay_ms(100);
// } else {
fprintf(xbee,"jjff ");
linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer
conta++;
// fprintf(byteGPS, BYTE);
fprintf(xbee,"%u",byteGPS);
//}
if (byteGPS==13){ // If the received byte is = to 13, end of transmission
// digitalWrite(ledPin, LOW);
cont=0;
bien=0;
for (i=1;i<7;i++){ // Verifies if the received command starts with $GPR
if (linea[i-1]==comandoGPR[i-1]){
bien++;
}
}
if(bien==6){ // If yes, continue and process the data
for (i=0;i<75;i++){
if (linea==','){ // check for the position of the "," separator
indices[cont]=i;
cont++;
}
if (linea=='*'){ // ... and the "*"
indices[12]=i;
cont++;
}
}
fprintf(xbee,"/r"); // ... and write to the serial port
fprintf(xbee,"/r");
fprintf(xbee,"---------------/r");
for (i=0;i<12;i++){
switch(i){
case 0 :fprintf(xbee,"Time in UTC (HhMmSs): ");break;
case 1 :fprintf(xbee,"Status (A=OK,V=KO): ");break;
case 2 :fprintf(xbee,"Latitude: ");break;
case 3 :fprintf(xbee,"Direction (N/S): ");break;
case 4 :fprintf(xbee,"Longitude: ");break;
case 5 :fprintf(xbee,"Direction (E/W): ");break;
case 6 :fprintf(xbee,"Velocity in knots: ");break;
case 7 :fprintf(xbee,"Heading in degrees: ");break;
case 8 :fprintf(xbee,"Date UTC (DdMmAa): ");break;
case 9 :fprintf(xbee,"Magnetic degrees: ");break;
case 10 :fprintf(xbee,"(E/W): ");break;
case 11 :fprintf(xbee,"Mode: ");break;
case 12 :fprintf(xbee,"Checksum: ");break;
}
for (j=indices;j<(indices[i+1]-1);j++){
fprintf(xbee,"%c",linea[j+1]);
}
fprintf(xbee,"/r");
}
fprintf(xbee,"---------------/r");
}
conta=0; // Reset the buffer
for (i=0;i<75;i++){ //
linea=' ';
}
}

}
}
}
regards,
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top