Sursa de tensiune liniară (bazat pe LM317) - Afișor de tensiune (7)

Afișor de tensiune

Afișorul de tensiune a început sa prindă contur dar cu foarte multe piedici, ba se strica una, ba se strica alta. În momentul acesta placa funcționează și controlerul dă toate semnalele către LCD, dar acesta refuza sa funcționeze. Cred că s-a paradit ceva în integratul de pe placa LCD-ului. O să mai dureze un pic până o să cumpăr altul. Până atunci o să pun la punct soft-ul. Afișorul arată cam așa în momentul acesta:

Afișorul de tensiune a început sa prindă contur dar cu foarte multe piedici, ba se strica una, ba se strica alta. În momentul acesta placa funcționează și controlerul dă toate semnalele către LCD, dar acesta refuza sa funcționeze. Cred că s-a paradit ceva în integratul de pe placa LCD-ului.


Software

Iar software-ul de inițializare și control LCD bazat pe soft-ul arduino arată cam așa:


// include the library code:
#include "LiquidCrystal.h"

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Pin 7 has an LED connected on most Arduino boards.
// give it a name:
int ledLow = 7;
int ledTest = 8;
int voltajValue = 0;  // variable to store the value coming from voltage
int voltajPin = A0;    // select the input pin for the voltage

const int R1 = 3000; // value for a maximum voltage of 20 volts
const int R2 = 1000;
// determine by voltage divider resistors, see text
const int resistorFactor = 255 / (R2/(R1 + R2));
const int batteryPin = 0; // +V from battery is connected to analog pin 0

// the setup routine runs once when you press reset:
void setup() {    
  Serial.begin(9600);  
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Voltmetru v1.0");
  // initialize voltage pin
  pinMode(voltajPin, INPUT);
  // initialize the digital pin as an output.
  pinMode(ledLow, OUTPUT);    
  // initialize the digital pin as an output.
  pinMode(ledTest, OUTPUT);  
  delay(500);               // wait for a second
}

// the loop routine runs over and over again forever:
void loop() {
  float volts;
  lcd.setCursor(0, 0);
  lcd.print("Voltaj masurat: ");  
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);

  voltajValue = analogRead(voltajPin);

  Serial.println(voltajValue ); // print the raw value 
  
  lcd.print(voltajValue);
  lcd.setCursor(0, 1);
  
  SetToHigh(ledTest);  // turn the LED on (HIGH is the voltage level)    
  SetToLow(ledTest);   // turn the LED off by making the voltage LOW  
}


void SetToHigh(int led)
{
  digitalWrite(led, HIGH); // turn the LED off by making the voltage LOW
  delay(500);              // wait for a second
}
void SetToLow(int led)
{
  digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
  delay(500);             // wait for a second
}

Conexiunile circuitului

Circuitul LCD se leagă la placa bazată pe Arduino pe următorii pini:
- LCD RS pin to digital pin 12
- LCD Enable pin to digital pin 11
- LCD D4 pin to digital pin 5
- LCD D5 pin to digital pin 4
- LCD D6 pin to digital pin 3
- LCD D7 pin to digital pin 2
- LCD R/W pin to ground
- 10K resistor:
- ends to +5V and ground
- wiper to LCD VO pin (pin 3)

Sper sa nu fi greșit nimic. Deocamdată soft-ul ar trebui sa afișeze valoarea neprocesată a voltajului citit pe pinul analog A0. În postul următor o sa calculez rezistentele și o sa vedem ce iasă.
O seară faină tuturor.

Etichete

Afișați mai multe

Arhiva

Afișați mai multe