Loading...
  Show Posts
Pages: 1 ... 245 246 [247] 248 249 ... 454
3691  Using Arduino / Project Guidance / Re: need to read an analog voltage on: November 20, 2012, 06:15:48 pm
Quote
One possible issue is that the input voltage must not exceed the analog reference voltage, so if you reduce the analog reference to (say) 200mV you would have to make absolutely sure that the voltage you're reading could never exceed that.

Never exceed sounds like a safety warning which does not apply in this case.

I stand corrected.
3692  Using Arduino / Programming Questions / Re: Using a mapped value which is then ramped analog output on: November 20, 2012, 05:41:51 pm

'Indenting' refers to laying out your code so that the structure can be seen and understood. It doesn't affect the logic, but does affect how easy it is for the programmer to understand the logic. The code you posted wasn't indented and as a result is very hard to follow. The Arduino IDE includes tools to indent your code for you.
3693  Using Arduino / Programming Questions / Re: serial.begin preventing digitalWrite on: November 20, 2012, 05:37:08 pm
Do you have anything at all connected to the Arduino except the USB lead to the PC? If not, I'd be looking for errors in the way the sketch was uploaded or the Arduino was powered.

Have you tried commenting the Serial.begin() out, verifying and uploading and just prove that it then starts blinking as normal?

3694  Using Arduino / Project Guidance / Re: need to read an analog voltage on: November 20, 2012, 05:30:24 pm
The Arduino has a ten-bit ADC which gives you a value from 0 .. 1023. By default it covers the range 0 - 5V so the resolution is only 5mV - and it would probably not be wise to rely on the accuracy or consistency of the results when you're that close to the limits of the ADC. However, the Arduino has an analog reference which can be used to configure the ADC to cover a smaller voltage range. I haven't any personal experience of using it, but if I understood it correctly you should be able to configure it to give the resolution you're asking for. One possible issue is that the input voltage must not exceed the analog reference voltage, so if you reduce the analog reference to (say) 200mV you would have to make absolutely sure that the voltage you're reading could never exceed that.
3695  Using Arduino / Programming Questions / Re: Boot time and DS18B20 problem on: November 20, 2012, 04:49:11 pm
I think i just solve the problem. I'm calling temperature in void setup and now it works, without 85  smiley-lol

I had a similar problem with DS18B20 sensors where they would return a spurious value (around 85 C) at the first read. I just did a range check on the result. Given that it seems to be a one-off thing, doing a dummy read in setup() is probably as good a way of dealing with it as any other.
3696  Using Arduino / Programming Questions / Re: Relay and temperature sensor on: November 20, 2012, 04:43:51 pm
I thought I could find a function for the hysterisis but none. However, I guess I can make one enough simple but wouldn't the problem be the same, if I set a new threshold, wouldn't I encounteer the same problem?


No; hysteresis gives you a 'dead band' so that the output has to drop by a small amount before the heater will come back on.

The behaviour you're simulating is the same as an old fashioned, cheap, simple, reliable bimetallic thermostatic switch; have you considered just using one of those?
3697  Using Arduino / Programming Questions / Re: Brackets error on: November 20, 2012, 04:37:00 pm
it kicks out an error related to the brackets of my "if" statement.
 "Sketch Error - no opening bracket for switch"

I don't see anything wrong with the pairing of { } and ( ) and no errors relating to switches or cases. I'd expect that to compile without error. However, I'm not a compiler - why don't you simply compile it in the Arduino IDE to find out whether it's actually valid?

If it compiles I don't think it would do what you intend since you are comparing the pin number switchPin instead of digitalRead(switchPin). I suppose it's barely possible that the simulator has somehow picked up on this but given a misleading error message.

Edit to add: the misleadingly-named Coding Badly beat me to it.  smiley-mad
3698  Using Arduino / Programming Questions / Re: reading information from sd card on: November 20, 2012, 04:30:25 pm
You've got the basic idea but there are a couple of details wrong.

When using 'C' strings, you need to put a null character after the last character in the string. The functions such as atoi() that operate on strings use this to know where the end of the string is. Make your buffer array one element bigger, and write a null character at the end of the string. The easiest way to ensure this is always done is to write the null whenever you append a character.

You have a typo - you used '=' (assignment) instead of '==' (test for equality).

You don't really need to append the ',' to the buffer. It probably won't hurt, but to avoid any doubt test the character before you decide what to do with it.

So that you know what's going on, print out the content of the buffer as well as the value that atoi() gave you from it.

Just to be on the safe side, you should add a check that you aren't adding more characters to the buffer than it has space for.

Code:

const int LEN = 4;
char array[LEN+1]; // +1 allows space for the null terminator
int counter = 0;

...

