Show Posts
Pages: [1] 2 3 ... 10
1  Using Arduino / General Electronics / Re: Calculating power dissipation in a tranzorb for inductive flyback clamp on: March 15, 2013, 03:16:54 pm
Well the units seem correct.    Frequency = Counts per second.   Joules * count(unitless) /seconds = Joules/seconds, which is correct units for Watts.
2  Using Arduino / Project Guidance / Re: Luminous Intensity Sensor on: December 16, 2012, 05:04:20 pm
I've just been playing with this, to great success - using a LED as the sensor!  I used a fairly large white one I had lying around.

http://playground.arduino.cc/Learning/LEDSensor
3  Using Arduino / General Electronics / Re: Newbie questions on: November 14, 2012, 05:27:48 pm
Have you read about the stepper library.

Arduino site home page - Reference - Library - Stepper.  There are 3 links on that page, Tom Igoes page is a good read.
http://arduino.cc/en/Reference/Stepper
4  Using Arduino / General Electronics / Re: 6V Battery Power Arduino on: October 07, 2012, 10:29:03 am
I drive atmega328 chips directly with 4 AA NiMh cells, which have a slightly lower voltage.
5  Using Arduino / Programming Questions / Re: How to enable the External Occillation. on: October 07, 2012, 10:26:54 am
What are you trying to do?  Are you sure that speed is needed?
6  Using Arduino / Programming Questions / Re: How to enable the External Occillation. on: October 07, 2012, 10:02:02 am
The atmega328 will run up to about 20Mhz with a crystal oscillator, depending on version and voltages.  You need to read the
processor specification for the exact parameters.

It will not run at 100MHz.

The arduino board already uses an external crystal oscillator.  To have a standalone atmega328 with an external oscillator you need
to have a 16Mhz crystal, and 2 22pF capacitors.  Look at the microprocessor part of this forum for more details.

You also need to program the fuse bits correctly - if you have an in-circuit programmer this is easy to do, again in the forums, loading a standard bootloader will set the fuse bits correctly on a brand new processor chip.

If you buy a chip with a bootloader already burnt it will be set for an external crystal oscillator already.
7  Using Arduino / Programming Questions / Re: A latching trigger on: October 06, 2012, 12:23:27 pm
I think you are on the right track with the states, but you do not have enough of them for easy debugging.

How about these names for states (you may think of others for your application)
IDLE, OPENING, FULLY_UP, CLOSING, FULLY_DOWN.

Now try writing down what you want it to do for each state transition, and what will start the transition.  Try and cover
the cases from all sensor inputs that are available, including your buttons.  That will give the logic of what happens at
each state, and should make it easy to code.  As part of what will happen, decide on which next state is wanted.


For example:
Its IDLE, and light sensor says dark => switch to CLOSING

Its FULLY_DOWN and light sensor says dark => do nothing
Its FULLY_DOWN and light sensor says daylight => switch to OPENING

Its OPENING and not at encoder limit => motor up
Its OPENING and at encoder limit => motor off, switch to FULLY_UP
Its OPENING and down_button pressed => do nothing (or if that is the wrong spec for you, say something else).
Its OPENING and light sensor says dark => do nothing
Its OPENING and light sensor says daylight => do nothing

Then try drawing out a state diagram (optional, but really useful). In your case, for each state there are inputs from the sensor, encoder and buttons.

Don't try "clever" tricks like state = state -1, explicitly set the next state wanted, e.g. state = OPENING;
(A useful, but advanced idea is a C++ enum).
8  Using Arduino / Microcontrollers / Re: Giant Arduino! on: October 05, 2012, 03:06:45 pm
How do you shrink it down to the normal size?
Also, could you shrink one even smaller to a complete arduino about the size of a thumbnail?
9  Using Arduino / Programming Questions / Re: Looping for a set amount of times. on: October 05, 2012, 02:58:06 pm
One way of doing what you want is a state machine

Imagine your states are:
Idle
Any_button_seen
Button1_flashing
Button_2_flashing

What would make the transition idle->Any_button_seen?  How would you decide to go to the state Button1_flashing?
If you were in the state Button1_flashing, what should the Arduino do?  How would it decide to finish flashing (hint: look at blinkwithoutdelay example)
When finished flashing, what state do you think it should go back to?

Look up state machine.
Try drawing out the state machine on a sheet of paper.  What might make it move from one state to another?

You will need a variable representing a state, and a switch statement.
10  Using Arduino / General Electronics / Re: How to read a pulse on: October 04, 2012, 03:53:35 pm
The female 9 way d-type, which I understand is part of a USB-RS232 converter is NOT compatible with your arduino.  Stop connecting it.
The output is +10 to -10V, which might blow the Arduino input pins.

