Show Posts
Pages: [1]
1  International / Software / Re: domanda da fucilazione on: August 13, 2012, 04:13:25 am
"Il simbolo or" è un po vago, in quale linguaggio? In c l'OR inclusivo si scrive con il "pipe" '|', mentre l'esclusivo con '^', ma entrambi sono presenti sulla tastiera italiana, forse ti riferisci al simbolo del complemento a uno '~' che su windows puoi scrivere tenendo premuto ALT e digitando sul tastierino numerico 126.
2  International / Software / Re: Assembly inline on: August 05, 2012, 07:05:12 pm
A giudicare da
[Arduino src]/app/src/processing/app/debug/Compiler.java : 131
sembrerebbe che l'IDE attuale sia capace di compilare file asm con restrizione .S

Spulciando il change log / history su git
https://github.com/arduino/Arduino/commit/048143f3d5b61544811634243902fcc74ab0d845
pare che la patch sia stata applicata nel 2009...

Puoi postare l'output di compilazione dell'IDE?
3  International / Software / Re: Passaggio di argomenti ad una funzione on: August 05, 2012, 06:16:27 pm
Questo e' con i template, a mio parere la scelta migliore nel tuo caso ( Arduino ci va a nozze e tu non ti devi sbattere sul codice smiley-wink ):
Code:
void EPROOM_write( unsigned addr , void* buff , unsigne length )
{
unsigned i;
while( length - i++ ) EPROOM.write( ((unsigned char*)addr) + i , buff[i] );
}

template <class type> void EPROOM_write( unsigned addr , type var )
{
EEPROM.write( addr , &var , sizeof(type) );
}

void EPROOM_write( unsigned addr , const char* str )
{
do EEPROM.write( addr++ , *str ); while( *str++ ); // oppure EEPROM.write( addr , str , strlen( str ) + 1 );
}

Ci sarebbe anche un'altra via, che non necessita di g++ ma si basa sul precompilatore, in pratica il risultato e' lo stesso dei template, ma se vuoi del codice C99 "pulito" ti puo' aiutare, probabilmente e' inutilmente macchinoso nel tuo caso, ma hai detto mai:
Code:
void EPROOM_write_ptr( unsigned addr , void* buff , unsigne length )
{
unsigned i;
while( length - i++ ) EPROOM.write( ((unsigned char*)addr) + i , buff[i] );
}

#define EPROOM_write( TYPE , ADDR , VAR ) EPROOM_write_ ## TYPE ( unsigned ADDR , VAR )

#define EPROOM_WRITE( TYPE ) void EPROOM_write_ ## TYPE ( unsigned addr , TYPE var ) \
{ \
EEPROM_write_ptr( addr , &var , sizeof(type) ); \
}
EPROOM_WRITE( unsigned char )
EPROOM_WRITE( unsigned short )
...
EPROOM_WRITE( signed short )
EPROOM_WRITE( signed long )

void foo()
{
EPROOM_write( unsigned int , 0xDEADBEAF, 12345 );
EPROOM_write( signed car , 0xABCDEFAB, 0x7F );
...
}

Good luck!
4  International / Software / Re: Corretto uso dell'array on: August 01, 2012, 04:05:47 pm
Ma LOL!
Next step: pthread_create( ... ) + pthread_join( ... ) smiley-wink
5  International / Software / Re: Corretto uso dell'array on: August 01, 2012, 12:36:03 pm
4) usare il leOS  smiley-razz
Il leOS? Chi o cosa e' il leOS? smiley-lol
6  International / Software / Re: Corretto uso dell'array on: July 31, 2012, 01:25:33 pm
Felice d'esserti stato d'aiuto smiley
Strano pero' il fatto della perdita di alcune letture, il delay(1) l'hai messo all'interno del corpo dell'if?
Code:
     if (tempo%50==0) {     
                       Serial.print (i);
                       Serial.print ("\t");
                       Serial.print (contar);
                       Serial.print ("\t");
                       Serial.println (tempo,DEC);
                       delay(1)
}
Comunque l'importante è che hai risolto smiley
Ciao!
7  International / Software / Re: Corretto uso dell'array on: July 30, 2012, 07:34:01 am
Guarda così ad occhio ( non posso testare il codice ora ) direi che semplicemente la tua routine è troppo veloce, quindi tra un ciclo e l'altro passa meno di un millisecondo e il risultato di millis() è lo stesso per 2 volte. Puoi ovviare in 3 modi:

