Show Posts
Pages: 1 ... 125 126 [127] 128 129 ... 304
1891  Using Arduino / Programming Questions / Re: Why is this program not preforming as it should? on: March 17, 2013, 10:48:38 pm
So you say show me show me show me till it's done?
1892  Community / Bar Sport / Re: Your latest purchase on: March 17, 2013, 09:01:21 pm
You get big price breaks by buying insane quantities or by licensing manufacture and making same.

What we individuals get is the small quantity (less than 100,000's, less than 1,000's) price jacked up to retail levels. If I can make it at a factory for $1, retail is $4+ to whatever cloud in the sky the market will bear... if the price threatens to drop then like oil and gas it will be exported cheaper to mass-buyers offshore. Look at how they do food here. If the price might drop then milk gets spilled down creeks, wheat gets burned or sent to Russia and oranges get rolled into the outgoing tide. Hail Mammon, guardian of Profit!

1893  Using Arduino / Programming Questions / Re: Why is this program not preforming as it should? on: March 17, 2013, 08:42:27 pm
int x[ 10 ]; // has 10 ints.

x[0], x[1], x[2], ... x[9]

If I want the first it is x[0] and the last is x[9].

I'm not very good at C, and I don't understand.

What else do I need to do?

Learn what is going on with arrays. Slow Down and Take The Time.

If I have an array of 14 ints, they will be numbered from 0 to 13. That is 14 ints.
We start counting from 0. We don't start with 1 unless we're doing something special.

Use paper and pencil to draw boxes or whatever you need and count the pieces because that is so basic you really need to understand.

There are basics you need to understand the way you need to know the alphabet before you start spelling words. But you want to write a book instead of learn ABC.
1894  Using Arduino / Programming Questions / Re: Arduino Uno and SPI - Coding Issues on: March 17, 2013, 02:33:31 pm
goforsmoke, indeed, they are expensive and not ideal for this use. I've actually got several other kinds of angle sensors that I've got the code working for. This is for a senior engineering design course, and so I have to prove to the faculty that I've explored and tested numerous solutions before choosing a final model. Our cheapest solution was to just use a rotary potentiometer for like $0.50 - but that just doesn't work within the scope of my project. However, I will check out Hall sensors, as they may very well be another viable option for me! Thanks!

You are being thorough then. It is good.

As an engineer, this is the time when to ask for support from the maker and see what is free. When I looked for application notes and examples, I found nothing helpful to myself. There was a tab for support by I did not click it.

Just looking up Hall sensor... there are many different sensors that use the Hall Effect that say Hall sensor. The inexpensive ones are mostly switch/security type or linear type. I suppose there are also logarithmic as well.
You want the linear (analog) for this, sometimes used in good joysticks. What they lack in features of the MCP411000 you can make up for mostly in software but temperature compensation if needed I think takes extra parts in a circuit. In practice you can likely get around that without.

1895  Using Arduino / Programming Questions / Re: Why is this program not preforming as it should? on: March 17, 2013, 02:20:33 pm
int x[ 10 ]; // has 10 ints.

x[0], x[1], x[2], ... x[9]

If I want the first it is x[0] and the last is x[9].
1896  Using Arduino / Programming Questions / Re: Creating a timer that can reset when a sensor activates on: March 17, 2013, 02:16:50 pm
Quote
Not rocket surgery...

Nor brain science, LOL!

Really Callum, timers are the equivalent of post-it notes saying when something started or happened. Then later code looks at the difference between "now" and "when" to decide if the eggs are cooked. We like simple!  smiley-grin

Details are important but the hardest part takes care of itself, also good news.

* time is kept in unsigned variables, usually unsigned long
* there is no need to code for counter rollover as long as you use unsigned math
* millis() gives you "now" in milliseconds since the Arduino started
* micros() gives the same but closer measure with accuracy of 4 microseconds for tech reasons.

The math you use is ( now - when >= interval ) whether in if or while or other logic, as long as you use unsigned integer variables. The unsigned long used by millis() is good for intervals up to 49.7-some days, micros() is good for 1.193 hours maximum interval.

The best example code to show&play with this that I know is the BlinkWithoutDelay sketch that comes with your IDE. It needs no wiring or parts.
I do have a short unsigned math example (suitable for altering) that shows results in decimal, hex and bits if you really need that.

1897  Using Arduino / Programming Questions / Re: Why is this program not preforming as it should? on: March 17, 2013, 01:52:43 pm
Small thing. You can switch the IR led for a red one to test.
Red led puts out lots of IR, you can confirm on your camera view the red led looks white.

1898  Using Arduino / Programming Questions / Re: Adding a 3 second input delay, using 'delay' lesson for me. on: March 17, 2013, 01:43:49 pm
Quote
With the delay(2000) you're not checking for input persists for over 2 seconds but rather seeing the switch HIGH one very short moment then checking 2 seconds later and if it's HIGH right then, assuming it must have been HIGH the whole time between. What it was really, the delay() keeps you from knowing at all.

