Show Posts
Pages: 1 ... 34 35 [36] 37 38 ... 160
526  Using Arduino / General Electronics / Re: Reliable Debounce Circuit on: November 07, 2013, 08:44:54 am
Quote
As for the diode, the diode allows the cap to quickly and sharply transition states when you press the button (direct path to gnd) so it will discharge a lot quicker than relying on the resistor???

That is incorrect. The diode is reverse biased when the capacitor is charged and you press the button.

The diode bypasses the discharge resistor when you let go of the pushbutton.

Thank you for the information, but you're also incorrect... i added "????" meaning (to me at least) it's a question, the way i phrased it was bad I know....  but i meant it as a question.

[edit]

but yes after looking at it again, i see where i was going wrong... I was for some reason thinking + could get to gnd (and discharge) but it can't because of the diode. (i got confused)
527  Using Arduino / Networking, Protocols, and Devices / Re: SPI - Pullup/down required? [Solved it myself] on: November 07, 2013, 08:16:38 am
SI pins is for selecting the interface
From the datasheet
Quote
SI Pin ---Select Interface (GND->SPI or VDD->I²C
So if you wire it to ground you will use it as SPI interface, if pulled to VDD it will be using I2C.



ahhh.... duh!

Thanks  smiley-red
528  Using Arduino / Networking, Protocols, and Devices / SPI - Pullup/down required? [Solved it myself] on: November 07, 2013, 06:02:19 am
Months and Months ago, i bought 2 tatuic lightning sensor boards.. both gave different results so finally today i got the soldering iron out and wired them all up.

Now when i bring my hand up close to where the pins are on the Arduino, the sketch goes mental

Quote
Out of range lightning detected.
Noise level too high, try adjusting noise floor
Disturber detected
Out of range lightning detected.
Noise level too high, try adjusting noise floor
Disturber detected
Out of range lightning detected.


So then, before I start collecting schematics, datasheets, posting pictures..


When i bring my hand close to the clock/data pins it goes mad, so does this mean I simply need to connect a pullup/pulldown? I never had issues with SPI programming attiny85's though..

Code:
/*
  LightningDetector.pde - AS3935 Franklin Lightning Sensor™ IC by AMS library demo code
  Copyright (c) 2012 Raivis Rengelis (raivis [at] rrkb.lv). All rights reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 3 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <SPI.h>
#include <AS3935.h>

void printAS3935Registers();

// Function prototype that provides SPI transfer and is passed to
// AS3935 to be used from within library, it is defined later in main sketch.
// That is up to user to deal with specific implementation of SPI
// Note that AS3935 library requires this function to have exactly this signature
// and it can not be member function of any C++ class, which happens
// to be almost any Arduino library
// Please make sure your implementation of choice does not deal with CS pin,
// library takes care about it on it's own
byte SPItransfer(byte sendByte);

// Iterrupt handler for AS3935 irqs
// and flag variable that indicates interrupt has been triggered
// Variables that get changed in interrupt routines need to be declared volatile
// otherwise compiler can optimize them away, assuming they never get changed
void AS3935Irq();
volatile int AS3935IrqTriggered;

// First parameter - SPI transfer function, second - Arduino pin used for CS
// and finally third argument - Arduino pin used for IRQ
// It is good idea to chose pin that has interrupts attached, that way one can use
// attachInterrupt in sketch to detect interrupt
// Library internally polls this pin when doing calibration, so being an interrupt pin
// is not a requirement
AS3935 AS3935(SPItransfer,SS,2);

void setup()
{
  Serial.begin(9600);
  // first begin, then set parameters
  SPI.begin();
  // NB! chip uses SPI MODE1
  SPI.setDataMode(SPI_MODE1);
  // NB! max SPI clock speed that chip supports is 2MHz,
  // but never use 500kHz, because that will cause interference
  // to lightning detection circuit
  SPI.setClockDivider(SPI_CLOCK_DIV16);
  // and chip is MSB first
  SPI.setBitOrder(MSBFIRST);
  // reset all internal register values to defaults
  AS3935.reset();
  // and run calibration
  // if lightning detector can not tune tank circuit to required tolerance,
  // calibration function will return false
  if(!AS3935.calibrate())
    Serial.println("Tuning out of range, check your wiring, your sensor and make sure physics laws have not changed!");

  // since this is demo code, we just go on minding our own business and ignore the fact that someone divided by zero

  // first let's turn on disturber indication and print some register values from AS3935
  // tell AS3935 we are indoors, for outdoors use setOutdoors() function
  AS3935.setIndoors();
  // turn on indication of distrubers, once you have AS3935 all tuned, you can turn those off with disableDisturbers()
  AS3935.enableDisturbers();
  printAS3935Registers();
  AS3935IrqTriggered = 0;
  // Using interrupts means you do not have to check for pin being set continiously, chip does that for you and
  // notifies your code
  // demo is written and tested on ChipKit MAX32, irq pin is connected to max32 pin 2, that corresponds to interrupt 1
  // look up what pins can be used as interrupts on your specific board and how pins map to int numbers

  // ChipKit Max32 - irq connected to pin 2
  attachInterrupt(1,AS3935Irq,RISING);
  // uncomment line below and comment out line above for Arduino Mega 2560, irq still connected to pin 2
  // attachInterrupt(0,AS3935Irq,RISING);
}

void loop()
{
  // here we go into loop checking if interrupt has been triggered, which kind of defeats
  // the whole purpose of interrupts, but in real life you could put your chip to sleep
  // and lower power consumption or do other nifty things
  if(AS3935IrqTriggered)
  {
    // reset the flag
    AS3935IrqTriggered = 0;
    // first step is to find out what caused interrupt
    // as soon as we read interrupt cause register, irq pin goes low
    int irqSource = AS3935.interruptSource();
    // returned value is bitmap field, bit 0 - noise level too high, bit 2 - disturber detected, and finally bit 3 - lightning!
    if (irqSource & 0b0001)
      Serial.println("Noise level too high, try adjusting noise floor");
    if (irqSource & 0b0100)
      Serial.println("Disturber detected");
    if (irqSource & 0b1000)
    {
      // need to find how far that lightning stroke, function returns approximate distance in kilometers,
      // where value 1 represents storm in detector's near victinity, and 63 - very distant, out of range stroke
      // everything in between is just distance in kilometers
      int strokeDistance = AS3935.lightningDistanceKm();
      if (strokeDistance == 1)
        Serial.println("Storm overhead, watch out!");
      if (strokeDistance == 63)
        Serial.println("Out of range lightning detected.");
      if (strokeDistance < 63 && strokeDistance > 1)
      {
        Serial.print("Lightning detected ");
        Serial.print(strokeDistance,DEC);
        Serial.println(" kilometers away.");
      }
    }
  }
}

void printAS3935Registers()
{
  int noiseFloor = AS3935.getNoiseFloor();
  int spikeRejection = AS3935.getSpikeRejection();
  int watchdogThreshold = AS3935.getWatchdogThreshold();
  Serial.print("Noise floor is: ");
  Serial.println(noiseFloor,DEC);
  Serial.print("Spike rejection is: ");
  Serial.println(spikeRejection,DEC);
  Serial.print("Watchdog threshold is: ");
  Serial.println(watchdogThreshold,DEC);  
}

// this is implementation of SPI transfer that gets passed to AS3935
// you can (hopefully) wrap any SPI implementation in this
byte SPItransfer(byte sendByte)
{
  return SPI.transfer(sendByte);
}

// this is irq handler for AS3935 interrupts, has to return void and take no arguments
// always make code in interrupt handlers fast and short
void AS3935Irq()
{
  AS3935IrqTriggered = 1;
}


// pin name:    not-mega:         mega(1280 and 2560)
// slave reset: 10:               53
// MOSI:        11:               51
// MISO:        12:               50
// SCK:         13:               52


So pins 10,11,12,13 the "irq" goes to pin 3.

http://wiki.tautic.com/Category:AS3935_Lightning_Sensor_Dev_Board



PDF - Technical, wiring.

https://s3.amazonaws.com/tautic1/public/Product+Documentation/AS3935/AS3935+Schematic+and+Mechanical.pdf


The only wire I don't have connected (Because well, I honestly have no idea where to put it..) is the "SI" pin..

So does this SI need to be connected somewhere or am i missing pullups/downs?  (based on the fact just getting near the wires makes them go mental)...  

Any suggestions?

[edit]

https://gist.github.com/TAUTIC/3969372/raw/25222f90e83c14edb4d3277afd4b3aa4f80ea31e/AS3935_LC.spin

Basically, this last unused pin... after some searching I found it, and in the code above it says pull to gnd.. no problems, I did and what do you know... 18 months later it works !

So SI pin to gnd seems to have fixed it... whatever SI is.
529  Using Arduino / Microcontrollers / Re: Virtual Memory? on: November 07, 2013, 04:52:10 am
Quote
Allocating virtual ram either from SD card or otherwise.
Tell me about your page-fault mechanism.

Not even in the right forest, far less barking up the wrong tree.

I never claimed it to be easy.... in theory could it be done?           

(I'd store huge amounts of arrays into memory virtually, might be slow but it could also be useful)
530  Using Arduino / Microcontrollers / Virtual Memory? on: November 06, 2013, 11:46:59 pm
Allocating virtual ram either from SD card or otherwise..

A replacement set of routines that when used store the data else where (with an internet shield for example and the cloud or with an SD breakout)

Literally writing out your memory elsewhere and retrieving it ...  allowing an Arduino to do some  interesting things?  (or am i barking up the wrong tree) ?
531  Community / Bar Sport / Re: Arduino powered by capacitor on: November 06, 2013, 11:34:12 pm
I ran an automotive 12v bulb the other day from 2 400F caps (via a step up inverter) it lasted around 40 seconds or so...

And i kinda welded (by accident) a resistor leg to the casing lol
532  Using Arduino / General Electronics / Re: Reliable Debounce Circuit on: November 06, 2013, 10:37:58 pm
Easier to use a circuit emulator (there's a few good free ones about, like ltspice) once you got it, increase the resistor sizes to compensate for the smaller capacity of the smt capacitors (unless it's not a ceramic and it's an electrolytic)

533  Using Arduino / General Electronics / Re: Which of these is better to detect touch on a water tap? on: November 06, 2013, 08:31:35 pm
got a picture of the tap you have in mind?..

534  Using Arduino / General Electronics / Re: What is the reason you find 100nF || 47uF in circuits? on: November 06, 2013, 08:28:12 pm
And yes,  electrolytic capacitors DO have a correct polarity   and  will be degraded by reversed voltage,   so the polarity does matter.

not ALL electrolytic caps have polarity....

535  Using Arduino / General Electronics / Re: Reliable Debounce Circuit on: November 06, 2013, 08:24:36 pm
ButtonPressed=digitalRead(pin);
if (ButtonPressed==HIGH)
  {
    delay(1000); // could swap for milli and simply check time stamps for 1 second's worth.
   if (digitalRead(pin)==HIGH)
     {
         //Yup user really is holding down button.
     }   
 }

Delay without delay(); is the better option, but I like the hardware version lol, you could reduce the capacitor size to something like 1uf and increase resistor values to compensate.

As for the diode, the diode allows the cap to quickly and sharply transition states when you press the button (direct path to gnd) so it will discharge a lot quicker than relying on the resistor???
536  Using Arduino / General Electronics / Re: Using LM317 in CONSTANT CURRENT mode to power board? on: November 06, 2013, 04:25:53 pm
Well there's not much difference supplying a resistor on the 7805 output to limit it's current.

5/100ma (eg sensor)
50ohm resistor  (1 watt) from 5v out.

Problem is if the sensor > 100ma the voltage will sag...
537  Using Arduino / LEDs and Multiplexing / Re: Which capacitor on: November 05, 2013, 11:37:54 pm
Flickering would indicate a loose connection maybe on the latch or clock..

But a 0.1uf cap should be plenty between 5v pin and gnd pin....
538  Using Arduino / LEDs and Multiplexing / Re: 10 Watt high power LEDs. on: November 05, 2013, 11:35:20 pm
I KNOW!

Read my first post I even said I could upgrade it..


So how are you mr wall? Having a nice day?
539  Using Arduino / General Electronics / Re: Understanding forward current on: November 05, 2013, 09:48:02 pm
Um

Sure... but I bet the battery will self discharge quicker lol
540  Using Arduino / General Electronics / Re: powered usb hubs ... on: November 05, 2013, 09:45:20 pm
Yes... 

So how tolerant is my psu going to be if I feed a second 5v (externally) source to the usb rail?

Pages: 1 ... 34 35 [36] 37 38 ... 160