Visual C++ and Microcontroller
-
Hi. Currently I have a Visual C+ program that communicates with a GPS device through a serial-to-USB interface. Analysis of the GPS information leads to a set of control signals being sent to a Motorola HC12 Microcontroller. I was wondering if anyone had any ideas on how this process could take place. Basically the micro controls acceleration and steering for an autonomous vehicle I am working on. From the micro, 5 volts control an analog switch varying +/- 12 volts to a steering motor and alos from the micro a bit signal that sets the correct wiper setting in the digital potentiometer. I need a way to send a signal from the Windows XP laptop I am using to the microcontroller through a serial port. I am using the MarshallSoft GPS DLL to manipulate the USB port that the GPS information comes into. Since I have a serial-to-usb conversion acting on COM4, how do I take control of Com1 lets say and send a particular bit pattern to the micro?????Any help would greatly be appreciated.
-
Hi. Currently I have a Visual C+ program that communicates with a GPS device through a serial-to-USB interface. Analysis of the GPS information leads to a set of control signals being sent to a Motorola HC12 Microcontroller. I was wondering if anyone had any ideas on how this process could take place. Basically the micro controls acceleration and steering for an autonomous vehicle I am working on. From the micro, 5 volts control an analog switch varying +/- 12 volts to a steering motor and alos from the micro a bit signal that sets the correct wiper setting in the digital potentiometer. I need a way to send a signal from the Windows XP laptop I am using to the microcontroller through a serial port. I am using the MarshallSoft GPS DLL to manipulate the USB port that the GPS information comes into. Since I have a serial-to-usb conversion acting on COM4, how do I take control of Com1 lets say and send a particular bit pattern to the micro?????Any help would greatly be appreciated.
Got me. But if I was going to try to do that, I'd look at how the free software works from parallax.com, interesting stuff. Basic stamps and PLC's and such. Best I can do. Gyrogearloose
-
Hi. Currently I have a Visual C+ program that communicates with a GPS device through a serial-to-USB interface. Analysis of the GPS information leads to a set of control signals being sent to a Motorola HC12 Microcontroller. I was wondering if anyone had any ideas on how this process could take place. Basically the micro controls acceleration and steering for an autonomous vehicle I am working on. From the micro, 5 volts control an analog switch varying +/- 12 volts to a steering motor and alos from the micro a bit signal that sets the correct wiper setting in the digital potentiometer. I need a way to send a signal from the Windows XP laptop I am using to the microcontroller through a serial port. I am using the MarshallSoft GPS DLL to manipulate the USB port that the GPS information comes into. Since I have a serial-to-usb conversion acting on COM4, how do I take control of Com1 lets say and send a particular bit pattern to the micro?????Any help would greatly be appreciated.
If you're asking how to send data over a serial port, you can open "COM1" as a file using
CreateFile()
and send characters usingWriteFile()
. If you're asking something else, you'll have to be a lot clearer.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
If you're asking how to send data over a serial port, you can open "COM1" as a file using
CreateFile()
and send characters usingWriteFile()
. If you're asking something else, you'll have to be a lot clearer.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
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 #include #include #include #include #include #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 \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
-
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 #include #include #include #include #include #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 \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