Netduino Plus 2 Project Issue

Hello all,

I am working on a project with my Netduino Plus 2. I am encountering a strange problem.

In a nutshell, the device I’m designing is running tests on a circuit board to check for functionality. I am using the Netduino to send signals to this board. I have 6 push-buttons that trigger interrupts which send certain signals to the board being tested. If the correct level is detected at this board’s output pin, a corresponding LED is turned on. If an incorrect level is detected, the LED is flashed. The interrupt ports are interruptedgehigh with accompanying pull down resistors. The N+2 is being powered by 8 volts coming from a power supply circuit which itself is powered with your basic 120VAC.

The board I am testing requires 120VAC to be sent through 4 paths one at a time. This tests functionality of the components located on that particular path. So I have 4 line/neutral pairs sent to the board. But since the paths must be run one at a time, I have each line switched. This way, when I want to run the AC line tests, I flip line switch 1, press the test’s push-button to trigger the interrupt which runs the test, and then check the test results via the LED.

Now here is where my problem arises. My test seems to function correctly, but when I switch on the AC during any of the four AC line tests, either that test’s LED flashes or another AC line test’s LED flashes. So to be specific, let’s say I flip the switch to send AC through Line Test 1. No lights should turn on or flash until I press the push-button to trigger the interrupt. However, any of the four Line Test LED’s flash. It’s as if the interrupts are being triggered without the push-button being pressed.

I have included my entire program code below. I know this is long winded but I am just stumped as to a hardware cause and want to check all bases software wise before wracking my brain any further.

Attached is a wiring diagram of the circuit, as well as a picture of the front of the fixture. The AC lines are not included in the diagram because they are independent of the circuit. The fixture pic is to show where the ac switchers are in relation to the LEDs that continue to flash when the switches are flipped. Thanks so much for any and all help!

using System;
using System.Net;
using System.Net.Sockets;
using System.Diagnostics;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
 
namespace TLS_350_Pump_Sense_Module_Test_Program
{
    
