Show Posts
Pages: 1 2 3 [4] 5 6 ... 15
46  Forum 2005-2010 (read only) / Syntax & Programs / Re: Debouncing on: August 28, 2010, 08:29:59 pm
Quote
It is considered good practice in software debouncing not to wait until the bouncing is over, but to immediately act at the first edge because you know that the key has been pressed!

It is considered good practice in electronics to make sure that the circuit is not experiencing Impulse noise and giving a false reading.  You don't know that the first edge is due to the button being pushed: Instead, you should recheck a short time later to see if the input is still high.
47  Forum 2005-2010 (read only) / Syntax & Programs / Re: Debouncing on: August 26, 2010, 04:06:26 am
Hey there,

You need to see if you can shorten that interrupt routine- they need to be as short as possible, because other interrupts may be waiting, or even missed- you should just get the data you need and let your main code deal with any data manipulation.  

When you read a port "PORTC", you should instead read "PINC" (see section 13.2.4 of the datasheet)

I think that all the states should be volitile global variables, so that the main code can take some functionality from that interrupt routine.

smiley
48  Forum 2005-2010 (read only) / Syntax & Programs / Re: Infraferd Text Communication on: August 31, 2010, 08:08:11 pm
Post your library and we'll see if we can find any errors.
49  Forum 2005-2010 (read only) / Syntax & Programs / Re: "Addressing" multiple arduino's on a sin on: August 31, 2010, 07:43:22 pm
"vdd and gnd"

I meant that you don't need both, only one.

(I think that that is what you are asking?...)
50  Forum 2005-2010 (read only) / Syntax & Programs / Re: "Addressing" multiple arduino's on a single serial on: August 31, 2010, 07:56:54 am
Ignore my post as you do not need Vdd and gnd for RS comms.

51  Forum 2005-2010 (read only) / Syntax & Programs / Re: "Addressing" multiple arduino's on a sin on: August 30, 2010, 08:59:49 pm
Sorry, but what was wrong with I2C?

It uses 1 less wire (no ground), and does all the addressing for you.

[edit]It also makes sure that only one device uses the bus at a time.[/edit]

[edit]http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1283156757/#13[/edit]
52  Forum 2005-2010 (read only) / Syntax & Programs / Re: Size of unknown array element on: August 31, 2010, 08:08:25 am
No worries dave!

Grove, can you please explain what you mean?  I don't understand how this can solve the sizeof() problem?

smiley
53  Forum 2005-2010 (read only) / Syntax & Programs / Re: Size of unknown array element on: August 30, 2010, 08:55:28 pm
@ davekw7x
Quote
1.  In the original post, digits[] was an array of pointers, so sizeof digits[n] is equal to 2 for n = 0, 1, ..., 9

2.  In the most recent code, digits[] is an array of arrays, and sizeof digits[n] is equal to 8 for n = 0, 1, ..., 9

I think you misunderstood me.

What I meant was to create a different single dimension array with all the lengths stored in it.
Code:
uint8_t sizeof_digits[] = {
6,  //sizeof(digits[0])
2,  //sizeof(digits[1])
5,  //sizeof(digits[2])
5,  //sizeof(digits[3])
...
}

And just get the info out of that instead of calculating it at run time.

When I said, "What I thought that they meant was to add this to your code..." I was just saying where the idea came from.

smiley
54  Forum 2005-2010 (read only) / Syntax & Programs / Re: Size of unknown array element on: August 29, 2010, 09:11:32 pm
What I thought that they meant was to add this to your code:

Code:
uint8_t sizeof_digits[] = {
6,  //sizeof(digits[0])
2,  //sizeof(digits[1])
5,  //sizeof(digits[2])
5,  //sizeof(digits[3])
...
}

And just access the size of, say, digits[4] by using sizeof_digits[4].
55  Forum 2005-2010 (read only) / Syntax & Programs / Re: PLC program on: August 30, 2010, 09:15:35 pm
PLC's are programmed completely differently to an Arduino.

What you need to do is read each input and then update each output based on what the inputs are (Which can be redone just using C programming and "ditching" the PLC format).

If you are translating a large PLC program that you do not want to re-write, you can follow this logic:
If 2 input switches are in series, use an AND statement; if they are in parallel, use an OR statement, and check everything before updating.

However, be aware that the Arduino does not have the safety functions that are included on a PLC, so you would be better staying with them.
56  Forum 2005-2010 (read only) / Syntax & Programs / Re: if ┬ástatement on: August 29, 2010, 07:06:40 pm
Quote
if(currentMillis = previousMillis>interval)

I believe that you have 2 typos here.

did you mean...
 if(interval [glow]==[/glow] (currentMillis [glow]-[/glow] previousMillis))

57  Forum 2005-2010 (read only) / Syntax & Programs / Re: Load a specific pde on arduino-ide startup on: August 29, 2010, 07:17:12 pm
Why not save your template on your desktop and just open that each time?
58  Forum 2005-2010 (read only) / Syntax & Programs / Re: Need some PROGMEM suggestions on: August 28, 2010, 08:16:40 pm
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=38003

smiley
59  Forum 2005-2010 (read only) / Syntax & Programs / Re: Pseudo Code Clarification on: August 28, 2010, 08:07:34 pm
Sorry about the late reply.

Although you might not get too much of an issue with that code, I did have quite a lot of trouble with the sensor inputs.

Basically, your analogue input is going to be the correct value +/- a random value (noise).  There was a few ways in which people got around this: 2 that comes to mind are:
  • Take 10 (or more) samples and take the average.  (Or just make your threshold 10 times bigger)
  • Or what I did was have a variable that incremented every time the sensor value was above threshold value (until it got to 10), and decremented when it was below (until it got to 0).  When ever the variable was above 5, it was considered on, and when it was below, it was considered off.

My advice is to NOT overlook this problem.
60  Forum 2005-2010 (read only) / Syntax & Programs / Re: Pseudo Code Clarification on: August 26, 2010, 12:37:11 am
Gotta love Stampy!  Yes that is it!

For one of my subjects at Uni, we had a 3 round tournament which included:
  • (Qualifying) finding a box in an "arena" and pushing it out
  • (Qualifying) a defensive mode, where it had to evade that same box chasing it around on a bit of string
  • and then the tournament where you needed to push the other robot out of the ring
Restrictions where 1000g (2.2lb?) and AU$160.  You couldn't use kits either (well sort of:  You could get a motor and gearbox kit).

It's in bits and pieces now.
Pages: 1 2 3 [4] 5 6 ... 15