Σελίδα 1 από 2 1 2 ΤελευταίαΤελευταία
Εμφάνιση αποτελεσμάτων : 1 έως 10 από 12

Θέμα: μπαρομετρο αυτοκινήτου με arduino

  1. #1
    Μέλος
    Όνομα
    george
    Εγγραφή
    Jun 2005
    Περιοχή
    ΤΡΙΚΑΛΑ
    Μηνύματα
    421

    Προεπιλογή μπαρομετρο αυτοκινήτου με arduino

    καλησπέρα.εχω φορτώσει το παρακάτω πρόγραμμα σε ένα arduino το οποίο απεικονίζει την πίεση σε μια οθόνη 20χ4.εχω όμως το έξης θέμα.η πρώτη επάνω σειρά δείχνει την βαθμονόμηση της πίεσης ανά 5 δηλαδή. 5 10 15 και επίσης την δείχνει με μια μπάρα που ανεβοκατεβαίνει ανάλογος με την πίεση.το πρόβλημα είναι ότι η μπάρα που ανεβοκατεβαίνει βγαίνει και αυτή στην πρώτη σειρά που είναι και τα νούμερα 5. 10. 15 με αποτέλεσμα να μου τα σβήνει.πως μπορώ να μεταφέρω αυτή την μπάρα στην δεύτερη σειρά????

    Ευχαριστω

    0 Not allowed! Not allowed!

  2. #2
    Μέλος
    Όνομα
    george
    Εγγραφή
    Jun 2005
    Περιοχή
    ΤΡΙΚΑΛΑ
    Μηνύματα
    421

    Προεπιλογή

    ο κωδικας ειναι ο παρακατω

    // Dangerous Dave's Boost Gauge Project
    // Reads boost from MPX4250AP on Analog 0.
    // Converts vacuum readings to inHg.
    // Displays peak boost

    // include libraries
    #include <LiquidCrystal.h>
    #include <LcdBarGraph.h>

    float rawval = 0; // Setup raw sensor value
    float kpaval = 0; // Setup kPa value
    float boost = 0; // Setup boost value
    float barboost = 0; // Setup value for boost bar
    float vac = 0; // Setup vacuum value
    float peak = 0; // Setup peak value

    LiquidCrystal lcd(12, 11, 8, 7, 6, 5); // set LCD interface pins
    byte lcdNumCols = 20; // number of columns in the LCD

    LcdBarGraph lbg1(&lcd, 20); // setup bargraph with width 20 starting at column 0 on row 1

    byte five[8] = { B01110, B01000, B01110, B00010, B01110, B00000, B00100, B00100 }; // Setup custom LCD character for bargraph legend
    byte ten[8] = { B10111, B10101, B10101, B10101, B10111, B00000, B00100, B00100 }; // Setup custom LCD character for bargraph legend
    byte fifteen[8] = { B10111, B10100, B10111, B10001, B10111, B00000, B00100, B00100 }; // Setup custom LCD character for bargraph legend

    void setup() // Start setup
    {
    lcd.createChar(5, five); // Create custom character defined above
    lcd.createChar(6, ten); // Create custom character defined above
    lcd.createChar(7, fifteen); // Create custom character defined above
    lcd.begin(20, 4); // set the LCD's columns and rows
    pinMode(7, OUTPUT);
    pinMode(9, OUTPUT);
    pinMode(8, OUTPUT);

    // Setup static characters on the lcd
    lcd.setCursor(0,2);
    lcd.print("Boost:");
    lcd.setCursor(0,3);
    lcd.print("Peak :");
    lcd.setCursor(14,3);
    lcd.print("Peak");
    lcd.setCursor(4,0);
    lcd.write(5);
    lcd.setCursor(9,0);
    lcd.write(6);
    lcd.setCursor(14,0);
    lcd.write(7);
    } // End setup

    void loop() // Start loop
    {
    // some base calculations to get pressures
    rawval = analogRead(0); // Read MAP sensor raw value on analog port 0
    kpaval = (rawval*(0.005)/(0.022)+20); // Calculate kpa value from raw value for debugging
    boost = ((rawval*(0.005)/(0.022)+20)*(0.145)-14.5); // Calculate psi from raw value ***(calculations need proving)***
    barboost = (rawval-357); // Calculate boost value for the bargraph ***(not exact, needs investigation, currently uses higher raw value for a smoother bar but is not exact)

    if ( boost <= 0 )
    {
    digitalWrite(7, HIGH);
    }
    else
    {
    digitalWrite(7,LOW);
    }

    if ( boost >= 17 )
    {
    digitalWrite(9, HIGH);
    }
    else
    {
    digitalWrite(9,LOW);
    }
    if ( boost >= 0,03 )
    {
    digitalWrite(8, HIGH);
    }
    else
    {
    digitalWrite(8,LOW);
    }
    if (boost >= 0) // Set condition for bargraph to show above zero (negative numbers cause LCD crash)
    {
    lcd.setCursor(9,2);
    lcd.print(boost,1); // Prints the boost figure
    lcd.setCursor(14,2);
    lcd.print("Boost "); // Prints 'psi' with a space after it to clear the 'g' off 'inHg'
    lbg1.drawValue(barboost, 700); // Draw bar graph from the analog value read with a maxvalue of 500
    }

    if (boost < 0)
    {
    lcd.setCursor(9,2);
    lcd.print(vac,1); // Prints the vacuum figure
    vac = boost*-2.036025; // Used 'minus' 2.036025 so that the figure printed wont have a minus symbol in front of it
    lcd.setCursor(14,2);
    lcd.print("Vaccum"); // Changes the units to 'inHg' on the lcd
    lcd.setCursor(0,1);
    lcd.print(" "); // clears the boost bar if any characters are left after going below 0
    }

    if (boost > peak) // If current boost is higher than peak, store new value
    {
    peak = boost ; // Store new peak value in peak memory
    }

    lcd.setCursor(9,3);
    lcd.print(peak,1); // Prints the peak value
    } //end loop

    0 Not allowed! Not allowed!

  3. #3
    Μέλος
    Όνομα
    george
    Εγγραφή
    Jun 2005
    Περιοχή
    ΤΡΙΚΑΛΑ
    Μηνύματα
    421

    Προεπιλογή μπαρομετρο αυτοκινήτου με arduino


    0 Not allowed! Not allowed!

  4. #4
    Μέλος Το avatar του χρήστη SProg
    Όνομα
    Σάββας
    Εγγραφή
    Mar 2014
    Περιοχή
    Θεσσαλονίκη
    Μηνύματα
    2.612

    Προεπιλογή

    Δοκίμασε

    Παράθεση Αρχικό μήνυμα από FMTRIKALA Εμφάνιση μηνυμάτων
    LcdBarGraph lbg1 (&lcd, 16, 0, 2)

    0 Not allowed! Not allowed!

  5. #5
    Μέλος
    Όνομα
    george
    Εγγραφή
    Jun 2005
    Περιοχή
    ΤΡΙΚΑΛΑ
    Μηνύματα
    421

    Προεπιλογή

    το φορτωσα και μου βγαζει αυτο το σφαλμα
    1.jpg

    0 Not allowed! Not allowed!

  6. #6
    Μέλος Το avatar του χρήστη Kernel Panic
    Όνομα
    Kernel Panic
    Εγγραφή
    Aug 2016
    Περιοχή
    Αθήνα
    Μηνύματα
    430

    Προεπιλογή

    στην γραμμή 20 άλλαξε το LcdBarGraph lbg1(&lcd, 20);
    σε LcdBarGraph lbg1(&lcd, 20, 0, 1);

    0 Not allowed! Not allowed!
    Τελευταία επεξεργασία από το χρήστη Kernel Panic : 31-01-18 στις 08:53

  7. #7
    Μέλος
    Όνομα
    Βασίλης
    Εγγραφή
    Sep 2011
    Περιοχή
    Κερατσίνι
    Μηνύματα
    8.778

    Προεπιλογή

    lcd.begin(20, 4); // set the LCD's columns and rows
    pinMode(7, OUTPUT);
    pinMode(9, OUTPUT);
    pinMode(8, OUTPUT);

    // Setup static characters on the lcd
    lcd.setCursor(0,2);
    lcd.print("Boost:");
    lcd.setCursor(0,3);
    lcd.print("Peak :");
    lcd.setCursor(14,3);
    lcd.print("Peak");
    lcd.setCursor(4,0);
    lcd.write(5);
    lcd.setCursor(9,0);
    lcd.write(6);
    lcd.setCursor(14,0);
    lcd.write(7);
    } // End setup

    Εχεις δηλωσει 4 σειρες.
    τον set cursor (τι ειναι αυτο?) δηλωνεται σειρα 0,2,3.Δοκιμασε τα 0 να τα κανεις 1.επισης θα δοκιμαζα(αν και δεν νομιζω) να κανεις 5rows

    ΥΓ ειδα και αυτο

    LcdBarGraph lbg1(&lcd, 20); // setup bargraph with width 20 starting at column 0 on row 1δεν βλεπω να τδηλωνει στο row1.
    A ,τωρα ειδα οτι αυτο προτεινε ο kernel panic.(γιατι να βαλει το 0 ? )

    0 Not allowed! Not allowed!
    Δυο πράγματα είναι άπειρα, το σύμπαν και η ανθρώπινη βλακεία, αλλά για το σύμπαν δεν είμαι εντελώς σίγουρος

  8. #8
    Μέλος Το avatar του χρήστη Kernel Panic
    Όνομα
    Kernel Panic
    Εγγραφή
    Aug 2016
    Περιοχή
    Αθήνα
    Μηνύματα
    430

    Προεπιλογή

    το λέει στην βιβλιοθήκη του

    Κώδικας:
    class LcdBarGraph{
    public:
        /**
         * Create an instance of the class. The bar will be drawn in the startY row 
         * of the LCD, from the startX column positon (inclusive) to to the startX+numCols column position
         * (inclusive).
         * lcd - A LiquidCristal instance should be passed.
         * numCols - Width of the bar.
         * startX - Horzontal starting position (column) of the bar. Zero based value.
         * startY - Vertical starting position (row) of the bar. Zero based value.
         */
        LcdBarGraph(LiquidCrystal* lcd, byte numCols, byte startX = 0, byte startY = 0);
        /**
         * Draw a bargraph with a value between 0 and maxValue.
         */
    να διορθώσω και το "διορθωμένο" σε

    Κώδικας:
     LcdBarGraph lbg1(&lcd, 16, 0, 1); // setup bargraph with width 20 starting at column 0 on row 1
    edit: αυτό που πρότεινε ο SavKok δεν θα έπρεπε να βγάζει σφάλμα, αλλά να πάει την μπάρα στην 3η γραμμή.
    για κάνε ένα κοπι πάστα απο εδώ:

    Κώδικας:
    // Dangerous Dave's Boost Gauge Project// Reads boost from MPX4250AP on Analog 0.
    // Converts vacuum readings to inHg.
    // Displays peak boost
    
    
    // include libraries
    #include <LiquidCrystal.h>
    #include <LcdBarGraph.h>
    
    
    float rawval = 0; // Setup raw sensor value
    float kpaval = 0; // Setup kPa value
    float boost = 0; // Setup boost value
    float barboost = 0; // Setup value for boost bar
    float vac = 0; // Setup vacuum value
    float peak = 0; // Setup peak value
    
    
    LiquidCrystal lcd(12, 11, 8, 7, 6, 5); // set LCD interface pins
    byte lcdNumCols = 20; // number of columns in the LCD
    
    
    LcdBarGraph lbg1(&lcd, 16, 0, 1); // setup bargraph with width 20 starting at column 0 on row 1
    
    
    byte five[8] = { B01110, B01000, B01110, B00010, B01110, B00000, B00100, B00100 }; // Setup custom LCD character for bargraph legend
    byte ten[8] = { B10111, B10101, B10101, B10101, B10111, B00000, B00100, B00100 }; // Setup custom LCD character for bargraph legend
    byte fifteen[8] = { B10111, B10100, B10111, B10001, B10111, B00000, B00100, B00100 }; // Setup custom LCD character for bargraph legend
    
    
    void setup() // Start setup
    {
      lcd.createChar(5, five); // Create custom character defined above
      lcd.createChar(6, ten); // Create custom character defined above
      lcd.createChar(7, fifteen); // Create custom character defined above
      lcd.begin(20, 4); // set the LCD's columns and rows
      pinMode(7, OUTPUT);
      pinMode(9, OUTPUT);
      pinMode(8, OUTPUT);
    
    
      // Setup static characters on the lcd
      lcd.setCursor(0, 2);
      lcd.print("Boost:");
      lcd.setCursor(0, 3);
      lcd.print("Peak :");
      lcd.setCursor(14, 3);
      lcd.print("Peak");
      lcd.setCursor(4, 0);
      lcd.write(5);
      lcd.setCursor(9, 0);
      lcd.write(6);
      lcd.setCursor(14, 0);
      lcd.write(7);
    } // End setup
    
    
    void loop() // Start loop
    {
      // some base calculations to get pressures
      rawval = analogRead(0); // Read MAP sensor raw value on analog port 0
      kpaval = (rawval * (0.005) / (0.022) + 20); // Calculate kpa value from raw value for debugging
      boost = ((rawval * (0.005) / (0.022) + 20) * (0.145) - 14.5); // Calculate psi from raw value ***(calculations need proving)***
      barboost = (rawval - 357); // Calculate boost value for the bargraph ***(not exact, needs investigation, currently uses higher raw value for a smoother bar but is not exact)
    
    
      if ( boost <= 0 )
      {
        digitalWrite(7, HIGH);
      }
      else
      {
        digitalWrite(7, LOW);
      }
    
    
      if ( boost >= 17 )
      {
        digitalWrite(9, HIGH);
      }
      else
      {
        digitalWrite(9, LOW);
      }
      if ( boost >= 0, 03 )
      {
        digitalWrite(8, HIGH);
      }
      else
      {
        digitalWrite(8, LOW);
      }
      if (boost >= 0) // Set condition for bargraph to show above zero (negative numbers cause LCD crash)
      {
        lcd.setCursor(9, 2);
        lcd.print(boost, 1); // Prints the boost figure
        lcd.setCursor(14, 2);
        lcd.print("Boost "); // Prints 'psi' with a space after it to clear the 'g' off 'inHg'
        lbg1.drawValue(barboost, 700); // Draw bar graph from the analog value read with a maxvalue of 500
      }
    
    
      if (boost < 0)
      {
        lcd.setCursor(9, 2);
        lcd.print(vac, 1); // Prints the vacuum figure
        vac = boost * -2.036025; // Used 'minus' 2.036025 so that the figure printed wont have a minus symbol in front of it
        lcd.setCursor(14, 2);
        lcd.print("Vaccum"); // Changes the units to 'inHg' on the lcd
        lcd.setCursor(0, 1);
        lcd.print(" "); // clears the boost bar if any characters are left after going below 0
      }
    
    
      if (boost > peak) // If current boost is higher than peak, store new value
      {
        peak = boost ; // Store new peak value in peak memory
      }
    
    
      lcd.setCursor(9, 3);
      lcd.print(peak, 1); // Prints the peak value
    } //end loop

    0 Not allowed! Not allowed!
    Τελευταία επεξεργασία από το χρήστη Kernel Panic : 31-01-18 στις 10:19

  9. #9
    Μέλος
    Όνομα
    george
    Εγγραφή
    Jun 2005
    Περιοχή
    ΤΡΙΚΑΛΑ
    Μηνύματα
    421

    Προεπιλογή

    καλησπερα και παλι και καλο μηνα σε ολους.τελικα το προβλημα λυθηκε.εφταιγε η βιβλιοθηκη που χρησημοποιουσα η (LcdBarGraph.h).εγω ειχα εγκαταστησει την LcdBarGraph-1.0 ενω ηθελε την LcdBarGraph-1.3.μολις την αλλαξα δουλεψε αμεσως.
    σας ευχαριστω παντως ολους ηταν προθυμοι να βοηθησουν

    0 Not allowed! Not allowed!

  10. #10
    Μέλος
    Όνομα
    george
    Εγγραφή
    Jun 2005
    Περιοχή
    ΤΡΙΚΑΛΑ
    Μηνύματα
    421

    Προεπιλογή

    επισης ηθελα να ρωτησω πως μπορω να μετατρεψω την ενδειξη απο psi σε bar????ξερω οτι μπορει να εχω γινει κουρατσικος,αλλα η αληθεια ειναι οτι δεν γνωριζω απο προγραμματισμο arduino.η σχεση μου με το arduino ειναι φτιαχνω το κυκλωμα,copy-paste το προγραμμα και αντε να κανω καποιες ψιλοαλλαγες
    ευχαριστω

    0 Not allowed! Not allowed!

Σελίδα 1 από 2 1 2 ΤελευταίαΤελευταία

Παρόμοια Θέματα

  1. μπαρομετρο αυτοκινητου με arduino ...
    By gourtz in forum Μικροελεγκτές
    Απαντήσεις: 10
    Τελευταίο Μήνυμα: 01-09-15, 12:08
  2. ήχος αυτοκινήτου!!!
    By Μάμουλας in forum Car Audio & Theater
    Απαντήσεις: 3
    Τελευταίο Μήνυμα: 01-07-11, 12:55
  3. ψηφιακο μπαρομετρο αυτοκινητου
    By G.POL in forum Κυκλώματα για Auto & Moto
    Απαντήσεις: 15
    Τελευταίο Μήνυμα: 17-05-10, 12:35

Δικαιώματα - Επιλογές

  • Δημιουργία θεμάτων: Όχι
  • Υποβολή μηνυμάτων: Όχι
  • Σύναψη αρχείων: Όχι
  • Επεξεργασία μηνυμάτων: Όχι
  •  
  • BB code: σε λειτουργία
  • Smilies: σε λειτουργία
  • [IMG]: σε λειτουργία
  • [VIDEO] code is σε λειτουργία
  • HTML: εκτός λειτουργίας