Show Posts
Pages: 1 2 [3] 4 5 ... 25
31  International / Français / Re: Comment incrémenter ceci 0x0100 on: September 25, 2013, 04:08:40 am
Oui tu as raison, mais je ne suis pas expert en EEPROM. En fait c'est la premiere fois que j'utilise un EEPROM et je suis passé par la décourte pour en arrivé.

Je suis arrivé aussi à cette déduction. 2h c'est suffisant pour l'useage que je veux en faire. même si j'exploite mal la mémoire.

L'aventage que je vois dans cette manière de faire, c'est que je sais exactement ou son mes informations, par minutes.

Pour le moment je ne vois pas comment faire mieux, avec mes connaissances, mais je n'exclu pas une maélioration en deuxième temps, quand j'aurais acquis plus de connaissances...

Mais merci pour cette remarque qui est juste.
32  International / Français / Re: Comment incrémenter ceci 0x0100 on: September 24, 2013, 09:30:19 am
Bonjour,¨

Je suis toujours bloqué avec ceci. Du moins j'ai une solution, mais j'en suis pas convaicnu.
Si vous pour m'en convaincre ou me dire comment vous le feriez mieux.

En résumé et pour rappel
Je defini la position des enregustrement longitude, latitude, altitude etc
Code:
// 24LC236
#define EPROM_COU 0x0001
#define EPROM_LON 0x0008 // 8 en dec
#define EPROM_LAT 0x0018 // 24 en dec
#define EPROM_ALT 0x0028 // 40 en dec
#define EPROM_TIM 0x0038 // 56 en dec
#define EPROM_VEL 0x0048 // 72 en dec
#define EPROM_STA 0x0058  // 88 en dec
#define EPROM_INC 0x0100  // Incrementation
unsigned int mask=0x0000;
const byte rom = 0x50;    // Address of 24LC256 eeprom chip
char data[15];

Puis en suite , je dois trouver un truc pour que lorsque la fonction GetGPS() est appelée la deuxieme fois, il enregistre ces positions aux positions incrémentée de 0x0100, par exemple
Quote
course à l'adresse 0x0101
lontitude à la position 0x0108
latitude à la position 0x0118
altitude à la position 0x0128
etc
Puis quand elle sera appelée la troisème fois, ca serait ca
Quote
course à l'adresse 0x0201
lontitude à la position 0x0208
latitude à la position 0x0218
altitude à la position 0x0228
etc
et aindi de suite

J'ai donc trouvé cette solution. Comme pourriez-vous faire mieux, comment feriez-vous
Code:
char cou[15];
char lon[15];
char lat[15];
char alt[15];
char time[14];
char vel[6];
char sta[2];

// 24LC236
#define EPROM_COU 0x0001
#define EPROM_LON 0x0008 // 8 en dec
#define EPROM_LAT 0x0018 // 24 en dec
#define EPROM_ALT 0x0028 // 40 en dec
#define EPROM_TIM 0x0038 // 56 en dec
#define EPROM_VEL 0x0048 // 72 en dec
#define EPROM_STA 0x0058  // 88 en dec

#define EPROM_INC 0x0100  // Incrementation
unsigned int mask=0x0000;
const byte rom = 0x50;    // Address of 24LC256 eeprom chip

setup(){
 Serial.begin(9600);
  Wire.begin ();
}

loop(){
GetGPS();
delay(60000);
}

