Panda - Interupts fire when motor starts?

HI,
I have a little project where I control a 12vdc motor. I am using an L293D as the motor controller and is on a seperate board from the Panda. The Motor has an isolated power supply from the Panda. The only wires between the Panda the the motor control board are the inputs to the controller(2) and a ground. I also have some limit switches (normally open) to control the motor when it reaches the end of a track. The idea is when the limit switch is closed the motor stop and reverses. In testing my poject the limit switches work a expected when tesing alone, and the motor operates as expected when testing alone. I have include in the wiring of the motor control board capacitors to smooth out and reduce spikes in the circuit. My wiring is similiar to this [url]http://farm4.static.flickr.com/3524/3235658022_7f505922e3_o.jpg[/url] My problem is when the motor starts the interupts of the limits switches fire. How can i prevent this from happening? I have capacitors on both of the motor control lines. How are current spike getting to the Panda. I am a newbie to this so I probably missing something… thanks for read all of this and any help you can provide. farmertom

How are the limit switches wired? are you sure the interrupt is set correctly (HIGH or LOW edge).

Yes I am sure the limit switches are hooked up. They are wired the same way as when i tested them alone where they functioned as expected.

BTW i have provided a link to a similiar wiring diagram in the orginal post.

more info. here is the code for one of the interupts . The other side if the limit switch is 5V

 
InterruptPort homeSwitch = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di4, true,
Port.ResistorMode.PullDown,
 Port.InterruptMode.edgeInterruptEdgeHigh);

I also removed the wires from the Panda and the interupts still fire.

If you are sure you have done plenty checkign for noise and spikes that may damage your system, you can add a pull up/down resistor on your interrupt pin to help with noise.

I think i am doing that. Please take a look at the code from one of my replys and (above) and tell me if I am doing what you are telling me to try…thanks
farmertom.

No, I mean add an external resistor. The built in pull up is about 100K which can pickup noise. Add a 10K or less resistor externally to help out with picking up noise.

OK. So I understand correctly, put a 10K resistor inline with the wire going to the from the limit switch to the Panda interrupt port pin. Is this correct( I told you i was a newbie)?

Just for my own understanding. Why do the interupts fire when i have no pins connected to the limit switches?

Thanks for your help
farmertom

Farmertom,

Resistor from the pin to the ground or to Vcc (to the ground will pull the port down, Vcc - up), parallel to the switch.

Also, with DC motors (exspecially brushed ones) you REALLY want to ensure that you have shottki diodes all over the place. Reverse current can be an issue when the coil voltage collapses.
I had similar issue with MSP430, where a floating port was enegized by overvoltage on another port and triggered the interrupt. Also, you might want to put optoisolator between the FEZ board and the motor driver.

Regards
Yuriy

OK thanks for the reply and info. Looks like in need some more work on my circuit design.
farmertom

All,
This is an update to my problem with interrupts firing when they should not. As advised, I connected optoisolators and diodes to the motor control inputs and added resistors to the switch input pins. This had no effect at all. I then explored the use of bypass capacitors. And again these had no effect. The interrupt pins used on my limit switches were next to the pins used for the motor controller. I moved the switch pins to interrupts on the other side of the Panda from the motor controller and behold the interrupts work correctly now . I am glad I solved my problem but am puzzled as to if i was getting “bleed” from one pin the the next on the Panda and how to avoid this in the future. Any advice please.
Thanks
farmertom

@ farmertom: Have you discovered what cause this behavior? I have same problem with Cerberus. It is very strange I get random interrupts event if there is no connection between motor and Cerberus (so motor have own batteries connected directly to brushed DC motor).

Are you using pull-up/pull-down resistors? If yes, you might want to use a stronger one…

I’m using eBlock button, connected with eblock Expansion Module. This button have pullup resistor as far as I know. DO you think it is not strong enought?

Don’t know. What’s the value?

I checked with multimeter and there is 10k ohm pull up resistor and my eBlock button. Do you think that is enough?

Any idea, anyone?

Can you please show us how did you connect everything?

10K is considered strong, you could switch to 4K7 however… All depends on wire length, wire positioning, power supply, … Can you give us a picture and schematic of your setup?

First I would like to try with a simple picture. If picture is not enough, I can try to make detailed schematics.
There are actually two different electrical circuits. First one:

  • USB Power bank connected through SP module to Cerberus
  • On Cerberus is connected only one module (eBlock expansion module) with two eBlocks. First is button eBlock connected to pin 3 (with interrupt support) and led connected to pin 9 using provided cables.
    Code for Cerberus is very simple, just toggle led on every interrupt.

    public class TestInterrupt
    {
        private static OutputPort DebugLed = new OutputPort(FEZCerberus.GetPin(2, 9), false);
        public static void Run()
        {
            InterruptPort interrupt = new InterruptPort(FEZCerberus.GetPin(2, 3), true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
            interrupt.OnInterrupt += new NativeEventHandler(interrupt_OnInterrupt);

            Thread.Sleep(Timeout.Infinite);
        }

        static void interrupt_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            Debug.Print("Interrupt: " + time.Ticks);
            DebugLed.Write(!DebugLed.Read());
        }
    }

Second circuit is also very simple. 6V power supply connected to breadboard. On power line there are two capacitors one 100uF and one 0.1uF. From power line there are cables to two motors, both on the same side of the car. So, no connection with Cerberus.
But most of the times, when I turn motors on, interrupt fires. Sometimes interrupt fires also when motors are running, especially when I try to stop to motors.
Im sure, this have some connection with magnetic or any other field generated by electric motor, but I dont know how to prevent that.

Any advice? Thank you for you help!