Show Posts
Pages: [1] 2 3 ... 975
1  Using Arduino / Programming Questions / Re: ATtiny 85 Code Compile Error (multiple definition) on: Today at 08:19:38 pm

Use this core...
https://code.google.com/p/arduino-tiny/
2  Using Arduino / Programming Questions / Re: analogWrite > 255 by accident on: Today at 04:57:34 pm

True but... The same limit checking (with a different range) should be in all variations of analogWrite.  The current behaviour is really not acceptable for the intended Arduino audience.
 
3  Using Arduino / Programming Questions / Re: MersenneTwister.h Troubleshooting#size on: Today at 04:53:07 pm

Marsaglia and Jones for the win!   smiley-cool
4  Using Arduino / Programming Questions / Re: analogWrite > 255 by accident on: Today at 03:06:25 pm
These libraries are out dated, so why can't we, the community remake or update the core files?

Some of us have...
https://code.google.com/p/arduino-tiny/source/browse/cores/tiny/wiring_analog.c#77
 smiley-wink

Quote
We use them all the time, and we are the ones who spot the mistakes, so why can't we be allowed fix and distribute them? Or tell the original creators what to fix and have them update the libraries?

The most effective path is the create a pull request in GitHub.  The Arduino folks said they will soon be automatically executing pull requests for the nightly builds so the turnaround time should be significantly shorter.
5  Using Arduino / Programming Questions / Re: const int and memory space on: Today at 03:09:40 am

AWOL, I fear your edits may have been lost to the ether.  We appear to have been editing simultaneously.  I apologize.  And am finished for the night.

Good night to all!
6  Using Arduino / Programming Questions / Re: const int and memory space on: Today at 03:05:58 am
What's an indirect reference to a const? Can you give an example?

An array of constants used for linear interpolation (may have syntax errors)...

float const C[] const = ( 36, 1274, 283745 );

The compiler optimizes away the array if the array index is always a compile time constant...

C[0]

The array is brought into SRAM if the array index is variable...

for ( i=0; i < 3; ++i )
  Serial.println( C [ i ] );

Edited to make example clearer. AWOL
7  Using Arduino / Project Guidance / Re: Arduino Micro connect with Shield on: Today at 02:41:14 am

Please do not cross-post.  Other thread removed.
8  Community / Workshops and Events / MOVED: Some Problems with the Arduino Mega2560 on: Today at 12:20:29 am
This topic has been moved to Project Guidance.

http://forum.arduino.cc/index.php?topic=264260.0
9  Using Arduino / Programming Questions / Re: MersenneTwister.h Troubleshooting#size on: September 01, 2014, 10:58:21 pm
Thanks for your answer.

You are welcome.

Quote
...if I set up a seed with number 10 for example, I have to always get the same number, do you understand?

Yes.  Both generators work that way.

Quote
In this code I do not know which one is the seed:

I believe all five constitute the seed.  For the Arduino, with its limited SRAM, this is what I use...

Code:
/* A poor way to maange the seed but, in the Arduino world, simple is paramount. */

void tc_RandomSeed_JKISS32( unsigned long newseed )
{
  if ( newseed != 0 )
  {
    x = 123456789;
    y = newseed;
    z = 345678912;
    w = 456789123;
    c = 0;
  }
}



Code:
static unsigned int x=123456789,...

unsigned int is not the correct type for the Arduino.  unsigned long is.  (uint32_t is an even better choice.)


This is the entire JKISS32 implementation I use...

Code:
#include <Arduino.h>

// http://www.cs.ucl.ac.uk/staff/d.jones/GoodPracticeRNG.pdf

/* Implementation of a 32-bit KISS generator which uses no multiply
instructions */


static unsigned long x=123456789, y=234567891, z=345678912, w=456789123, c=0;

unsigned long tc_RandomGenerate_JKISS32( void )
{
  long t;

  y ^= (y<<5); y ^= (y>>7); y ^= (y<<22);
  t = z+w+c; z = w; c = t < 0; w = t&2147483647;
  x += 1411392427;

  return x + y + w;
}

/* A poor way to maange the seed but, in the Arduino world, simple is paramount. */

void tc_RandomSeed_JKISS32( unsigned long newseed )
{
  if ( newseed != 0 )
  {
    x = 123456789;
    y = newseed;
    z = 345678912;
    w = 456789123;
    c = 0;
  }
}

10  Using Arduino / Programming Questions / Re: Issues with strstr_P (PROGMEM) on: September 01, 2014, 02:51:18 pm
Can you explain me why is the "static" keyword important here ?

Without it the foos exist on the stack.

Quote
Actually, I thought that all PROGMEM var (in FLASH) were static, since the FLASH isn't written during the execution of the program

We are discussing a C++ program which means C++ rules still apply.  Without the static they are automatic variables which puts them on the stack.
11  Using Arduino / Programming Questions / Re: Issues with strstr_P (PROGMEM) on: September 01, 2014, 01:00:31 pm
Quote
static const char *foo PROGMEM = "is";

...stores the pointer to the string in Flash.  The string is stored in SRAM.

Quote
static const char foo[] PROGMEM = "is";

...stores the string in Flash.  The pointer only exists in the compiler's head.

See the difference?
12  Using Arduino / Programming Questions / Re: MersenneTwister.h Troubleshooting#size on: September 01, 2014, 12:57:42 pm
Where can I find JKISS32

Look up.

Quote
or Xorshift algorithm

https://code.google.com/p/arduino-tiny/source/browse/cores/tiny/tc_random_XorShift.cpp?repo=core2

Quote
(Java and Arduino)

Needy thing, aren't ya?

Quote
with Seed to get the same number with regard to this Seed?

Are you asking for a pseudo-random number generator?
13  Using Arduino / Programming Questions / Re: Issues with strstr_P (PROGMEM) on: September 01, 2014, 03:43:57 am

Try this...
Code:
void setup() {
  //WITH PROGMEM
  static char foo1[] = "With PROGMEM is not working";
  static char foo2[] PROGMEM = "is";
  char *foo3 = strstr_P(foo1, foo2);
 
  //WITHOUT PROGMEM
  char *foo4 = "Without PROGMEM is working";
  char *foo5 = "is";
  char *foo6 = strstr(foo4, foo5);
 
  Serial.begin(9600);
 
  //RESULT
  if ( foo3 != NULL )
    Serial.println( foo3 );
  else
    Serial.println( F( "NULL" ) );
 
  Serial.println(foo6);
 
}

void loop() {
  // put your main code here, to run repeatedly:

}
14  Using Arduino / Installation & Troubleshooting / MOVED: Problems with AREF on: August 31, 2014, 10:25:38 pm
This topic has been moved to General Electronics.

http://forum.arduino.cc/index.php?topic=264255.0
15  Using Arduino / Project Guidance / Re: Timer 0 overflow interrupt on: August 31, 2014, 03:49:48 pm

Enable the pin change interrupt on one of the two output pins.  Start the PWM output (analogWrite will work).  Trigger a conversion in the pin change interrupt handler.

Quote
I want to have a variable to generate accurate delays without having to compare the milis function every loop.

...is an extremely weak argument for using interrupts.
Pages: [1] 2 3 ... 975