Show Posts
Pages: 1 ... 77 78 [79] 80 81 ... 289
1171  Using Arduino / Programming Questions / Re: Trying to make accurate 20 KHz clock, not getting there on: October 27, 2013, 07:43:51 pm
Yeah I think I can see the burst duration varying too.  Not sure why yet.
1172  Community / Exhibition / Gallery / Re: Vetinari Clock on: October 27, 2013, 07:16:14 pm
Nice project, but shouldn't it move the second hand forwards by the "countOfEvenNumbers + 1" ?
I guess, if it keeps good time, you must be doing that already.

Yes, in fact that is what it does.
1173  Using Arduino / Motors, Mechanics, and Power / Re: Arduino Power on: October 27, 2013, 07:15:38 pm
Wow, thanks for pointing that out, I actually hooked the relay directly to my Arduino, better to take it off now before it permanently damage my Ardunio.  smiley-confuse:~:~

Hope it's not already damaged.
1174  Using Arduino / Programming Questions / Re: Trying to make accurate 20 KHz clock, not getting there on: October 27, 2013, 07:14:53 pm
Trace 2 is the burst?
1175  Using Arduino / Programming Questions / Re: Trying to make accurate 20 KHz clock, not getting there on: October 27, 2013, 05:13:11 pm
Found a button smiley-grin

Code:
//Arduino Uno, Arduino 1.0.5
//Output a given number of PWM cycles when button pressed

#include <Button.h>        //https://github.com/JChristensen/Button
#include <TimerOne.h>      //http://playground.arduino.cc/code/timer1

const unsigned int BUTTON_PIN = 8;
const unsigned int OUTPUT_PIN = 9;
const unsigned int NCYCLE = 336;             //number of cycles to output
const unsigned long PERIOD = 25;             //length of half a cycle in microseconds
const unsigned int DUTY = 512;               //duty cycle as a number between 0 and 1023
const boolean BUTTON_PULLUP = true;
const boolean BUTTON_INVERT = true;
const unsigned long BUTTON_DEBOUNCE = 25;    //ms

Button btnStart(BUTTON_PIN, BUTTON_PULLUP, BUTTON_INVERT, BUTTON_DEBOUNCE);    //Declare the button

void setup()
{
    Timer1.attachInterrupt( timerIsr );
}

void loop()
{
    btnStart.read();       
    if (btnStart.wasPressed()) {
        Timer1.pwm(OUTPUT_PIN, DUTY, PERIOD);
    }
}

void timerIsr()
{
    static unsigned int toggleCount;

    if (++toggleCount > NCYCLE * 2) {
        Timer1.disablePwm(OUTPUT_PIN);
        toggleCount = 0;
    }
}
1176  Using Arduino / Programming Questions / Re: Trying to make accurate 20 KHz clock, not getting there on: October 27, 2013, 04:51:51 pm
Give this a try.  I didn't bother wiring up a button, am just generating the burst every 3 seconds.

Code:
//Arduino Uno, Arduino 1.0.5
//Output a given number of PWM cycles

#include <TimerOne.h>

const int OUTPUT_PIN = 9;
const unsigned long EVERY = 3000;        //start the burst every this many milliseconds
const int NCYCLE = 336;                  //number of cycles to output
const unsigned long PERIOD = 25;         //half a cycle in microseconds
const int DUTY = 512;                    //duty cycle as a number from 0 to 1023

void setup()
{
    Timer1.attachInterrupt( timerIsr ); // attach the service routine here
}

void loop()
{
    unsigned long ms = millis();
    static unsigned long lastStart;
   
    if (ms - lastStart >= EVERY) {
        lastStart += EVERY;
        Timer1.pwm(OUTPUT_PIN, DUTY, PERIOD);
    }
}

void timerIsr()
{
    static unsigned int toggleCount;

    if (++toggleCount > NCYCLE * 2) {
        Timer1.disablePwm(OUTPUT_PIN);
        toggleCount = 0;
    }
}
1177  Using Arduino / Programming Questions / Re: Trying to make accurate 20 KHz clock, not getting there on: October 27, 2013, 03:49:09 pm
Sure, give me a bit to look at the TimerOne library, I haven't used it before.  Let's see if it's easier to work with that or just program down to the bare metal.
1178  Using Arduino / Programming Questions / Re: Trying to make accurate 20 KHz clock, not getting there on: October 27, 2013, 03:30:20 pm
Use the compare match ISR to count the number of times the output pin is toggled, and turn off the timer after the desired number with
Code:
TCCR1B = 0;
1179  Using Arduino / Motors, Mechanics, and Power / Re: Arduino Power on: October 27, 2013, 03:15:01 pm
Well the VR module says 40mA.  I don't see a spec for the relay.  I might go ahead and hook it all up, and put a finger on the Arduino's voltage regulator.  If it gets uncomfortable to leave your finger there, find another AC adapter.

