Show Posts
Pages: 1 ... 48 49 [50] 51 52 53
736  Using Arduino / Programming Questions / Re: Serial and Timer Interrupt Simultaneously on: February 08, 2011, 12:21:21 pm
When an ISR is executed, interrupt processing is disabled for that ISR.  This will prevent you from sending serial data within the ISR.

You can get around this by re-enabling interrupts within your ISR yourself, but you want to be extremely careful about doing so.  In your example, doing so would be unnecessary.  What you should do is set a global flag in the ISR, and in your loop() function,  monitor that flag and issue the println when it's set (then unset).  The global will have to be declared volatile for it to work properly.
737  Topics / Product Design / Re: How long should a project take? on: February 08, 2011, 12:14:33 pm
As a general rule of thumb, I find that once I have a prototype running, I'm only about a third of the way done with the project.  That could just be me though.
738  Using Arduino / Programming Questions / Re: millis calculation failing on: February 08, 2011, 10:55:03 am

The line:

    unsigned long fin_retardo = currenttime + tiempo_para_ejercitar; // fin retardo, tiempo actual+diff tiempo hasta ejercitar

inside your if() block is declaring a second fin_retardo variable that is only local and available within your if block (this block being the code inside the if's { and }).  Once this block is left, that local variable goes out of scope and is gone.  So your later print statement is referring to the global fin_retardo, which never got assigned anything and is thus still = 0.

Get rid of the unsigned long in that line.  You don't want to declare a new variable, but use the global you've already declared.
739  Using Arduino / Programming Questions / Re: implementing a "soft reset" ISR / delay inside isr on: February 08, 2011, 10:42:48 am
Seems to me the root of your troubles is the use of delay().  Instead of trying to work around the problem, why not just fix the root problem, ie use millis() instead of delay().  In my book, that is a far cleaner solution than trying to resort to a stack manipulating ISR() to abort a delay().
740  Using Arduino / Motors, Mechanics, and Power / Re: Step Motor Library on: February 08, 2011, 09:52:19 am

It looks like that Gecko motor driver handles all the control logic for you. IOW, you don't need a step motor library to interface with that motor driver.  Just tie two Arduino outputs to the direction and step inputs on the motor driver.  Set the 'direction' output to the direction you want the motor to turn, and pulse the step output to turn the stepper motor in that direction (one step per pulse).

I do not believe the Stepper library works with a direction/step arrangement.  The motor pins refer to the pins driving the coils themselves.  Direction is determined by specifying a positive or negative number of steps when you call the step() method.
741  Using Arduino / Motors, Mechanics, and Power / Re: PID Example 1 on: February 08, 2011, 09:14:45 am
analogWrite() works with the PWM pins, so pin 3 refers to digital pin 3, not analog pin 3.  The analog inputs are input only (as outputs they are digital, but without PWM capabilities)

And that sample is from the PIDLibrary in the playground here:
742  Using Arduino / Programming Questions / Re: Timer overflow interrtups - how ? on: February 07, 2011, 03:26:17 pm
Tutorial on AVR timers.
743  Using Arduino / Programming Questions / Re: ADDING SINGLE PUSH BUTTON TO EXISTING CODE USING BRICK SHIELD V4 HELP PLEASe on: February 04, 2011, 09:44:07 pm
Sorry, I had one incorrect line in my sample code for you.  Change the following line:

active != active;


active = !active;

That's what I get when I rush something and just compile it without running it.
744  Using Arduino / Motors, Mechanics, and Power / Re: Motorshield? on: February 03, 2011, 05:00:25 pm
The tamiya twin gearbox motors are only rated for 1.5-3.0 volts.  People have run them at 5 volts, but their life can be severely shortened by doing so.  They just aren't built to handle more than 3 volts.

That being said, that gearbox is well suited to small robotic rovers.  Just don't overdrive the motors.  I burned out one of mine with about half an hour of runtime at 5 volts.  (That was half an hour of intermittent usage over a period of a few hours as I was writing and debugging my control code).

I then replaced both motors with a pair of these: and they've been running like a champ ever since.
745  Using Arduino / Programming Questions / Re: ADDING SINGLE PUSH BUTTON TO EXISTING CODE USING BRICK SHIELD V4 HELP PLEASe on: February 03, 2011, 02:48:13 pm
Almost, but not quite.  My last instruction was a bit misleading though, so that's my fault.

I really meant to say fill in the two blocks of the second if statement.  The first if is just toggling the active state, and there shouldn't be any other code in there.  The second if statement has two blocks (a block being a section of code surrounded by { and }).  One will execute while active = true, the other will execute while active = false.

If you don't want anything happeneing while active = false, then leave that section blank.

Delete the code you added in the first if() and see if that does what you want.
746  Using Arduino / Programming Questions / Re: ADDING SINGLE PUSH BUTTON TO EXISTING CODE USING BRICK SHIELD V4 HELP PLEASe on: February 03, 2011, 11:34:38 am
It appears that mini push button board has some hardware debounce (there's a resistor and a cap on the board, and I think it's safe to assume that is what they're there for).

If I am understanding correctly, you want to toggle your servo/led activity on and off with separate activations of the button.

boolean active = false;
boolean lastState = LOW;
boolean currentState = LOW;
byte buttonPin = A0;

void setup(){

void loop(){
  currentState = digitalRead(buttonPin);
  //When lastState is LOW and currentState is HIGH, we have detected a rising edge transition
  //ie the input has just gone high.  This is when we toggle are active boolean
  if(lastState == LOW && currentState == HIGH){
    //toggle active state
    active != active;
  lastState = currentState;
    //Perform actions when active = true;
    //Perform actions when active = false;

I was unclear exactly what you wanted to happen in those two states, but simply fill the two if blocks with the code you wish to have executed for each state.
747  Using Arduino / Project Guidance / Re: DC Motor Indirectly Powered by a Solar Panel on: February 03, 2011, 09:45:04 am
If we crunch a few numbers, we can easily get an idea of how long the train can be run via the solar panels.

12V solar panels at 25mA = 300 mW of power.

12V motors drawing 2A = 24 watts of power (or 24000 mW).

At 100% efficiency (unrealistic, but just to get some ballpark numbers), for every minute the train runs, the solar panels will need more than 80 minutes to recharge.  If we factor in the inefficiencies of the system, you're looking at increasing that time by upwards of 50%.
748  Using Arduino / Project Guidance / Re: Counting Ants on: February 03, 2011, 09:13:26 am
but I don't know how to do this 60 times, or otherwise keep track of when to log the numbers, when the minute is up. How does one use interrupts? What's the digital--> blink you referred to?

Each time you add to the average, increment a separate counter variable as well.  When the counter = 60, log and reset.  Something like:

  temperature += (voltage - 0.5) * 100 / 60;
  tempCounter++; //this can be defined as a byte (but if you want to increment up to values above 255, you'll need to use a larger variable
  if(tempCounter == 60){
    //write out your temperature
    //reset variables
    tempCounter = 0;
    temperature = 0;

There are several timer libraries available that will help you easily run the above code at some specified interval.  No need to reinvent the wheel, except as a learning experience.  But for that you can just read the code those libraries use.
749  Using Arduino / Programming Questions / Re: Floating point math on: February 01, 2011, 03:08:05 pm
That's great news, thanks! I need to do several dozen caculations in a second, so I probably have the time, and lots more to spare.

You could easily do several thousand calculations per second more than likely.
750  Topics / Robotics / Re: l293d motor shield for Tamiya on: February 01, 2011, 01:34:35 pm
You want VCC1 and all your logic inputs running off the Arduino power supply.
You don't want a 10k resistor inline with VCC1.
You need to flip the ground side diodes on your motor outputs.
All grounds should be tied together. (this includes Arduino and motor supply grounds)
Pages: 1 ... 48 49 [50] 51 52 53