    public class Program
    {
        private static InterruptPort LT1Switch = new InterruptPort(Pins.GPIO_PIN_D6, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
        private static InterruptPort LT2Switch = new InterruptPort(Pins.GPIO_PIN_D7, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
        private static InterruptPort LT3Switch = new InterruptPort(Pins.GPIO_PIN_D2, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
        private static InterruptPort LT4Switch = new InterruptPort(Pins.GPIO_PIN_D3, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
        private static InterruptPort TransTestSwitch = new InterruptPort(Pins.GPIO_PIN_D5, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
        private static InterruptPort U1TestSwitch = new InterruptPort(Pins.GPIO_PIN_D4, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
        private static OutputPort J1pin3 = new OutputPort(Pins.GPIO_PIN_D0, false);
        private static InputPort J1pin4 = new InputPort(Pins.GPIO_PIN_D13, true, Port.ResistorMode.Disabled);
        private static OutputPort J1pin5 = new OutputPort(Pins.GPIO_PIN_D9, false);
        private static OutputPort J1pin7 = new OutputPort(Pins.GPIO_PIN_D10, false);
        private static OutputPort J1pin9 = new OutputPort(Pins.GPIO_PIN_D11, false);
        private static OutputPort J1pin10 = new OutputPort(Pins.GPIO_PIN_D12, true);
        private static OutputPort LT1LED = new OutputPort(Pins.GPIO_PIN_D8, false);
        private static OutputPort LT2LED = new OutputPort(Pins.GPIO_PIN_A1, false);
        private static OutputPort LT3LED = new OutputPort(Pins.GPIO_PIN_A2, false);
        private static OutputPort LT4LED = new OutputPort(Pins.GPIO_PIN_A3, false);
        private static OutputPort TTLED = new OutputPort(Pins.GPIO_PIN_A4, false);
        private static OutputPort U1TLED = new OutputPort(Pins.GPIO_PIN_A5, false);
        private static DateTime lastEvent = DateTime.Now;
 
        public static double ReadRaw()
        {
            AnalogInput TransistorTest = new AnalogInput(AnalogChannels.ANALOG_PIN_A0); 
            const double maxVoltage = 3.3;
            const int maxADCValue = 4095;
            double rawValue = TransistorTest.ReadRaw();
            TransistorTest.Dispose();
            double voltagevalue = (rawValue * maxVoltage) / maxADCValue;
            double realworldvalue=(((voltagevalue - 0.5) * 1000) / 10) - 4;
            return voltagevalue;
         }
        
             
        public static void Main()
        {
            TransTestSwitch.OnInterrupt += new NativeEventHandler(TransTestSwitch_OnInterrupt);
            LT1Switch.OnInterrupt += new NativeEventHandler(LT1Switch_OnInterrupt);
            LT2Switch.OnInterrupt += new NativeEventHandler(LT2Switch_OnInterrupt);
            LT3Switch.OnInterrupt += new NativeEventHandler(LT3Switch_OnInterrupt);
            LT4Switch.OnInterrupt += new NativeEventHandler(LT4Switch_OnInterrupt);
            U1TestSwitch.OnInterrupt += new NativeEventHandler(U1TestSwitch_OnInterrupt);
 
            Debug.Print(ReadRaw().ToString("f"));
            Thread.Sleep(300); 
 
            Thread.Sleep(Timeout.Infinite);
        }
 
 
 
        static void U1TestSwitch_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            J1pin3.Write(false);
            J1pin5.Write(true);
            J1pin7.Write(false);
            J1pin4.Read();
            U1TestSwitch.ClearInterrupt();
 
            if (time.AddMilliseconds(-500) > lastEvent)
            {
                lastEvent = time.AddMilliseconds(500);
 
                if (J1pin4.Read() == true)
                {
                    U1TLED.Write(true);
                }
 
                else
                {
                    int U1number = 7;
                    for (int i = 0; i < U1number; i++)
                    {
                        U1TLED.Write(true);
                        Thread.Sleep(200);
                        U1TLED.Write(false);
                        Thread.Sleep(200);
                    }
                }
            }
        }
 
 
        static void TransTestSwitch_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            J1pin3.Write(true);
            J1pin5.Write(true);
            J1pin7.Write(true);
            J1pin9.Write(true);
            ReadRaw();
            TransTestSwitch.ClearInterrupt();
 
            if (time.AddMilliseconds(-500) > lastEvent)
            {
                lastEvent = time.AddMilliseconds(500);
 
                if (ReadRaw() > 2.4 && ReadRaw() <= 2.7)
                {
                    TTLED.Write(true);
                    Debug.Print(ReadRaw().ToString("f"));
                    Thread.Sleep(300);
                }
 
                else
                {
                    int Tnumber = 7;
                    for (int i = 0; i < Tnumber; i++)
                    {
                        TTLED.Write(true);
                        Thread.Sleep(200);
                        TTLED.Write(false);
                        Thread.Sleep(200);
                    }
                }
            }
        }
 
        static void LT1Switch_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            J1pin3.Write(false);
            J1pin5.Write(false);
            J1pin7.Write(false);
            J1pin4.Read();
            LT1Switch.ClearInterrupt();
 
            if (time.AddMilliseconds(-500) > lastEvent)
            {
                lastEvent = time.AddMilliseconds(500);
 
                if (J1pin4.Read() == false)
                {
                    LT1LED.Write(true);
                }
 
                else
                {
                    int L1number = 7;
                    for (int i = 0; i < L1number; i++)
                    {
                        LT1LED.Write(true);
                        Thread.Sleep(200);
                        LT1LED.Write(false);
                        Thread.Sleep(200);
                    }
                }
            }
        }
 
        static void LT2Switch_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            J1pin3.Write(true);
            J1pin5.Write(false);
            J1pin7.Write(false);
            J1pin4.Read();
            LT2Switch.ClearInterrupt();
 
            if (time.AddMilliseconds(-500) > lastEvent)
            {
                lastEvent = time.AddMilliseconds(500);
 
                if (J1pin4.Read() == false)
                {
                    LT2LED.Write(true);
                }
 
                else
                {
                    int L2number = 7;
                    for (int i = 0; i < L2number; i++)
                    {
                        LT2LED.Write(true);
                        Thread.Sleep(200);
                        LT2LED.Write(false);
                        Thread.Sleep(200);
                    }
                }
            }
        }
 
        static void LT3Switch_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            J1pin3.Write(false);
            J1pin5.Write(true);
            J1pin7.Write(false);
            J1pin4.Read();
            LT3Switch.ClearInterrupt();
 
            if (time.AddMilliseconds(-500) > lastEvent)
           {
                lastEvent = time.AddMilliseconds(500);
 
                if (J1pin4.Read() == false)
                {
                    LT3LED.Write(true);
                }
 
                else
                {
                    int L3number = 7;
                    for (int i = 0; i < L3number; i++)
                    {
                        LT3LED.Write(true);
                        Thread.Sleep(200);
                        LT3LED.Write(false);
                        Thread.Sleep(200);
                    }
                }
            }
        }
 
        static void LT4Switch_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            J1pin3.Write(true);
            J1pin5.Write(true);
            J1pin7.Write(false);
            J1pin4.Read();
            LT4Switch.ClearInterrupt();
 
            if (time.AddMilliseconds(-500) > lastEvent)
            {
                lastEvent = time.AddMilliseconds(500);
 
                if (J1pin4.Read() == false)
                {
                    LT4LED.Write(true);
                }
 
                else
                {
                    int L4number = 7;
                    for (int i = 0; i < L4number; i++)
                    {
                        LT4LED.Write(true);
                        Thread.Sleep(200);
                        LT4LED.Write(false);
                        Thread.Sleep(200);
                    }
                }
            }
        }
    }
 
}
 
 

