Show Posts
Pages: [1] 2 3 ... 18
1  Using Arduino / LEDs and Multiplexing / Re: Hc595 7 Segment on: January 28, 2013, 03:39:20 pm
Also notice that although the max sink/source current per pin is 30mA, the max total sink/source current of 74hc595 is only 70mA. If you multiplex one digit (7 or 8 segments) at time and use 220R resistor as in the Arduino shifout tutorial, you may exceed the max current rating. Use big enough cathode resistors so that the total current stays below 70mA when all segments are illuminated. The exact resistor value depends on the forward voltage of the leds, which is typically about 2V with red leds. 330R is probably on the safe side. Or if you want brighter display and drive the leds at higher currents, you can use  ULN2003 transistor array between 74hc595 and the cathodes. You still need to pick cathode resistors so that the current stays below the max current/segment (typically about 20mA).
2  Using Arduino / Displays / Re: Pervasive Displays [no power displays - e-paper] on: January 26, 2013, 03:40:23 pm
Well I finally got the display to work with PIC18F. 

Congratulations! Could you tell a bit more about your implementation? Did you use a driver IC (e.g, epson) or did you drive it directly from the PIC? Perhaps post the schematics?
3  Using Arduino / General Electronics / Re: Combining the Ampere of two voltage regulator? on: January 05, 2013, 03:07:37 pm
thank god we don't live in a simulator.

You don't really know that. (Sorry, off topic, but couldn't resist.  smiley-wink)
4  Using Arduino / General Electronics / Re: Standalone arduino/capacitors on: December 11, 2012, 06:12:21 pm
Thank you all for thorough explanations. I'll use 0.1 uF ceramics then.
5  Using Arduino / General Electronics / Re: Standalone arduino/capacitors on: December 09, 2012, 04:25:41 pm
OK, thanks Mike. Does it have to be elco or will ceramic do?
6  Using Arduino / General Electronics / Standalone arduino/capacitors on: December 09, 2012, 03:45:40 pm
I'm building my first standalone arduino project (atmega328 on stripboard). I power it through a 7805 regulator which has 10uF caps on input and output. The 7805 is on a separate circuit board. The wire from the 7805 to atmega328's VCC is about 20 cm (ten inches) long, quite thick (0.75mm2) wire, plus about ten cm on the stripboard.

Should I place an additional cap between atmega328's VCC and GND (and AVCC and GND) close to the pins? And what would be a proper size for the cap?
7  Using Arduino / Programming Questions / Re: software low pass filter debug help on: December 09, 2012, 02:12:25 pm
Sizeof returns the size of the array in bytes, not the number of elements.
8  Using Arduino / Programming Questions / Re: A function to handle multiple datatypes on: November 04, 2012, 10:36:24 am
Quote
He probably expects to send the strings without terminating zeros.
foo1 and foo2 have terminating NULLs.

Code:
char nonsense[4] = { 'c', 'r', 'a', 'p' };
does not.

Yes, I am very well aware that foo1 and foo2 have terminating nulls and that char nonsense[4] in your example doesn't. Instead of writing "He probably expects to send the strings without terminating zeros.",  I perhaps should have written "When he sends strings, he probably doesn't want to send the terminating zeros."

Though why one would want to do this is unclear. The definition of a string is "a NULL terminated array of chars", so your premise is flawed from the start.

My premise wasn't flawed. My premise was that when he sends null terminating char arrays a.k.a strings, he probably wants to send the non-null characters only and not the terminating nulls. I am not sure  if thats what the OP wanted, but it certainly is a valid assumption. And that is something that was not possible with Nick's templated sendAnytihing().
9  Using Arduino / Programming Questions / Re: A function to handle multiple datatypes on: November 04, 2012, 04:57:35 am
After what pYro_65 just demonstrated, I am inclined to claim that for OP's case the sendAnything(const byte *value, unsigned int size) is more reasonable that all the extra hassle that the template alternative would require.

Code:
int MyInt = 42;
char *MyString = "foo";
sendAnything((const byte *)&MyInt, sizeof(MyInt));
sendAnything((const byte *)MyString, strlen(MyString));
10  Using Arduino / Programming Questions / Re: A function to handle multiple datatypes on: November 04, 2012, 03:42:10 am
Nick has provided very convincing arguments for using templates. One more question still. The OP's requirements were:

Quote
I want a function that I can pass either a string of characters or an integer or an object ..

He probably expects to send the strings without terminating zeros. The code below won't probably work with the template version of sendAnything, will it? Can sendAnything be fixed to work with strings as well?

Code:
char *foo1 = "foo1";
char foo2[] = "foo2";

sendAnything(foo1);
sendAnything(foo2);
11  Using Arduino / Programming Questions / Re: A function to handle multiple datatypes on: November 03, 2012, 07:12:48 pm
And I'll guess that the memory consumption also depends on how complicated (or big) the function body is. sendAnything() was trivial. If the function's body is bigger then the overhead in the template alternative starts to pile up sooner.
12  Using Arduino / Programming Questions / Re: A function to handle multiple datatypes on: November 03, 2012, 07:04:03 pm
So the templated version used less program memory.

Even if I send two different type (int and float) the templated version still is 6 bytes shorter. Of course, if you were sending dozens of types of data (would you actually do that?) then the pointer version would use less program memory.

Test on a Uno with 1.0.1.


I though that the whole point of using templates or generic pointer types was the function will be used to send objects of several types (definitely more than two). If that wasn't the case, instead of sendAnything(), I could have as well have implemented sendMyInt() and sendMyFloat() or overloaded send(MyInt &data) and send(MyFloat &data).
13  Using Arduino / Programming Questions / Re: A function to handle multiple datatypes on: November 03, 2012, 05:25:57 pm
Thanks Nick, I can see your point, especially on sending down the size. On the other hand, using templates makes the sketch bigger (consumes more of the precious flash memory) and people with C background are already used to functions like memset() and read() which use the same calling convention as my version of sendAnything(). I don't think that either of the alternatives is absolutely better.
14  Using Arduino / Programming Questions / Re: A function to handle multiple datatypes on: November 03, 2012, 04:29:34 pm
C/C++ hasn't been my primary programming language in recent years and the strict aliasing issue has evaded me. I not sure if I understood it correctly. There are plenty of standard C functions which have void * parameters, such as memset, memcpy, read, write, etc. Does the strict aliasing rule mean the code below is not valid any more?

Code:
typedef struct {
    int a;
    char b;
  } my_struct;

  my_struct foo;
  my_struct bar;
  char buffer[sizeof(my_struct)];

  foo.a = 42;
  foo.b = 'a';
  memcpy ((void *)buffer, (const void *)&foo, sizeof(my_struct));
  memcpy ((void *)&bar, (const void *)buffer, sizeof(my_struct));

If the code above is valid, is there then something fundamentally wrong with the code below?

Code:
void sendAnything(const byte *value, unsigned int size)
{
  for (unsigned int i = 0; i < size; i++)
    Serial.write(*value++);
}
sendAnything((const byte *)&MyInt, sizeof(MyInt));


These were meant to be sincere questions, not intention to reignite the argument  smiley-grin

edit: typos
15  Using Arduino / Programming Questions / Re: Using the RDM630 RFID Tag Reader and NewSoftwareSerial library on: November 01, 2012, 04:41:54 pm
I tend to use goto exception throwing in languages that don't support actual try/catch/throw mechanism, such as in Perl and vanilla C. I have to say that try/catch/throw exception handling is not any of my favorite features. It is especially irritating in Java, which forces to catch exceptions is cases where I would rather just let the program crash.
Pages: [1] 2 3 ... 18