Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Visual C++ and Microcontroller

Visual C++ and Microcontroller

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionagentic-aihardwareregex
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    knightri
    wrote on last edited by
    #1

    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.

    G R 2 Replies Last reply
    0
    • K knightri

      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.

      G Offline
      G Offline
      gyrogearloose
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • K knightri

        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.

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #3

        If you're asking how to send data over a serial port, you can open "COM1" as a file using CreateFile() and send characters using WriteFile(). 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"

        K 1 Reply Last reply
        0
        • R Ryan Binns

          If you're asking how to send data over a serial port, you can open "COM1" as a file using CreateFile() and send characters using WriteFile(). 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"

          K Offline
          K Offline
          knightri
          wrote on last edited by
          #4

          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

          A 1 Reply Last reply
          0
          • K knightri

            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

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            bump

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups