Show Posts
Pages: 1 ... 25 26 [27] 28 29 ... 93
391  Using Arduino / Project Guidance / Re: Quadcopter stabilization algorithm on: December 01, 2012, 10:14:21 pm
I'm using the BMP085.  Over a short time period it can detect changes of 1-2ft precision.  I'd like to keep it within 10ft of the setpoint, where I activate it.  Using the P term only loop, you have to sample often to keep it stable, between 1-5 samples/sec.  At 2 s/sec it does not change very often when it's stable.  That's why there are so many 0 values in chg.  Instead of looking at the magnitude of chg, I have to count the number of 0's in a row for the I term.  Am I making sense?  Or am I in my own world? 
392  Using Arduino / Project Guidance / Re: Quadcopter stabilization algorithm on: December 01, 2012, 11:27:37 am
Can you tell me why it won't work properly before I make these changes?
Ideas for improvement?
Thanks for taking the time to read it.
393  Using Arduino / Project Guidance / Re: Project feasibility and cost on: December 01, 2012, 11:19:32 am
Sent you a PM about your project.
394  Using Arduino / Project Guidance / Re: Battery Pack, individual cell voltage measurement on: December 01, 2012, 11:13:59 am
If your goal is to maintain the battery's health, I think 0.04 is enough precision.  Accuracy requires calibration.  You will be lucky to get 0.04 anyway even with 0.01 precision.  Do you understand my solution?  No switching is needed within each bank.
395  Using Arduino / Project Guidance / Re: Battery Pack, individual cell voltage measurement on: November 30, 2012, 10:48:11 pm
Let's say you need to measure within 0.08v.  Then make 2 banks of 20.  Put Gnd at one end and measure the total voltage of each point along the way using a simple voltage divider.  20*4v/1024 is about 0.08v.  In this case you need 1k and 15k resistors x45, cheap.  With a Mega there are nearly 20 analog inputs, but darn only 16. 

Let's say you need to measure within 0.04v.  Then make 4 banks of 12.  Put Gnd at one end and measure the total voltage of each point along the way using a simple voltage divider.  12*4v/1024 is about 0.05v.  In this case you need 1k and 9k resistors x45, cheap.  With a Mega there are >12 analog inputs, so no switching is needed!
396  Using Arduino / Project Guidance / Re: What to do with weird IC on: November 30, 2012, 10:29:23 pm
First you obtain an IC, then you try to think of a use for it?  I like the way you think!
397  Using Arduino / Project Guidance / Re: Arduino two way communication (walkie talkie) on: November 30, 2012, 10:28:22 pm
Reading from a Mic and writing back to a speaker is the easy part.  All you have to do is figure out how to move the data from one Uno to another greater than 10Kb/sec if you want it to sound good.  This can be done using the serial port if the cable is not too long.  A small buffer should do if there are no transmission errors.  I have done it using XBee or Wifly.
398  Community / Exhibition / Gallery / Re: 28BYJ-48 Stepper motor code on: November 30, 2012, 07:13:04 pm
You do not have to read the torque pin yourself unless you want to.  My function ccwss() measures torque and halts program if spike to prevent damage.  Look in that function for example code to see how you could read it to print a warning instead of halting.  But you do have to wire it up.  Just hook any motor winding to analog pin 0.  If you're worried about damage use a resistor like 1k.  Pin 0 does not give you any absolute data, only relative.  After it has been running the code stores the normal value at the normal load.  Anything abnormal will cause the program to halt.  It detects increased torque as well as zero torque if a linkage were to break.  The current the motor consumes is a constant amperage with a given voltage supply.  You can measure this with an ammeter and store it as a constant as it will not change much, even when not moving.  Use the function off() to save power and keep the motor cool when not moving.
399  Community / Exhibition / Gallery / Re: 28BYJ-48 Stepper motor code on: November 30, 2012, 07:05:33 pm
Non-blocking.  No delay().  More than one motor.  Run other tasks at the same time in Loop()

The library is setup to run other code in loop while spinning the motor non-blocking without using interrupts.  First initialize the move you want to make 1x.  This could be done in setup or an if statement in loop for example:

void degrpm_nowait (boolean bcw, long deg100, int rpm100)

Then call this function often:

int calloften_micro (boolean bcw)

At faster speeds you have to call it more often or it will get behind and run slower.  You can look at d in loop to see how much time you have in micros.  There are lines to uncomment if you want it to be more smooth consistent and partly blocking, some of the time.  The calloften functions use little integer math so they are fast.

There is another pair of functions for going slower and cooler using 12v:
void degrpmslowCool4_nowait (boolean bcw, long deg100, int rph100)
int calloften()

With these functions you have much more free time to process in loop, d milliseconds.  If you miss a step it's no big deal, the motor will catch up to keep the speed mostly constant.  It will move the correct distance no matter what you do wrong with timing.

All you have to do is choose the RPM and *100.
400  Community / Exhibition / Gallery / 28BYJ-48 Stepper motor code on: November 30, 2012, 06:52:49 pm
Will update it here when I get feedback or feature requests:

https://gist.github.com/4178431

Here's some help to get you started:

http://arduino.cc/forum/index.php/topic,89159.0

Here is a brief summary of the code.
It can spin a full size DSLR on it's shaft without bearings at 30RPM!
Ramping up and slowing down to prevent bouncing.
It can measure torque to detect an abnormal load or error.
It works without blocking or waiting or interrupts.
Enhanced performance using 12v without warming up the motor.
And much more!
Sounds like an advert, but it's all for Free.
Hardware is $4.

