Show Posts
Pages: 1 [2] 3 4 ... 433
16  Using Arduino / Programming Questions / Re: How to protect my program in ATmega328? on: April 13, 2014, 05:36:41 am
There is no way to simultaneously protect your code AND use the standard arduino bootloader and tools.
17  Using Arduino / Programming Questions / Re: Bjorklund’s algorithm on: April 12, 2014, 04:55:33 pm
Yeah; right.
If you're dealing with relatively small sequences and don't care about O(n) efficiency, it looks to me like an O(n2) algorithm would be relatively straight-forward.
Code:
while (remainderSeqs > 1)
  while (remainderSeqs > 1) {
    remainderSeqs -= moveRemainderAfterEachMain(mainSeqSize, RemainderSeqSize, RemainderStart)
    mainSeqSize += remainderSeqSize
  }
  recomputer remainderSeqs at new size
}
I'm don't think I understand what it's doing enough to test an implementation, though...
18  Using Arduino / General Electronics / Re: Why won't Eagle route this airwire? on: April 11, 2014, 04:41:33 am
It looks to me as though the groundplane on the bottom of the picture may be completely cut off from the ground plane at the top, in which case this airwire is the only thing connecting some portion of the board to GND.  (Although that doesn't explain why the autorouter didn't just connect them with trace on the TOP layer...)
19  Using Arduino / Microcontrollers / Re: How to choose cheapest AVR for a task on: April 11, 2014, 03:59:40 am
Quote
Are there any good resources out there for choosing the cheapest AVR that fits a set of requirements?
Well, the major distributors have "parametric search" where you can specify things like "6 to 20 IOs, 8k of program memory, DIP14, DIP16, DIP18, DIP20 packages", and then sort  the results by price.
Digikey says the tiny84 is it, as far as AVRs go.  And it's about $1.63 in tens.  Tiny861 is another alternative.

