Show Posts
Pages: 1 2 [3] 4 5 ... 15
31  Development / Suggestions for the Arduino Project / Re: uint64_t in Serial.print on: November 25, 2012, 05:24:40 pm
I get:

Initializing SD card...Wiring is correct and a card is present.

Card type: SDHC

Volume type is FAT32

Volume size (bytes): 31099904
Files found on the card (name, date and size in bytes):
DCIM/         2011-06-20 14:58:52
  100_PANA/     2011-06-20 19:07:48
    P1000812.JPG  2011-09-08 09:19:54 4158647
    P1000781.JPG  2011-08-20 21:02:02 4309863
    P1000813.JPG  2011-09-08 09:20:00 4258311
32  Development / Suggestions for the Arduino Project / Re: uint64_t in Serial.print on: November 25, 2012, 02:19:13 pm
Not sure how to merge that into the sd cardinfo sketch .....
33  Development / Suggestions for the Arduino Project / Re: uint64_t in Serial.print on: November 25, 2012, 01:35:33 pm
ok. I get

start...
12345678912345678
34  Development / Suggestions for the Arduino Project / Re: uint64_t in Serial.print on: November 25, 2012, 11:47:37 am
I attached print.h

Does it look correct?
35  Development / Suggestions for the Arduino Project / Re: uint64_t in Serial.print on: November 25, 2012, 08:46:04 am
I get

C:\Users\Steve\Programs\arduino-1.0.2\hardware\arduino\cores\arduino\nPrint.cpp:230: error: prototype for 'size_t Print::printNumber(long long unsigned int, uint8_t)' does not match any in class 'Print'
C:\Users\Steve\Programs\arduino-1.0.2\hardware\arduino\cores\arduino\/Print.h:38: error: candidate is: size_t Print::printNumber(long unsigned int, uint8_t)

When I run

Code:
/*
  SD card test
  
 This example shows how use the utility libraries on which the'
 SD library is based in order to get info about your SD card.
 Very useful for testing a card when you're not sure whether its working or not.
 
 The circuit:
  * SD card attached to SPI bus as follows:
 ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
 ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
 ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
 ** CS - depends on your SD card shield or module.
  Pin 4 used here for consistency with other Arduino examples

 
 created  28 Mar 2011
 by Limor Fried
 modified 9 Apr 2012
 by Tom Igoe
 */
 // include the SD library:
#include <SD.h>


// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 4;    

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("\nInitializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
  pinMode(10, OUTPUT);     // change this to 53 on a mega


  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
   Serial.println("Wiring is correct and a card is present.");
  }

  // print the type of card
  Serial.print("\nCard type: ");
  switch(card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    return;
  }


  // print the type and size of the first FAT-type volume
  uint64_t volumesize;
  Serial.print("\nVolume type is FAT");
  Serial.println(volume.fatType(), DEC);
  Serial.println();
  
  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  // volumesize *= 512;                            // SD card blocks are always 512 bytes
  // Serial.print("Volume size (bytes): ");
  // Serial.println(volumesize);
  Serial.print("Volume size (Kbytes): ");
  // volumesize /= 1024;
  volumesize /= 2;
  Serial.println(volumesize);
  Serial.print("Volume size (Mbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);

  
  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);
  
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}


void loop(void) {
  
}
36  Development / Suggestions for the Arduino Project / uint64_t in Serial.print on: November 25, 2012, 07:04:35 am
I'm working with the Card info sketch in the sd examples, and my 16gb sd card reports as 3gb. It's my understanding that this is a result of Serial.print only understanding uint32_t. I've tried editing print.h to understand long long int, but it's not taking.

What am I not understanding?

Code:
   
    size_t print(const __FlashStringHelper *);
    size_t print(const String &);
    size_t print(const char[]);
    size_t print(char);
    size_t print(unsigned char, int = DEC);
    size_t print(int, int = DEC);
    size_t print(unsigned int, int = DEC);
    size_t print(long, int = DEC);
//size_t print(long long, int = DEC);
    size_t print(unsigned long, int = DEC);
//size_t print(unsigned long long, int = DEC);
    size_t print(double, int = 2);
    size_t print(const Printable&);

    size_t println(const __FlashStringHelper *);
    size_t println(const String &s);
    size_t println(const char[]);
    size_t println(char);
    size_t println(unsigned char, int = DEC);
    size_t println(int, int = DEC);
    size_t println(unsigned int, int = DEC);
    size_t println(long, int = DEC);
//size_t println(long long, int = DEC);
    size_t println(unsigned long, int = DEC);
//size_t println(unsigned long long, int = DEC);
    size_t println(double, int = 2);
    size_t println(const Printable&);
    size_t println(void);
37  Topics / Home Automation and Networked Objects / Controlling devices with a TV Remote on: November 04, 2012, 06:31:55 am
I've set up a recycled IR sensor from an old VCR with my Arduino. I heavily modified a sketch and used the library from http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html to display number values from keypresses, documented a value for each key, and used a switch / case statement to activate different pins based on keypresses.

I used a samsung remote, but this will work with any TV remote, and could work with any device that can output IR at 38kHz, AFAIK.

Use a SSR instead of the LED to control line voltage ac devices, and a MOSFET or BJT for DC devices. A neat adaptation would be changing a variable with the vol up/down for a thermostat or Light dimming. The TV channel buttons would work for this as well. Better yet, if one could select a device with the number pad, and use a button to on / off, and the volume to change levels. My simple code does not implement that. I'd be interested it seeing it done though.

Full details, including video at http://arduinotronics.blogspot.com/2012/11/arduino-ir-receiver-part-2.html


Code:
/*
 * IRremote: IRrecvDump - dump details of IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
 * Heavily modified by Steve Spence, http://arduinotronics.blogspot.com
 */