while (dataFile.available())
{
    char c = dataFile.read();
    if(c == ',')
    {
        if(counter > 0)
        {
            Serial.print("Buffer: [");
            Serial.print(array);
            Serial.println("]");
            value = atoi(array);
            Serial.print("Value: ");
            Serial.println(value);
        }
        counter = 0;
    }
    else
    {
        if(counter < LEN)
        {
            array[counter++] = c; // append the character
            array[counter] = 0; // null-terminate the array
        }
    }
}

It would probably be a good idea to check for any other characters and not just assume that anything that isn't a comma must be a digit, but if you wrote the file and know it doesn't have any spaces or line feeds or anything else in it then you might decide not to bother.
3699  Using Arduino / Project Guidance / Re: A simple approach to a stepper controller, which got a little complicated. on: November 20, 2012, 04:11:32 pm
Do both steppers behave the same i.e. if you move stX first then stY do you get the same behaviour as when you move stY first and then stX?

How fast is the PC writing to the LPT port? Is it possible that it's so fast that the delay waiting for the first motor to complete its step is causing the second stepper to miss its input? You might be able to test for that by slowing down the PC controlling application so that both steppers are moving at a crawl. Alternatively, write a test sketch that just moves both steppers in a hard-coded pattern and confirm they both do work - this would confirm the problem is to do with your control logic not the steppers.

3700  Using Arduino / Project Guidance / Re: sending of spoofing FM signals to a RC car ? on: November 20, 2012, 04:02:43 pm
If you're powering the Arduino through Vin you need to provide at least 7V. If the V+ from the speed controller supplies a regulated 5V then you could connect it directly to the Arduino 5V line and power it like that.

Using the Servo library, I suggest you use write(angle) rather than writeMicroseconds(microseconds).

I didn't realise that the forum's alignment codes would affect stuff in [ code ] blocks too but it seems to, so it would probably be best to make sure any code you post is left aligned in future - the center alignment doesn't work at all well for code.
3701  Using Arduino / Project Guidance / Re: interfacing webcam on: November 20, 2012, 12:36:08 pm
Is it possible that ... webcam captures the image?

That's not how it usually works. Usually, the USB host machine (presumably a PC) reads the image from the web cam and captures it in some form. In other words, the 'capture' part is performed by the PC application and not by the web cam. This implies that your problem is to find/create a PC application which can read the image from the web cam on demand, and provide a mechanism for the Arduino to tell it to do that. There are plenty of freeware applications which you can run from a command prompt to do this, and if you're using Microsoft Windows then you could use Gobetwino to run the application when the Arduino commands it.
3702  Using Arduino / Project Guidance / Re: assistance with temp comtrol project plzzzzz. on: November 20, 2012, 12:30:28 pm
Are you going to implement the PID control algorithm yourself, or use the standard PID library? The standard library should be easier to get working and more reliable (since it has already been tested and debugged) but may be harder for you to work out how to model the behaviour mathematically.
3703  Using Arduino / Project Guidance / Re: Arduino based Pulse Oximeter on: November 20, 2012, 12:27:21 pm
What I don't understand is what parameter the frequency of red/infrared light that has passed through represents, and how I can use it to calculate SpO2

I haven't done the research you have, but nothing you've said prior to this gives me any reason to think that the frequency represents anything; you're talking about measuring the absorption at two frequencies, both of which are known, and from the two absorption figures you should be able to calculate the O2 saturation by some formula that your research should have given you. Presumably the two frequencies you're using need to be chosen carefully to match the absorption characteristics of Hb and Hb02 so you need to choose the appropriate hardware but once you've done that the frequency is fixed, and is not something you need to measure or derive any values from. It seems to me that what you need to measure is the light intensity, not the frequency.
3704  Using Arduino / Project Guidance / Re: Server Tape Drive on: November 20, 2012, 10:51:09 am
This reminds me of the sort of thing people have done with Lego Mindstorm NXT, which I've never played with, but I get the impression some of these solutions must have taken a huge amount of effort to get working reliably.

If time is money and reliability is important it might be more sensible to buy a commercial system, but you'd need to spend thousands of dollars - it would work out cheaper to simply pay somebody nearby to go into the office and swap the tape for you:

http://content.dell.com/us/en/gen/storage-solutions-tape-backup
3705  Using Arduino / Programming Questions / Re: reading information from sd card on: November 20, 2012, 10:43:44 am
they are separated by commas. but how can I do that, is there a code or command to do that?

There are various approaches open to you, but the simplest one is to read the file character by character. If the character is not a comma, append it to a char array buffer. If it is a comma, parse the content of the buffer to a number and clear the buffer. This will give you a sequence of numbers read from the file. I assume you know what to do with the numbers from there on.
Pages: 1 ... 245 246 [247] 248 249 ... 454