Jump to content

scotty

EstablishedMember
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

0 Neutral

About scotty

  • Rank
    Newbrie

Profile Information

  • Location
    California
  1. I never got around to writing any code, but found this site helpful in understanding LCD custom characters. http://www.dinceraydin.com/djlcdsim/djlcdsim.html
  2. It compiles when written as such: void main(void) { U8_t tempo; while(1) { void_DIO_initial(); tempo = ECUAL_scanf(); ECUAL_printf(tempo); } }
  3. the following project was based on Jon's compass project. It receives NMEA sentences from a LORAN and retransmitts them as GPS sentences to allow a PC chartplotter to track my course. Until LORAN was shut downearlier this year. Runs on a PIC 16F690 #include <system.h> #pragma CLOCK_FREQ 4000000 // Used with 4Mhz crystal #pragma DATA _CONFIG, _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF #define forever 1 #define YES 1 #define NO 0 #define ZED 'z' //for test #define DOLLAR '$' //for NMEA #define CR 13 //carriage return #define LF 10 //line feed #define LCGLL 72 //lat long #define LCXTE 70 //lat long #define LCAAM 66 //lat long #define LCVTG 74 //lat long #define LCBOD 71 //lat long #define LCWPL 68 //lat long #define RX_BUFFER_SIZE 30 #define LAT_LON_BUFFER_SIZE 20 #define NULL 0 short command, cmd, reading; //NMEA receive variables unsigned short cRxByteCnt, cRxIsrState, cRxMsgTypeReceived, cReceiveFlag; char cRxBuffer[ RX_BUFFER_SIZE ] = "$PRGMM,WGS 84 "; char cRxBuff[10] = "DEFAULT "; char ownship[20], waypoint[20]; char cRxbyteCnt, cRxMsgReady, OKtoSleep; char *cRxBufferWritePtr; // char cLat_Lon_Buffer[ LAT_LON_BUFFER_SIZE ]; char string[4]; #define low 0 #define high 1 #define current 2 void putc(char txc) // Put char function to transmit one char { set_bit( txsta, TXEN ); // Enable transmission bit txreg = txc; // Put function parameter txc into the txreg while(( txsta&0x02 ) == 0 ); // Wait until character transmission finished } char getc(void) // Getc function loop until a character is pressed { while( ( pir1&0x20 ) != 0x20 ); // Loop until Rxflag = 1 return rcreg; // Return rcreg } void puts(char *source) // put string function, return the refered string { while (*source != 0 ) // wait until tx register is empty { putc(*source++); // Send the string refered by pointer } } void interrupt( void ) // Called function on interrupts { char cChar, display; int count; if test_bit( pir1,RCIF) // If Rxflag = 1 then -----> { // puts("You pressed "); // Send the string "You pressed " cChar = getc(); // Call getc function then put the character pressed switch ( cRxIsrState ) { case 0: { if (cChar == DOLLAR) // start of NMEA sentence { cRxByteCnt = 0; //reset byte count cRxMsgTypeReceived = NULL; cRxIsrState++; // putc(DOLLAR); } break; } case 1: case 2: case 3: case 4: case 5: { cRxMsgTypeReceived ^= cChar; //XOR in character received if ( cRxIsrState++ == 5 ) //check message type { if ( cChar == 'D' ) cRxMsgTypeReceived++; // cRxIsrState = 0; if ( (cRxMsgTypeReceived == LCGLL) | (cRxMsgTypeReceived == LCWPL) ) { cReceiveFlag = YES; cRxBufferWritePtr = cRxBuffer; } else { cRxIsrState = 0; //wait for next message } } display = cChar + 64; // putc(display); break; } case 6: { //case 6 skips the comma cRxIsrState++; break; } default: { if ( cReceiveFlag == YES ) { *cRxBufferWritePtr = cChar; //put character in fifo cRxBufferWritePtr++; if ( cRxBufferWritePtr == ( cRxBuffer + RX_BUFFER_SIZE)) { cRxBufferWritePtr = cRxBuffer; //set pointer to start of buffer } cRxbyteCnt++; if (cChar == CR ) { // cRxMsgReady = YES; //message ready cRxIsrState = 0; //allow next message cReceiveFlag = NO; //end receive if (cRxMsgTypeReceived == LCGLL) { for (count=0; count < 20; count++) { ownship[count] = cRxBuffer[count]; } } if (cRxMsgTypeReceived == LCWPL) { for (count=0; count < 20; count++) { waypoint[count] = cRxBuffer[count]; OKtoSleep = YES; //allow sleep mode cRxMsgReady = YES; //message ready cRxIsrState = 0; //allow next message } } } } } } } } void main() { trisa = 0; // set all ports as outputs trisb = 0; trisc = 0; porta = 0; //set all ports low portb = 0; portc = 0; OKtoSleep = YES; //allow sleep mode anselh = 0; //digital inputs cRxMsgReady = NO; //initialize receive ansel = 0; cRxIsrState = 0; //initialize NMEA state // cLat_Lon_Buffer = *cRxBuffer; // set up the EUSART set_bit(trisb,TRISB5); //eusart receive pin set_bit(trisb,TRISB6); set_bit(trisb,TRISB7); //eusart transmit pin set_bit(intcon,PEIE); //enable peripheral interrupt set_bit(pie1,RCIE); //enable EUSART interrupt set_bit(intcon,GIE); //enable global interrupt set_bit(baudctl, BRG16); spbrgh = 0; spbrg = 207; //Set SPBRG to 4800 BPS clear_bit(txsta, SYNC); set_bit(rcsta,SPEN); set_bit(rcsta, CREN); set_bit(txsta, BRGH); puts("test the serial port "); // Send the string "test the serial port " // puts("$GPRMC,120002,A,4731.3888,N,12223.8193,W,0.0,41.1,250208,0.0,W*47"); putc(CR); putc(LF); // puts("$GPRMA,A,llll.ll,N,lllll.ll,W,,,,,"); // putc(CR); // putc(LF); while (forever) { if ( cRxMsgReady == YES) //message ready { cRxMsgReady = NO; //end receive cRxIsrState = 0; //allow next message puts("$PRGMM,WGS 84"); // Send the datum sentence putc(CR); putc(LF); puts("$PFEC,GPwpl,"); // $PFEC,GPwpl,3351.446,N,11910.866,W,NWP001,,@rNAMED WAYPOINT T,A,,,, unsigned short count; for (count=0; count < 20; count++) { putc(ownship[count]); } puts(",OWNSHP,,@rPRESENT POSITION,A,,,"); // puts(cLat_Lon_Buffer); // $PFEC,GPxfr,CTL,E putc(CR); putc(LF); puts("$PFEC,GPwpl,"); // $PFEC,GPwpl,3351.446,N,11910.866,W,NWP001,,@rNAMED WAYPOINT T,A,,,, for (count=0; count < 20; count++) { putc(waypoint[count]); } puts(",NWP001,,@rPRESENT POSITION,A,,,"); // puts(cLat_Lon_Buffer); // $PFEC,GPxfr,CTL,E putc(CR); putc(LF); puts("$PFEC,GPxfr,CTL,E"); //end of waypoint sentence putc(CR); putc(LF); cRxBufferWritePtr = cRxBuffer; //reset buffer pointer } if ( OKtoSleep == YES) //no message ready { set_bit(baudctl, WUE); //enable wake up OKtoSleep = NO; //don't allow sleep after wake up // puts("sleep"); sleep(); // puts("awake"); clear_bit(baudctl, WUE); //disable wake up } } }
  4. The GPS monitor project at this website is a nice example. http://www.vermontficks.org/northernlight/gps_monitor.html
  5. Great plugin, it's been very useful on a couple of my projects. The input button plugins do not work though when the VCD plugin is up, is this to be expected. The button toggles, but no change is seen in the simulator ports.
×
×
  • Create New...