Hello guys,
i have a bit of a problem with an RFID reader, though that is not the issue.
I recently finished a project and was ready to put inside a box permanently when i noticed an issue. When the serial/usb adapter is not plugged into the computer, the RFID reader did not work. I debugged the code with LEDs and found out that interrupts aren't processed when the board is powered with an external power supply.
The board i'm using is the Arduino-compatible XBoard v2, the USB/Serial Adapter is the Foca.
I'm testing the sketch with this code: see code three posts below
The DATA0 pin of the RFID reader is at Arduino D2, DATA1 on D3. When i'm powering the board via the Foca from the computer usb the sketch lights up the LED to indicate setup, then both LEDs start lighting when i hold a RFID tag in front of the reader. When i do the same thing with a power supply the yellow LED (interrupt1) starts lighting right after turning the device on, so an interrupt has been executed. When i put a tag in front of the reader nothing changes anymore. I can even remove the RFID reader with the same outcome. I can also remove all calls to Serial.* in sketches with no effect. The external power supply provides enough current, i tested 3-4 different ones ranging from 6 to 9V and even a lab supply, but this does not change anything.
Is there any communication between an Arduino and a computer or some bits which are different in that case which would cause problems with interrupts when not attached?!
I tried deactivating and reactivating interrupts in general, but that does not help either.
If anyone knows something it is very appreciated! Thanks!
Re: Interrupts do not work with external power supply
There are some programming issues to work out before arriving at that conclusion.
void setup()
{
cli(); // <-- Remove this. It serves no purpose.
delay(10);
sei(); // <-- Remove this. It serves no purpose.
pinMode(lpin1,OUTPUT);
pinMode(lpin2,OUTPUT);
digitalWrite(lpin1,HIGH);
delay(1000);
digitalWrite(lpin1,LOW);
// Serial.begin(9600);
// These have to be AFTER all initialization. Once called, an interrupt can occur AT ANY TIME. If the initialization has not been performed and an interrupt occurs, what will happen in the interrupt service routine? Chaos? Confusion? Will the interrupt service routine work correctly?
attachInterrupt(0, ISRreceiveData0, FALLING ); //data0/rx is connected to pin 2, which results in INT 0
attachInterrupt(1, ISRreceiveData1, FALLING ); //data1/tx is connected to pin 3, which results in INT 1
}
I'm obviously only talking about my specific case.
I stripped the code down to simple attachInterrupts, which power on LEDs, but still no difference, so i arrived at this conclusion.
#define lpin1 4
#define lpin2 5
void setup()
{
pinMode(lpin1,OUTPUT);
pinMode(lpin2,OUTPUT);
digitalWrite(lpin1,HIGH);
delay(1000);
digitalWrite(lpin1,LOW);
attachInterrupt(0, ISRreceiveData0, FALLING ); //data0/rx is connected to pin 2, which results in INT 0
attachInterrupt(1, ISRreceiveData1, FALLING ); //data1/tx is connected to pin 3, which results in INT 1
}
void loop()
{
delay(1);
}
// handle interrupt0
void ISRreceiveData0(){
digitalWrite(lpin1,HIGH);
}
// handle interrupt1
void ISRreceiveData1(){
digitalWrite(lpin2,HIGH);
}
The LED lights up for setup, then no LED ever blinks again. Same sketch while powering over the FOCA, everything works flawless.
edit: If i power the board via FOCA and disconnect the DTR line both LEDs light up -> both interrupts are executed. Is this noteworthy?
Hardware?
Schematic?
XBoard v2 from DFRobot, schematics: http://www.dfrobot.com/image/data/DFR0162/X-BoardV2Sch.pdf
Nothing but the RFID Reader on Pin2/3, 3 LEDS on 4,5,6 and the FOCA are connected.
Since an RFID device is by definition an RF activated device could the inclusion of the USB connector modify the available RF seen by the RFID device by:
- Modifying the Actual "Antenna" BY: A. increasing it's aperture {(size) Length or Area} or B. modifying it's Plane of orientation (Vertical or Horizontal)
or - Radiate noise from: A. the Computer connected by the USB cable or B. Radiate noise created by the Arduino to the RFID Device
or - Both 1 and 2
For a possible entry point to answer this question does the device work properly if Both the USB and External PSU are simultaneously?
as it might be possible to be some other as yet undiscovered source of interfering radiation as well
Doc
arduino_enthusiast:
Nothing but the RFID Reader on Pin2/3,
Grounds not connected? You may want to fix that.
Have you tried triggering the interrupt yourself by producing a falling edge on pin 2? Does it not work then too? If then interrupt is handled then you have to get more specific about your RFID reader as it may be your problem.
Docedison:
Since an RFID device is by definition an RF activated device could the inclusion of the USB connector modify the available RF seen by the RFID device by:
- Modifying the Actual "Antenna" BY: A. increasing it's aperture {(size) Length or Area} or B. modifying it's Plane of orientation (Vertical or Horizontal)
or- Radiate noise from: A. the Computer connected by the USB cable or B. Radiate noise created by the Arduino to the RFID Device
or- Both 1 and 2
For a possible entry point to answer this question does the device work properly if Both the USB and External PSU are simultaneously?
as it might be possible to be some other as yet undiscovered source of interfering radiation as wellDoc
Thanks! Unfortunately this did not help. If i connect both it works, if i connect only the PSU it doesn't. If i connect both but don't plug the USB cable into the computer (so the cable is still connected, if it acts as an antenna) it doesn't work (both LEDs immediately light up).
Sure, Ground and VCC are connected too, but that aren't data pins so i didn't mention them. Thanks anyway!
The RFID reader is a RDM630 in Wiegand mode btw.
pylon:
Have you tried triggering the interrupt yourself by producing a falling edge on pin 2? Does it not work then too? If then interrupt is handled then you have to get more specific about your RFID reader as it may be your problem.
Will try that now
pylon:
Have you tried triggering the interrupt yourself by producing a falling edge on pin 2? Does it not work then too? If then interrupt is handled then you have to get more specific about your RFID reader as it may be your problem.
Well that does work, so the reader is the problem i guess.
What is the external display (voltage and current rating) and how is it connected?
I have tried several,
for example 5V/1A via the internal mini usb, then
currently 6V/330mA via the external voltage JST connector,
but i also have tried 9V/1A via external and a lab supply with 6-9V (tried different values), the complete board with sensors, buzzer, etc. (stuff i don't have connected right now) was drawing 220mA.
An image of the board is here: XBoard V2 -A bridge between home and internet (Arduino Compatibl [DFR0162] - 20.10EUR : komputer.de, Arduino Open Source Hardware
It definitely seems to be a problem of the RDM630 reader and not the Arduino. Try measuring the 5V line at the reader once with power from the USB and once with power from the external supply. Then post the results here.
I have an RDM630 too and the spec says it's TTL serial and Wiegand. I used it with the serial successfully. How did you change to Wiegand mode? Or do you have a different module where Wiegand is factory set?
Well i have bought a version which says Weigand mode: http://www.komputer.de/zen/index.php?main_page=product_info&cPath=29&products_id=93
There is an other product with UART mode, but the data sheet (which is very poor and even has DATA0/DATA1 wrong) is unclear to what the jumper on the pcb does. Maybe it changes the mode to UART, but i don't know (i think there was a jumper, i'm at work so don't know for sure).
RFID reader code which does not rely on interrupts does work iirc, but i need those reader interrupts in my project to make it work.
Will try measuring on the weekend when i have my measurement stuff.
Does that mean that the reader code which does not rely on interrupts work even when powered externally? That would probably mean that there is a signal but not good enough to trigger the interrupt. Do you have the possibility to connect an oscilloscope?
pylon:
Does that mean that the reader code which does not rely on interrupts work even when powered externally? That would probably mean that there is a signal but not good enough to trigger the interrupt. Do you have the possibility to connect an oscilloscope?
Well this is weird too, it's totally inconsistent.
So as i have written i can power the board via FOCA usb adapter, via the internal mini usb connector and the JST connector for 6+V. When i try code without interrupts it works with powering by FOCA or internal usb but not with JST external ps. Then i uploaded my original sketch again which should work at least by powering it with the FOCA, now even this does not work anymore. Sometimes the sensor seems to pick up something, but the board just resets completely.
I have an oscilloscope available to me on the weekend, will measure it then. Right now i'm thinking about buying the updated version of the reader (RDM6300) and just disregard this. Such weird behavior.
I have the same problem with an Arduino Uno R3, the interrupts do not work when using an external power supply; I did the same thing as you (using leds to debug and even to count the interrupts that get into pin 3, which is interrupt 0)... since I did not see a clear solution in this specific forum thread I will keep looking to get a solution and get back to this one to share with you.
Regarding my last post, the interrupt I am using is "0" so that is in pin "2" sorry for my typo.
Now, I found a solution that is not elegant, but it works... I found out that if I connect an External battery to the USB connected to the Arduino like the ones used to charge smartphones the Interrupt pin works fine and the program does as it does when plugged into the computer, so it is not a matter of using a computer but the 5V it gets form the USB port.
I have connected the 5V External supply to the pin "VIn" at my Arduino R3 board, but it seems that the other 5V that comes from the USB are not the same as the "VIn" and this is when the real hacking begins... I will try soldering some pins in the Arduino board and get back in another post with the findings.
CarlosFT:
I have connected the 5V External supply to the pin "VIn" at my Arduino R3 board, but it seems that the other 5V that comes from the USB are not the same as the "VIn" and this is when the real hacking begins...
Hi Carlos. It's very well documented that the board is NOT supplied from V_in in the same way that it is supplied from V_usb.
The voltage supplied from the USB connector is assumed to be already well regulated, so it's able to supply the board pretty much directly.
The voltage supplied by V_in however is allowed to vary much more widely, from about 6.5 volts up to nearly 20 volts. This voltage then passes through a (onboard) regulator before powering the board. So if you only put 5V into the V_in connector you are definitely not powering it correctly. You need at least 6.5 volts, with 7V through to 12V being ideal.
The board may still run somewhat successfully at reduced voltage, but the input thresholds are likely to be effected. Perhaps your problem is an interaction between reduced operating voltage and interrupt signals that are not quite meeting the correct thresholds.