GetGPS(){
         
          gps.getPar(lon,lat,alt,time,vel);

        // first time mask is egual to 0x0000 then it will be recorded at position 0x0001
        // next time , mask is equla to 0x0100, then it will be recorded at position 0x0101
        // next time, mask is equal t0 0x0200, then it will be recorded at position 0x0201
        writeEEPROM(rom,mask+EPROM_COU,cou); // No worries about the value of cou, it's work
       // EPROM_LON will inrement as for EPROM_COU, etc
        writeEEPROM(rom,mask+EPROM_LON,lon);
        writeEEPROM(rom,mask+EPROM_LAT,lat);
        writeEEPROM(rom,mask+EPROM_ALT,alt);
        writeEEPROM(rom,mask+EPROM_TIM,tim);
        writeEEPROM(rom,mask+EPROM_VEL,vel);
        writeEEPROM(rom,mask+EPROM_STA,sta); // No worries about the value of sta, it's work, it not my worries

       mask = mask+EPROM_INC;
       // Incrment mask as the folowing 0x0100, 0x0200, 0x0300, 0x0400 .... 0x1100, 0x1200.. etc

}
How would you to bette, to increment the 2 digit of the hexa.

Was I clear to undertand, my wories?
33  Using Arduino / Programming Questions / Re: How use a hexa as a mask on: September 22, 2013, 05:24:19 pm
Dear Michael

You structure example was very clear and it's hihlight me for a different question I has previously.

Thank

However, even if I understood you, regarding
Code:
bool a=0;
bool b=1
a|=b
a = a|b // Equivalent
a will dsiplay 1

But I am still confused about. I am going to ask my question and comment in CAPITAL

Code:
unsigned int obj;

#define OBJ_BIG       0x1 // THIS EGAL TO 1
#define OBJ_BLACK 0x2 // THIS EGAL TO 2
#define OBJ_ODD     0x4 // THIS IS EGAL TO 4

// ...

if (object_is_big) {
    obj |= OBJ_BIG;          // mark that the object is big
  // THIS IS THE EQUIVALENT OF obj = obj | OBJ_BIG, OR obj = 0|1 (0 because it's not defined yet, and 1 because 0x1)
  // SO AT THE END, OBJ WILL HAVE THE VALUE OF 1
  // CAN WE NOT SIMPLY WRITE obj = true;?
}

if (object_is_white) {
    obj &= ~OBJ_BLACK;   // clear the black mask
   // HERE OBJ_BLACK HAVE THE VALUE OF 2, BUT IT'S CLEARED TO 0 BECAUSE OF ~
  // THEN obj IS EQUAL TO 0 BECAUSE WE CAN WRITE THE EQUIVALENCE OF obj = obj&OBJ_BLACK OR obj = 0&0
  // BUT CAN WE NOT WRITE SIMPLY obj = false
}

if (object_is_seen) {
    obj ^= OBJ_ODD;
}

But after all of you nice explication, does it really ask to my need? Or may be I have to be sorry, if I have not undertood a part!

At each loop (loop()), the function GetGPS is call and I wish to store the position in a postion of my EEPROM.

So at position
Quote
0x0008 => course
0x0018 => longitude
0x0028 => latitude
0x0038 => altitude
0x0048 => time
0x0058 => speed
0x0068 => stat
and the 2nd position of hexa digit must be incremented, each time GetGPS() is called. It's the reason why I am trying to use a "mask" of 0x0100

Quote
0x0108 => course
0x0118 => longitude
0x0128 => latitude
0x0138 => altitude
0x0148 => time
0x0158 => speed
0x0168 => stat
Quote
0x0208 => course
0x0218 => longitude
0x0228 => latitude
0x0238 => altitude
0x0248 => time
0x0258 => speed
0x0268 => stat

For example
Code:
#define EPROM_COU 0x0008
#define EPROM_INC 0x0100 // Incrementation
const int mask = 0x0000;
void GetGPS(){
[...]
writeEEPROM(rom,mask+EPROM_COU,course_id); // here, the second parameter should be equal to 0x00ii, then 0x01ii, then 0x03ii, then 0x04ii, etc
mask = mask+EPROM_INC; // Here mask should 0x0100, then 0x0200, then 0x0300, etc
[...]
}

But in the same time, I will think how to use structure, but I think, at the end, I have to answer to the same problem, how to increment the 2nd digit of the hexa for the second loop...
 smiley
34  Using Arduino / Programming Questions / Re: How use a hexa as a mask on: September 21, 2013, 01:37:41 pm
Dear Michael,