Understand that prices are subject to random influences, and subject to significant changes over short periods of time.
I wouldn't use eBay as an indication of chip pricing unless that's really the only place you intend to buy chips (which is a bad idea, too.)  Certain "popular" chips become artificially expensive, and everything is distorted by postage issues (some eBay sellers seem to make their profits by mailing things cheaply, so that you can buy one chip for $3 including postage, whereas a real distributor will frequently have postage fees that start at $7+ (minimum sized UPS package.)  But, like I said, that's "distorted" from real pricing.
20  Using Arduino / Programming Questions / Re: Having Difficulty With Accurate Readings Below 20 Celsius with MS5607 Altimeter on: April 10, 2014, 12:10:11 am
Quote
uint16_t C[1];
   :
  OFF  = ( (int64_t)C[2]*131072 ) + ( (dT * C[4]) / (64)); 
  SENS = ( (int64_t)C[1]*65536  ) + ( (dT * C[3]) / (128));
Well, THAT'S not likely to work very well...

Personally, I don't think "we" recommend subroutines nearly often enough.  Why don't you do it just like in the datasheet:
Code:
void setup() {
  read_calibration();
}

void loop() {
  read_data();
  calculate_temp();
  adjust_lowtemp();  // for especially low temperatures
  calculate_pres();
}
I'm not liking the datasheet very much.  When they say something like "if temp < 20C then do something with (2000-temp)", they're really mixing up their real temperatures vs their scaled temperatures.  And why can't we have a real equation for getting temp/pressure instead of this mishmash of fixed and floating point...
 
21  Using Arduino / Programming Questions / Re: Having Difficulty With Accurate Readings Below 20 Celsius with MS5607 Altimeter on: April 09, 2014, 10:22:34 pm
Code:
      T2=(dT*dT)/(2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2);
Oh, don't do that!
C has this rule about doing math with "int" sized things, unless some element of the expression is larger than that.
Now, "dT" is a 64bit int, so that MIGHT cause the 2^31 (?) to be calculated using 64bit numbers.  But the 2s are also inside of parenthesis, which leaves me "uncertain" as to what the compiler will do.  You should NEVER be uncertain if you can avoid it.
You can fix this by making the constant expression also use 64bit numbers, like:
  (((in64_t)2)*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2)
or perhaps
 (1LL<<31)

avr-gcc is known to be pretty slow at 64bit math; it might be a good idea to restrict the 64bit calculations to exactly those expressions where they are actually needed.
22  Using Arduino / Programming Questions / Re: Having Difficulty With Accurate Readings Below 20 Celsius with MS5607 Altimeter on: April 09, 2014, 08:07:59 pm
Also, doesn't setting the bits on the output port of an input ENABLE the  pull-ups?
Code:
// Disable internal pullups, 10Kohms are on the breakout
 PORTC |= (1 << 4);
 PORTC |= (1 << 5);
23  Using Arduino / Programming Questions / Re: Having Difficulty With Accurate Readings Below 20 Celsius with MS5607 Altimeter on: April 09, 2014, 08:04:54 pm
Code:
if(TEMP < 2000) // if temperature lower than 20 Celsius
  {
    int32_t T1    = 0;
    int64_t OFF1  = 0;
    int64_t SENS1 = 0;
   
    t_mod = (TEMP - 2000)*(TEMP - 2000);
    T1 = (dT*dT)>>31;
    OFF1=(61*t_mod)>>4;
    SENS1=2*t_mod; 
  }

By declaring the variables inside the code block, you are creating new instances of them, which are discarded when the block is done.   That is almost certainly NOT what you want (since you don't actually do anything with the values you calculate.  In fact, gcc probably optimizes away the calculations and does nothing except setting t_mod.)

Lose the declarations...
24  Using Arduino / Programming Questions / Re: Any ideas on why this code would work on a Uno, but not on a micro? on: April 09, 2014, 04:09:21 pm
Does sw serial support SerialEvent?
25  Using Arduino / Microcontrollers / Re: Parallel Programmer usage ...‏ on: April 09, 2014, 02:56:30 am
0) It's a "parallel port progammer", but it isn't a "parallel programmer" (from the AVR perspective.)  It still uses SPI/ISP for the programming, which means the AVR needs to have a clock, and it won't recover from some of the mistakes that a "real parallel programmer would."
1) try AT; that's about the most basic, I think.
2) No; most USB/Parallel adapters are actually USB/Printer adapters, and don't provide the programmatic per-pin access that  programming requires.
26  Using Arduino / Programming Questions / Re: Array Basics (sizeof) on: April 08, 2014, 02:18:25 am
Quote
I showed clearly how to pass a pointer to an array and get the correct size using sizeof.
Code:
void Foo( arr_t *arrp ){
But that's not a pointer to an array; it's a pointer to a PARTICULAR SIZE of array.
27  Community / Bar Sport / Re: Your latest purchase on: April 08, 2014, 12:15:35 am
I have lots of UV EPROMs.  We used to use them 8 per board, and they weren't expensive enough to erase stock when the software upgraded.   (Eventually, we went to OTP EPROMs.  But I have a lifetime supply of EPROMs, a programmer, and an eraser.  (and even a PC with a parallel port for the programmer to connect to.  Yeah!)
28  Using Arduino / Project Guidance / Re: Suggestions needed: Arduino Camera on: April 07, 2014, 10:47:28 pm
An Arduino isn't really very suitable for doing actual image manipulation.  It doesn't have enough RAM.
(maybe an Intel Gallileo, or one of the new Arduinos with onboard linux co-processors.)
29  Using Arduino / Programming Questions / Re: Array Basics (sizeof) on: April 07, 2014, 10:26:01 pm
Quote
If you dereference a real pointer to an array, you can get the size using sizeof.
Only if it's a compile-time constant, right?
(and, are you sure?  I though ((sizeof array)/sizeof(*array)) was one of those tricks for finding the number of elements in an array...)
30  Using Arduino / Programming Questions / Re: Array Basics (sizeof) on: April 07, 2014, 10:10:27 pm
In C, a pointer to the array is THE SAME THING as a pointer to the first element of the array.  That's because arrays are just consecutive occurrences of elements; there is no additional internal structure describing the size of the array...
Pages: 1 [2] 3 4 ... 433