Click here to Skip to main content
15,914,160 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralDisable Back/Next/FontChange in webbrowser2 Pin
Ravi Bhavnani31-Mar-04 12:06
professionalRavi Bhavnani31-Mar-04 12:06 
Generaldlgdata.cpp error in line 43 Pin
youssef31-Mar-04 10:52
youssef31-Mar-04 10:52 
GeneralRe: dlgdata.cpp error in line 43 Pin
Rob Manderson31-Mar-04 11:25
protectorRob Manderson31-Mar-04 11:25 
GeneralRe: dlgdata.cpp error in line 43 Pin
xinzhu_liu23-Nov-09 15:17
xinzhu_liu23-Nov-09 15:17 
GeneralVisual C++ and Microcontroller Pin
knightri31-Mar-04 10:28
knightri31-Mar-04 10:28 
GeneralRe: Visual C++ and Microcontroller Pin
gyrogearloose31-Mar-04 14:12
gyrogearloose31-Mar-04 14:12 
GeneralRe: Visual C++ and Microcontroller Pin
Ryan Binns31-Mar-04 17:24
Ryan Binns31-Mar-04 17:24 
GeneralRe: Visual C++ and Microcontroller Pin
knightri1-Apr-04 7:13
knightri1-Apr-04 7:13 
Ok let me lay it out for everyone so they have a cleaer picture.

Free to use

This is the c file I am using.



//RMC Message Parser
// COMPILE: From the command line:
//
// nmake -f gprmc._m_


#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <iostream.h>
#include <fstream.h>




#include "mgc.h"
#include "keycode.h"

char DataBuffer[256];

int Port;
double latitude;
double longitude;
double currentlatitude;
double currentlongitude;
/* For error detection */

int ShowMGC32Error(int Code)
{
static char ErrBuffer[128];
mgcErrorText(Code, (char *)ErrBuffer);
printf("%s\n", ErrBuffer);
return Code;
}

/*** main ***/

