Show Posts
Pages: [1] 2
1  Forum 2005-2010 (read only) / Troubleshooting / Re: multi dem arrays using data from EEPROM on: December 15, 2008, 09:57:07 am
no they are all 10 byte
2  Forum 2005-2010 (read only) / Troubleshooting / Re: multi dem arrays using data from EEPROM on: December 14, 2008, 09:45:49 pm
the eeprom will be storing 10byte RFID ids for use in a locking mechanism.
the sole reason for using the eeprom for storing these ids is so that they can be entered into the program without having to modify the sketch code using a computer, and to allow the values to be retained and recalled after a power cycle.

Im planning on posting all of the code once it is finished and im happy with it. im on revision 3 now

also i know i cant uset use the C syntax to insert and extract information from the eeprom, that will be done via the eeprom library and then parsed with c to create the array.  the recall and parsing would be done in setup() due to the fact that it will more then likely require some heavy lifting.  seeing as to how if i filled the eeprom space with data it could contain 51 sets of 10 byte IDs. they would be parsed into an array and subsiquently placed into progmem.  the only other time an eeprom read/write would take place is during a program ID routine

my main question is, how would i declare a numerically indexed multi-dimensional array of chars?  
3  Forum 2005-2010 (read only) / Troubleshooting / Re: multi dem arrays using data from EEPROM on: December 14, 2008, 10:56:35 am
i guess i should clarify that a little

the EEPROM would contain a string of chars

ARRAY [?] (
1 <= "asdfghjklz"
2 <= "zlkjhgfdsa"
3 <= "azsldkfjgh" )

ints i know can do defined as
int [3][10] (
{1,2,3,4,5,6,7,8,9,0}
{0,9,8,7,6,5,4,3,2,1}
{1,0,2,9,3,8,4,7,5,6} )

but i dont know if the same would work for chars.

better question, can i store chars in EEPROM?
4  Forum 2005-2010 (read only) / Troubleshooting / multi dem arrays using data from EEPROM on: December 14, 2008, 08:09:53 am
im wanting to store some string data in the EEPROM.

what id like to know is if i can recall that data from the EEPROM and put it in a multi dem array.  I looked at the documentation in the reference and didnt see it mentioned.

each string is 10 bytes long and id like to be able to store it as following

ARRAY  keys[?] (
1 <= "1234567890"
2 <= "0987654321"
3 <= "1029384756" )

? will be determined by the ammount of data pulled form EEPROM.

Can i do something like that, and if i can what would i declare the main array as?
I want it to be numarically indexed but contain CHAR strings
5  Forum 2005-2010 (read only) / Troubleshooting / Re: Power output on digital pin not working properly on: December 14, 2008, 04:16:39 pm
oooooh

iv been powering it via the +5vdc line on the board for testing.  seems to work ok but ill make sure to change that when i finalize my design.

the board is currently being powered by the USB jack.

sure makes it alot less convenient not being able to use the +5vdc line on the board.  Now im going to have to redesign my board layout to interface with the power supply.

the power supply is a wall wart jack with a relay to switch between wall wart power (if available) and a battery pack without powering down the board.

it was going to be a separate board but now i need to figue out how to roll it all into one.

back to the drawing board
6  Forum 2005-2010 (read only) / Troubleshooting / Re: Power output on digital pin not working properly on: December 14, 2008, 01:58:01 pm
i cant find a spec sheet that lists the load in mA so i dont know how to calculate the resisters needed.
(hell i cant find a spec sheet that lists any electrical details)

 smiley-sad

what are the odds ill find a relay that will opperate at or under 30mA
7  Forum 2005-2010 (read only) / Troubleshooting / Power output on digital pin not working properly on: December 14, 2008, 12:51:07 pm
so im trying to use a servo in the following fashion. (a mini servo from an old RC helicopter kit that crashed and is waiting to be fixed)

gnd to gnd
+5 to digital pin 8 set to output
control to digital pin 9 attached to servo object via servo.h

