Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

dhensel

Member Since 01 Apr 2015
Offline Last Active Jun 02 2015 04:35 PM
-----

Posts I've Made

In Topic: Possible i2c issue from shorting something on Netduino

30 May 2015 - 01:00 AM

The shield used to work fine, until something happened - possibly a short to the LCD shield which is known to be damaged now.  After that incident, the n2 does not seem to write to SPI devices and the LCD shield is unresponsive.  At least on the Mega, the LCD shield worked 50% but with visible defects (see earlier link to adafruit forum), but the SD/RTC shield was fine.

 

On a side note, it seems like the n2 can create files on the SD card, but they remain empty and nothing is written to them.  Again, possibly this SPI not writing any bytes, however there is no exception thrown on the SD card... just nothing happens.


In Topic: Possible i2c issue from shorting something on Netduino

29 May 2015 - 03:15 PM

So an update:

Pins D0 - D13, SCL, SDA, A0 - A5 will light up an LED when used as an OutputPort. 

Pins A0 - A5 also read realistic values from an accelerometer I have (eg: gravity as a known value)

 

Still, I'm having an issue with the Datalogging Arduino Shield, not writing to the SD card and throws the exception when I try to set the time or synchronize the DS1307.

 

Any ideas of what else to test?  Again, this shield works when used on an Arduino Mega that we have here.

 public void SetTime(DateTime Time)
        {
            // Writing 7 bytes to the buffer, starting at address 0
            int BytesTransferred = this._Device.Write(new byte[] {
                0x00, 
                (byte)Tools.Hex2Dec(Time.Second.ToString()),
                (byte)Tools.Hex2Dec(Time.Minute.ToString()),
                (byte)Tools.Hex2Dec(Time.Hour.ToString()),
                (byte)Tools.Hex2Dec(((int)Time.DayOfWeek).ToString()),
                (byte)Tools.Hex2Dec(Time.Day.ToString()),
                (byte)Tools.Hex2Dec(Time.Month.ToString()),
                (byte)Tools.Hex2Dec((Time.Year - 2000).ToString())
            });
            if (BytesTransferred != 8) throw new ApplicationException("Something went wrong setting the time. Did you use proper pull-up resistors and is there a 3V battery connected?");
        }

This is the exception thrown, so it's not writing bytes to the buffer.  There is a good battery connected, and I have not changed any pull-up resistor modes or anything physically on the board.  This code used to run without errors before.

 

Oddly enough, the onboard LED1 and LED2 do not light up - they're supposed to be tied to D2 and D3.


In Topic: Driving 5v Relay and False Interrupts

26 May 2015 - 04:25 PM

I have been using a similar relay shield, and found it to be very "noisy" electrically.  It would send a large spike that would be picked up on my other channels and more importantly - on my interrupts.  

 

My workaround for this was to create a bool to "lock" my interrupt.  So it would still fire on switch bounce and from the noise, but I'd discard any unwanted ones and "return".

 public void doorClose(OutputPort output)
            {
                //Originally was Open, 3s Close, .5s. Then wait 2s in other call.
                Debug.Print("enable door close solenoid");
                output.Write(true);
                Thread.Sleep(500);

                //Unlock interrupt before door solenoid switches off.
                Debug.Print("Interrupt Unlocked");
                interruptLocked = false;
                
                //Wait for expected interrupt to fire here
                Thread.Sleep(3500);
                

                //Lock Interrupt before door solenoid switches off
                interruptLocked = true;
                Debug.Print("Interrupt Locked");
                Thread.Sleep(1000);

                //Close Door
                Debug.Print("disable door close solenoid");
                output.Write(false);
                Thread.Sleep(500);                
            }

This way, I knew I was looking for the interrupt within a specified period of time - and I didn't allow known  external sources (closing the door via output.Write(false) on the relay shield) to send a valid interrupt.

 static void doorSwitchOK_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            if (control.interruptLocked)
            {
                Debug.Print("++++++++ return, interrupt was locked-------------");
                return;
            }
            //Debounce the switch
            if (DoorButtonLastPushed.AddMilliseconds(500) > time)
            {
                Debug.Print("oooooooo return, switch bounce-------------");
                return;
            }
            //Update last time greater than 500 ms.
            DoorButtonLastPushed = time;

            Debug.Print("-----------door switch button pressed-------------");
            control.keepRunning = true;
        }

The result of this on my debug output would be several lines of noise from the relay shield, then I'd get one line of the desired interrupt, and several lines of switch bounce return, and then several lines of noise again from the relay shield.

 

Not sure if this applies to your case, but if you hook up your outputs to an oscilloscope, I'd guess you would see the relay noise too.


In Topic: I2C LCD with Netduino 3

26 May 2015 - 03:04 PM

This is the snippet from the NETMF sample that I used in my program.  It's for the RGB, but I think the Adafruit hardware implementation is the same for both?  There are a bunch of examples in "Documents\NETMF Toolbox Samples" and should run standalone which I've used to test out my components when I first got them, and later when things went awry.  Have you tried running any of the samples?

// The Adafruit LCD Shield uses a MCP23017 IC as multiplex chip
Mcp23017 Mux = new Mcp23017();

// Pins 0 to 4 on the Mux-chip are connected to the buttons
IGPIPort ButtonSelect = Mux.Pins[0];
IGPIPort ButtonRight = Mux.Pins[1];
IGPIPort ButtonDown = Mux.Pins[2];
IGPIPort ButtonUp = Mux.Pins[3];
IGPIPort ButtonLeft = Mux.Pins[4];
// Enables pull-ups for all the buttons
for (int i = 0; i < 5; ++i)
{
    Mux.EnablePullup(i, true);
    Mux.Pins[i].InvertReadings = true;
}

// Pins 6 to 8 on the Mux-chip are for the backlight
IGPOPort Red = Mux.Pins[6];    // Red backlight
IGPOPort Green = Mux.Pins[7];  // Green backlight
IGPOPort Blue = Mux.Pins[8];   // Blue backlight

// Pins 9 to 15 are connected to the HD44780 LCD
Hd44780Lcd Display = new Hd44780Lcd(
    Data: Mux.CreateParallelOut(9, 4),
    ClockEnablePin: Mux.Pins[13],
    ReadWritePin: Mux.Pins[14],
    RegisterSelectPin: Mux.Pins[15]
);

In Topic: I2C LCD with Netduino 3

22 May 2015 - 07:50 PM

I get the default "boxes" displayed on the lcd, so at least something is happening... but I don't get any backlight or other response from the display.

 

 

Not to sound disrespectful, but have you tried adjusting the contrast pot?  Mine was all the way down originally and I saw the same "boxes".  On my N2 I've had good a good, straightforward experience using that LCD shield (actually the RGB version) from Adafruit, and I've been using the NETMF Toolbox "Hd44780Lcd" class


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.