Variables:
bcw 1 is clockwise 0 is ccw
deg100 9000 is 90 deg
rpm100 1000 is 10 rpm, 100 is sec hand
rph100 hour 100 is like minute hand on clock
percslow 10 is 10% slow at end of move
steppos 90.0*STEPERDEG is 90 deg
steps same
xinrev 0,2,3,4,8x in 360 deg
revo # revolutions
const float STEPERDEG=float(64)*64/360;

These are ordered just like in the code:
void unramp (boolean bcw, long deg100, int rpm100, int percslow)
void unramp1 faster
void moveto (int steppos)
void movetodir (boolean bcw, int steppos)

void midspeedcool_12v (boolean bcw, long steps)
void ramp (boolean bcw, int rpm100)
void revRestart (boolean bcw, long revo, int rpm100, int xinrev)
void rev (boolean bcw, long revo)

void degrpmslowCool4 (boolean bcw, long deg100, int rph100)
void degrpmslowCool4_nowait
int calloften()
void degrpm_nowait (boolean bcw, long deg100, int rpm100)
int calloften_micro (boolean bcw)

void degrpmslowCool (boolean bcw, long deg100, int rph100)
void degrpmslowHot
void degrpmslow2

void degrpmEZ (boolean bcw, long deg100, int rpm100)
void degrpm
void degrpm8
void move (boolean bcw)

1 line description for each function above:
unramp stops bounce at end of move
unramp1 faster
absolute position in degrees shortest direction
absolute choose direction

12v only 1/2 speed
speed up over 90 deg
restarts x in 360 rev
obsolete?

most efficient mAh
slow no wait
fast no wait
look at d in loop

cool 4 step
hot 4 step
mid 4 step

8 step 5 lines simple fast ramp, measure torque
8 step 5 lines +err 2.00deg move delay(10)
microstep speed limit 17RPM
relative move 1 step

ccwss() measures torque and halts program if spike to prevent damage
just hook motor winding to analog pin 0
401  Using Arduino / Motors, Mechanics, and Power / Re: New 28BYJ-48 library on: November 30, 2012, 06:23:01 pm
I posted my new library on Gist.  Here is the related posting:
http://arduino.cc/forum/index.php/topic,85335.0.html
402  Using Arduino / Motors, Mechanics, and Power / Re: 28BYJ-48 5-Volt Stepper on: November 30, 2012, 06:20:28 pm
Last summer I got a new Stepper motor!  It's big and does 1 degree / step.  It's faster 300RPM because there are no gears like the 28BYJ.  I wrote more code to do PWM to make it smoother at slow speeds.  It has no gears so you can't just turn off the power when you stop.  When stepping slowly you need to keep the coils on, at least at a lower voltage.  If you use 12v it will overheat within minutes.  It's all here, view at your own risk?  The 2nd file is smaller and much easier to understand first.

https://gist.github.com/4179366
403  Using Arduino / Motors, Mechanics, and Power / Re: 28BYJ-48 5-Volt Stepper on: November 30, 2012, 04:16:16 pm
Here's a demonstration of related code I've been working on.  It allows the same script format to control both a stepper and servo simultaneously and independently.  The script allows you to do motion easing and mechanical animation with Arduino and cheap servos/steppers.  It's a work in progress. 

https://gist.github.com/4178630
404  Using Arduino / Motors, Mechanics, and Power / Re: 28BYJ-48 5-Volt Stepper on: November 30, 2012, 03:46:00 pm
Here it is at last!  With new features.  Will update Gist from now on.
https://gist.github.com/4178431

Please...
Questions?  Comments?  Requests for new features?  Improvements?
Thanks for looking at my code!
Steve

As a learning exercise or tutorial feel free to check out the older version, which is now obsolete.
https://gist.github.com/4149982
405  Using Arduino / Project Guidance / Re: Quadcopter stabilization algorithm on: November 30, 2012, 12:48:18 pm
Here's how simple it can be using all 3 P,I,D:

loop
  error = setpoint - measured_value
  integral = integral + error*dt
  derivative = (error - previous_error)/dt
  output = Kp*error + Ki*integral + Kd*derivative
  delay(dt)

While experimenting you can assign dt,gain to the value of R/C channel 5,6.
Let's start by controlling altitude only using the throttle channel, P term only:

void loop()
ft=get_altitude();
set_throttle((wasft-ft)*gain+wasthrottle);  //gain is Kp
wasft=ft;
delay(dt);

A few more lines gives us I term:
const int NZEROSLOW=3;
const int NZEROSTOP=15;

ft=get_altitude();
chg=wasft-ft;
if last is in correct direction toward setpoint and j-lastj > NZEROSLOW then chg=0;
set_throttle(chg*gain+wasthrottle);
if chg then
   last=chg;
   lastj=j';
j++;
delay(dt);

It's not perfect, oversimplified a bit to make it easier to understand.
Another improvement in case it's moving too slow, not near the setpoint:

if ft-setpoint > 10ft and j-lastj > NZEROSTOP then chg= toward setpoint;

You can use the same method for pitch, roll, yaw using magnetic compass and GPS to correct towards setpoint.

Simple?  Questions?  Improvement?  It works!

PS- Oh great library BTW!  It's not needed for my solution here.
Pages: 1 ... 25 26 [27] 28 29 ... 93