Show Posts
Pages: 1 ... 28 29 [30] 31 32 ... 113
436  Products / Arduino Due / Re: I need help with an example. on: December 12, 2013, 12:04:42 pm
I copied the two, one behind the other in the same sketch
That's the wrong way to do it and is why the first error message is "Waveforms.h: No such file or directory".
Waveforms.h must be a separate file in the same directory as FunctionGenerator.ino

437  Using Arduino / Programming Questions / Re: logarithmic scaling on: December 12, 2013, 10:33:20 am
How long does your current linear method take to get from stopped to full speed and what is the preset constant?

the closer it is to full speed the shorter the time between steps is
I'm not sure that this is what you should do - it probably won't look right. I think the acceleration at the beginning and end should be lower than it is in the middle. But you'd have to experiment with it to find the right acceleration curve.

One way to approximate the exponential curve would be to break it into several linear pieces. At the moment, at any point in the acceleration (and, presumably, deceleration) you are using the same linear constant to increase the speed. You could keep track of what stage of the acceleration you are at (as you do now) and map that into one of, say, five constants such as 1, 3, 7, 3 and 1, or whatever is appropriate. If it doesn't take long to get up to full speed I doubt that you'll notice the difference between that and a true exponential.


438  Using Arduino / Sensors / Re: DS18S20 temp sensor won't go below 32F on: December 11, 2013, 12:05:28 pm
The DS18S20 returns the temperature as a twos complement number (as does the DS18B20) so you don't need to test the sign bit. You are just changing all negative numbers to positive ones.

439  Using Arduino / Programming Questions / Re: Problem with an alarm, tone and a while loop on: December 11, 2013, 12:00:24 pm
If the code enters the while loop, the only for it to exit the loop is if alarma1 is set to zero. This happens only if "ircode == but1". You will have to figure out why ircode never equals but1.

It would help if you used the IDE menu Tools|Auto Format on your code before posting it. Also get rid of most of the blank lines.

440  General Category / General Discussion / Re: Morse Code blinker on: December 10, 2013, 05:45:25 pm
You'd be a lot better off using an array.

441  General Category / General Discussion / Re: Morse Code blinker on: December 09, 2013, 07:58:11 pm
You didn't test it very well. It doesn't work.

442  Community / Gigs and Collaborations / Re: probably not the right thing to request... on: December 09, 2013, 04:54:45 pm
Which bit(s) are you going to do?

443  Using Arduino / Interfacing w/ Software on the Computer / Re: Serial.Available is blocking on: December 09, 2013, 10:00:58 am
Your code reads lines of data from the serial port but does nothing when a complete line is entered.
You don't do any bounds checking so that if a line of more than 39 characters is entered, your code will clobber something off the end of the array, leading to unpredictable behaviour such as "blocking at the Serial.available line".

444  Using Arduino / Project Guidance / Re: Alarm code not working, outputs strange things!!! on: December 08, 2013, 12:33:40 pm
"key" is an ASCII character representing the key - not a binary number.
Convert key from ASCII to binary:
input = input + (key - '0') * pow(10, (3 - num));

BTW. AWOL is right. pow doesn't always produce the result that you would expect.

445  Using Arduino / Sensors / Re: Ds18b20 temp sensor and dim leds on: December 07, 2013, 03:13:42 pm
In setup() you have:
    pinMode(5, OUTPUT);
but in loop() you have:
    digitalWrite(4, HIGH);

This is why it is useful to define a name for the pin and use that throughout.
#define LED_PIN 4
    pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, LOW);
    digitalWrite(LED_PIN, HIGH);

446  Using Arduino / Programming Questions / Re: Interrupt -> cli() -> Wireless Serial Transmission -> sei() on: December 05, 2013, 08:11:53 pm
Don't use String. It will eventually cause a mysterious crash.
Use null-terminated C strings instead.

447  Using Arduino / Microcontrollers / Re: What pins is PORTB on the Teensy 3.0? on: December 05, 2013, 07:20:20 pm
would be a better place to ask.

But they are:
0, 1, 16, 17, 18, 19, 25, 32

The code from a Teensy2 will not necessarily be easy to port to a Teensy3. The T3 is not just a bigger T2. It uses a completely different type of chip, an ARM Cortex M4.

448  Using Arduino / Programming Questions / Re: Interrupt -> cli() -> Wireless Serial Transmission -> sei() on: December 05, 2013, 07:15:24 pm
Using cli/sei like that is probably not going to help. When you disable interrupts you should only do it for very brief periods.
But your Send function seems to have other problems. It is entered from loop() when IR_INTERRUPT has been set which means that IR_PIN is now high. The while loop then waits for IR_PIN to go low. The pulseIn statement is going to measure the length of the next high pulse but as soon as IR_PIN goes high there will be another interrupt, which is going to confuse things.
I think what you have to do in Send() is first detach the interrupt so that it can't occur while pulseIn is measuring the next pulse. Remove cli/sei. Then attach the interrupt again at the end of Send().

449  Using Arduino / Programming Questions / Re: Help for code optimization on: December 05, 2013, 02:16:31 pm
If there were a lot of long strings, I'd agree, but I changed the constant strings in the Serial.println etc. to use F() and the static ram went from 1027 to 923 bytes. I don't think the other strings would take more than another 100 bytes especially if the repetitive code in the RelaySMS function were condensed into a function.
I don't know how static ram is used up by the rs485 or ethernet libraries but the big problem is going to be the use of the String class. It won't matter how much free static ram is there, the code is going to crash eventually.

450  Using Arduino / Programming Questions / Re: Help for code optimization on: December 05, 2013, 01:59:42 pm
I don't think using the F() macro is going to make a significant difference to the amount of static ram that's used. Every little bit helps but I don't think F() is going to make a significant dent.
The program uses about 18kB of flash (out of about 30kB) and 1kB of static ram (out of 2kB).
There are two things you can do.
1. Do not use the String class. It (mis)uses static ram and eventually your code will mysteriously crash. Use null-terminated C strings.
2. In RelaySMS(), the code for each of the large if statements (e.g. the if(c=='1')) is almost identical. As far as I can see, each of the four blocks of code only differs in which pins are used by the digitalRead and digitalWrite. You could put all this code in a separate function which has those two pin numbers as arguments and call the function from each if statement.

You could add some code for rs485 or ethernet and see how much it increases the size of your code so that you know whether attempting to optimize the code is even worthwhile.

Pages: 1 ... 28 29 [30] 31 32 ... 113