#include

int RECV_PIN = 19;

int reversePin = 4;                 // LED connected to digital pin 4
int forwardPin = 5;                 // LED connected to digital pin 5
int playPin = 6;                 // LED connected to digital pin 6
int pausePin = 7;                 // LED connected to digital pin 7

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(reversePin, OUTPUT);      // sets the digital pin as output
  pinMode(forwardPin, OUTPUT);      // sets the digital pin as output
  pinMode(playPin, OUTPUT);      // sets the digital pin as output
  pinMode(pausePin, OUTPUT);      // sets the digital pin as output
}

void loop() {
  if (irrecv.decode(&results)) {
  
    long int decCode = results.value;
    Serial.println(decCode);
    switch (results.value) {
      case 1431986946:
        Serial.println("Forward");
        digitalWrite(forwardPin, HIGH);   // sets the LED on
        break;
      case -11780576:
        Serial.println("Reverse");
        digitalWrite(reversePin, HIGH);   // sets the LED on
        break;
      case -873913272:
        Serial.println("Play");
        digitalWrite(playPin, HIGH);   // sets the LED on
        break;
      case -1025287420:
        Serial.println("Pause");
        digitalWrite(pausePin, HIGH);   // sets the LED on
        break;
      case 1791365666:
        Serial.println("Stop");
        digitalWrite(forwardPin, LOW);   // sets the LED off
        digitalWrite(reversePin, LOW);   // sets the LED off
        digitalWrite(playPin, LOW);   // sets the LED off
        digitalWrite(pausePin, LOW);   // sets the LED off
        break;
      default:
        Serial.println("Waiting ...");
    }

    irrecv.resume(); // Receive the next value
  }
}
38  Using Arduino / Programming Questions / pulse counting on: June 02, 2012, 11:51:43 am
I want to count how many times a transistor triggers per minute. It's important to not miss any triggers, so my assumption is that an interrupt is necessary. I've never used interrupts. I'm using a Arduino 2560, and a TCRT5000 IR emitter / photo transistor that is reading a reflective patch on a rotating shaft (One trigger per revolution, want to display RPM). It makes sense to me to count pulses per second and calculate RPM. RPM could be as low as 100 or as high as 10,000

What's the best way (accuracy) to go about this?
39  Using Arduino / Displays / Re: Sending data from Arduino to uVGA-II in GFX (4DGL) Mode on: May 30, 2012, 01:07:53 pm
BTW, the uVGA 4DGL language only supports Ints (16bit) as a variable type. No floats, boolean etc.

This means it can't handle our calculations. So it's back to doing the math on the Arduino, and sending multiple data sets over to the uVGA for display. 4DSYSFAN has a very good way for doing this, which includes a ID field so the uVGA knows which variable to stuff with that particular string of data. http://4d.websitetoolbox.com/post/picking-out-data-from-a-string-5821237
40  Using Arduino / Programming Questions / Re: GPS sketch Works on UNO not on Mega on: May 30, 2012, 12:19:55 pm
I'm berring he'll have to fix TinyGPS.h to not use softserial as well, but to use one of the hardware ports.
41  Using Arduino / Programming Questions / Re: Making a formula float free on: May 30, 2012, 11:43:07 am
That's very cool.

Another however, however. Sorry ;-)

The reason I use

f = (1000*(23285 - num * 10)) / 40;

instead of

f = (23285 - num * 10) * 250 / 10000;

is that for some gear families, jump isn't 40 (.004)

so it becomes f = ((1000 * (maxmm - (range / 2) - num * 10)) / jump);

where for this particular gear family:
maxmm = 23300;
range = 30;
jump = 40;
maxBin = 100;

num is a variable input from the micrometer
42  Using Arduino / Programming Questions / Re: Making a formula float free on: May 30, 2012, 10:09:23 am
ckiick,

First of all, fantastic job cleaning up this mess.

However, by declaring f and bin an int, the 7.125 developed by the formula becomes a 7

a 7.999 would also become a 7, when it should be an 8. Correct?

why do I need to round up or down? this is replacing a legacy system written in assembly, and new gears have to go in the right bins. I can't start with a clean slate. otherwise this would have been a lot cleaner.

so:

Code:
int convert(int num)
{
        int f, bin;
        f = (1000*(23285 - num * 10)) / 40;
        bin = 100 - f;
        return (bin);
}

Then I can use something like:

if formula >6999 & <7501
then formula = 7000
if formula >7500 & <8001
then formula = 8000

43  Using Arduino / Programming Questions / Re: Making a formula float free on: May 30, 2012, 09:54:41 am
yes, I figured that out above. We must have posted at the same time. I can do a set of if statements to convert 7000 or 8000 depending on where it falls.

then find the bin number by:

=((maxl*1000)-roundedformula)/1000
44  Using Arduino / Programming Questions / Re: Making a formula float free on: May 30, 2012, 09:48:05 am
yes,

round (((2.330-(0.003/2.000)-mm)/0.004))

you put

round (((2.330-0.003/2.000)-mm)/0.004)

That changed the order of arithmetic.

Another poster said to multiply everything by 1000 to get rid of decimals. If I use 10000:

round (((23300-(30/2)-23000)/40)

(((23300-(15)-23000)/40)

285 /40 = 7.125 (still back to a decimal)

so, ((1000*(23300-(30/2)-23000)/40))

gives me 7125

if formula >6999 & <7501
then formula = 7000
if formula >7500 & <8001
then formula = 8000

So 1000 * maxBin (100) = 100000 - 7000 = 93000 / 1000 = 93

Bin 93 is correct. No decimals.
45  Using Arduino / Programming Questions / Re: Making a formula float free on: May 30, 2012, 09:35:19 am
say what?
Pages: 1 2 [3] 4 5 ... 15