I am going to read carefully to your post, but before all, I would like to thank you for time you took for explication and example

It very nice to "meet" people who take this time

Cheers
35  Using Arduino / Programming Questions / Re: How use a hexa as a mask on: September 20, 2013, 03:06:45 pm
my goal is record some set

at 0x00ii at the first loop.
at 0x01ii at the 2nd loop
at 0x02ii at the third loop
at 0x03ii at the 4th loop

etc

"ii" being 08,18,28,38,48 depending of the subjetc (LAT, LON, ALT etc

36  Using Arduino / Programming Questions / Re: How use a hexa as a mask on: September 20, 2013, 03:01:55 pm
Dear Michael,

Your example is interresting but I do not understand a part.
Code:
// Set mask EPROM_INC in state
state |= EPROM_INC;
I miss skills, if EPROM_INC is 0x0100, state will be 1 or 0x0100 as well? |= is lake to copy a value to another variable? I0ve never see |
Code:
// clear EPROM_INC in state
state &= ~EPROM_INC;
I also never see this &= ~. And what do you mean by clearing. EPROM_INC must keep its value as it was a const
Code:
// do action if mask is set
if ((state & EPROM_INC) != 0)  { ... }
In Above condition, EPROM_INC will never be egal to 0, it will always be 0x0100, or may 0x0200...
Code:
// do action if mask is not set
if ((state & EPROM_INC) == 0) { ... }
idem
37  Using Arduino / Programming Questions / Re: How use a hexa as a mask on: September 20, 2013, 02:32:04 pm
Hello, thank for your answer and example.

May be I used a bad word with mask. I called "mask" because is going to be "applay" to a value, increment the 2nd digit. But it true, it's more an incrementation.
38  Using Arduino / Programming Questions / Re: How use a hexa as a mask on: September 19, 2013, 05:06:44 pm
Hello

Thank for your answer. It's look really better and it helps
I changed like this

Code:
// THIS WILL INCREMENT THE MASK
#define EPROM_INC 0x0100

#define EPROM_LAT 0x0008

unsigned int result;

// THIS IS A MASK
unsigned int mask = 0x0000;

mask = mask+EPROM_INC;

result = mask+EPROM_LAT;

We are agree, that now result will be 0x0108?

I will do better test tomorrow that I can not do right now.


0x0008 represente a position in the EEPROM to record a value.
This value change and it's important that the new value is recorded at
0x0108. And the next is recorded at
0x0208, and the next is recorded at
0x0308 etc....

(there will have a loop for the that)

Thank a lot
39  Using Arduino / Programming Questions / How use a hexa as a mask on: September 19, 2013, 04:38:41 pm
Dear All,

I am trying to increment a hexa

Code:
// THIS WILL INCREMENT THE MASK
#define EPROM_INC 0x0100

#define EPROM_LAR 0x0008
byte result;

// THIS IS A MASK
byte mask = 0x0000;

mask = mask+EPROM_INC; // MASK SHOULD BE 0x0100

result = mask+EPROM_LAR; // RESULT SHOULD 0x0108 but apparently the operation does not works as I expected

Following my example, maks should be egal to 0x0100?

and "result" should be 0x0108

How can I use a mask to change the value of a hexa?
How could you correct me?

many thnak

Cheers
40  Using Arduino / Programming Questions / Re: How to return a char from a function on: September 19, 2013, 03:50:42 pm
Ok this clear. I was hesitating to so like this, but I am bit surpise we can not return a char while we can do with a bit. It a point I do not undertand, but let change regarding to your example.

I am going to try and test

Cheers
41  International / Français / Re: Comment incrémenter ceci 0x0100 on: September 19, 2013, 03:47:46 pm
Par contre, je suis surpis d'un truc

Code:
#define EPROM_INC 0x0100
byte mask = 0x1100;

mask = mask+EPROM_INC;


mask devrait être egal à
Quote
0x1200
non?

42  Using Arduino / Programming Questions / Re: How to return a char from a function on: September 19, 2013, 03:06:55 pm
Dear all and Tom

Thank for your suggeston but I do not understand your change.
in my example
Code:
char readEEPROM(int deviceaddress, int eeaddress)
{
 
  int i=0;
  Wire.beginTransmission(deviceaddress);
  Wire.write((int)(eeaddress >> 8));   // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();
 
  byte val = EEPROM.read(eeaddress);
  int va = (int)val;
 
  char data[va+1];
 
  Wire.requestFrom(deviceaddress, va);
 
  while(Wire.available()){
   
    data[i] = Wire.read();
    i++;
  }
  data[i]='\0';
 
  Serial.println(data);
  //return datas;

}
Serial.println(data); display exactely what I need, and "data" is a char. So my idea was to return what Serial display
43  Using Arduino / Programming Questions / How to return a char from a function on: September 19, 2013, 01:47:45 pm
Dear All, Good day !  smiley

I have found a function and I am trying to adapt it

Here is the function and I explain in capital letter
Code:
char lat[15];
lat = readEEPROM(rom,0x0008);

char readEEPROM(int deviceaddress, int eeaddress)
{
 
  int i=0;
  Wire.beginTransmission(deviceaddress);
  Wire.write((int)(eeaddress >> 8));   // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();
 
// HERE IT READ THE ARDUINO EEPROM BECAUSE I SAVE THE LENTH OF THE STRING HERE. NO WORRIES ABOUT THIS.
  byte val = EEPROM.read(eeaddress);
  int va = (int)val;
 
  char data[va+1];
 
// HERE IT REQUEST THE DATA FOR THE LENTH OF va
  Wire.requestFrom(deviceaddress, va);
 
//  HERE, AS LONG AS WIRE IS AVAILABLE, IT "FILLUP" THE data VAR. AT THE END WE WILL HAVE THE LONGITUDE, LATITUDE ETC...
  while(Wire.available()){
   
    data[i] = Wire.read();
    i++;
  }
// I TERMINATE WITH \0
  data[i]='\0';
 
 // Serial.println(data);
// I RETURN THE VALUR OF DATA TO HAVE IT IN lat VARIABLE
 return datas;

}

The problem is , my terminal return me
Quote
incompatible type of assignement of 'char' to 'char[15]'

I ask me self if it's because of the lenth of data, which is aleatoiry. By I try to define a lenth of 15, and the problem is the same.
44  Using Arduino / Programming Questions / Re: Can we parse into a XML file with Arduino on: September 19, 2013, 01:15:32 pm
Quote
You seem to have a misunderstanding of what parse means
You are right. Sorry. I do not want to parse, but create an XML format
Quote
In the above code, I know there is an issue. the functon readEEPROM() return a char
I will not continue this Post with this issue. I am going to create a new Post for this problem.

Quote
You simply need to write the appropriate start and end tags manually
Ok then there is no library or some things else.

So I am still a bit worries because coords has a lenth of 87 (char coords[87]smiley-wink
If I want to add to coords 5 set of coordinate, I have to extent the length to 435
If I have to add the xml format, I have to extent the length to xxx. It's a lot, no? It will take a lot of memory?
My sketch code have 25000, and the maximum of arduino is 32000.

No my question, is better to use the function
Code:
if(inet.httpPOST(host, port, path, coords, "Result", 0)){}else{}
for each set of cordinate. The each minute it collect a GPS it will send it.

Or it better to have a large lenth of coords, and send a 5 sets ina XML format?


45  Using Arduino / Programming Questions / Can we parse into a XML file with Arduino on: September 19, 2013, 03:51:13 am
Dear All,

Acrually, I am collecting data and saving it into an EEPROM.
The data is a set of pisition
  • Course
  • Longitude
  • Latitude
  • Altitude
  • Time
  • Spped
  • Stat

I have not test this code yet, but I will past it

Each minutes the a set of GPS coordinate is save into the EEPROM
Each 5 minutes, the 5 sets of coordinate is set to a sevrer . It should send all sets once, this is to avoid 5 connections.
And I am looking how the send the 5 sets in once


Before, how it works,
the void GetGPS() funtion is collection the GPS cordinate each minutes. And exh minute the mask in incremented of 0x0100 (the 1 is representing the inute) . So, at the fift minute, the mask variable is egual at 0x0500;

Code:
byte mask = 0x0000;
define EPROM_INC x0100 // THis is the incrementation

char stat[2];
char lon[15];
char lat[15];
char alt[15];
char time[15];
char vel[15];
char coords[74];
char courseid[6];

// THIS IS CALL EACH 5 MIN:
void SendDATA(void){

  Serial.println(F("Data is going to be collected form EEPROM"));
  // Read and get the pos record from the EEPROM

  // HERE I AM MAKING A LOOP STARTING FROM 0x000 and going to the "mask" VALUE. USUAL , IT SHOULD BE 0x0500
  for(byte xmask = 0x0000; xmask <= mask ; xmask = xmask + EPROM_INC){
    courseid = readEEPROM(rom, xmask+EPROM_COU); // READ THE EPROM AT 0x0008, then READ THE EPROM AT 0x0108, then READ THE EERPOM at 0x0208, etc
    lon = readEEPROM(rom, xmask+EPROM_LON); // READ THE EPROM AT 0x0018, then READ THE EPROM AT 0x0118, then READ THE EERPOM at 0x0218, etc
    lat = readEEPROM(rom, xmask+EPROM_LAT); // READ THE EPROM AT 0x0028, then READ THE EPROM AT 0x0128, then READ THE EERPOM at 0x0228, etc
    alt = readEEPROM(rom, xmask+EPROM_ALT); // READ THE EPROM AT 0x0038, then READ THE EPROM AT 0x0138, then READ THE EERPOM at 0x0238, etc
    time = readEEPROM(rom, xmask+EPROM_TIM); // READ THE EPROM AT 0x0048, then READ THE EPROM AT 0x0148, then READ THE EERPOM at 0x0248, etc
    vel = readEEPROM(rom, xmask+EPROM_VEL); // READ THE EPROM AT 0x0058, then READ THE EPROM AT 0x0158, then READ THE EERPOM at 0x0258, etc
    sta = readEEPROM(rom, xmask+EPROM_STA); // READ THE EPROM AT 0x0068, then READ THE EPROM AT 0x0168, then READ THE EERPOM at 0x0268, etc


 sprintf(coords, "g=%s,%s,%s,%s,%s,%s,%s",course_id,lon,lat,alt,tim,vel,_stat);


    Serial.println(F("\n"));
   
    // HERE I WOULD LIKE TO PARSE THE VARIABLE coords INTO XML FORMAT, AND EACH NEW LOOP, IT ADD TO THE END OF XML THE NEW VALUE


   // THIS SEND THE FUTURE XML FORMAT TO THE REMOTE SERVER. TJHE FORTH PARAMETER IS THE DATA TO SEND
if(inet.httpPOST(host, port, path, coords, "Result", 0)){
         // Check if there is collected data then send
         #ifdef DEBUG
           Serial.println(F("Data sent"));
         #endif
         //Read EEPROM
      }else{
         #ifdef DEBUG
           Serial.println(F("Data not sent"));
           // Save in EEPROM
         #endif
         #ifdef LED 
           blinkLed(redGPRS,5, MSEC);
         #endif
         
      }
  }

In the above code, I know there is an issue. the functon readEEPROM() return a char and I do not know to do in the way that for example, vel take the value of the return char value
Code:
vel = readEEPROM(rom, xmask+EPROM_VEL)
May be should I use sprintf, as I did with coords?

But for now my main worries is how to parse into XML file to send once, to a remote server, the 5 sets of coordinates.

I hope I provided you enough information and it clear for you.
..... and many thank for your help. Feel you free to ask me aditionnal information

Cheers
Pages: 1 2 [3] 4 5 ... 25