Show Posts
Pages: 1 ... 1067 1068 [1069] 1070 1071 ... 1896
16021  Using Arduino / Programming Questions / Re: RGB Code not working. on: April 17, 2012, 07:11:04 am
Quote
t's also not really a good idea to keep posting the same question all over the forums.
It's actually a really bad idea.
@OP: Don't do it - no more warnings.
16022  Using Arduino / Programming Questions / Re: send command via rs232 on: April 17, 2012, 07:01:30 am
Tell us what equipment you do have, and what equipment you know how to use.
16023  Using Arduino / Programming Questions / Re: Using goto during the interrupt on: April 17, 2012, 06:58:43 am
Quote
Goto is bad thing and it's impossible to use it with an interrupts
1)Yes it is, but it is part of the language and has its place (this isn't it)
2) No-one said it was impossible (it isn't), just that what you were trying do was not possible.
16024  Using Arduino / Programming Questions / Re: Using goto during the interrupt on: April 17, 2012, 06:52:58 am
Quote
Has someone solved such problem?
Yes.
Look at the blink without delay example, without delay.
16025  Using Arduino / Project Guidance / Re: Use of A/D converter on: April 17, 2012, 06:43:05 am
Would it make sense to merge this with your other thread on the subject?
I don't understand why you can't follow the advice I've already given.
16026  Using Arduino / Project Guidance / Re: solenoid on: April 17, 2012, 06:00:37 am
Do some simple ballistics calculations (you can assume vacuum if it makes things easier) - it should be fairly simple to come up with the minimum energy requirements.
16027  Using Arduino / Project Guidance / Re: Use of A/D converter on: April 17, 2012, 05:06:10 am
Quote
I can't afford to have such long busy-wait state.
So get rid of it.

analogRead, 1.0
Code:
int analogRead(uint8_t pin)
{
uint8_t low, high;

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
if (pin >= 54) pin -= 54; // allow for channel or pin numbers
#elif defined(__AVR_ATmega32U4__)
if (pin >= 18) pin -= 18; // allow for channel or pin numbers
#else
if (pin >= 14) pin -= 14; // allow for channel or pin numbers
#endif

#if defined(__AVR_ATmega32U4__)
pin = analogPinToChannel(pin);
ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);
#elif defined(ADCSRB) && defined(MUX5)
// the MUX5 bit of ADCSRB selects whether we're reading from channels
// 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high).
ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);
#endif
 
// set the analog reference (high two bits of ADMUX) and select the
// channel (low 4 bits).  this also sets ADLAR (left-adjust result)
// to 0 (the default).
#if defined(ADMUX)
ADMUX = (analog_reference << 6) | (pin & 0x07);
#endif

// without a delay, we seem to read from the wrong channel
//delay(1);

#if defined(ADCSRA) && defined(ADCL)
// start the conversion
sbi(ADCSRA, ADSC);

// ADSC is cleared when the conversion finishes
while (bit_is_set(ADCSRA, ADSC));

// we have to read ADCL first; doing so locks both ADCL
// and ADCH until ADCH is read.  reading ADCL second would
// cause the results of each conversion to be discarded,
// as ADCL and ADCH would be locked when it completed.
low  = ADCL;
high = ADCH;
#else
// we dont have an ADC, return 0
low  = 0;
high = 0;
#endif

// combine the two bytes
return (high << 8) | low;
}
Just split this into two - the setup and start conversion in one routine, and the wait and read.
Do useful work between calling them.
16028  Using Arduino / Programming Questions / Re: Speed up arduino on: April 17, 2012, 03:58:15 am
Quote
So what is the reason behind that slower the output frequency?
I'd expect more like 8kHz, but an analogRead takes (from my memory) around 104us, most of it, as I've already said, is spent in a busy-wait for the end-of-conversion.
digitalWrite is also quite slow, but still doesn't quite account for the 4kHz vs 8kHz expected.
16029  Using Arduino / Programming Questions / Re: Using the switch statement on: April 17, 2012, 03:50:21 am
Quote
'100' is nonsense.
BZZZT!

Code:
unsigned long oneHundred = '100';
is perfectly valid C/C++.
Sometimes, it can even be useful, though I agree, in this case (no pun intended), useless.
16030  Using Arduino / Project Guidance / Re: Too hard for First Arduino Project? Aquarium Monitor on: April 17, 2012, 03:31:07 am
Quote
Haha my girlfriend wasn't even crazy about my idea to timer PWM our aquariums LED light
I can understand concerns like that; just because humans are not particularly sensitive to 500Hz flicker doesn't mean other creatures aren't also.

Quote
Because this doesn't control anything, rather tells you information, in my eyes you are still better of with this thing rather than not knowing this info at all.
But presumably, you are going to base decisions on the presented information, so if the information is incorrect because of a programming error, you're still in the same situation as if you'd put the computer in the driving seat.
16031  Using Arduino / Project Guidance / Re: Too hard for First Arduino Project? Aquarium Monitor on: April 17, 2012, 03:06:53 am
All doable and feasible, but ask yourself: do you want to trust your fish to your programming skills?
16032  Using Arduino / Project Guidance / Re: Use of A/D converter on: April 17, 2012, 03:05:49 am
Not sure what you're saying there.
It is true that the existing analogRead has a busy-wait, but as I pointed out in your other thread, this is easily reduced or eliminated.
You can even interrupt on the end-of-conversion condition if you wish.
The converter itself does not consume processor resources.
16033  Using Arduino / Project Guidance / Re: Use of A/D converter on: April 17, 2012, 02:26:35 am
Why do you want to use that converter?
It has lower resolution and is about the same speed as the built-in one.
16034  Using Arduino / Programming Questions / Re: HOW DO I GET OUT OF IF STATEMENT?? on: April 17, 2012, 02:23:42 am
Help us (and yourself) by getting into the habit of giving the pins meaningful names.

Oh, and please DON'T SHOUT.
16035  Using Arduino / Programming Questions / Re: strncpy() causes reset on: April 17, 2012, 02:22:25 am
Quote
I don't know about running out of memory.  How do I tell?  When I compile it says Binary Sketch:  18,082 bytes (of a 30,720 byte maximum)
That only reports program (flash) memory - the amount of SRAM used is not reported.
My guess is that you have lots of strings consuming RAM.
But without seeing code, it really is just a guess.
Pages: 1 ... 1067 1068 [1069] 1070 1071 ... 1896