Show Posts
Pages: 1 ... 26 27 [28] 29 30 ... 111
406  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?

Quote
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.

Pete

 
407  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.

Pete
408  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.

Pete
409  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.

Pete
410  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.

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

Pete
412  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".

Pete
413  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:
Code:
input = input + (key - '0') * pow(10, (3 - num));

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

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

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

Pete
415  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.

Pete
416  Using Arduino / Microcontrollers / Re: What pins is PORTB on the Teensy 3.0? on: December 05, 2013, 07:20:20 pm
http://forum.pjrc.com/forum.php
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.

Pete
417  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().

Pete
418  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.

Pete
419  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.

Pete
420  Products / Arduino Due / Re: FFT on Arduino Due? on: December 05, 2013, 11:11:48 am
This thread might help.
http://forum.arduino.cc/index.php?topic=140107.0

Pete
Pages: 1 ... 26 27 [28] 29 30 ... 111