On another note, the relay should almost certainly not be connected directly to the Arduino, but should be driven by a transistor.  See the last page here for the proper way to connect it:
http://pgdev.pighixxx.com/ABC/SET/s1.pdf
1180  Community / Exhibition / Gallery / Re: Vetinari Clock on: October 27, 2013, 12:04:00 pm
Very good, Jack.

Thanks!

Quote
Although, that clock would drive me insane. smiley-wink

Well, that is part of the idea after all! smiley-grin  I've had one running here in my office for a couple months or so (with wires dangling out, connecting it to a breadboard) and I wondered about it at first too, but I got used to the sound pretty quickly.  Think of it as low-frequency white noise smiley-grin
1181  Using Arduino / Motors, Mechanics, and Power / Re: Arduino Power on: October 27, 2013, 11:59:44 am
Not really sure how much current those modules draws from the board...  smiley-confuse smiley-confuse smiley-confuse Any suggestions how to get it?  smiley-red smiley-red

Measure it as Jimbo says, or read the spec sheets/data sheets from the manufacturer.  Can you give us links to the relay and VR module?

I don't think I'd be too concerned if it's just a small relay, but it's always nice to know.  Typical small 5V relays might draw 60 or 70mA, but bigger ones could be ten times that.

If the adapter continues to put out 14V, then the Arduino's voltage regulator has to drop 9V.  50mA for the Arduino, 70mA for the relay and just a SWAG for the VR board, say another 70mA, round up the total to 200mA.  The voltage regulator has to dissipate 0.2A * 9V = 1.8W which means it'll get pretty warm.  If a regulated 9V adapter were used, power dissipation would be less than half of that.

Take the above analysis as an example only, because I have no clue what current your gear actually requires.
1182  Using Arduino / Motors, Mechanics, and Power / Re: Arduino Power on: October 27, 2013, 06:36:55 am
Thanks for the reply. I am thinking to use this adapter on my UNO and Mega 2560. The other parts hooked into my arduino is the following:

*5v DC relay
*Voice Recognition Module -- Arduino

This adapter should not harm my arduino right?

Thanks again!

How much current do the relay and the VR module draw?
1183  Community / Exhibition / Gallery / Re: SPI library for ATtiny MCUs on: October 26, 2013, 09:05:52 pm
OK, 8 lots of 10 rather than 16 lots of 5.

BTW, I had another look at the code on my SPI page and found that I had another suggested way of doing the transfer, which unravels the loop, and gets the time down to 2 µS rather than 9 µS.

You may want to look at that. And thanks to your post I added code for the ATtiny24/44/84 range.

Yes I did see that, there is a similar example in the datasheet.  That approach gives the fastest possible SPI clock.  Thanks!
1184  Using Arduino / Motors, Mechanics, and Power / Re: Arduino Power on: October 26, 2013, 09:03:00 pm
It's probably an unregulated type supply.  Not sure which Arduino you have, but for an Uno (see the Summary section) the recommended maximum is 12V, however up to 20V should not damage the circuit.  A problem may occur if too much current is drawn from the Arduino's supply, it could overheat its voltage regulator.  Even this should not be fatal, they are made to turn themselves off if they get too hot, but obviously it's something to avoid.

If you're just going to run the Arduino and not a whole lot else (LEDs and such are fine) you should be OK.  It would be interesting to measure the adapter's output voltage while it is powering the Arduino, I would expect it to drop some and that is a better measurement than an open circuit measurement.  But good on you for checking it!

Here is some reading on the subject.  I might prefer to get a regulated supply.
https://www.sparkfun.com/tutorials/103

Welcome to the forum!
1185  Community / Exhibition / Gallery / Re: SPI library for ATtiny MCUs on: October 26, 2013, 08:55:00 pm
Right, it makes one pass through the loop for each clock edge, so 5 cycles per edge, and 10 per bit.
Pages: 1 ... 77 78 [79] 80 81 ... 289