Show Posts
Pages: [1] 2 3 ... 165
1  Community / Gigs and Collaborations / Re: Quick $5 for the first working response on: July 27, 2014, 07:22:45 pm
When are there ever pinMode calls for analog input pins?

I really didn't know that there weren't, that it's unnecessary, and I think that I made that clear.
After a couple of years, I didn't know that analogWrite doesn't require a pinMode call either.
The Reference doesn't note that pinMode calls for analog inputs (vis-a-vis analogRead) are unnecessary.
Technically, a digital input doesn't require a pinMode call either  (but there's one up there - and I'm OK with it.)

So, like I said before, already, I went down the rabbit-hole!
Now, if you'll pardon me, I have to go set fire to myself in the backyard.
2  Community / Gigs and Collaborations / Re: Quick $5 for the first working response on: July 27, 2014, 10:28:18 am
I was looking for the pinMode for that.
Pins are Inputs by default, I know, but since there was a pinMode for button I was caught up looking for one for "pot" (nonesuch).
3  Using Arduino / Project Guidance / Re: Quadcopter Follow me on: July 27, 2014, 09:32:38 am
How about several going around you in a circle, shooting flames (chariots of fire?)
4  Community / Gigs and Collaborations / Re: Quick $5 for the first working response on: July 27, 2014, 09:29:54 am
Where's the "pot adjustment" part, John?
5  Using Arduino / General Electronics / Re: Connecting Lm2904P on: July 27, 2014, 08:46:45 am
If you connect the input to +5 then the output will be nearly Gnd.
If you connect the input to Gnd then the output will be nearly +5V.
6  Using Arduino / General Electronics / Re: Connecting Lm2904P on: July 27, 2014, 08:45:04 am
Your op-amp, as shown, is configured as an Inverting amplifier.
7  Using Arduino / General Electronics / Re: Connecting Lm2904P on: July 27, 2014, 08:42:47 am
I see... My mistake...
But, anyway, it is 0.8...

And you expect it to be, I guess, "0"?
0.8 is about as close to Gnd as that particular op-amp will go.
8  Using Arduino / General Electronics / Re: Connecting Lm2904P on: July 27, 2014, 08:32:46 am
As i know, output should be -3.3V in this case, but I have 0.81V...
What I am doing wrong?

How could the op-amp have a negative voltage output without being  connected to a negative supply voltage?
9  Using Arduino / General Electronics / Re: IR Led and Phototransistor connection give always 0 value on: July 26, 2014, 08:09:05 am
I think, for one thing, that analogRead takes too long.
IMO, you  ought to be digitalRead'ing.

That delay(20) that you have is pretty big, too,
The time between one grain and the next is probably (much) shorter than that.
Get rid of the buzzer thing right now and get the counts right.

[I worked with optical sorting machines once upon a time.]
10  Using Arduino / Programming Questions / Re: Trough Detector on: July 26, 2014, 07:10:40 am
Code:
  pinMode(transistorPin, OUTPUT);
  transistorPin = 9;
Using transistorPin  to set pinMode before it is defined to a value?

Yes, that was naughty.  Corrected.

This is what I have, and have in the Arduino, at present:
Code:
byte transistorPin;
byte x;
float currentVal;
float previousVal;
float formerDiff;  // old    currentVal - previousVal
float currentDiff; // latest currentVal - previousVal

void setup()
{
  transistorPin = 9;
  pinMode(transistorPin, OUTPUT);
  x = 1;                // freq of the ramping
  previousVal = 100.0;  // starter value, rubbishy
  formerDiff = -20.0;   // starter value, rubbishy
  //Serial.begin(9600);
  delay(500);
}

void loop()

  currentVal = (exp(sin(millis()/1500.0*x*PI)) - 0.36787944)*108.0;
  currentDiff = currentVal - previousVal;
  //Serial.print(currentVal,DEC);
  //Serial.print(" _ ");
  //Serial.print(currentDiff,DEC);
  //Serial.print(" _ ");
  //Serial.println(formerDiff,DEC);

  if( (currentDiff>0) && (formerDiff < 0) ) //
  {
    // trough detected, so swap pins
    swap_pins();
  }
  analogWrite(transistorPin, currentVal);
  formerDiff = currentVal - previousVal;
  previousVal = currentVal;
  delay(35);  // takes the place of the Serial.prints
              // pins won't swap consistently w/o it.
}

void swap_pins ()
{
  if(transistorPin == 9)
  {
    transistorPin = 10;
  }
  else
  {
    transistorPin = 9;
  }
}

