RFID Card Ignition Acting Weird, Relay causing problems? (Video)

I want to start by thanking everyone here for helping so much, without you guys this would not be possible.

So I have an Arduino Pro connected to a Parallax RFID card reader.
12v to 5v regulator for the Arduino Pro and Parallax Reader.
Arduino Pro Pin 2 connects to the /Enable on the Reader.
Arduino Pin 8 connects to the TX on the Reader.
Arduino Pin 5 connects to 130Ohm resistor then to a Transistor.
Transistor connects to 30 amp Relay Switch with a Rectifier Diode across the coil on the relay. Cathode towards 12v+ and Anode towards 12v-.

The Problem:

The RFID reader basically works as a switch to control 2 other Relays: Fan Relay and Fuel Pump Relay (Both of these relays do NOT have diodes on them)
The set-up I have will work correctly most of the time, but 25% of the time it will switch on normally and then the relay will switch back off on its own without the RFID card being present.
Also when I turn on all three switches for the: Ignition, Fuel Pump, and Fans and then immediately turn off the Fuel Pump and Fan switches at the same time, the Ignition will turn off with them 75% of the time.

Video of problems:

(Watch in 720p HD for better quality)

I don’t think it is the code but if you want to look it over you are more than welcome:
http://pastebin.com/raw.php?i=iVjRpUaq

Is the diode too large/ small and causing it to do this? Industrial Rectifier (NTE5804)
PRV - 400V Max IFSM - 200A Max
IF - 3A Max VF - 1.2V @ 3A

or

Is it the fact that the other 2 relays do not have diodes on them?

Thanks everyone,

Andrew

Here is a schematic sketch with an example of one of the switches for the “fans”.

Can't quite figure out what is controlling what.

Does the Arduino just control a single relay which feeds the three rocker switches on the console?

Is the Arduino deliberately turning this relay on/off when you get these problems, or is it a relay driver problem?

If the Arduino is causing it, does the Arduino think it has seen the RFID tag again (although the tag is supposed to be out of range at the time)?

If the Arduino is causing it, does the Arduino think it has seen the RFID tag again (although the tag is supposed to be out of range at the time)?

That was what it looked like to me. Of course, without seeing the Arduino code, it is hard to tell if it is a software problem.

pwnm, You have a camera. How about putting pencil to paper and sketching out a diagram of your electronics, taking a picture of that, and posting it for everyone? Anyway, I'd get on that "pin 5" with a voltmeter (better a logic probe, or a 'scope, if you have one of those) to see what its story is. I wonder whether so much base current is needed, but that's likely a separate issue.

PaulS:

If the Arduino is causing it, does the Arduino think it has seen the RFID tag again (although the tag is supposed to be out of range at the time)?

That was what it looked like to me. Of course, without seeing the Arduino code, it is hard to tell if it is a software problem.

The code is posted above in the main thread. It's the pastebin link. or you can click here: http://pastebin.com/raw.php?i=iVjRpUaq

runaway_pancake: pwnm, You have a camera. How about putting pencil to paper and sketching out a diagram of your electronics, taking a picture of that, and posting it for everyone? Anyway, I'd get on that "pin 5" with a voltmeter (better a logic probe, or a 'scope, if you have one of those) to see what its story is. I wonder whether so much base current is needed, but that's likely a separate issue.

I only have a voltmeter, solid 4.86 volts or so from pin 5. I honestly do not think it is PIN 5.

Here is a schematic sketch with an example of one of the switches for the "fans".

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

Why are you creating a new instance of SoftwareSerial on every pass through loop()?

What version of the IDE are you using?

        if (found == 0)
        Serial.println("Fail"); //Failed Auth

        // Toggle the transmitting flag
        TRANSMITTING ^= 1;

        // Apply the proper voltage to the relay pin
        if (TRANSMITTING) {
            // Set to high voltage
            analogWrite(RELAY_PIN, 255);
        } else {
            // Set to low voltage
            analogWrite(RELAY_PIN, 0);
        }

