RFID noob project

Hi all,

Noob post. Trying to adapt some RFID reader code. Would like to make a standalone (have code working with reader on arduino). Not sure if this is an option, but I have a spare ATtiny85, and would like to use it. I changed the code that I have working on the arduino, and tried programming the ATtiny, but it will not take. Can anyone offer me advice? Is it not possible on this IC? Code below. Thank you.

#include <NewSoftSerial.h>
const int LEDpin2=0;
const int LEDpin=1;
const byte Locked=LOW;
const byte Unlocked=!Locked; //"not" locked
char sFrmTag[13] = "123456789abc";
byte bTmp;
const int SerInToArdu=4; //Defines pin data passes
    //to Arduino over from RFID reader
const int SerOutFrmArdu=3; //Not used, but
    //"fills" a parameter in the set up of
    //mySerialPort
NewSoftSerial mySerialPort(SerInToArdu,SerOutFrmArdu);
boolean TagMatch(char sToMatch[13])
{ boolean boTmp=true;
  for (byte bTmp=1; bTmp < 13; bTmp++)
    {if (sFrmTag[bTmp]!=sToMatch[bTmp])
       {boTmp=false;};
    } 
  return boTmp;
};

void OpenDoor()
{
digitalWrite(LEDpin,Unlocked);
delay(3000);
digitalWrite(LEDpin,Locked);

};

void OpenDoor2()
{
digitalWrite(LEDpin,Unlocked);
delay(1000);
digitalWrite(LEDpin,Locked);

};

void Indicator(){
  digitalWrite(LEDpin2, HIGH);
  delay(1000);
  digitalWrite(LEDpin2, LOW);
}

void setup()
{
mySerialPort.begin(9600);
pinMode(LEDpin,OUTPUT);
pinMode(LEDpin2, OUTPUT);
digitalWrite(LEDpin2, LOW);
digitalWrite(LEDpin,Locked);
};

void loop()
{
int incomingByte;
if (mySerialPort.available() > 0) {
		// read the incoming byte from the serial buffer
		incomingByte = mySerialPort.read();
		if (incomingByte==2){bTmp=0;}//no ; here
                  else {
                       if (bTmp<12) {
                                     sFrmTag[bTmp]=incomingByte;
                                     bTmp++;};
                       }
		
                if (incomingByte==3) {
                                      
                                      Indicator();
                                    
                                      if (TagMatch("4500F727F788")||
                                          TagMatch("0038CA584684")||
                                          TagMatch("4500F78192A1"))
                                           {OpenDoor();}
                                         if (TagMatch("4500F727F762"))
                                           {OpenDoor2();}
                                     
                                      };
     };
}

Hi.

tried programming the ATtiny, but it will not take

Obstinate little bugger is it? Try verbal threats.

Or, you could provide a better description of the problem than “will not take”.

error below. thought the attiny85 was an 8mhz. is it the rx from the reader that the chip cannot do?

C:\Users\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp:139:2: error: #error This version of NewSoftSerial supports only 20, 16 and 8MHz processors
C:\Users\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp: In member function 'void NewSoftSerial::begin(long int)':
C:\Users\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp:394: error: 'table' was not declared in this scope
C:\Users\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp: In member function 'virtual void NewSoftSerial::write(uint8_t)':
C:\Users\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp:473: error: 'XMIT_START_ADJUSTMENT' was not declared in this scope
C:\Users\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp: In static member function 'static void NewSoftSerial::enable_timer0(bool)':
C:\Users\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp:520: error: 'TIMSK0' was not declared in this scope
C:\Users\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp:526: error: 'TIMSK0' was not declared in this scope

error below.

This should take care of NewSoftSerial... http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274820597/93#93 http://arduino.cc/forum/index.php/topic,51984.msg472041.html#msg472041

thought the attiny85 was an 8mhz

From the factory, the processor runs at 1 MHz. If you are using this core...

http://code.google.com/p/arduino-tiny/

... you can...

• Select the [u]ATtiny85 @ 8 MHz[/u] board

• Click [u]Tools[/u] / [u]Burn Bootloader[/u] / [u]{YourProgrammerName}[/u]

...to change the fuse settings so the processor runs at 8 MHz.

is it the rx from the reader that the chip cannot do?

It is difficult to say without knowing more about the RFID reader.

RFID reader is ID-12. Thank you for the other information. I will look at this tonight to see if I understand how to change the fuse settings (I am not familiar with this; any more detail you would be willing to offer is greatly appreciated!). Will also look at changing the cpp for the newsoftserial. Can I edit this in notepad?

Can I edit this in notepad?

Any text editor will work. The only issue you may encounter is line endings (file contents will be one very long line in Notepad). If that is a problem, just download and use a good quality editor like Programmer’s Notepad or Notepad++.