I understand about not checking for persistence, continuous input, I probably worded my intent incorrectly.  But I'm satisfied with an assumption that if the (normally steady-state) input is is still there in a couple seconds, its assumed on then.  I'm trying to keep the basic code of this project as simple as possible, initially, to leave as much space as possible for necessities.  I can always improve various modules after its completely roughed-in and operating.

You will have to regardless but the route you chose is the road to spaghetti-ville.

Add: and besides, debouncing usually takes less than 2 seconds.
 
1899  Using Arduino / Programming Questions / Re: Arduino Uno and SPI - Coding Issues on: March 17, 2013, 01:28:34 pm
Those look like a very expensive, complicated way to do what a < $1 linear Hall sensor does but with features the Hall does not have.  

1900  Using Arduino / Programming Questions / Re: Adding a 3 second input delay, using 'delay' lesson for me. on: March 17, 2013, 12:32:04 pm
I'm trying to watch a switch input, and not respond unless the input persists for over 2 seconds, etc.

With the delay(2000) you're not checking for input persists for over 2 seconds but rather seeing the switch HIGH one very short moment then checking 2 seconds later and if it's HIGH right then, assuming it must have been HIGH the whole time between. What it was really, the delay() keeps you from knowing at all.



1901  Using Arduino / Programming Questions / Re: FREQUENCY METER on: March 17, 2013, 03:32:44 am
Count a bunch of pulses using an interrupt and see how long that took. You then have pulses and time. The more pulses, the better your average. Also use micros() for time.

I wrote a program for one guy here just last week but he decided to stick with a library.

Here it is, just happened to have a copy in my sketchbook. You can change what you want.

Code:
volatile unsigned long pulseCount = 0UL;
unsigned long startT, endT, freq, pC;

void counter()
{
  pulseCount++;
}

void setup()
{
  Serial.begin(38400);
  Serial.println( "Frequency counter" );
  attachInterrupt(0, counter, RISING);
}

void loop()
{
  noInterrupts();
  pC = pulseCount;
  interrupts();
 
  if ( pC == 1UL )
  {
    startT = micros(); // start time very close to on a pulse edge
    // getting end time should have the same lag within a few cycles
  }

  // if pulses are 5/second, 10 seconds will take 50 pulses --- check the 5/sec!
  if ( pC >= 51UL ) // 50 pulses -after- pulse 1
  {
    endT = micros();

    endT -= startT; // end now holds elapsed micros

    // frequency = pulses/second, we have pulses and microseconds, 1000000 usecs/sec
    // Hz = pulses x 1000000 / microseconds   

    freq = pC * 1000000UL / endT;

    Serial.print( "\n count " );
    Serial.println( pC );
    Serial.print( " micros " );
    Serial.println( endT );
    Serial.print( " freq " );
    Serial.println(freq);

    noInterrupts();
    pulseCount = 0UL;
    interrupts();
  }
}


1902  Using Arduino / Programming Questions / Re: how to convert g-code to electrical signal??? on: March 17, 2013, 03:26:18 am
Quote
i want to write a program tat converts the gcode to electrical signal on my own

Maybe you should visit a shop where they have NC/CNC machines and watch for a while, then look through some NC/CNC manuals. Because it's nothing so simple as "an electrical signal".

Some people may refer to NC/CNC codes as G- codes when in fact depending on the machine these may be X, Y. Z, T and G codes with G codes standing for whole routines like circle left or right or hogging out a pocket, things like that.

To go from there to doing things with your router like turning it on and moving it around is going to require power control and axis motor control and loads of fun things that takes shop time to know not just how they matter but even that they do matter.

But I have a question for you and many others. Why do you pick something you don't know enough about to even ask vaguely the right questions about for a FINAL YEAR PROJECT?

Good luck, I hope your prof/teacher is clueless on the subject so that anything that works will look good.
1903  Using Arduino / Programming Questions / Re: Float precision 6-7 digits, is it 6 or 7? on: March 16, 2013, 08:09:42 pm
Yup, those last 3 get to wear red shirts. You know they won't be beaming back up.

1904  Using Arduino / Programming Questions / Re: Float precision 6-7 digits, is it 6 or 7? on: March 16, 2013, 04:23:38 pm
Even with integers, once I do division that has a remainder.. if I discard that and scale up, I lose places.

Just saying, it's not enough to simply be able to hold a value.

So maybe when I want 3 place decimals I would choose to work with 6.

1905  Using Arduino / Programming Questions / Re: Wait for real end of serial transmission on: March 16, 2013, 11:44:03 am
I use 0022 and have 1.03 that I set up to work someone else's sketch with. XP being what it is, I've had to reload drivers to go back.

Yes, I know the solution. Quit using XP and the things that I run that only run on Winblows.
I'm just not ready yet. The day is coming though.

Pages: 1 ... 125 126 [127] 128 129 ... 304