Show Posts
Pages: 1 ... 792 793 [794] 795 796 ... 1115
11896  Forum 2005-2010 (read only) / Syntax & Programs / Re: sizeof(int) troubleshooting on: September 19, 2009, 04:56:46 pm
Ah, you wish a function to return the number of significant digits of the contents of an integer variable?

11897  Forum 2005-2010 (read only) / Syntax & Programs / Re: Reading Port B using inline assembler on: September 13, 2009, 12:18:24 pm
Quote
Any hints on this?

No, sorry but I don't speak AVR assembly  smiley-wink

Lefty
11898  Forum 2005-2010 (read only) / Syntax & Programs / Re: Reading Port B using inline assembler on: September 13, 2009, 09:55:50 am
You can do direct port reading in C, and with the optimization done by gcc I would be very surprised if it was any slower then your inline asm. Give it a test before dismissing.

http://www.arduino.cc/en/Reference/PortManipulation

Lefty
11899  Forum 2005-2010 (read only) / Syntax & Programs / Re: no DIVIDE BY ZERO error? on: September 15, 2009, 11:26:19 pm
Well I'm more a hardware guy then a software guy, so I'm not the one to ask such details  smiley-wink

A quick google checked implied that some C++ implementations may have some math error reporting, most likely as part of their math library routines, maybe straight C could have the same, but I am pretty sure that it's not a part of C's core language, not sure about C++.

Lets let some of the software wizards that hang here comment further.

Lefty
11900  Forum 2005-2010 (read only) / Syntax & Programs / Re: no DIVIDE BY ZERO error? on: September 15, 2009, 11:00:31 pm
Quote
But, back in the last century when I learned math and computer science, I think we were taught that division by zero should result in a program error, regardless of data type. Did they change that rule somewhere along the way and I miss the memo?

Some languages still do you run time error trapping, however C is not one of them. C was designed to be low level, low overhead with no run time code that I know of. It's a good language match for microcontroller because of their limited resources and complex I/O components.

Lefty
11901  Forum 2005-2010 (read only) / Syntax & Programs / Re: Serial communications end char on: September 09, 2009, 06:45:05 pm
I will only add that when using the Arduino serial.print function, then just the character(s) are sent. If a serial.println function is used then the function adds a ascii 13 (\r) character to the output.

http://arduino.cc/en/Serial/Println

Lefty
11902  Forum 2005-2010 (read only) / Syntax & Programs / Re: interrupt based debouncing registers two presses on: September 07, 2009, 08:29:25 pm
MC14490 is nice chip that will debounce six inputs and is avalible in several different package types.

http://www.onsemi.com/PowerSolutions/product.do?id=MC14490P

Little pricey but designed for success.  smiley-wink



Lefty
11903  Forum 2005-2010 (read only) / Syntax & Programs / Re: debouncing a switch triggered by interrupt? on: September 06, 2009, 10:37:11 am
Yes, that can be a problem when using mechanical switch contacts with a interrupt input. Of course using external components to eliminate contact bounce is one solution. Sometimes it's as simple as hanging the right size cap from the input to ground. There are also active components, cross coupled gates, direct set/reset flip flops, etc.

Lefty
11904  Forum 2005-2010 (read only) / Syntax & Programs / Re: How to make a motor go backwards? on: August 20, 2009, 04:42:36 pm
More hardware is required. To reverse a DC motor on must reverse the direction of current going through the motor. This can be done either with a DPDT relay or a H-drive motor driver circuit. This would require another Arduino output pin to be used to control the direction for the motor and of course the proper software statements to control the pin.

Lefty

11905  Forum 2005-2010 (read only) / Syntax & Programs / Re: Changing Global Variables From WIthin an ISR on: August 18, 2009, 11:27:48 am
Well that's how I declare a variable in a optical encoder program I use that has a ISR to increment or decrement the global variable, and it works fine. Perhaps if you posted your code.

Lefty

11906  Forum 2005-2010 (read only) / Syntax & Programs / Re: working on buttons and can't find the problem. on: August 17, 2009, 08:20:54 pm
Quote
Also this resistor will cause the arduino to sink 2.3 mA through the resistor when the button is pressed. Even with a 4 buttons pressed, that's only 9 mA, which the IC can easily handle.

Actually when using external pull-up or pull-down resistors, virtually no current is being sunk or sourced via the Arduino IC. A AVR input pin is a very high impedance input, so the current flowing through an external resistor is being sourced via the 5vdc regulator IC, not the Arduino. It's only when an AVR I/O pin is programmed as a output pin, does source or sink currents pin specifications come into play.

Lefty


11907  Forum 2005-2010 (read only) / Syntax & Programs / Re: Control a Servo -How? on: August 05, 2009, 08:13:36 pm
Quote
What sort of logic does a typical hobby servo use to decode the pulse train, and how does the changing the frequency of the signal affect it?

Here is an article that goes into some details of a very popular servo control chip, the NE544, that for decades was the standard device used inside of many servos.

http://www.seattlerobotics.org/encoder/200009/Servos.html

Lefty
11908  Forum 2005-2010 (read only) / Syntax & Programs / Re: Control a Servo -How? on: August 01, 2009, 11:09:02 pm
The best way is to utilize the library routine designed to support servos. The MegaServo library is the most comprehensive one at the present time. It's located in the Arduino playground site and has the files to download, instructions on use and an example sketch.

http://www.arduino.cc/playground/Code/MegaServo

Lefty
11909  Forum 2005-2010 (read only) / Syntax & Programs / Re: Input pin always reads high, even with nothing on: July 16, 2009, 04:15:11 pm
Quote
But there's no resistor in the current path?  it doesn't hurt the chip to have a short circuit?

When an Arduino pin is programmed to be an input pin it is a high impedance load and will draw almost no current, so with a external pull down resistor the only current draw is from the ground through the external pull down resistor to the external voltage source, ohms law can help you determine the amount of current that the pull down resistor will draw. Now grounding a Arduino pin that is programmed to be an OUTPUT pin and setting the pin to high in software will cause a short circuit and damage the pin. Conversely wiring an output pin to +5vdc and setting the pin to a low output will also cause a short circuit and damage the pin, But Arduino pins set to input mode can only really be damaged by wiring to voltages above or below the maximum allowed, generally 0 volts and +5vdc ( so no negitive voltages of volts above +5volts allowed) for 5 volt systems.

That make sense?

Lefty
11910  Forum 2005-2010 (read only) / Syntax & Programs / Re: Adding a Subroutine to a perfectly good program on: August 02, 2009, 10:06:37 pm
One setup function only, you will have to combine any initialization code from the two programs into the single setup function.

As far as how to call the second program from the first, you will have to 'wrap' the second program inside a new function statement which will include the code from your second program. There is no need for a break from the new function as it will proceed to the next statement on the calling program when it completes. The return word is used to return/assign a value to calling program if it is required in your coding, otherwise the return is automatic when the new function reaches it's last statement.



Lefty
Pages: 1 ... 792 793 [794] 795 796 ... 1115