If the RFID reader saw a tag, but it was not an expected tag, print an error message, but toggle the relay anyway.

If that is really what you want to do, I'd just remove the RFID reader and put a sign on the car "Please steal me".

Finally, relays are either on or off. Why you are using analogWrite to turn the relay on or off escapes me. You can't really be planning to turn the relay half way on in the future.

That is probably for debugging, he doesn't want to get locked out of his car.

bogdacutu: That is probably for debugging, he doesn't want to get locked out of his car.

No, I'd say it's a bug and explains why the system keeps toggling on and off for no apparent reason.

Without any form of interlock to prevent this system cutting in while the engine is running, this system doesn't look remotely robust enough to use in practice. You only need one of these glitches to kill the engine, which could be inconvenient at best, but at the wrong time could be quite nasty.

I think it would be sensible to add a new keyswitch (not necessarily on the column) or fit a hidden isolator switch or even a conventional immobiliser.

By the way, are you absolutely certain that lock on the column is safe to leave like that? It isn't going to spit the key out one day, or decide to engage the steering lock, is it?

PaulS:

SoftwareSerial RFID = SoftwareSerial(rxPin,txPin); 

RFID.begin(2400);



Why are you creating a new instance of SoftwareSerial on every pass through loop()?

It gave me an error when the RFID.begin(2400) was not in the loop and I guess that I copied SoftwareSerial too. That would be my fault.

PaulS:
What version of the IDE are you using?

		if (found == 0)
	Serial.println("Fail"); //Failed Auth
			
	// Toggle the transmitting flag
	TRANSMITTING ^= 1;
	
	// Apply the proper voltage to the relay pin
	if (TRANSMITTING) {
		// Set to high voltage
		analogWrite(RELAY_PIN, 255);
	} else {
		// Set to low voltage
		analogWrite(RELAY_PIN, 0);
	}


If the RFID reader saw a tag, but it was not an expected tag, print an error message, but toggle the relay anyway.

If that is really what you want to do, I'd just remove the RFID reader and put a sign on the car "Please steal me".

How would you program it?

PaulS:
Finally, relays are either on or off. Why you are using analogWrite to turn the relay on or off escapes me. You can’t really be planning to turn the relay half way on in the future.

So should I use, High and Low instead of 0 and 255?

PeterH:
No, I’d say it’s a bug and explains why the system keeps toggling on and off for no apparent reason.

Without any form of interlock to prevent this system cutting in while the engine is running, this system doesn’t look remotely robust enough to use in practice. You only need one of these glitches to kill the engine, which could be inconvenient at best, but at the wrong time could be quite nasty.

It would be inconvenient, it wouldn’t do much harm unless someone was tailgating me.
The car is not being driven, snow is on the ground. I have 1 month - 2 months to sort out glitches.

PeterH:
I think it would be sensible to add a new keyswitch (not necessarily on the column) or fit a hidden isolator switch or even a conventional immobiliser.

By the way, are you absolutely certain that lock on the column is safe to leave like that? It isn’t going to spit the key out one day, or decide to engage the steering lock, is it?

The key switch on the column is dead. It has no voltage going to it. I eliminated it from the equation. Pretend its not there. I have an aftermarket ignition box that controls the car. It has a built in relay and shouldn’t be a problem.

Thanks for the help guys!

^^ still doesn't account for locking of the hub. Looks like an Arduino powered death trap to me. as the commenter above asked, what's to prevent the steering column from locking on you while in a turn or something?

pwnm30rdi3: The key switch on the column is dead. It has no voltage going to it. I eliminated it from the equation. Pretend its not there.

Does it still have a working steering lock? Presumably disengaged now because the key is stuck, but what happens if the key frees itself while you're driving? Given that the lock is not working properly, it's hard to be confident about just what it's going to do.

