Show Posts
Pages: 1 2 [3] 4 5 ... 52
31  Using Arduino / Programming Questions / Re: Search for a charactter in a file on: September 24, 2012, 03:28:05 pm
Quote
this file will be passed to an java sript evry time that there is some web request,when i recieve the request i need write in the end of the file ' ]' to close the function,
but once the web request finish ,i need to cancel the ']',and write th temperture

In that scenario, I would never write the ] to the file, but include it in the output to the java script.
32  Community / Bar Sport / Re: The bestest General Electronics forums, next to this one (obviously). on: September 24, 2012, 03:15:14 pm
Here's an electronics focused forum I occasionally peruse:
http://forum.allaboutcircuits.com/

33  Community / Bar Sport / Re: SHOUT OUT if you are female. on: September 24, 2012, 03:13:09 pm
I have worked with a small handful of female engineers over the years.  I don't think that 12.5:1 ratio is that far off.  In our current development team of 25, there are 2 females, which is a ratio of 11.5:1.
34  Using Arduino / Programming Questions / Re: Search for a charactter in a file on: September 24, 2012, 03:07:32 pm
And where are you searching for this character?  our post title says 'in a file'.  Is this some file on an SD card?

Why exactly do you not want to use the 'read' function?  How else do you expect to read data from a file?
35  Using Arduino / Programming Questions / Re: Creating Circular Buffer lib on: September 24, 2012, 03:04:34 pm
ditto for your usage of queueDuplicateExists as well.
36  Using Arduino / Programming Questions / Re: Creating Circular Buffer lib on: September 24, 2012, 03:02:42 pm
queueIsEmpty and queueIsFull are both functions, each taking a single parameter that is a pointer to a queue.

Code:
if (!queueIsEmpty)

isn't going to work, because you are not calling the function properly.  You need to call it like this:

Code:
if (!queueIsEmpty(&testqueue))

same with queueIsFull().
37  Using Arduino / Programming Questions / Re: Understanding counting with arrays on: September 24, 2012, 01:23:14 pm
Quote
FWIW, I originally wrote the program with an UNO board but then trimmed it down for use on an ATTiny44 at 8MHz

Is the problem also seen on the UNO as well as the ATTiny44?  Sounds like it may be a memory issue (which is often the case in scenarios where x number of y types works, but when I add one more, it doesn't work, and it doesn't matter which one is added).  The ATTiny44 has far less SRAM/EEPROM/Flash memory than the UNO.
38  Using Arduino / Programming Questions / Re: WiFi Connection problems - Digitalfoosball App on: September 21, 2012, 01:16:19 pm
I don't have a WiFly shield, and have no experience using one.  I did notice that the library does come with several examples.  Have you looked through those to see if they do what you are trying to do?
39  Using Arduino / Programming Questions / Re: WiFi Connection problems - Digitalfoosball App on: September 21, 2012, 10:15:47 am
sketch_sep21b:78: error: 'Status' is not a member of 'WiFlyDevice'

Why do you believe WiFlyDevice has a member called Status?  It doesn't, hence the compile error when you try to access a member that doesn't exist.