OK great!

As for the 8mhz, am I understanding correctly? I hook up the ATTiny85 to the arduino (same connections as using the arduino as ISP), select attiny85 @ 8 mhz, then select burnbootloder. From there on the 85 will be at 8 mhz?

Yes.

OK - I don't have that selection in my drop down. I only have the attiny 85 (w/ arduino as ISP). Is there a boards.txt or something that I need to add the attiny85 at 8mhz to the drop down?

Don’t know. Which core are you using?

Appologies; don't believe I know what a core is.

Try the core I referenced earlier... http://arduino.cc/forum/index.php/topic,66749.msg491518.html#msg491518

OK. Got the core. Here's the error I get when loading the bootloader (ATTiny85 at 8mhz selected as board, arduino as ISP selected, using connection as seen here: http://hlt.media.mit.edu/wiki/pmwiki.php?n=Main.ArduinoATtiny4585):

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avr_read(): error reading address 0x0000
    read operation not supported for memory "lock"
avrdude: failed to read all of lock memory, rc=-2

Also changed the .cpp and here is the error I get there:

File\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp:394: error: 'table' was not declared in this scope
C:\Users\C\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp: In member function 'virtual void NewSoftSerial::write(uint8_t)':
C:\Users\C\arduino-0022\libraries\NewSoftSerial\NewSoftSerial.cpp:473: error: 'XMIT_START_ADJUSTMENT' was not declared in this scope

Looks like I am still doing something wrong. Advice? Thank you in advance!

This should help with the "PAGEL and BS2" warning... http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286388623/47#47

Unfortunately, in the best case, it will be several days before I can help with the NewSoftSerial error. I've not used it myself on the ATtiny85 processor so I will have to research the problem. I suggest either starting a new topic with an eye catching subject (something like "ATtiny85 + NewSoftSerial") or sending a Personal Message to BrainBooster or harry.

Appreciate the help. Changed the boards.txt and followed info from other post; still have the same error.

I'm thinking it will be easier to give up on the attiny85 for this project. Short of going to another ATMega328 (basically purchasing another arduino), are there any other AVRs you might recommend. ?

Was hoping to use the 85 for size. The 328 is still pretty cheap, but seems a waste to only use a couple pins...

Are you able to upload and run a sketch at 1 MHz?

Short of going to another ATMega328 (basically purchasing another arduino), are there any other AVRs you might recommend. ?

I'm a big fan of the ATtiny84. It's like the 85's bigger cousin. You'll have similar issues preparing a development environment.

If you plan to do three or more projects with "non-Arduino" processors, I strongly suggest getting an In System Programmer (ISP).

I'm thinking it will be easier to give up on the attiny85 for this project.

Is the 85 a good fit for any of your other / future projects?

I've got some projects I can use the 85 for, so no prob there. My code uses the newserialsoft, so can't run at 1mhz. Since I have it working on my arduino (I built my own on a breadboard with the ATMega328 w/ bootloader), I am looking at simply building another board with the 328 (I can get build the whole thing again for fairly cheap).

Just didn't know if there were any other options that were smaller, but would not present the challenges I have been having with the 85. Perfect world for me would be a standalone chip that doesn't require an external crystal, doesn't require reseting fuses, and can be programed with the code in this post with my arduino as ISP.

C5150: I've got some projects I can use the 85 for, so no prob there

In which case it is worth the time to get a development environment working. Once you get the wrinkles ironed out, it really is a breeze to develop for the 85.

My code uses the newserialsoft, so can't run at 1mhz

Absolutely. Unmodified, NewSoftSerial does not support 1 MHz. I recall that it is essentially impossible for receives to work when the processor is running at 1 MHz.

But, it's trivial to change the fuses so the processor runs at 8 MHz. Just "Burn Bootloader". The processor is erased and the fuses are changed to whatever "board" you have selected.

Since I have it working on my arduino (I built my own on a breadboard with the ATMega328 w/ bootloader), I am looking at simply building another board with the 328 (I can get build the whole thing again for fairly cheap).

Also a great plan.

Perfect world for me would be a standalone chip that doesn't require an external crystal

Which is nearly all AVR processors.

doesn't require reseting fuses

They all come from the factory ready-to-run at 1 MHz. See above for changing the fuses for 8 MHz.

and can be programed with the code in this post with my arduino as ISP

If you select "ATtiny85 @ 8 MHz (internal oscillator; BOD disabled)" does your sketch compile?

If you select "ATtiny85 @ 8 MHz (internal oscillator; BOD disabled)" does your sketch compile?

Yes, it does thanks to the changes to the cpp you mentioned. But I cannot get the burn bootloader to work.

Error?