1) salvandoti il risultato dell'ultima lettura di millis() e fare la lettura solo quando millis() restituisce un risultato maggiore a quel valore, o ancora meglio, uguale a quel valore + 50 ( il modo più semplice )

2) aggiungendo una delay(1) dopo Serial.println (tempo,DEC); ( il modo ancora più semplice smiley )

3) agganciandoti alla callback di interrupt di uno dei timer ( possibilmente timer2 ), settato opportunamente a intervalli di 50 millisecondi ed eseguire la routine all'interno di essa ( molto più complessa, può darti un sacco di grane la trasmissione asincrona sulla seriale, ma in linea di massima la soluzione ottimale secondo me ).

Facci sapere!
8  Topics / Home Automation and Networked Objects / Re: Champion IR Remote Control (IR Codes) on: July 29, 2012, 08:50:26 pm
for instance, signals sent by my Daikin cooler are > 120 state-changes long.

Did you check to see if perhaps they were sending the same sequence several times?  That's often done for noise immunity.

Yhea in fact it does, but the IRLibrary doesn't make any check on raw signals for redundancy, so it still could lead to a failed retransmission ( just like happened to me smiley-grin )

[edit]

Ooops I wrote 2 wrong things in one sentence!
The signal is not > 200 state-change long, it's > 500!! Il lasts for more than 400ms, almost half a second smiley-eek-blue
I double checked the signal to find the repeat point, but I could not recognize a repeated pattern as all other sampled signals did ( hitachi, apple, philips ) smiley-sad

I don't think Arduino can transmit hex string pulses given my current programming experience.

