Loading...
  Show Posts
Pages: 1 2 [3] 4 5 ... 38
31  Using Arduino / Storage / Using the writeAnything utility without struct on: February 06, 2013, 06:07:40 pm
This is currently what I have.  I like to have more than one struct value so as to keep things organized in my mind:
Code:
struct config_settings { //these are stored in EEPROM @ 50
  int accel;  //(516 orginally) Offset for the accelerometer when setting level
  int gyro;   //(467 orginally) Offset for the gyro when setting level
}
offset;

struct config_steering { //these are stored in EEPROM @ 25
  int center; //the value of the steering potentiometer in the center position
}
steering;

So then I can refer to them like:
Code:
steering.center
...or
offset.gyro

my question is: Since I only have one variable in the struct called steering, can I skip the struct, and just use a normal variable, like "steeringVal", and yet still use the writeAnything utility to save it to memory.  I currently do this:
Code:
  EEPROM_writeAnything(25, steering);  //save the steering settings to EEPROM @ 25

Could I skip the struct thing and just do this?
Code:
int steeringVal = analogRead(steeringPin);
EEPROM_writeAnything(25, steeringVal);  //save the steering settings to EEPROM @ 25
32  Using Arduino / General Electronics / Re: looking for a louder buzzer on: February 04, 2013, 01:42:35 pm
ok, thanks again.
33  Using Arduino / General Electronics / Re: looking for a louder buzzer on: February 04, 2013, 01:08:17 pm
I would add a series resistor from D8 to the gate to protect against gate capacitance charge/discharge.


OK.  Like a 330ohm or a 1K?  I'm slowly learning about mosfets.  I think the 1K would make it turn on slower?  ...but in the case of a buzzer, it shouldn't matter.
34  Using Arduino / General Electronics / Re: looking for a louder buzzer on: February 04, 2013, 12:05:32 pm
Before I order one of these buzzers, does this schematic look like all's well?
The buzzer is:
http://www.digikey.com/product-detail/en/MAS803Q/458-1257-ND/1957907
The SMD N-MOSFET is:
http://www.digikey.com/product-detail/en/DMN3404L-7/DMN3404LDICT-ND/2052805

The buzzer is 6 VDC, but thats 105dB, so 5 VDC should be loud enough to hear thru a sealed Hammond enclosure.
Thanks
35  Using Arduino / General Electronics / Re: looking for a louder buzzer on: February 02, 2013, 11:48:35 pm
Oh yeah,  I remember now.  I'm still catching on to these transistors and MOSFET's.  I need one that's rated well over what I'll actually be using in current.
This one should work well.
http://www.digikey.com/product-detail/en/DMN3404L-7/DMN3404LDICT-ND/2052805
36  Using Arduino / General Electronics / Re: looking for a louder buzzer on: February 02, 2013, 10:54:35 pm
heatsink...  HMM, this one I was thinking of is SMD, tiny.
Maybe I need a bigger one, so I don't need a heatsink.  The buzzer only uses 130ma...
37  Using Arduino / General Electronics / Re: looking for a louder buzzer on: February 02, 2013, 10:32:57 pm
Thanks, Crossroads,
My segway is powered by 24V, but I only have 5 volt coming onto my control board (supply from Sabertooth motor driver).  I'm hoping to find one that is loud enough, but is PCB mountable, I like cutting out extra wires anytime I can.
It will, however be in a plastic enclosure, at my feet, like this:


I wonder if this one would be loud enough to be heard? http://www.digikey.com/product-detail/en/MAS803Q/458-1257-ND/1957907   It probably would.  It says continuous, does that mean I just have to turn it on, or do I have to give it PWM?  It say 1.5 to 6 V.  I'd give it 5 volts. I have some of these. http://www.digikey.com/product-detail/en/MMBT3904/MMBT3904FSCT-ND/458971  Would this work to power it?
Thanks
38  Using Arduino / General Electronics / looking for a louder buzzer on: February 02, 2013, 09:38:51 pm
I've used this little buzzer from Sparkfun, but it's not very loud.  It works using the tone function.
https://www.sparkfun.com/products/7950


