VIVAX GPS i HP VFD

VIVAX GPS i HP VFD

Nakon što mi je VIVAX GPS počeo slabije loviti signal, nisam odolio iskušenju odmah sam ga otvorio da vidim kako bi ga mogao iskoristiti.

Jedan pin zelemio sam na masu VIVAX-a i spoji ga na arduino.
Na adruino sam utočio sljedeći kod

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly: 
  if (Serial.available()>0){
    Serial.print(Serial.read(),BYTE);
  }
}

Nakon toga sam na arduino spojio žićicu i sa njom se prošetao po VIVAX-u na sve lemove na kojima bi mogao biti izlaz serijskog porta od GPS modula.
Ispalo je da je to na VIVAX-u peti po redu pin.

vivaxGPS_hack_prikaz_za_lemilicu

nakon što sam dobio signal sa njime sam radio razno razne stvari, ali evo jednog projekta gdje sam iskoristio VFD izvađen iz HP pisača.
Da bi nam kod radio trebati ćemo i dodatni library kojeg možemo naći na liku
http://playground.arduino.cc//Main/M66004Vfd

A na ovom linku možemo vidjeti kako spojiti pinove

http://playground.arduino.cc//Main/HpLaserJetControlDemo

Kada to sve spojimo na arduino zajedno sa VIVAX GPS-om na RX pinu na arduino trebamo natočiti ovaj kod.
Kod nije preveden niti dorađen onakav je kakav je bio kada sam to spajao :(

#include 
#include 
#include  // VFD library.
#include  // Button and LED library.

 int ledPin = 13;                  // LED test pin
 int rxPin = 0;                    // RX PIN 
 int txPin = 1;                    // TX TX
 int byteGPS=-1;
 char linea[300] = "";
 char comandoGPR[7] = "$GPRMC";
 int cont=0;
 int bien=0;
 int conta=0;
 int indices[13];
 String Time = "00:00:00.000";
 /////////////////////////////////////////////////////////////////////////////
 M66004Vfd vfd(8, 6, 7);
HpLaserJetControl control(9, 6, 7, 10);
void StartupLedSequence()
{
  static const uint8_t LED_ON_TIME_IN_MS = 75;
 
  for (uint8_t i=0; i < 5; i++)
  {
    control.setLedState(1, HIGH);
    delay(LED_ON_TIME_IN_MS);
    control.setLedState(1, LOW);
  
    control.setLedState(2, HIGH);
    delay(LED_ON_TIME_IN_MS);
    control.setLedState(2, LOW);
  
    control.setLedState(0, HIGH);
    delay(LED_ON_TIME_IN_MS);
    control.setLedState(0, LOW);
  }
  
  delay(LED_ON_TIME_IN_MS);
    
  for (uint8_t i=0; i < 2; i++)
  {
    delay(LED_ON_TIME_IN_MS);
    control.setLedState(0, HIGH);
    control.setLedState(1, HIGH);
    control.setLedState(2, HIGH);
    delay(LED_ON_TIME_IN_MS * (i*2+1));
    control.setLedState(0, LOW);
    control.setLedState(1, LOW);
    control.setLedState(2, LOW);
    
  }
}
 // We call this each frame to process button presses and update LED's accordingly.
////////LCD gumbi

 /////////////////////////////////////////////////////////////////////////////
 void setup() {
   pinMode(ledPin, OUTPUT);       // Initialize LED pin
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   StartupLedSequence();
   delay(3000);
   Serial.begin(9600);
   for (int i=0;i<300;i++){       // Initialize a buffer for received data
     linea[i]=' ';
 //////////////////////////////////////////////////////////////////////////////
   // Prepare the VFD library for use.
  vfd.begin(16, 1);
  if (control.isDeviceAttached()) // Test that isDeviceAttached() works correctly
  {
    // Sets all pixels on the display.
    vfd.allDisplay();
        // Enables normal character display.
    vfd.display();
    vfd.print(Time);
    }
/////////////////////////////////////////////////////////////////////////////// 
   }   
 }
 void loop() {
////////////////////////////////////////
UpdateButtonsAndLeds();

///////////////////////////////////////
  // digitalWrite(ledPin, LOW);
   //vfd.clear();
   byteGPS=Serial.read();         // Read a byte of the serial port
   if (byteGPS == -1) {           // See if the port is empty yet
     delay(100); 
   } else {
     linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
     conta++;                      
   //  Serial.print(byteGPS, BYTE); 
     if (byteGPS==13){            // If the received byte is = to 13, end of transmission
    //   digitalWrite(ledPin, HIGH); 
       cont=0;
       bien=0;
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
           bien++;
         }
       }
       if(bien==6){               // If yes, continue and process the data
         for (int i=0;i<300;i++){
           if (linea[i]==','){    // check for the position of the  "," separator
             indices[cont]=i;
             cont++;
           }
           if (linea[i]=='*'){    // ... and the "*"
             indices[12]=i;
             cont++;
           }
         }
         for (int i=0;i<12;i++){
          switch(i){
            /* case 0 :Serial.print("Time in UTC (HhMmSs): ");break;
             case 1 :Serial.print("Status (A=OK,V=KO): ");break;
             case 2 :Serial.print("Latitude: ");break;
             case 3 :Serial.print("Direction (N/S): ");break;
             case 4 :Serial.print("Longitude: ");break;
             case 5 :Serial.print("Direction (E/W): ");break;
             case 6 :Serial.print("Velocity in knots: ");break;
             case 7 :Serial.print("Heading in degrees: ");break;
             case 8 :Serial.print("Date UTC (DdMmAa): ");break;
             case 9 :Serial.print("Magnetic degrees: ");break;
             case 10 :Serial.print("(E/W): ");break;
             case 11 :Serial.print("Mode: ");break;
             case 12 :Serial.print("Checksum: ");break;
           */
           }
           for (int j=indices[i];j<(indices[i+1]-1);j++){
           if (i==0){
           Time = Time + linea[j+1]; 
           if (Time.length()==2){
            // Time = Time + 2;
             //int Time2 = int(Time) + 2;
             Time = Time + ":";
             }
             if (Time.length()==5){
             Time = Time + ":";
             }
           }
           if (i==1){
           //Serial.print("\n\r");
           Time = Time + "    ";
           vfd.print(Time);
         //  delay(1000);
          Time = "";
           vfd.setCursor(0, 0);
           }
           }
         }
       }
       conta=0;                    // Reset the buffer
       for (int i=0;i<300;i++){    //  
         linea[i]=' ';             
       }                 
     }
   }
 }
 void UpdateButtonsAndLeds()
{
  // Top row of buttons being pressed toggles.
  if (control.wasButtonPressed(6))
  {
    // Toggle LED1.
   control.setLedState(1, (control.getLedState(1) == LOW) ? HIGH : LOW);
  }
  /*
  if (control.wasButtonPressed(5))
  {
    // Toggle LED0.
    //control.setLedState(0, (control.getLedState(0) == LOW) ? HIGH : LOW);
  }

  if (control.wasButtonPressed(4))
  {
    // Toggle LED2.
    //control.setLedState(2, (control.getLedState(2) == LOW) ? HIGH : LOW);
  }

  if (control.wasButtonPressed(3))
  {
    // Toggle all LEDs.
    
  }

  // Second row of buttons currently down sets LED.
  if (control.isButtonPressed(7))
  {
    // Set LED1.
    //control.setLedState(1, HIGH);
  }
  
  if (control.isButtonPressed(1))
  {
    // Set LED0.
    //control.setLedState(0, HIGH);
  }
  
  if (control.isButtonPressed(2))
  {
    // Set LED2.
  //  control.setLedState(2, HIGH);
  }
  
  if (control.isButtonPressed(0))
  {
    // Set all LEDs.
  //  control.setLedState(0, HIGH);
  //  control.setLedState(1, HIGH);
  //  control.setLedState(2, HIGH);
  }
  
  // Second row released clears LED state.
  if (control.wasButtonReleased(7))
  {
    // Clear LED1.
    //control.setLedState(1, LOW);
  }
  
  if (control.wasButtonReleased(1))
  {
    // Clear LED0.
    //control.setLedState(0, LOW);
  }
  
  if (control.wasButtonReleased(2))
  {
    // Clear LED2.
   // control.setLedState(2, LOW);
  }
  
  if (control.wasButtonReleased(0))
  {
    // Clear all LEDs.
    //control.setLedState(0, LOW);
    //control.setLedState(1, LOW);
    //control.setLedState(2, LOW);
  }*/
  }

Nakon što GPS ulovi signal, on će izbaciti vrijeme na VFD...
Vrijeme će biti krivo :)
Morati ćete podesiti kod da bi ga pomakli na +1 za sat vremena unaprijed.

Ovako je to izgledalo kad je radilo

http://www.youtube.com/watch?v=P34UDlPL3Ro&feature=youtu.be

Leave a Reply