1 Like

I have invited him here. There are not much activity there.

5 Likes

@ WriterGuy

It sounds like some sort of self-induction issue. Do you have proper shielding in your set-up?

@ WriterGuy - Welcome to GHI forum.

Just a few thoughts.

  • Has this project, or any portion of it worked successfully in the past?

  • The circuit diagram didn’t make the attachment. Is the DC GND of the Netduino connected to the ground of the system under test?

  • Have you tried .1uF capacitors between GND and the interrupt input pins?

EDIT: a few more things.

  • Are you connected through USB to you computer when this happens? Any difference when you are disconnected?

  • What kind of power supply are you using to power the Netduino?

2 Likes

@ WriterGuy - You probably can’t reply right away until grace period is over (antispam feature). But you can edit your original post and attach additional images.

Welcome to the NetMF Forums :wink: .

This to me is the telling comment. Since we have debugging capability, lets make sure the flash is caused by your code firing, sprinkle debug.print in your handlers. That will tell you if it’s spurious interrupts (most likely) or spurious digital signals. Given your 500ms dead time you may find that there’s more than one interrupt triggered but only one gets past the time test.

As we haven’t seen your circuit diagram, can you tell us about how you are switching the AC lines? Simple relays? Simple mechanical switches? SSRs? What about zero crossing detection, which might cause less energy spikes.

One other suggestion is look at your power supply powering the N+2, and see if it does or does not have an earth pin, there could be benefit in one or the other scenario… if you have multiple power supplies, test them all.

Welcomes! Good Guy Arch for the win :clap:

1 Like

Thanks so much for the replies everyone!

I was unable to reply yesterday due to the anti-spam measurements, but it also wasn’t allowing me to upload my wiring diagram. I don’t know what happened I thought I had it uploaded on the original post but it didn’t make it on the final post for some reason. I have attached to the main post, but I will put it here as well.

The diagram is a basic layout of my circuit. The J1 Connector (PSM) located on the diagram is the connector that attaches to the board under test. The same ground runs throughout the power supply (CFM40M090 9V Supply) as well as the circuit PCB and the board under test. The AC lines are not included on the wiring diagram, but they are independent of the rest of the circuit. The lines simply run from the wall outlet to 4 switches and from there to another connector on the board under test.

Architect - I currently do not have any shielding in place. This is probably an oversight on my part. I ran the circuit on breadboard before assembling the fixture and it seemed to work properly with not stray flashing LEDs. However, the breadboard setup did not include the power supply as I ran the test off of the netduino +2 USB connector.

skeller - I answered many of your questions above. The USB is not connected when I power my fixture. And I have not tried .1uF caps between GND and the interrupt port pins.

Brett - When you say sprinkle in debug.print, what am I supposed to be printing to the window? The AC switching is being done by 4 simple mechanical switches, although they are rated for the proper AC voltage. Replacing them with heavy duty power switches produced the same problem. The outer case of the fixture has been connected and unconnected to Earth ground with not effect on the issue. All other ground are connected.

1 Like

debug.print enough information to prove your ghost flashes are or are not coming from interrupts firing - and print the interval you test in your code or print inside the check, so you can see what you are filtering out. You may find you’re getting hundreds of additional interrupts you weren’t expecting…

I added the .1uF caps between GND and the interrupt port pins and it now works perfectly! Thanks so much to everyone that replied, but a big thank you to Skeller for the winning solution!

5 Likes

–Update–

Well, looks like I might be back to square one. The caps seemed to stop the flashing when I had the board outside of the case. However, this morning I put the PCB back into the case and wired everything back up. Now, low and behold, the flashing LEDs have returned. I am positively irritated and stumped.

Architect, you mentioned shielding before. What is the purpose of this and how is it best to go about it?

Can you snap a pic of the internals of your case with the board inside?

Here it is. It looks a hot mess, but all major power connections are mostly covered in heat shrink. The AC switches are circled in yellow.

1 Like

To me this is art, not mess :slight_smile:

2 Likes

@ andre.m,

No it’s not commercial. We do similar things at work, but this was an individual project I started in order to help strengthen my proper coding and microcontroller interfacing skills. I did many similar projects while getting my bachelor’s degree.

@ WriterGuy - So your Netduino plugs-in to the green board underneath it?

@ Architect,

Yes the netduino connects to pins that are soldered to the green PCB underneath

I would call it a complex order of cleanliness :wink:

4 Likes

@ RobvanSchelven - I am stealing that phrase.

1 Like

Your major issue is that you have AC and DC wiring in close proximity so you are going to get noise induced onto the DC wiring. The Low Voltage Directive cover things like this. You should consider rewiring the enclosure so that all of your AC wiring is along one side and your DC on the other. They should be separated as much as possible. If you have to have DC near the AC wiring, arrange for it to pass over at 90 degrees but the further away the better.

2 Likes