I'm wondering if anyone could tell or would know if this one is louder?  http://www.digikey.com/product-detail/en/AI-3035-TWT-3V-R/668-1204-ND/1745457?cur=USD
The datasheet says 100dB @ 3V, 10cm.  And does this one work off the tone function, or do I just supply it with 3 volts?  Looking at the data sheet on it, it seems I just supply 3 volts.  I'm hoping to find a fairly loud buzzer to alert a me if I'm starting to max out my motor speed on a segway, so the rider can know they're fixing to fall over if they don't slow down.
39  Using Arduino / Sensors / Re: Calculating if I'm within 10% of the center of a pot on: February 02, 2013, 07:13:49 pm
thanks for the info.
40  Using Arduino / Sensors / Re: Calculating if I'm within 10% of the center of a pot on: February 02, 2013, 07:01:59 pm
Here's what I ended up with:
Code:
boolean StraightAhead( void) {
  int lowest, range, middle;
  int limit_low, limit_high;
  lowest = min (steering.left, steering.right); //the lowest of the 2
  range = abs (steering.left - steering.right); //the range from left to right
  middle = lowest + (range / 2);  //the center steering value
  limit_low = middle - (range / 20);       // 5% lower than center
  limit_high = middle + (range / 20);     // 5% higher than center
  int curentVal = steeringVal();
  if (curentVal > limit_low && curentVal < limit_high)
    return (true);
  else
    return (false);
}


What is the difference between these two lines?  Are they the same?
Code:
boolean StraightAhead( void) {
boolean StraightAhead() {
41  Using Arduino / Sensors / Re: Calculating if I'm within 10% of the center of a pot on: February 02, 2013, 08:54:14 am
Are the steering.left and steering.right the raw values from the analogRead() functions ?
Or are they calculated values from 0 to 180 (the degrees for the pot) ?

I assume they are the raw analogRead() values.
Is steering.left always the lower value, or could steering.left be the lower value ?

How do you use the 10%. Do you want the range to be from -5% to +5% around the center ?

I see 3 problems:
(1) Your center is not the range divided by two, but you have to add the steering.right or steering.left (whatever is the lowest value).
(2) Ten percent is "0.1", you use ".01" which is 1%.
(3) A value of "0.1" or ".01" is a floating point value, and you use integers to calculate it. That is not possible.

I used many variable in the next example, to show what is going on.
Code:
// example, not tested

boolean StraightAhead( void) {
  int lowest, range, middle;
  int steering, limit_low, limit_high;
 
  lowest = min (steering.left, steering.right);
  range = abs (steering.left - steering.right);
  middle = lowest + (range / 2);
 
  limit_low = middle - (range / 20);       // 5% lower
  limit_high = middle + (range / 20);     // 5% higher
 
  steering = steeringVal();
 
  if (steering > limit_low && steering < limit_high)
    return (true);
  else
    return (false);
}

Thanks, yes, I see all 3 problems, and your were correct. 
steeringVal(), steering.left, and steering.right  are all raw analog readings, though they typical range from 500-600 min/max, not 0-1024.  So I think what you've come up with looks like it will work.  I'll make a serial monitor debug loop and check it out.  Thanks.
42  Using Arduino / Sensors / Calculating if I'm within 10% of the center of a pot on: February 02, 2013, 01:16:06 am
This one's got me a bit stumped.  On power up, I want my bot to wait until the steering mechanism is within 10% of 'neutral'
Here's some variables I've got assigned to the min/max readings of the steering POT
steering.left
steering.right

steeringVal() is another function that returns the current reading of the POT

I'd like to make a boolean that will return TRUE if the steering is within 10% of center, or FALSE is it's not
This is as far as I got, but I'm not really sure about it...

Code:
boolean StraightAhead() {  //returns true if within 10% of center
  int steeringRange = abs(steering.left - steering.right); //the total range of the steering POT
  int steeringCenter = steeringRange / 2;  //the neutral steering position
  int tenPercent = steeringRange * .01;  //10% of the range, I think
  if (abs(steeringVal() - steeringCenter) < tenPercent) return true;
  else return false;
}
43  Using Arduino / General Electronics / Re: Map() function for curve on: January 29, 2013, 07:25:03 am
Thanks, Robbins!  That's what I'm doing, too.  Even made some crude out of bounds voltages to detect connection failure, so things don't go haywire on a broken wire! 
I should've post a little detail about what I was doing/needing for the benefit of other readers.
I'll take a look at your code...
44  Using Arduino / General Electronics / Re: Map() function for curve on: January 28, 2013, 05:24:18 pm
Thanks.  I'll test this out and see how it works.

45  Using Arduino / General Electronics / Re: Map() function for curve on: January 28, 2013, 01:27:30 pm
Ok, so if I've got variables to work with instead of numbers, it'd be like this?

Code:
unsigned long reading = analogRead(inputPin);
unsigned long SQneutral = NeutralVal * NeutralVal;
unsigned long SQmax = MaxVal * MaxVal;
reading = reading * reading;
reading = reading / (reading / 799);
Pages: 1 2 [3] 4 5 ... 38