Retransmitting hex strings is just a matter of how did u packed the stream info, in Manchester encoding ( while now i've seen just this on sampled signals ) it's quite easy to transform a number in a sequence of dent/holes, given a specific frequency, and a mimimum interval reconstructing the signal is on the way. But it could be messy to share the same "way of encoding"" between different IR protocols.

By the way http://www.ladyada.net/wiki/tutorials/learn/sensors/ir.html was an interesting read, the way he checks for pin state with a single logical AND is really nice.

I don't understand how he can modulate the carrier frequency relying on delay() while disabling interrupts, wich should drive delay() itself smiley-surprise

Thank u for sharing smiley
9  Topics / Home Automation and Networked Objects / Re: Champion IR Remote Control (IR Codes) on: July 29, 2012, 04:27:25 pm
Even if Ken Shirriff's IR Remote Library is VERY powerful and well written it has a major disadvantage: it uses a local very short buffer ( 76 state change samples ) to store variations in the received signal.
Now, some protocol works sending/receiving more complex signals than the ones u can fetch with that library, for instance, signals sent by my Daikin cooler are > 120 state-changes long.

You can try oversizing the buffer used to receive the signal hackin' IRremote.h:88 and increasing RAWBUF to something bigger, but be carefull doing so bucause if u set it to a to big value, ure kernel will simpy not run at all smiley-wink

I hope this will help you smiley
10  International / Software / Re: Corretto uso dell'array on: July 29, 2012, 01:52:17 pm
Ciao, guarda su Arduino generalmente usare array cosi' grandi non e' una buona idea, se un domani volessi aggiungere una nuova funzionalita' o anche semplicemente rivedere il codice ti potresti trovare costretto a ricominciare tutto da capo.

Se un campionamento piu' lento ti puo' bastare, puoi provare questo:

Code:

#define idle 0
#define sampling 1
#define tot 100

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

void loop()
{
static unsigned action = idle;
static unsigned long baseTime;
static unsigned i;

if( action == idle )
{
if( Serial.available() )
{
do Serial.read(); while( Serial.available() );
action = sampling;
baseTime = millis();
i = 0;

char temp[16];            

Serial.write( (byte*)temp , sprintf( temp , "+ %lu\n" , baseTime ) );
}
}
else
{
if( i++ < tot )
{
char temp[32];

Serial.write( (byte*)temp , sprintf( temp , "%u = %u\n" , millis() - baseTime , analogRead( A0 ) ) );
}
else action = idle;
}
}

Il campionamento viene fatto/inviato a intervalli di circa 8-9 millisecondi, quindi molto piu' lentamente del tuo codice "bufferizzato" ma hai il vantaggio di avere un footprint praticamente nullo e di poter campionare a lungo quanto ti pare.

Nell'esempio che ti ho scritto ogni volta che mandi un carattere qualsiasi tramite il serial monitor Arduino ti risponde con "tot" campioni.
Puoi usare l'offset temporale che viene mandato in testa all'output per sincronizzare i rilevamenti.

Spero ti sia utile smiley
Ciao!

[Edit]

Ho provato a 115200 bps e il campionamento arriva a quasi 2 KHz, quindi molto simile al tuo campionamento originale smiley-wink
11  Development / Suggestions for the Arduino Project / Re: uint_8 or such like on: July 25, 2012, 06:45:40 pm
Ok, i'll retry in a lesser trolly way so...

First of all uint8_t isn't a shortcut, it's a macro ( preprocessor definition ) or compiler type definition, the C preprocessor will substitute every occurrence of that word in the code with something else.
Now, uint8_t means "Unsigned INTeger 8 bit long data Type" and then, its equivalent in standard C99 for any 8bit or bigger address length processor is unsigned char, a bitfields that can contain integral values between 0x0 and 0xFF ( 0 - 255 ).
Other useful macros like this are uint16_t, uint32_t, uint64_t, uint128_t, int8_t, int16_t, int32_t, int64_t, int128_t, each used to declare a specific data type, in size and signess, they are provided almost just for cross compatibility ( for instance on arduino uint16_t is unsigned int , while on usual x86 desktop processor is unsigned short due to the nature of the Atmel cpu it has on board ).

The use of uint_8 inside the Arduino core files is due to the strict relation between the Atmel GCC (Gnu Compiler Collection) and the *NIX based GCC, wich storically has been used with this kind of core data types ( usually declared in /usr/include/stdint.h ), almost every UNIX or GNU/Linux system cores ( any kind of system that strictly follows the POSIX specifications ) have been written using those kind of keyword, while Windows systems are historically written with similar BYTE, WORD, DWORD and QWORD data types.

Because Atmel choose to use a semi-standard gcc *NIX based tool-chain they kept as a legacy the use of the "stdint.h" file ( look in [Your Arduino folder]/hardware/tools/avr/avr/include/stdint.h, at line 79 there is our friend uint8_t ), but as you see this has nothing to do with Arduino, but with its third-party toolchain.

This is why ( i think ) there should not be a topic about it on the Arduino documentation, at least i could understand something about their specific byte ( defined in [Your Arduino folder]/hardware/arduino/cores/arduino/Arduino.h line 94 ) but it is so much self explanatory that would be somewhat redundant.

I hope my answer will be more usefull this time and will give u more details to solve you question.  smiley-wink

@cunctator: Your approach is harmful, we are all here to learn. Is prohibited to attack verbally other users.

Please change your attitude to beginners, if you are an expert, spread your knowledge if you want.

My attempt was not to attack anyone, just to say that this product is an advanced piece of hardware and software, not an entry point for beginner coders, for instance the 2K available memory management is something that even a skilled programmer feels hard to handle in complex projects, the way timers and interrupts are fired needs some background for beeing used in a safe and productive way, serial communication needs precise optimization, and that's asynchronous!
(you?) Arduino guys made a great work making it easy to use, but still there is GCC, and AR behind the corner and much more that needs some kind of know-how, background and competence.
Nothin against beginners ( we were all noobs smiley ) but a learning curve exsists because we cannot just jump to the top, and even if Arduino is not (yet) the top, it lies high!
12  Development / Suggestions for the Arduino Project / Re: uint_8 or such like on: July 24, 2012, 11:02:01 pm
dis agree on a fundamental basis.

Arduino is aimed at artists etc, not programmers.
   or so the aims say on the front page.

hence we should make learning as easy as possible , that I guess is  why the guide says dont use pointers.

Arduino is made for competent artists.
It's a piece of programmable hardware, not a toy, when you write down a sketch ure writing it in C/C++ not in hendecasyllables.
It is a "prototyping board", built by technicians for technicians with simplicity in mind and ease of use for technicians, not for "what a uint8_t is?" people.
RTFM, STFW.
Pages: [1]