|
6977
|
Using Arduino / Storage / Re: EEPROM_writeAnything - slightly improved
|
on: May 29, 2011, 05:16:01 pm
|
Maybe it is better to change it one level lower in the EEPROM class in EEPROM.cpp, Then other EEPROM applications would benefit from it too! from EEPROM.cpp uint8_t EEPROMClass::read(int address) { return eeprom_read_byte((unsigned char *) address); }
void EEPROMClass::write(int address, uint8_t value) { eeprom_write_byte((unsigned char *) address, value); } to uint8_t EEPROMClass::read(int address) { return eeprom_read_byte((unsigned char *) address); }
void EEPROMClass::write(int address, uint8_t value) { if (eeprom_read_byte((unsigned char *) address) != value) eeprom_write_byte((unsigned char *) address, value); }
|
|
|
|
|
6978
|
Using Arduino / Storage / Re: EEPROM_writeAnything - slightly improved
|
on: May 29, 2011, 04:55:24 pm
|
Besides a memory test, do you have some figures about the speed differences? I think of a testcase with a 20 bytes struct or array ... ( don't have an Arduino free at the moment  # same, # time without read, time with read 0, t1, t2 1, ... 20, TIA, Rob The theoretical value : http://www.arduino.cc/en/Reference/EEPROMWrite => An EEPROM write takes 3.3 ms to complete Can't find the value for EEPROMRead() ?? --- the char c is not needed? template <class T> int EEPROM_writeAnything(int ee, const T& value) { const byte* p = (const byte*)(const void*)&value; int i; for (i = 0; i < sizeof(value); i++) { if (EEPROM.read(ee) != *p) EEPROM.write(ee, *p); } *p++; ee++; } return i; }
|
|
|
|
|
6980
|
Using Arduino / Project Guidance / Re: Text Messaging Dog Water Bowl
|
on: May 29, 2011, 04:38:16 pm
|
First of all , very nice project! I often advise people to spent time on the reference and tutorial sites of Arduin.cc as there is so much information there how to program things. What should the water sensor measure? an ON/OFF condition ? There is water / there is no water? of There is xyz milliliter of water? a more analog condition. The fun of the latter is of course on can make nice graphs in Excel how the water evaporates, what happens when the dog drinks and when it is refilled. Check - http://www.sparkfun.com/products/9072 - Furthermore I advise to order a good watertight casing for the Arduino... sofar my 2 cents,
|
|
|
|
|
6981
|
Using Arduino / Project Guidance / Re: Ammeter project
|
on: May 29, 2011, 04:25:15 pm
|
|
THink the title should say "mA meter" ?
As I'm no electrical engineer I don't know it it will work, I would say the GND from the right must be connected somewhere to the left and that said, Is this not one of the things you use opamps for?
Rob
|
|
|
|
|
6983
|
Using Arduino / Programming Questions / Re: Send struct using Ethernet library
|
on: May 29, 2011, 03:23:29 pm
|
For the Arduino side it is not really complex, something like this simple_send(uint8_t *p, uint8_t size) { for(uint8_t i=0; i< size; i++) client.write(*p++); }
send_struct_numbers(struct numbers_t *num) { simple_send(&num.first, 1) simple_send(&num.second, 2); simple_send(&num.third, 4); }
void loop() { ... send_struct_numbers(&numbers); ... }
|
|
|
|
|
6985
|
Using Arduino / Programming Questions / Re: Send struct using Ethernet library
|
on: May 29, 2011, 10:24:55 am
|
|
Thanx Ramo102,
So the lesson learned is that sending structs is not straightforward due to different memory alignment at the sending and receiving side. Your solution is to force memory alignment to be identical, is a good option as it works.
Another option would be explicit serialization and deserialization at both side. That means mapping the structmembers one by one on a bytestream and on the receiving side map the bytestream on the members. The advantage of serialization is portability for the price of some extra code.
|
|
|
|
|
6987
|
Using Arduino / Programming Questions / Re: Sending Full Words from Serial Monitor
|
on: May 29, 2011, 09:15:56 am
|
You need to define a command packet, and a piece of code that reads a complete packet. How do you know its complete? The trick is to add a separator that is no part of the command. Example true,255# false,113# Note that the , functions as separator You need something like this readCommand() [not tested] to read one complete command; then you can split command into fields ( search for strtok() example ) int readCommand() { char lastchar = '''; int i= 0; while (lastchar != '#') { if (Serial.available()>0) { lastchar = Serial.Read(); if (lastchar == #) { command[i] = '\0'; } else command[i++] = lastchar; } } } Hopes this helpes
|
|
|
|
|
6989
|
Using Arduino / Programming Questions / Re: multi-array
|
on: May 29, 2011, 07:36:57 am
|
|
Furthermore there is one dimension with size 1
#define cnt_programs 1
so it will allways have the same value, does this change in the future? If not you better remove that dimension.
|
|
|
|
|