Show Posts
|
|
Pages: [1] 2
|
|
1
|
Using Arduino / Displays / Re: Graphic LCD Double text problem
|
on: February 03, 2013, 04:44:11 am
|
|
Ok, thanks for reply,
i am agree with you that both chips receiving the same info, but i am sure that CS1 and CS2 are not connected together and it works with the demo program !
Please, do you have other idea ?
|
|
|
|
|
2
|
Using Arduino / Displays / Graphic LCD Double text problem
|
on: February 02, 2013, 06:27:24 pm
|
Hello, thanks for this great forum !!! i'm running a 128x64 Graphic LCD with a Arduino MEGA 2560, and i try to make lines of text display on the screen, Everything works fine with the demo Program, but with my program everything is displayed 2 times this is a part of my program. thanks #include <glcd.h> #include "fonts/Arial14.h" // proportional font #include "fonts/SystemFont5x7.h" // system font
void setup() { GLCD.Init(); // initialise the library, non inverted writes pixels onto a clear screen }
void loop(){ GLCD.ClearScreen(); GLCD.SelectFont(System5x7); GLCD.Puts("PROGRAMME"); GLCD.CursorTo (0 , 1); GLCD.Puts ("HEAT V1.06"); delay (2000); }
|
|
|
|
|
3
|
Using Arduino / Sensors / Nano and float bas result
|
on: December 16, 2012, 09:09:12 am
|
|
Hello,
i"m here to ask for a bad result of float data acquisition on NANO Card.
I'm acquiring, with PulseIn(), the lenght (in µS) of a square wave impulsion.
Next i want to transform it to Second.
The problem is that the Float variable is limited at 0,001, no more decimals available.
I also, tried with Double, and get the same problem.
--> Do you know how to increase the decimal numbers.
thanks
Olivier
|
|
|
|
|
6
|
Using Arduino / Programming Questions / DS1307 SPI incorrect values
|
on: October 25, 2011, 12:26:25 am
|
Hi, i can't find solution at my problem, maybe someone coud help me ! I'm running with an arudino MEGA2560, DS1307 is connected via I2C, SD Card is connected to SPI. On the first code, it is a function to acquire date on RTC DS1307 (date and time variables are declared as byte) On the second part of code, it a a string arrangement to send values to SD CARD file. For date and time values, the data sent to the file are always "10", i can't have the real date and time values, i'm sure that the DS1307 is giving good informations (it's working with demo program) I feel that the problem is in string arrangement with date/time variable format. Please can you help me ? Thanks void getDateDs1307() { // Reset the register pointer Wire.beginTransmission(0x68); Wire.send(0); Wire.endTransmission(); Wire.requestFrom(0x68, 7); second = bcdToDec(Wire.receive() & 0x7F); minute = bcdToDec(Wire.receive()); hour = bcdToDec(Wire.receive() & 0x3F); // Need to change this if 12 hour am/pm dayOfWeek = bcdToDec(Wire.receive()); dayOfMonth = bcdToDec(Wire.receive()); month = bcdToDec(Wire.receive()); year = bcdToDec(Wire.receive()); Serial.print(hour,DEC); Serial.print(":"); Serial.print(minute,DEC); Serial.print(":"); Serial.print(second,DEC); Serial.print(" "); Serial.print(dayOfMonth,DEC); Serial.print("/"); Serial.print(month,DEC); Serial.print("/20"); Serial.print(year, DEC); Serial.println(); }
getDateDs1307();
dataString = "*** "; // *** sur la chaine de caractères dataString += commentaire; // Ajout de la chaine commentaire dans la chaine de caractères dataString += "***"; // *** sur la chaine de caracteres dataString += ";"; dataString += hour; dataString += ":"; dataString += minute; dataString += ":"; dataString += (second,DEC); dataString += ";"; dataString += (dayOfMonth,DEC); dataString += "/"; dataString += (month,DEC); dataString += "/20"; dataString += (year,DEC);
|
|
|
|
|
7
|
Using Arduino / Networking, Protocols, and Devices / Re: DS1307 problems
|
on: October 24, 2011, 04:01:03 pm
|
Thank you PaulS, it works fine ! You tips was the right one ! Following, i found why my DS1307 was not working, i was missing Wire.begin() inside setup ! Now i still have a last problem before running my Arduino on heater: On the first code, it is a function to acquire date on RTC DS1307 (date and time variables are declared as byte) On the second part of code, it a a string arrangement to send it to SD CARD file. The data sent to the file are always "10", i can't have the real date and time values, i'm sure that the DS1307 is giving good informations. I feel that the problem is in string arrangement with date/time variable format. Please can you help me ? Thanks void getDateDs1307() { // Reset the register pointer Wire.beginTransmission(0x68); Wire.send(0); Wire.endTransmission(); Wire.requestFrom(0x68, 7); second = bcdToDec(Wire.receive() & 0x7F); minute = bcdToDec(Wire.receive()); hour = bcdToDec(Wire.receive() & 0x3F); // Need to change this if 12 hour am/pm dayOfWeek = bcdToDec(Wire.receive()); dayOfMonth = bcdToDec(Wire.receive()); month = bcdToDec(Wire.receive()); year = bcdToDec(Wire.receive()); Serial.print(hour,DEC); Serial.print(":"); Serial.print(minute,DEC); Serial.print(":"); Serial.print(second,DEC); Serial.print(" "); Serial.print(dayOfMonth,DEC); Serial.print("/"); Serial.print(month,DEC); Serial.print("/20"); Serial.print(year, DEC); Serial.println(); }
getDateDs1307();
dataString = "*** "; // *** sur la chaine de caractères dataString += commentaire; // Ajout de la chaine commentaire dans la chaine de caractères dataString += "***"; // *** sur la chaine de caracteres dataString += ";"; dataString += hour; dataString += ":"; dataString += minute; dataString += ":"; dataString += (second,DEC); dataString += ";"; dataString += (dayOfMonth,DEC); dataString += "/"; dataString += (month,DEC); dataString += "/20"; dataString += (year,DEC);
|
|
|
|
|
8
|
Using Arduino / Networking, Protocols, and Devices / Re: DS1307 problems
|
on: October 23, 2011, 12:27:13 pm
|
Hi PaulS, thanks for helping me, my problem is with this part of code. First, during serial connection, i write C with text after and sending to Arduino. Arduino needs to read each character, adding the current date/time and write them inside SD file AND send the String to the serial. The string sended to Arduino by Serial is for example: CAAA, but when arduino send it back to Serial, it sends 656565. So i would him to send AAA. Please help me, Regards if (command == 'C') // Si le caractère C est envoyé { int chrserial = 0; String dataString = ""; String commentaire = ""; for (int i=0 ; i<10 ; i++){ chrserial = Serial.read (); // Lecture du commentaire sur le port série commentaire += chrserial; } dataString = "*** "; // *** sur la chaine de caractères dataString += (commentaire); // Ajout de la chaine commentaire dans la chaine de caractères dataString += "***"; // *** sur la chaine de caracteres File dataFile = SD.open("data00.csv", FILE_WRITE); // Ouverture du fichier Data00/csv sur la carte SD if (dataFile) { // Si le fichier existe dataFile.println(dataString); // Ecriture de la chaine de caractères dataFile.close(); // Fermeture du fichier dans la carte SD Serial.println ("Commentaire ajouté :"); // Envoi sur le porte série du résultat Serial.print (commentaire); // Envoi sur le porte série du commentaire ajouté }
|
|
|
|
|
9
|
Using Arduino / Networking, Protocols, and Devices / Re: DS1307 problems
|
on: October 23, 2011, 10:45:22 am
|
|
Sorry,
i forgot to tell you, that i'm using Arduino Mega 2560, I2C connected to 20 et 21 (I2C SDA/SCL). I'm sure it is a syntax problem, because when using DS1307 demo program, all is functionning ok !
For ASCII, i tried what you tell Serial.print(Val,DEC), but it continue giving a A as 65.
Please let me know
Olivier
|
|
|
|
|
10
|
Using Arduino / Networking, Protocols, and Devices / DS1307 problems
|
on: October 23, 2011, 08:53:35 am
|
Hi, i'm neewby on arduino, so please i need help, It is a datalogger with Analog senders, RTC DS1307 on SPI bus and SD Card --> I can't make the Date/time functionning when building the String for SD File --> I can't make the caracters sended to Serial being "A" and not 65, i feel that's is ASCII form, but i don't know how to convert it ! If someone have ideas, please, let me know ! Thanks #include <SD.h> #include "Wire.h" #define DS1307_I2C_ADDRESS 0x68 // This is the I2C address #include <LiquidCrystal.h> /* The circuit: * LCD RS pin to digital pin 8 * LCD Enable pin to digital pin 3 * LCD D4 pin to digital pin 4 * LCD D5 pin to digital pin 5 * LCD D6 pin to digital pin 6 * LCD D7 pin to digital pin 7 * SD MISO to digital pin 50 * SD MOSI to digital pin 51 * SD SCK to digital pin 52 * SD SS to digital pin 53 * Led to digital pin 32 * Bouton to digital pin 30 */ int command = 0; // Déclaration de la variable de stockage de la commande envoyée par le port série int i; byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; // déclaration des variables de stockage de la date et heure const int buttonPin = 30; // Declaration du port E/S du bouton const int ledPin = 32; // Declaration du port E/S de la led de statut int buttonState = 0; // variable de stockage du statut du bouton
byte decToBcd(byte val) // Conerti les nombres décimaux en nombres binaires codés en décimal { return ( (val/10*16) + (val%10) ); } byte bcdToDec(byte val) // Converti les nombres binaires codés decimal en nombres décimaux normaux { return ( (val/16*10) + (val%16) ); } void Print2Digit(byte Val) { if (Val < 10) { Serial.print("0"); } Serial.print(Val, DEC); }
// Gets the date and time from the ds1307 and prints result void getDateDs1307() { // Reset the register pointer Wire.beginTransmission(DS1307_I2C_ADDRESS); Wire.send(0x00); Wire.endTransmission(); Wire.requestFrom(DS1307_I2C_ADDRESS, 7); // A few of these need masks because certain bits are control bits second = bcdToDec(Wire.receive() & 0x7F); minute = bcdToDec(Wire.receive()); hour = bcdToDec(Wire.receive() & 0x3F); // Need to change this if 12 hour am/pm dayOfWeek = bcdToDec(Wire.receive()); dayOfMonth = bcdToDec(Wire.receive()); month = bcdToDec(Wire.receive()); year = bcdToDec(Wire.receive()); Serial.print ("flag"); Serial.println (second); Print2Digit(hour); Serial.print(":"); Print2Digit(minute); Serial.print(":"); Print2Digit(second); Serial.print(" "); PrintDayName(bcdToDec(dayOfWeek)); Serial.print(" "); Print2Digit(dayOfMonth); Serial.print("-"); PrintMonthName(bcdToDec(month)); Serial.print("-20"); Serial.print(year, DEC); Serial.println(); }
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(8,3, 4,5,6,7); int sensorcorr = 0; int Val7 = 0; int analogPin = 0; int sensor = 0;
void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); Serial.begin(9600); const int chipSelect = 53; Serial.print("Init. SD Card..."); pinMode(53, OUTPUT); // see if the card is present and can be initialized: if (!SD.begin(chipSelect)) { Serial.println("Carte muette ou absente"); // don't do anything more: return; } Serial.println("carte initialisee."); pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop() { buttonState = digitalRead(buttonPin); // Vérifie l'état du bouton 30 est appuyé if (buttonState == HIGH) { // Si le bouton est appuyé // turn LED on: digitalWrite(ledPin, HIGH); // Allumage de la Led 32 Logging(); } else { digitalWrite(ledPin, LOW); // Extinction de la led 32 int commentaire = 0; if (Serial.available()) // Vérifie si la connexion Série est disponible { command = Serial.read(); // lecture de la commande série if (command == 'T') // Si le caractère T est envoyé alors { setDateDs1307(); // Lance la fonction SetDateDs1307() Serial.println("Set time OK"); // Envoi sur le porte série Serial.println(); // Envoi saut de ligne sur le port Série getDateDs1307(); // Envoi la date et l'heure courante sur le port série } if (command == 'C') // Si le caractère C est envoyé { int chrserial = 0; String dataString = ""; String commentaire = ""; for (int i=0 ; i<10 ; i++){ chrserial = Serial.read (); // Lecture du commentaire sur le port série commentaire += chrserial; } dataString = "*** "; // *** sur la chaine de caractères dataString += (commentaire); // Ajout de la chaine commentaire dans la chaine de caractères dataString += "***"; // *** sur la chaine de caracteres File dataFile = SD.open("data00.csv", FILE_WRITE); // Ouverture du fichier Data00/csv sur la carte SD if (dataFile) { // Si le fichier existe dataFile.println(dataString); // Ecriture de la chaine de caractères dataFile.close(); // Fermeture du fichier dans la carte SD Serial.println ("Commentaire ajouté :"); // Envoi sur le porte série du résultat Serial.print (commentaire); // Envoi sur le porte série du commentaire ajouté } } } } lcd.clear(); // Effacement afficheur Val7 = analogRead(A7); // lecture voie analogique 7A7
lcd.setCursor(0,0); // Positionnement curseur à ligne 0, colonne 0 lcd.print("Maison:"); // Affichage sur le LCD "Maison" Val7 = Val7/2; // Conversion de la valeur Maison lcd.setCursor (7,0); // Positionnement curseur à la ligne 0, colonne 7 lcd.print(Val7); // Affichage de la valeur de A7 }
void Logging(){ // Sub routine Logging getDateDs1307(); // Affichage de la date et heure courant delay(1000); String dataString = "" ; // Confection du String pour enregistrement dans le fichier dataString +=" "; dataString +=";"; dataString += (hour,DEC); dataString += ":"; dataString += (minute,DEC); dataString += ":"; dataString += (second,DEC); dataString += ";"; dataString += (dayOfMonth,DEC); dataString += "/"; dataString += (month,DEC); dataString += "/"; dataString += (year,DEC); dataString += ";"; dataString += Val7; File dataFile = SD.open("data00.csv", FILE_WRITE);
// if the file is available, write to it: if (dataFile) { dataFile.println(dataString); dataFile.close(); // print to the serial port too: Serial.println(dataString); } // if the file isn't open, pop up an error: else { Serial.println("impossible d'ouvrir data00.csv"); } }
|
|
|
|
|
11
|
Using Arduino / Programming Questions / Re: Wireless Serial Array problem
|
on: September 02, 2011, 10:49:22 am
|
Hi, this code sounds good, value printed on screen is ok, but now, the code following the Serial comm. does not work properly (check for buttons), and the code joined is not working, variable rollTR is not shown on screen, do you know how to get printed, on screen, Gite "rollTR variable" ? Thanks MenuItem roll = MenuItem("Gite " , rollTR);
|
|
|
|
|
14
|
Using Arduino / Programming Questions / Re: Wireless Serial Array problem
|
on: August 31, 2011, 11:37:14 am
|
hi, thanks for reply, i tried this code: but the code received on lcd, is one number after one number, i really need to extract the prefix and the value, wish you got idea, because i'm lost ! Thanks prefix = 0; if (Serial1.available() > 0) { // get incoming byte: delay(5); //i=1; //while(i<6){ myStr = Serial1.read(); // i++; // Serial1.print(myStr[5]); lcd.setCursor(1,1); lcd.print(myStr , BYTE);
|
|
|
|
|
15
|
Using Arduino / Programming Questions / Wireless Serial Array problem
|
on: August 30, 2011, 03:42:36 pm
|
Hi, This is a RC Model Submarine, this section is for wireless diagnostic ! I need help on how to make my wireless communication working: Wireless transmission by APC220 between 2 Arduino MEGA, Operations: I need, when the data arrive (2 numbers for prefix and 3 numbers for data), to be treated corresponding to the header value for exemple: 01200 - No treatement at all ! - No variables printed beside menuItems, for example ( gite 200) - The program is always on serial receive, and it is not possible to navigate through the menus. - When navigation will be possible, i need a little temporisation between menu items when navigating - Do the Serial Buffer is cleaned automatically ? Many thanks for who can help me Regards (Some parts of menus have been removed (9500 characters maximum on forum) #include <MenuBackend.h> #include <LiquidCrystal.h>
int secoursTR = 0, periscopeTR = 0, lampeTR = 0, sigsurfaceTR = 0, ledTR = 1, cdebarresavTR = 0, tiltbarresavTR = 0, cdeevballastTR = 0, powerTR = 0; int prefix = 0,value = 0; int sigairtankTR = 0, emergencyTR = 0, sigtempmotTR = 0, sigtempcompTR = 0, ppmbarresTR = 0; int lestTR = 0, cdecaisseavTR = 0, cdecaissearTR = 0, sigballastfullTR = 0, waterTR = 0, compgTR = 0, compdTR = 0, airpowerTR = 0; int cdewatpumpTR = 0, cdeinvpumpTR = 0, rollvar = 0, ballastinTR = 0, ballastoutTR = 0; int opentrapTR=0; // Temporisation de vidange du ballast int menugval = 0, validval = 0, menudval = 0, outval = 0, menuval = 0; // Definition des variables de pilotage du menu long voie1TR = 0, voie3TR= 0, voie5TR = 0, voie6TR = 0, voie7TR = 0; int pitchTR = 0, rollTR = 0, sigprofTR = 0, siglampeTR = 0; int timetorpTR = 0 , timemissTR = 0 , maxtempTR = 0 , maxprofTR = 0 , sinkadjustTR = 0; int pressureTR = 0; const int pressurepin = 8; int myStr[5]; int i = 0; int touche = 0, ad0val = 0; const int ad0pin = 0;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
MenuBackend menu = MenuBackend(menuUseEvent,menuChangeEvent);
MenuItem systeme = MenuItem("Systeme"); MenuItem serial = MenuItem("View Serial", value); MenuItem tester = MenuItem("TESTER"); MenuItem roll = MenuItem("Gite " , rollTR); MenuItem pitch = MenuItem("Pitch " , pitchTR); MenuItem sigtempmot = MenuItem("Temp Moteur " ,sigtempmotTR); MenuItem sigtempcomp = MenuItem("Temp Compr " , sigtempcompTR); MenuItem sigprof = MenuItem("Profondeur " , sigprofTR); MenuItem sigsurface = MenuItem("Capt Surf " , sigsurfaceTR); MenuItem lampe = MenuItem("Lampe " , siglampeTR); MenuItem secours = MenuItem("Ballon " , secoursTR); MenuItem periscope = MenuItem("Periscope " , periscopeTR); MenuItem led = MenuItem("Led: " , ledTR); MenuItem cdebarresav = MenuItem("Bar AV R/S " , cdebarresavTR); MenuItem tiltbarresav = MenuItem("Bar AV Tilt" , tiltbarresavTR); MenuItem cdeevballast = MenuItem("EV Ballast " , cdeevballastTR);
MenuItem reglages = MenuItem("REGLAGES"); MenuItem timetorp = MenuItem("Duree Torp" , timetorpTR); MenuItem timemiss = MenuItem("duree miss" , timemissTR); MenuItem maxtemp = MenuItem("Temp Max" , maxtempTR); MenuItem maxprof = MenuItem("Prof. max" , maxprofTR); MenuItem sinkadjust = MenuItem("Cal. Plongee" , sinkadjustTR);
void setup() { Serial1.begin(9600); lcd.begin(16,2); menuSetup(); lcd.setCursor(0,0); lcd.print("SUBSOFT V1.04"); establishContact(); // send a byte to establish contact until receiver responds
}
void loop() { prefix = 0; if (Serial1.available() > 0) { // get incoming byte: delay(5); i=1; while(i<6){ myStr[i] = Serial1.read(); i++; // Serial1.print(myStr[5]); lcd.setCursor(1,1); lcd.print(myStr[5]); } prefix = myStr[1] && myStr[2]; value = myStr[3] && myStr[4] && myStr[5]; lcd.setCursor(6,1); lcd.print(value); delay (200); } if (prefix == 'AA') { lcd.setCursor (14,0); lcd.print("OK"); } else { lcd.setCursor(14,0); lcd.print(" "); prefix = 00 ; value = 000; lcd.setCursor(14,0); lcd.print("KO"); delay (100); } switch (prefix) { case 01: rollTR = value; break; case 02: pitchTR = value; break; case 03: sigtempmotTR = value; break; case 04: sigtempcompTR = value; break; case 05: sigprofTR = value; break; case 06: sigsurfaceTR = value; break; } lcd.setCursor(0,1); ad0val = analogRead(ad0pin); if (ad0val >= 110 && ad0val <= 135) { touche = 3; // Touche UP menu.moveUp(); //lcd.setCursor(0,0); //lcd.print("Up"); } else if (ad0val >= 290 && ad0val <= 315) { touche = 4; // Touche DOWN menu.moveDown(); //lcd.setCursor(0,0); //lcd.print("Down"); } else if (ad0val >= 465 && ad0val <= 485) { touche = 1; // touche LEFT menu.moveLeft(); //lcd.setCursor(0,0); //lcd.print("left"); } else if (ad0val >= 0 && ad0val <= 150) { touche = 2; // touche RIGHT menu.moveRight(); //lcd.setCursor(0,0); //lcd.print("Right"); } else if (ad0val >= 700 && ad0val <= 730) { touche = 0; // touche SELECT menu.use(); //lcd.setCursor(0,0); //lcd.print("Use"); } }
void menuSetup() { menu.getRoot().add(tester); //setup the tester menu item //we want a left movement to pint to tester from anywhere reglages.addLeft(tester); tester.addLeft(tester); tester.addBefore(systeme); tester.addAfter(reglages); reglages.addAfter(systeme); systeme.addAfter(tester); reglages.addBefore(tester); tester.addRight(roll); roll.addBefore(emergency); roll.addAfter(pitch); pitch.addAfter(sigtempmot); sigtempmot.addAfter(sigtempcomp); sigtempcomp.addAfter(sigsurface); sigsurface.addAfter(sigprof); sigprof.addAfter(lampe); lampe.addAfter(periscope); roll.addLeft(tester); pitch.addLeft(tester); sigtempmot.addLeft(tester); sigtempcomp.addLeft(tester); sigsurface.addLeft(tester); sigprof.addLeft(tester); lampe.addLeft(tester); periscope.addLeft(tester); secours.addLeft(tester); led.addLeft(tester); cdebarresav.addLeft(tester); tiltbarresav.addLeft(tester); cdeevballast.addLeft(tester); power.addLeft(tester);
void establishContact() { while (Serial1.available() <= 0) { Serial1.print('AA', BYTE); // send a capital A delay(300); } }
|
|
|
|
|