Loading...
  Show Posts
Pages: [1] 2 3 ... 15
1  Using Arduino / Programming Questions / Re: Why is my code acting like that? on: April 29, 2013, 01:11:37 am
I am not familiar with the DHT22 library, but should you be passing the DHT22 by value as a parameter to your read function?  This is a guess, but I think the function will be creating its own instantiation of a DHT22 when you do that, which it probably not what you want.

Perhaps pass a pointer to your DHT22 object instead:
Code:
...
DHT22_PrintData( &DHT22_0 );
...
void DHT22_PrintData( DHT22* device)
{
  switch ( device->readData() )
...

2  Using Arduino / Programming Questions / Re: return array of uint8_t, why i can un C++ and cant in arduino IDE 1.0 on: April 23, 2013, 11:19:19 pm
The latest version of the Arduino source (1.0.4) already incorporates these changes.  That's what I was looking at when I thought they were implemented:

https://github.com/arduino/Arduino/commit/141684d4


Code:
int * ptr = new int[ payloadSize ];

The case with int actually does not compile on 1.0.1.

3  Using Arduino / Programming Questions / Re: return array of uint8_t, why i can un C++ and cant in arduino IDE 1.0 on: April 23, 2013, 02:24:06 pm
The Arduino implements the new operator, but not the new array operator. The Arduino does not have enough memory for that, generally, so you are encouraged (required, actually) to find alternatives.

If that were the case, wouldn't the case with int fail as well?

In new.h:

Code:
void * operator new[](size_t size);

Is this the operator the compiler is trying to use?
4  Using Arduino / General Electronics / Re: Bouncing exceeding 200 ms on: April 22, 2013, 03:18:52 pm
Hardware debouncing might be your friend;  see http://www.ganssle.com/debouncing-pt2.htm for some ideas.

I have used the RC solution with a model railroad system, where contact between the wheels and rails can be extremely dirty/bouncy.  


But if you need to detect a button release in less than the bounce time I'm not sure there is a decent solution.  At least hardware debouncing has the advantage of automatically "integrating" the amount of time the button is in the closed state.
5  Using Arduino / Programming Questions / Re: Array of pointers to objects on: February 13, 2013, 11:17:57 pm
Are you saying the constructor is called when you declare the array of pointers?
6  Using Arduino / Programming Questions / Re: Does Arduino have a problem with pointers to classes? on: February 02, 2013, 01:31:53 am
One could also put the class definition in a .h file, and #include the .h file in your main sketch.

7  Using Arduino / Programming Questions / Re: New User with Compiler Questions on: January 26, 2013, 02:46:32 pm
One can define and instantiate different things depending on which board is targeted, can't you?  E.g., hardware serial instantiates more serial objects depending on the target's UARTs:

Code:
#if defined(UBRRH) || defined(UBRR0H)
  extern HardwareSerial Serial;
#elif defined(USBCON)
  #include "USBAPI.h"
//  extern HardwareSerial Serial_; 
#endif
#if defined(UBRR1H)
  extern HardwareSerial Serial1;
#endif
#if defined(UBRR2H)
  extern HardwareSerial Serial2;
#endif
#if defined(UBRR3H)
  extern HardwareSerial Serial3;
#endif

I suppose you could define constants like "PIN47" that would be valid only for a particular board if you were really keen on providing compile-time hardware constraints - not that I think it would be a good idea!
8  Using Arduino / Programming Questions / Re: runtime error... memory overload? on: January 23, 2013, 06:55:57 pm
Code:
startOfNextPhoto = photosTaken * photoLength;

If you anticipate that photosTaken * photoLength will be greater than the value of an int (32,767) then I think you need to tell the compiler to work with long values in the multiplication:

Code:
startOfNextPhoto = (long)photosTaken * (long)photoLength;

Otherwise the result of the multiplication will be an int rather than a long.


Of course unless you are using negative numbers you might as well use unsigned ints and unsigned longs.
9  Using Arduino / Programming Questions / Re: Controlling a Kodak Slide Projector via RS232 (P-Com Protocoll) on: January 22, 2013, 04:42:08 pm
Are you inverting the serial data from TTL to RS232 in hardware?  From the documentation the projector expects RS232-level signals.
I think you can try inverting them with Softserial, but that assumes the projector is happy with 0-5v signals rather than true RS232.

As far as i know RS232 is somewhat a NRZ Code, so couldn't be emulated with TTL Levels?!

I missed the part in the original post where you specified that you were using a MAX232;  never mind!
10  Using Arduino / Programming Questions / Re: Controlling a Kodak Slide Projector via RS232 (P-Com Protocoll) on: January 22, 2013, 02:29:45 pm
Are you inverting the serial data from TTL to RS232 in hardware?  From the documentation the projector expects RS232-level signals.

I think you can try inverting them with Softserial, but that assumes the projector is happy with 0-5v signals rather than true RS232.
11  Using Arduino / Programming Questions / Re: Calling function from variable on: January 16, 2013, 10:05:49 pm
Are 'mlt' and 'mlf' integer constants?  If so, I would use Mikal Hart's Flash library and create a table that holds your values:

Something like:

Code:
FLASH_TABLE(int, servovalues, 6, {mlt, 1600, mlf, 1600, 500, 0}, {values for b}, {values for c}, etc... );

That is, you have a table of 26 rows, each row containing the parameters corresponding to a particular character.  Then just look up the appropriate row in the table based on the character received, and pass those values to move2.
12  Using Arduino / Programming Questions / Re: Variable declaring problem on: January 16, 2013, 04:43:30 pm
1) You need to declare soil as an array.  As your code stands, you would need to declare
Code:
int soil[7];
so you could reference members 1 to 6.  If you number your sensors 0 to 5 instead you could declare it to have only 6 members.

2) You would reference the array as a member of mydata:
Code:
mydata.soil[sensor] =  . . .

3) You declare val2 but never use it;  I think you intend to use (val1 + val2) rather than (val1 + val1) ?
13  Using Arduino / Programming Questions / Re: Constructor parameter issues on: January 15, 2013, 04:35:06 pm

The constructor is called before the main() function which does all the configuration and initialisation of the Arduino.


Is this always the case?  I.e., if you declare a variable in loop() or setup()?  Or in a function only called by them?
14  Using Arduino / Programming Questions / Re: Creating objects on the fly? on: January 15, 2013, 02:55:33 pm
I did something similar for a system where users could arbitrarily add model trains to a layout.

Different manufacturers' trains used different control code, so I implemented a virtual control function in a base class, and had code specific to each system in derived classes.  The system would then dynamically create and object of the desired class when it detected the addition of a new train.
15  Using Arduino / General Electronics / Re: Trying to assemble custom cables and housings? on: January 08, 2013, 11:57:46 pm
Molex makes a hand tool that works quite well for crimping their pins.  $34 at Mouser:

http://www.mouser.com/ProductDetail/Molex/63811-1000/?qs=sGAEpiMZZMtArvHj40ttL4Zoic5nRoqx93Wc1uWgp6E%3d

You will also need an insertion tool appropriate for the housing that you are using.  It works wonders stuffing your pins into your housing.  I use this for SL connectors;  don't know what is recommended for KK:

http://www.mouser.com/ProductDetail/Molex/11-02-0022/?qs=sGAEpiMZZMtVoztFdqDXO2Ur2jARPc6r

(the Mouser picture for the latter is incorrect)


And of course use stranded wire as has been already mentioned...
Pages: [1] 2 3 ... 15