Try this:
COM to Arduino ground (0V).
NO to an Arduino digital input pin.  Any will do (but not the dedicated serial 0 or 1).

Set the Arduino input pin to INPUT and write the value to HIGH.  This will turn on the internal pull up.  So the value read
will be 1 when the bucket is not tipped, and 0 when the bucket tips.
11  Using Arduino / General Electronics / Re: How to read a pulse on: October 04, 2012, 01:04:42 pm
Can you post your entire circuit.

The statement that it works and "However when I remove the connection to the computer the whole thing goes crazy printing lots of pulse times which are all wrong as I am not pouring water, and thus should not receive anything." seem mutually exclusive.

One wire will not work; there is a sneaky earth coming in somewhere.

If your bucket tips quite slowly (say, as slow as 10ms which is 1/100 second), you have plenty of time to poll
for a change, double or triple check the signal is stable to allow for debounce, increment your counter, then continue to poll until the end of the pulse.  An arduino runs its main loop about 20000 times a second.  Polling allows debounce,
interrupts make that quite a bit harder.  Try a quick polling sketch to see.
12  Using Arduino / Programming Questions / Re: Interrupt: Need to keep track of time spent in routine or ... ? on: September 22, 2012, 11:53:25 am
I suspect you are doing this:

delay(time1);
output_to_device_1;
delay(time2);
output_to_device_2;

Since you have not posted any code I am guessing.
Have you looked at the blink_without_delay example?  This allows several 'things' to go on at once,
with the advantage that the processor is not hung in a delay() statement.

Your  structure in that case could be something like this pseudocode,

Code:

// need a array of times to do things, what to do it on, which way to switch (on or off)
// a structure might be a good way to do this, you could probably get the (time, device address, operation) into
// ( a byte, two bytes, a byte), so for 500 devices would take 500 * 4 =  2K of program memory

void change_output_to_off(int current_step)
{
  // look into your sequence array, choose the device indexed by current step
  // and turn it off
}

void change_output(int current_step, boolean fault_found)
{
  if (fault_found){ return; }
  // look into your sequence array, choose the device indexed by current step
  // get the desired value,
  // do whatever address setting up you have to do for that device
  // change the value
}

setup()
{
   fault_found = false;
   current_step = 0;
   // other stuff, including recording starting time from millis()
}

loop()
{
if (!fault_found)
{
   fault_found = check_fault_state();
}
if (fault_found)
{
  change_output_to_off(current_step);
  if (time_elapsed_after_fault(millis()))
  {
     fault_found = false;
  }
}
if (time_to_do_next_step(millis())
{
   set_up_delay_to_step(millis(), current_step); // sets up next place to synchronise from array of devices and times
   change_output(current_step); // this drives output if there is no fault
   current_step += 1;
}

}
13  Using Arduino / Programming Questions / Re: Interrupt: Need to keep track of time spent in routine or ... ? on: September 21, 2012, 07:36:13 pm
So what's wrong with a function like what I wrote?
Is every hardware device driven by a different line of code?
14  Using Arduino / Project Guidance / Re: fastest speed of input pins, hardware prescaler on: September 21, 2012, 07:12:24 pm
Why not run the arduino at 11MHz?  It will run if you change the crystal or build a standalone board.
Then you can run a timer (e.g. timer2) using a prescaler on the clock frequency.  Your millis() timer would be out, but perhaps
that doesn't matter to you.  I don't think there is any internal prescaler you can use.

Or you could use a standalone board with an 11Mhz crystal, driving its own timer,  feeding into a second arduino.
That takes a 328P chip, two capacitors, a crystal and a resistor + capacitor for the reset line.  You could even write
the sketch to work on the arduino, then move the chip to your standalone board.
15  Using Arduino / Programming Questions / Re: Interrupt: Need to keep track of time spent in routine or ... ? on: September 21, 2012, 06:56:02 pm
Can the problem be stated another way?

Have a routine that is triggered by the interrupt.

When triggered it sets a "no output" flag for a time.  After the time expires reset the flag. (I assume this is being called
multiple times in loop(), so it can check the time)

Have a common output function like:

void output_for_one_device(int device address, boolean no_output)
{
   if (no_output)
  {
    set_output_safe();
    return;
   }
  // otherwise, carry on and do the output
 
}

Do you really mean interrupt - an interrupt is for a hardware signal that you have to respond to very fast.
From your problem description, why not have a digital input for your interruption, and when you poll that
change your output variable?  From my measurements on arduino code, the loop() repeats 20000 times a second,
so you can poll a digital input that fast.  Interrupt routines are tricky.
Pages: [1] 2 3 ... 10