void main(int argc, char *argv[])
{
int Code;
/* process args */
if(argc!=2)
{
printf("Usage: GPRMC <port>\n");
return;
}
Code = mgcAttach(MGC_KEY_CODE); //checks for proper identification
if(Code<0)
{
printf("Error %d: Cannot attach MGC32.DLL, check key code\n", Code);
return;
}
Port = atoi(argv[1]) - 1; //converts string into an integer
Code = mgcOpen(Port); //opens com
if(Code<0)
{
ShowMGC32Error(Code);
exit(1);
}
printf("GPRMC Test Program\n");
printf("MGC Version %1d.%1d.%1d\n",
mgcGetInteger(MGC_GET_VERSION_DIGIT1),
mgcGetInteger(MGC_GET_VERSION_DIGIT2),
mgcGetInteger(MGC_GET_VERSION_DIGIT3));

// specify which sentence (RMC)
Code = mgcSetInteger(MGC_SET_SENTENCE_TYPE, MGC_SENTENCE_GPRMC);
if(Code<0)
{
ShowMGC32Error(Code);
exit(1);
}
printf("Enter destination latitude: \n");
cin>>latitude;
printf("Enter destination longitude:\n");
cin>>longitude;
printf("Alex Czeto GPS RMC Message Parser Test Version \n");
printf("Date Time V Speed Course Latitude Longitude \n");
printf("==== ==== = ===== ====== ======== ========= \n");

while(1)
{// was any key pressed ?
if(kbhit()) break;
// lock data buffer
mgcLockData(1);
// get date
Code = mgcGetData(GPRMC_DATE,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code==1)
{// reference count = 1 (1st time seen this data)
if(Code>0) printf("%5s ", DataBuffer);
// get timestamp
Code = mgcGetData(GPRMC_UTC_TIME,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%5s ", DataBuffer);
// get validity
Code = mgcGetData(GPRMC_VALIDITY,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%s ", DataBuffer);
// get speed
Code = mgcGetData(GPRMC_SPEED,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%5s ", DataBuffer);
// get course
Code = mgcGetData(GPRMC_COURSE,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%5s ", DataBuffer);
// get Latitude
Code = mgcGetData(GPRMC_LATITUDE,(LPSTR)DataBuffer);
currentlatitude=Code;
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%8s ", DataBuffer);
// get North/South
Code = mgcGetData(GPRMC_NORTH_SOUTH,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%s ", DataBuffer);
// get Longitude
Code = mgcGetData(GPRMC_LONGITUDE,(LPSTR)DataBuffer);

if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%8s ", DataBuffer);


// get East/West
Code = mgcGetData(GPRMC_EAST_WEST,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%s\n", DataBuffer);
}
// unlock data buffer
mgcLockData(0);
Sleep(200);
}
mgcClose();
} /* end main */




and this is the potentiometer code that is running on the Motorola HC12 microcontroller


* Equate registers addresses
*-------------------------------------------------
copctl equ $0016 ;COP Control Register
mode equ $000b ;mode register
reset equ $fffe ;reset
sp0cr1 equ $00d0 ;spi control register 1
sp0cr2 equ $00d1 ;spi control register 2
sp0br equ $00d2 ;spi boud rate register
sp0sr equ $00d3 ;spi status register
sp0dr equ $00d5 ;spi data register
ports equ $00d6 ;port s data register
ddrs equ $00d7 ;data direction register for port s
purds equ $00db ;pull-up and reduced drive for port s
cs equ $0004 ;chip select (ps2)
*-------------------------------------------------
* Digital POT command and data bytes
*-------------------------------------------------
command equ $13 ;command byte for the digital pot
data equ $50 ;digital value to set the wiper position
*-------------------------------------------------
* Set register values for SPI
*-------------------------------------------------
org $8000 ;program the Flash EEProm
start ldaa #$19 ;special single chip mode
staa mode
ldaa #$00 ;turn off watchdog
staa copctl
ldaa #$5e
staa sp0cr1 ;set control register 1
clra
staa sp0cr2 ;set control register 2
staa sp0br ;set boud rate
staa purds ;set pull-up and reduced drive for ports
ldaa #$ff
staa ddrs ; set data direction register for ports
*-------------------------------------------------
* Program the POT
*-------------------------------------------------
bclr ports,cs ;select digital pot
ldaa #command ;load the command byte
staa sp0dr ;store command byte to the SPI data register
bsr transmit ;program the command byte
ldaa #data ;load the data byte
staa sp0dr
bsr transmit ;program the data byte
bset ports,cs ;deselect digital pot
swi ;software interrupt
*-------------------------------------------------
* Transmit data thru SPI
*-------------------------------------------------
transmit brset sp0sr,$80,done ;wait until the end of transmission
bra transmit
done ldaa sp0sr ;clear SPIF (SPI interrupt request)
ldaa sp0dr ;
rts ;return from subroutine
*-------------------------------------------------
* Set reset vector
*-------------------------------------------------
org reset ;set reset vector
dw start ;upon reset goto 'start'
*=================================================


Basically I need to send a 8bit code from the GPS program to the microcontroller to the data register value in memory. This digital value sets the wiper position on the potentiometer which the microcontroller is wired to.

When the GPS program determines a change in speed is neccesary, the signal will be sent.
GeneralRe: Visual C++ and Microcontroller Pin
Anonymous3-Apr-04 8:03
Anonymous3-Apr-04 8:03 
QuestionHow to create a Windows XP style button with an image on it? Pin
Paksas31-Mar-04 9:35
Paksas31-Mar-04 9:35 
AnswerRe: How to create a Windows XP style button with an image on it? Pin
Gary R. Wheeler31-Mar-04 16:20
Gary R. Wheeler31-Mar-04 16:20 
AnswerRe: How to create a Windows XP style button with an image on it? Pin
Gary R. Wheeler31-Mar-04 16:22
Gary R. Wheeler31-Mar-04 16:22 
GeneralDialogBox Creation Pin
monrobot1331-Mar-04 8:59
monrobot1331-Mar-04 8:59 
GeneralRe: DialogBox Creation Pin
Neville Franks31-Mar-04 9:03
Neville Franks31-Mar-04 9:03 
GeneralTemplate Specialization Pin
Yaron12631-Mar-04 8:45
Yaron12631-Mar-04 8:45 
GeneralRe: Template Specialization Pin
antlers31-Mar-04 10:51
antlers31-Mar-04 10:51 
Generaliterate through vector Pin
wadstar31-Mar-04 8:16
wadstar31-Mar-04 8:16 
GeneralMember of domain Pin
orcun colak31-Mar-04 5:57
orcun colak31-Mar-04 5:57 
GeneralRe: Member of domain Pin
David Crow31-Mar-04 8:03
David Crow31-Mar-04 8:03 
GeneralRe: Member of domain Pin
Robert M Greene31-Mar-04 15:55
Robert M Greene31-Mar-04 15:55 
GeneralTextOut() Pin
ns31-Mar-04 4:49
ns31-Mar-04 4:49 
GeneralRe: TextOut() Pin
Prakash Nadar31-Mar-04 4:54
Prakash Nadar31-Mar-04 4:54 
GeneralRe: TextOut() Pin
ns31-Mar-04 7:03
ns31-Mar-04 7:03 
GeneralRe: TextOut() Pin
grigsoft31-Mar-04 8:29
grigsoft31-Mar-04 8:29 
GeneralRe: TextOut() Pin
monrobot1331-Mar-04 8:39
monrobot1331-Mar-04 8:39 

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.