I don't know what sort of conditions you drive in, but in my environment it's not uncommon to get into situations where you need to decide whether to pass in front or behind of other traffic. Essentially, whether to accelerate or brake to fit in with the vehicles around you. Once you've committed, changing your mind can be quite tricky. So, having the engine cr@p out on you at the wrong time could be very awkward, perhaps even dangerous. Last time I shredded the rear axle I was in lane three of a dual carriageway and I was very lucky to be able to make my way across two lanes of traffic to a safe place to stop. For me, reliability would be quite an important requirement.

PeterH:

pwnm30rdi3: The key switch on the column is dead. It has no voltage going to it. I eliminated it from the equation. Pretend its not there.

Does it still have a working steering lock? Presumably disengaged now because the key is stuck, but what happens if the key frees itself while you're driving? Given that the lock is not working properly, it's hard to be confident about just what it's going to do.

I don't know what sort of conditions you drive in, but in my environment it's not uncommon to get into situations where you need to decide whether to pass in front or behind of other traffic. Essentially, whether to accelerate or brake to fit in with the vehicles around you. Once you've committed, changing your mind can be quite tricky. So, having the engine cr@p out on you at the wrong time could be very awkward, perhaps even dangerous. Last time I shredded the rear axle I was in lane three of a dual carriageway and I was very lucky to be able to make my way across two lanes of traffic to a safe place to stop. For me, reliability would be quite an important requirement.

It has no steering lock. The only thing on the steering column being used is the steering shaft which is connected to the rack and pinion, It does not have turn signals yet... Its a project car. I have lots of work to do still.

I trust it not to shut off. The only times it acts up is when I first place the RFID key in front of the reader. After it has been activated it will not turn off until I swipe the RFID key again. I want to fix this bug and intend to make it as safe as possible.

I know the risks to this car. This car is by no means safe whether it's Arduino powered or not. When you have 600hp+ and you hit something your chances of survival are very slim. The car will have a roll cage installed and 5 point safety harnesses soon. Do you trust your car? What if it gets stuck in cruise control because of a defect?

I'm posting this question in order to attempt to fix these bugs.

It gave me an error when the RFID.begin(2400) was not in the loop and I guess that I copied SoftwareSerial too.

"It"? We have an Arduino, an RFID reader, and RFID tag, a PC, and and application running on the PC, any of which could be it. While the most likely candidate is the Arduino IDE application on the PC, that doesn't give us a clue what the error was.

In any case, the correct fix is to put those two lines in setup() so that they get executed once.

How would you program it?

With more curly braces and an else block:

        if (found == 0)
                {
          Serial.println("Fail"); //Failed Auth
        }
                else
                {       
          // Toggle the transmitting flag
          TRANSMITTING ^= 1;

          // Apply the proper voltage to the relay pin
          if (TRANSMITTING) {
            // Set to high voltage
            digitalWrite(RELAY_PIN, HIGH);
          }
                  else
                  {
            // Set to low voltage
            digitalWrite(RELAY_PIN, LOW);
          }
               }

So should I use, High and Low instead of 0 and 255?

digitalWrite() instead of analogWrite(), as shown above.

What version of the IDE are you using?

You missed a question. This one is important, in that it defines whether SoftwareSerial is even appropriate.

PaulS: In any case, the correct fix is to put those two lines in setup() so that they get executed once.

With more curly braces and an else block:

      if (found == 0)
                {
          Serial.println("Fail"); //Failed Auth
        }
                else
                {       
          // Toggle the transmitting flag
          TRANSMITTING ^= 1;
      // Apply the proper voltage to the relay pin
      if (TRANSMITTING) {
        // Set to high voltage
        digitalWrite(RELAY_PIN, HIGH);
      }

                 else                  { // Set to low voltage digitalWrite(RELAY_PIN, LOW);  }               }




You missed a question. This one is important, in that it defines whether SoftwareSerial is even appropriate.

I'm using Arduino 1.0 with Arduino Pro 5V 16MHz w/ ATmega 328

This is the error I get when moving

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

from loop() over to setup()

sketch_jan16a.cpp: In function 'void loop()':
sketch_jan16a:50: error: 'RFID' was not declared in this scope

Make RFID a global variable, initialise it in setup(), it is available for you to use however you need within loop().