Another "thing" - without that delay() up there in the setup() function, it comes up funny like doing both outputs, for the period of a couple of iterations. I found that out when I commented it out.  It was originally 1000 and I tried jockeying the values (1, 10, 100), plugging in 500 made it happy again.
Curiouser and Curiouser.
11  Using Arduino / Programming Questions / Re: Trough Detector on: July 25, 2014, 09:30:27 pm
OK
I used delay(35);
[because, as I noted previous, Serial.print(currentVal,DEC); alone isn't enough]
I est. that to be the time of all the characters printed.

I placed it everywhere in the loop function, from first to last.
I didn't place it inside the if, i.e. the trough detector or in the swap_pins function.
No matter where (otherwise) the pin swapping is consistent.
But I don't know why it makes a difference.
[And but for this happy accident, it would not work at all.]

I guess that it could be that after 1,000 or 10,000 iterations that it might hiccup after all.
12  Using Arduino / General Electronics / Re: Component to connect parts in parallel on: July 24, 2014, 08:42:45 pm
Quote
Details matter
They do but at the end of the day it is wire.

I hope that you don't intend this to compete with my "Ground Bus Shield"TM
13  Using Arduino / Programming Questions / Re: Trough Detector on: July 24, 2014, 08:39:09 pm
Well, as you can see, the Serial.prints are right before the "trough detector", which is likely significant.
Somehow they're "beneficial".  It's a little shagged out after all that float math and can do with a respite, a relaxation interval?

I was hasty in saying that if I leave even "just one" then it's OK.
That's not really so, as it turns out. I had just the first there and it repeated once that I saw this morning. Pretty early on (always after the same number of reps after pressing Reset), too, but still an overall improvement over the very first attempt.
I went and put the others back in.
With all of them there, I haven't noticed any hiccups.
I suppose in printing the three floating values and the spaces etc, that's maybe 35 characters, 350 bits, 9600bps, 35+msecs on that.
Still, the effect doesn't seem to suffer for it.

[ Inquiring minds want to know. They don't always know how to find out though.]
14  Using Arduino / Programming Questions / Re: Trough Detector on: July 23, 2014, 08:09:02 pm
The fading up/down works.
(This is a pretty easy circuit to set up.)

The conundrum has been in steering the fading action into alternating outputs.
In the original version, that didn't go consistently.
With the latest Trough Detector's comparing trends, it stayed stuck (stuck on 1 output ) till I introduced some Serial.,print statements whereupon (mysteriously?) it works.

> > > Clarification - "stuck on 1 output"

> > > > Is this a fringe benefit of float? you can't dive right when you want to?
15  Using Arduino / Programming Questions / Re: Trough Detector on: July 23, 2014, 07:56:13 pm
Yes - it was getting late, that's how I had it, but I started grasping at straws and just chucked the >.
So, sorry for any mix up.

This isn't happening (but should):
Code:
byte transistorPin;
byte x;
float currentVal;
float previousVal;
float formerDiff;  // old    currentVal - previousVal
float currentDiff; // latest currentVal - previousVal

void setup()
{
  pinMode(transistorPin, OUTPUT);
  transistorPin = 9;
  x = 1;                // freq of the ramping
  previousVal = 100.0;  // starter value, rubbishy
  formerDiff = -20.0;   // starter value, rubbishy
}

void loop()
{
  currentVal = (exp(sin(millis()/1500.0*x*PI)) - 0.36787944)*108.0;
  currentDiff = currentVal - previousVal;
  if( (currentDiff>0) && (formerDiff < 0) ) //
  {
    // trough detected, so swap pins
    swap_pins();
  }
  analogWrite(transistorPin, currentVal);
  formerDiff = currentVal - previousVal;
  previousVal = currentVal;
}

void swap_pins ()
{
  if(transistorPin == 9)
  {
    transistorPin = 10;
  }
  else
  {
    transistorPin = 9;
  }
}

So, I said "Rats! Why not??"
Then I punched in some Serial.prints to get some data (currentVal, currentDiff, formerDiff)
Code:
byte transistorPin;
byte x;
float currentVal;
float previousVal;
float formerDiff;  // old    currentVal - previousVal
float currentDiff; // latest currentVal - previousVal

void setup()
{
  pinMode(transistorPin, OUTPUT);
  transistorPin = 9;
  x = 1;                // freq of the ramping
  previousVal = 100.0;  // starter value, rubbishy
  formerDiff = -20.0;   // starter value, rubbishy
  Serial.begin(9600);
  delay(1000);
}

void loop()
{
  currentVal = (exp(sin(millis()/1500.0*x*PI)) - 0.36787944)*108.0;
  currentDiff = currentVal - previousVal;

  Serial.print(currentVal,DEC);
  Serial.print(" _ ");
  Serial.print(currentDiff,DEC);
  Serial.print(" _ ");
  Serial.println(formerDiff,DEC);

  if( (currentDiff>0) && (formerDiff < 0) ) //
  {
    // trough detected, so swap pins
    swap_pins();
  }
  analogWrite(transistorPin, currentVal);
  formerDiff = currentVal - previousVal;
  previousVal = currentVal;
}

void swap_pins ()
{
  if(transistorPin == 9)
  {
    transistorPin = 10;
  }
  else
  {
    transistorPin = 9;
  }
}

And all that data looked right.
And then I noticed - it was working perfectly !

I deleted all of the Serial.prints and it bombs.
If I leave just one of those in then it works.
So, What Gives?
Pages: [1] 2 3 ... 165