i have it set up this way so that i can turn power to the servo off when its not being used so that the object it is conected to can be turned by hand while the servo is still attached.


I have run the servo with +5 to +5 gnd to gnd and data to 9 and run the sweep program to ensure the servo is still good (and it is)


the problem is that the "5 volts" from digital pin 8 (set to output, with a digital write to HIGH) doesnt seem to be providing enough power.

the servo hums but doesnt move when told to.

does the pin not provide enough amps?
can i not use a pin in this manner?

if it doesnt output enough amps to run the servo can i hope to have to activate a relay and provide power switching that way?
8  Forum 2005-2010 (read only) / Troubleshooting / Re: refferencing vars in functions on: December 14, 2008, 10:44:11 am
brilliant

thank you for answering my question so clearly.

Its been so long since i worked in C and of the 28 pages of the forum that i looked through in SOFTWARE i didnt find an answer to my question that was this clear.

again thank you
9  Forum 2005-2010 (read only) / Troubleshooting / refferencing vars in functions on: December 14, 2008, 08:58:39 am
i dont know if this is the proper term but id like to reference a var inside a function

what id like to do is create a function called change_state that takes one argument.  The argument it takes is the name of a var (a boolean)

id like it to wrok something like the following

void change_state (char var) {
  if (var == false) {
    var = true;
  }
  else {
    var = false;
  }
}

boolean open = false;
change_state("open");
//and now open = true
change_state("open");
//and now open = false again


is there a way to do that?
10  Forum 2005-2010 (read only) / Development / Re: RFID tag compair problem on: December 10, 2008, 02:39:01 pm
im sorry, i excluded that.

yes i am getting a tag code output.


if i use code[bytesread] = '\0' wont it overwrite the last byte read?
shouldnt i use code[bytesread+1] = '\0' ? <-- ignore that


IT WORKS!

you guys are fantastic.

now to read up on placing values into EEPROM and doing so conditionally
11  Forum 2005-2010 (read only) / Development / Re: RFID tag compair problem on: December 10, 2008, 12:02:53 pm
ok so still no joy

here is the code as it stands, maybe im just doing it wrong i dont know
-------------------------

#include <SoftwareSerial.h>

int  val = 0;
char code[10];
int bytesread = 0;

// ADDED
int strcmp(const char *s1, const char *s2)
{
    unsigned char uc1, uc2;
    /* Move s1 and s2 to the first differing characters
       in each string, or the ends of the strings if they
       are identical.  */
    while (*s1 != '\0' && *s1 == *s2) {
        s1++;
        s2++;
    }
    /* Compare the characters as unsigned char and
       return the difference.  */
    uc1 = (*(unsigned char *) s1);
    uc2 = (*(unsigned char *) s2);
    if (uc1 != uc2)
       return ((uc1 < uc2) ? -1 : (uc1 > uc2));
    else
       return 0;
}

#define rxPin 8
#define txPin 9
// RFID reader SOUT pin connected to Serial RX pin at 2400bps to pin8

void setup()
{
  Serial.begin(9600);  // Hardware serial for Monitor 9600bps

  pinMode(2,OUTPUT);       // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
  digitalWrite(2, LOW);    // Activate the RFID reader
}


void loop()
{
  SoftwareSerial RFID = SoftwareSerial(rxPin,txPin);
  RFID.begin(2400);

  if((val = RFID.read()) == 10)
  {   // check for header
    bytesread = 0;
    while(bytesread<10)
    {  // read 10 digit code
      val = RFID.read();

      if((val == 10)||(val == 13))
      {  // if header or stop bytes before the 10 digit reading
        break;                       // stop reading
      }
      code[bytesread] = val;         // add the digit        
      bytesread++;                   // ready to read next digit  
    }

    if(bytesread == 10)
    {  // if 10 digit read is complete
      Serial.print("TAG code is: ");   // possibly a good TAG
      Serial.println(code);            // print the TAG code

// ADDED / Check for Particular tags
      if (strcmp(code, "0415E9B02D") == 0) {
        Serial.println("Round Black WORLD TAG");
      }

    }
    bytesread = 0;
    delay(1000);                       // wait for a second
  }
}
12  Forum 2005-2010 (read only) / Development / Re: RFID tag compair problem on: December 10, 2008, 10:20:36 am
i tried putting it in hardware/libraries and got a litany of errors on code that used to verify.  I didnt bother copying it but needless to say it was a no go.

