Show Posts
Pages: 1 ... 439 440 [441] 442 443 ... 579
6601  Using Arduino / Programming Questions / Re: Code don't do what it should do on: April 28, 2011, 08:07:13 pm
@TWAIN
Just to clarify, what Big Oil is referring to is this

Code:
      if (ledStateRight == LOW)
        ledStateRight = HIGH;
      else
        ledStateRight = LOW;

While {} are technically not needed here because there is only a single statement after the if and else what often happens is you add another line one day, eg

Code:
      if (ledStateRight == LOW)
        ledStateRight = HIGH;
        digitalWrite (1, HIGH);
      else
        ledStateRight = LOW;

which looks ok visually (this is called "reading the indentation") but of course doesn't work as intended.

So it's good practice to add the {} all the time. (It does look ugly though so I'll confess I often don't do it smiley)
______
Rob
6602  Using Arduino / Project Guidance / Re: I'm somewhat new would like expert to critique my sketch on: April 28, 2011, 07:52:28 pm
Just a stylistic thing, I find long variable names like this

openmotoropenplus

very hard to read, especially when they are in large blocks. I would suggest camel case

OpenMotorOpenPlus

or maybe underscores

open_motor_open_plus

______
Rob
6603  Using Arduino / General Electronics / Re: firing a strobe / optocoupler confusion. on: April 28, 2011, 07:35:29 pm
You still need a current-limiting resistor for the LEDs though or you may kill the processor output. Something in the 330R area.

EDIT: maybe a smaller resistor as there's two LEDs in parallel, check the specs of the opto.

______
Rob
6604  Using Arduino / General Electronics / Re: Analog Input Protection? on: April 28, 2011, 07:30:14 pm
If you need a full 5v linear range i don't think you can use a zener. I'd go for schottky diode clamping to the power rails and a series resistor before the diodes.

______
Rob

 
6605  Using Arduino / Programming Questions / Re: serial errors and detection by Arduino on: April 28, 2011, 07:22:55 pm
Quote
I was wondering if there was a simpler way.
No.

Quote
I could implement a checksum and acknowledge protocol between sender and Arudino
Yes. That's the sort of thing you need to do.

Serial comms is by nature not reliable (more or less depending on speeds and distances).

How important is the data? Does it matter if a reading is missed? What speed and distance is involved?

______
Rob


6606  Using Arduino / Networking, Protocols, and Devices / Re: SPI multi master on: April 28, 2011, 10:34:46 am
OK, what is the nature of the data, are the masters reading sensors and the slave has to consolidate the readings or something.

Would all masters normally have data to send?

Also, what is the slave going to do with all this data? I gather it's not an Arduino.

______
Rob
6607  Using Arduino / Networking, Protocols, and Devices / Re: SPI multi master on: April 28, 2011, 07:24:16 am
Quote
The big question now is how to properly synchronize the masters
That is indeed the big question.

I can't think of a simple way to do this straight away.

What is the slave device? Smart or dumb? And how much data does it need?

______
Rob
6608  Using Arduino / General Electronics / Re: Circuit Help -- Voltage Divider + Input Protection on: April 28, 2011, 07:19:12 am
Those two circuits do != the third one if that's the idea.

The 3rd circuit has no current limiting for the zener and no voltage divider, apart from that it's exactly the same smiley

Do you still need the voltage divider? If so what's the expected max voltage because circuit #2 had a divider after the 4v so you will be reading a max of 1v.

______
Rob
6609  Using Arduino / Sensors / Re: switch and multiple interrupts on: April 28, 2011, 03:00:26 am
You will be missing a lot of numbers with this

Serial.println(vaschetteSvuotate );

because most of the values are not printable characters. Change to

Serial.println(vaschetteSvuotate, HEX );

Then at least we can see better what is happening.

______
Rob
6610  Using Arduino / General Electronics / Re: How to stop servos before reaching position on: April 28, 2011, 02:32:51 am
Quote
Can you explain how I can hook up a transistor like an electronic switch to control the power?
Same as a normal motor, this circuit

http://arduino.cc/playground/uploads/Learning/solenoid_driver.pdf

is the general idea (just substitute the solenoid for your servo motor).

______
Rob
6611  Using Arduino / General Electronics / Re: Soldering the top layer from the bottom layer question on: April 28, 2011, 12:52:09 am
Quote
If I solder these from the bottom pad, will the solder flow up through the hole and make a connection to the (more important) top pad?
Very unlikely, and if it doesn't you are stuffed.

Normally with home made boards you have a via just next to the pin. Too late for that now though.

I wouldn't do another board because there will probably be other bugs so you'll be doing another one anyway. What about doing this.

Drill the holes slightly over size if the pins are round (normal size if they are square), then get a very fine piece of wire (say a single strand from a multi-strand wire), solder that to the top track somewhere then poke it through the hole. Insert the terminal block and solder the bottom including the wire.

The block will sit up a fraction but not enough to worry you I wouldn't think.

______
Rob
6612  Using Arduino / Programming Questions / Re: Cduino project -- new project for C/make arduino programming on: April 28, 2011, 12:10:28 am
I've been using makefiles for some time, I only revert to the IDE if I'm posting code to make sure it compiles in that environment.

I still include all the normal Arduino files though, they are useful and you can still work "native" when it's required.

______
Rob
6613  Using Arduino / Project Guidance / Re: I'm somewhat new would like expert to critique my sketch on: April 28, 2011, 12:06:49 am
Same error.

______
Rob
6614  Using Arduino / Sensors / Re: switch and multiple interrupts on: April 27, 2011, 09:17:20 am
Quote
interrupt pin are digital so they can only "say": I am under or over a value.
That's not strictly true, there's a grey area in the middle where all bets are off.

Can you post the entire code?

______
Rob


6615  Using Arduino / Programming Questions / Re: sampling rates? on: April 27, 2011, 09:10:44 am
So you're looking to time a ~32uS pulse.

Thoeretically the pulseIn() function will do that but the resolution would not be great.

The on-chip timers have an external input but I don't think you can use it to gate a count which is what you need here.

Any form of interrupt will be too slow.

So I think you have to use an external counter and some logic. I think it would be fairly simple unless you need GHz resolution.

______
Rob
Pages: 1 ... 439 440 [441] 442 443 ... 579