Ditto for pretty much all the errors (although I didn't confirm each and every one).
40  Using Arduino / Programming Questions / Re: Creating Circular Buffer lib on: September 21, 2012, 09:50:22 am
Sketch:
Code:
#include "circularbuffer.h"

CircularBuffer cb;


void setup() {
    Serial.begin(115200);
    ElemType elem = {0};
 
    int testBufferSize = 10; /* arbitrary size */
    cbInit(&cb, testBufferSize);
 
    /* Fill buffer with test elements 3 times */
    for (elem.value = 0; elem.value < 3 * testBufferSize; ++ elem.value)
        cbWrite(&cb, &elem);
 
    /* Remove and print all elements */
    while (!cbIsEmpty(&cb)) {
        cbRead(&cb, &elem);
        Serial.println(elem.value);
    }
 
    cbFree(&cb);
   
}

void loop()
{
   
}

Header file:
Code:
#ifndef CIRCULARBUFFER_H
#define CIRCULARBUFFER_H

#include <stdlib.h>

struct ElemType{ int value; };
 
/* Circular buffer object */
struct CircularBuffer{
    int         size;   /* maximum number of elements           */
    int         start;  /* index of oldest element              */
    int         end;    /* index at which to write new element  */
    ElemType   *elems;  /* vector of elements                   */
};
 

void cbInit(CircularBuffer *cb, int size) {
    cb->size  = size + 1; /* include empty elem */
    cb->start = 0;
    cb->end   = 0;
    cb->elems = (ElemType *)calloc(cb->size, sizeof(ElemType));
}
 
void cbFree(CircularBuffer *cb) {
    free(cb->elems); /* OK if null */ }
 
int cbIsFull(CircularBuffer *cb) {
    return (cb->end + 1) % cb->size == cb->start; }
 
int cbIsEmpty(CircularBuffer *cb) {
    return cb->end == cb->start; }
 
/* Write an element, overwriting oldest element if buffer is full. App can
   choose to avoid the overwrite by checking cbIsFull(). */
void cbWrite(CircularBuffer *cb, ElemType *elem) {
    cb->elems[cb->end] = *elem;
    cb->end = (cb->end + 1) % cb->size;
    if (cb->end == cb->start)
        cb->start = (cb->start + 1) % cb->size; /* full, overwrite */
}
 
/* Read oldest element. App must ensure !cbIsEmpty() first. */
void cbRead(CircularBuffer *cb, ElemType *elem) {
    *elem = cb->elems[cb->start];
    cb->start = (cb->start + 1) % cb->size;
}

#endif
41  Using Arduino / Programming Questions / Re: Creating Circular Buffer lib on: September 20, 2012, 04:16:08 pm
http://arduino.cc/forum/index.php/topic,97455.0.html
In particular, read item 6.
42  Using Arduino / Programming Questions / Re: Problem adjusting code to work with Arduino 1.0 on: September 20, 2012, 04:13:24 pm
Quote
Serial.write() does different stuff with bytes and ints.

That there. An int is 2 bytes. A byte is, of course, 1 byte.

So, Serial.write(160) will output the integer value 160 as two bytes of data.
But you want a single byte of data output, so as Pauls said, cast it to a byte with Serial.write((byte)160) and it will output the byte value 160 as a single byte of data.
43  Using Arduino / Sensors / Re: ADXL345 Sensor perplexity on: September 20, 2012, 07:44:10 am
Quote
But when I reset it (the Arduino) on a non-zero-degree surface (x and y), for instance on 45 degrees on y axis, instead of giving me 120 on it, it gives me that interval of values highlighted up with 250 value on z axis.

As Arctic_Eddie pointed out, your init function is calibrating the offset on startup for your x, y, and z axis.  This will result in whatever orientation you startup in as being your 0, 0, 250 position, since that is the position you are calibrating to.  Either do as he recommended (use a separate calibration sketch, and load those calibrated values in your primary sketch), or make sure the unit only ever starts up in it's proper orientation.  If the latter isn't practical, then the former is the method you need to use.
44  Using Arduino / Programming Questions / Re: Library Tutorial doesn't seem to work on: September 19, 2012, 02:53:42 pm
Post the code that's generating those error message, and I'm sure you'll get all the hope you need.  Without the code, any help provided will just be shots in the dark.
45  Using Arduino / Programming Questions / Re: Battery discharge curve mapping on: September 19, 2012, 10:53:17 am
That graph is meant to show the useable capacity of a given battery at different discharge rates.  The basic gist being, the faster you discharge the battery, the less actual capacity you have.  It's not really useful for determining a percentage capacity left over (though there is a correlation).

An 'accurate' percentage is going to be difficult to computer and maintain, and likely not really worth the effort.  The simplest method is an approximate percentage based on battery voltage.  If you know the average current draw that the battery will be providing, then you can tailor your percentage to that current draw from the above discharge rate chart.  If it's a steady state current draw, just use the charts above as is.  If it's more of an intermittent current draw, then the capacity will be a bit better than the 'average' current would indicate (as the battery has time to rest in between demands for current, which gives the internal chemistry time to normalize and improves overall capacity)

Here's one thread on voltage to capacity conversions: http://www.helifreak.com/showthread.php?t=333661
There are others.  Again, a simple voltage measurement is only going to give you an approximation of capacity.
Pages: 1 2 [3] 4 5 ... 52