I give the code you posted a try and let you know how it goes
13  Forum 2005-2010 (read only) / Development / Re: RFID tag compair problem on: December 10, 2008, 06:47:42 am
well i tried replacing my IF statement with "if (strcmp(code, "0415E9B02D") == 0) {" and got no joy.

im looking into the TextString library but i already have a problem, it tells me to place the resulting folder into "lib/targets/libraries"
which i dont have.

Im running 0012 on MacOS X

would i be able to put it in "hardware/libraries"?

all and all having played with this for a few weeks my lack of familiarity with the programing environment is becoming incredibly frustrating.

im not used to these sort of limitations. PHP has spoiled me i guess
but then again thats what makes it fun, learning something new.

all im really trying to do here is build a simple door lock.
the ability to add a program tag into memory would be nice but ill stick with a hard coded list for now.
14  Forum 2005-2010 (read only) / Development / RFID tag compair problem on: December 09, 2008, 06:19:16 am
First off thanks in advance. Im fairly new to the arduino world.

So i found a cheap Parallax RFID reader and thought it would be fun to play with.

did some looking and found some example code (included below)

Code:
//    * Arduino Digital pin 8 to RFID TX
//    * Arduino GND to RFID GND
//    * Arduino Digital pin 2 to RFID enable
//    * Arduino +5V to RFID Vcc pin.
// Modified by Worapoht K.

#include <SoftwareSerial.h>

int  val = 0;
char code[10];
int bytesread = 0;

#define rxPin 8
#define txPin 9
// RFID reader SOUT pin connected to Serial RX pin at 2400bps to pin8

void setup()
{
  Serial.begin(9600);  // Hardware serial for Monitor 9600bps

  pinMode(2,OUTPUT);       // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
  digitalWrite(2, LOW);    // Activate the RFID reader
}


void loop()
{
  SoftwareSerial RFID = SoftwareSerial(rxPin,txPin);
  RFID.begin(2400);

  if((val = RFID.read()) == 10)
  {   // check for header
    bytesread = 0;
    while(bytesread<10)
    {  // read 10 digit code
      val = RFID.read();

      if((val == 10)||(val == 13))
      {  // if header or stop bytes before the 10 digit reading
        break;                       // stop reading
      }
      code[bytesread] = val;         // add the digit        
      bytesread++;                   // ready to read next digit  
    }

    if(bytesread == 10)
    {  // if 10 digit read is complete
      Serial.print("TAG code is: ");   // possibly a good TAG
      Serial.println(code);            // print the TAG code

// ADDED / Check for particular tags
      if (code == "0415E9B02D") {
        Serial.println("Round Black WORLD TAG");
      }
/////

    }
    bytesread = 0;
    delay(1000);                       // wait for a second
  }
}

for the most part it works as expected.

using serial monitor i see everything i expect except when i scan the round black world tag the tag code shows up but it doesnt display "Round Black WORLD TAG"  Its almost as if its skipping over that IF statement.

now the question, am i doing it wrong? or am i missing something?

Thanks all
15  Forum 2005-2010 (read only) / Interfacing / Re: Building an Ethernet bandwidth monitor - Suggestio on: January 13, 2009, 12:02:17 am
An inline tap between your modem and switch/router will expose all traffic in and out of the network.  you need to make sure that the arduino is only passively monitoring the traffic otherwise your risk corrupting your packets.

Sounds like a rather useful device.
being able to see all incoming and out going bandwidth usage, maybe even be able to break it down to packet type reporting (x% TCP y% UPD z% Other)
Pages: [1] 2