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.

loveelectronics's Content

There have been 11 items by loveelectronics (Search limited from 20-April 23)


By content type

See this member's

Sort by                Order  

#17356 Serial.read via USB? yu know like on the good ol Arduino.

Posted by loveelectronics on 31 August 2011 - 05:52 PM in Netduino 2 (and Netduino 1)

I built this little board to add Serial to USB communications to the Netduino: https://www.loveelec...--barebone-ftdi Its use is explained in this netduino tutorial: https://www.loveelec...how-to-use-them It shows how to use the Serial device to output to a WCF application.



#16846 Need help compiling C++ on Netduino

Posted by loveelectronics on 19 August 2011 - 06:53 PM in General Discussion

Excellent, thanks for the link. I should find what I need there.

BTW the reason I need this is because I'm working on a project that will allow you to take a full .Net exe (not .Net MF) and recompile it to C++. Then you can use a C++ compiler as a post-build step to convert it to a native executable. This project is moving along very well and I'm getting close to the point where I need to start testing this on a microcontroller.

This project will allow you to create C++ code from your .Net app that is very compact since it doesn't need the .Net runtime at all as it has its own CLR-like kernel. It does a static code analysis pass in order to only include the code that actually gets executed. It is fast since it is not interpreted but C++ (with added support for GC, full type checking, exception handling, delegates, threading etc). It will also allow P/Invoke just like you can right now with the full .Net, using the exact same P/Invoke syntax.

Once this project is at a good point, I will make it available on CodePlex. I will also post a thread here to describe the project in detail. It is a big project but as I said I have made very good progress.


I would be interested in contributing to this project... please contact me at james@loveelectronics.co.uk



#16639 XBee/Zigbee wireless, where to start?

Posted by loveelectronics on 11 August 2011 - 04:30 PM in Netduino 2 (and Netduino 1)

I have a tutorial on how to configure Series 2 XBees here: https://www.loveelec...t-up-your-xbees



#15779 Where buy netduino in Italy

Posted by loveelectronics on 22 July 2011 - 01:16 PM in Netduino 2 (and Netduino 1)

why you did not answer before?! I bought it in Germany and will arrive in a few days, I also spent more money for shipping :(


Sorry! I was waiting on the shipment to come from the Netduino guys! I'm sure your package will arrive soon and you'll be very pleased!



#15775 Accelerometers and how to use them.

Posted by loveelectronics on 22 July 2011 - 09:18 AM in Netduino 2 (and Netduino 1)

Brilliant - Thanks Jonny!



#15759 Accelerometers and how to use them.

Posted by loveelectronics on 21 July 2011 - 03:42 PM in Netduino 2 (and Netduino 1)

Hi Guys,

I run Love Electronics in England, and I'm putting together some tutorials on how to use the netduino. The first is a series of articles on creating an inertial measurement unit with the netduino. This particlar tutorial deals with accelerometers, and how we can use their readings to calculate the tilt of the device.

The article walks you through how your accelerometer works, and what benefits and problems it introduces. We then explain how to get your netduino hooked up to the sensor, by means of I2C, with the library we have released for it. Once we have the sensor connected, you are walking though collecting that data and visualising it with a WPF application, before filters are explained in a simple to understand way.

Accelerometers and how to use them: netduino

I think it may be of use to some of you guys here, and would appreciate it if you guys thought it usefull, to give it a tweet or like on facebook.

Thanks!
James
(Love Electronics)



#15758 Where buy netduino in Italy

Posted by loveelectronics on 21 July 2011 - 03:36 PM in Netduino 2 (and Netduino 1)

I can also shamelessly suggest my own site, Love Electronics for the netduino. https://www.loveelec...egories/78/.net €27.88 plus €1.49 for shipping to Italy, which takes 3 days.



#14781 Using multiple I2C devices. (I2CDevice)

Posted by loveelectronics on 27 June 2011 - 03:00 PM in Netduino 2 (and Netduino 1)

Yes, I changed the derived class so they no longer pass an I2CDevice.Configuration into the base class.

This is because, with the helper Read/Write classes the dervied classes do not need to know about I2CDevice and that portion of Microsoft.SPOT.Hardware.

They now call:
        /// <summary>
        /// Create an ADXL345 on a custom address.
        /// </summary>
        /// <param name="address">The address of the device.</param>
        /// <param name="clockRateKhz">The rate at which communication will occur.</param>
        public ADXL345(ushort address, int clockRateKhz)
            : base(address, clockRateKhz)
        { }

Thanks for the welcome.

You do not seem to have a constructor to match the following:

public ADXL345(ushort address, int clockRateKhz) : base(new Configuration(address, clockRateKhz))


Looking at the shared class I'd expect it to work if all of your I2C devices are using this. I'll get VS out later to look if no one else responds.

Sorry - I was not clear enough, this does now work. I was presenting a fix incase anyone else experiences this.
Although it increases read time by 0.12ms, it is better than creating/disposing the I2CDevice everytime, which increases read time by 1.2ms.



#14779 Using multiple I2C devices. (I2CDevice)

Posted by loveelectronics on 27 June 2011 - 02:04 PM in Netduino 2 (and Netduino 1)

A new instance of a shared class is created for each device that inherits from it (it is abstract), it is just the I2CDevice that is static and so shared between the devices.

The config is stored in the SharedI2CDevice and is set by calling the base() operator in the constructor of the derived class. You can see it sets m_Configuration when it is constructed.

Then when your derived classes perform an Execute (read/write to the I2CDevice) it changes the config at that point.
public int Execute(I2CDevice.I2CTransaction[] transactions, int timeout)
        {
            m_Device.Config = m_Configuration;
            return m_Device.Execute(transactions, timeout);
        }
It should not be up to the derived classes to implement this, as it is putting knowlage about the limitations of the implementation in the wrong place.



#14776 Using multiple I2C devices. (I2CDevice)

Posted by loveelectronics on 27 June 2011 - 01:44 PM in Netduino 2 (and Netduino 1)

Yeah, I created a new class called SharedI2CDevice which my devices now inherit from rather than I2CDevice, which uses a static I2CDevice to manage access to the bus:

public sealed class L3G4200D : SharedI2CDevice

/***
    This file is created by Love Electronics Ltd

    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License.
    If not, see <http://www.gnu.org/licenses/>.
***/

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

namespace LoveElectronics.Resources
{
    /// <summary>
    /// An I2CDevice wrapper which shares one I2C Device between multiple devices.
    /// Also provides a simplified helper methods to read/write to the device.
    /// <remarks>The user must ensure thread safety!</remarks>
    /// </summary>
    public abstract class SharedI2CDevice
    {
        /// <summary>
        /// The static shared I2C device.
        /// </summary>
        private static I2CDevice m_Device;

        /// <summary>
        /// The timeout of read/writes.
        /// </summary>
        protected int m_Timeout = 1000;
        /// <summary>
        /// The configuration of the current device.
        /// </summary>
        private I2CDevice.Configuration m_Configuration;

        /// <summary>
        /// Creates an instance of a shared I2C device.
        /// </summary>
        /// <param name="address"></param>
        /// <param name="clockRateKhz"></param>
        public SharedI2CDevice(ushort address, int clockRateKhz)
        {
            m_Configuration = new I2CDevice.Configuration(address, clockRateKhz);
            if (m_Device == null)
            {
                m_Device = new I2CDevice(m_Configuration);
            }
        }

        /// <summary>
        /// Executes the passed transactions.
        /// </summary>
        /// <param name="transactions"></param>
        /// <param name="timeout"></param>
        /// <returns></returns>
        public int Execute(I2CDevice.I2CTransaction[] transactions, int timeout)
        {
            m_Device.Config = m_Configuration;
            return m_Device.Execute(transactions, timeout);
        }

        /// <summary>
        /// Simple read of device.
        /// </summary>
        /// <param name="memoryAddress">Initial register address.</param>
        /// <param name="responseLength">Optional read length.</param>
        /// <returns></returns>
        protected virtual byte[] Read(byte memoryAddress, int responseLength = 1)
        {
            var buffer = new byte[responseLength];
            I2CDevice.I2CTransaction[] transaction;
            transaction = new I2CDevice.I2CTransaction[]
            {
                I2CDevice.CreateWriteTransaction(new byte[] { memoryAddress }),
                I2CDevice.CreateReadTransaction(buffer)
            };
            int result = Execute(transaction, m_Timeout);
            return buffer;
        }

        /// <summary>
        /// Simple write to the device.
        /// </summary>
        /// <param name="memoryAddress">Register address to write.</param>
        /// <param name="value">Byte to write.</param>
        protected virtual void Write(byte memoryAddress, byte value)
        {
            I2CDevice.I2CTransaction[] transaction;
            transaction = new I2CDevice.I2CTransaction[]
            {
                I2CDevice.CreateWriteTransaction(new byte[] { memoryAddress, value })
            };
            int result = Execute(transaction, m_Timeout);
        }
    }
}



#14773 Using multiple I2C devices. (I2CDevice)

Posted by loveelectronics on 27 June 2011 - 12:41 PM in Netduino 2 (and Netduino 1)

I have two I2C devices in my project, both are of type I2CDevice, they look like this:


    /// <summary>
    /// Encapsulates communication and management of the Analog Devices ADXL345 3-axis accelerometer.
    /// </summary>
    public class ADXL345 : I2CDevice

    /// <summary>
    /// Encapsulates communication and management of the ST Microelectronics L3G4200D 3-axis gyroscope.
    /// </summary>
    public class L3G4200D : I2CDevice

        /// <summary>
        /// Create an ADXL345 on a custom address.
        /// </summary>
        /// <param name="address"></param>
        public ADXL345(ushort address, int clockRateKhz)
            : base(new Configuration(address, clockRateKhz))
        {
            m_Address = address;
        }

        /// <summary>
        /// Create an L3G4200D on a custom address.
        /// </summary>
        /// <remarks>CS is tied to VDD high to enable I2C.</remarks>
        /// <param name="address"></param>
        public L3G4200D(ushort address, int clockRateKhz)
            : base(new Configuration(address, clockRateKhz))
        {
            m_Address = address;
        }

When I try to instansiate another two I2C devices, I get the following error:

#### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1) ####
    #### Message: 
    #### Microsoft.SPOT.Hardware.Port::ReservePin [IP: 0000] ####
    #### Microsoft.SPOT.Hardware.I2CDevice::.ctor [IP: 0021] ####
    #### LoveElectronics.Sensors.Gyroscopes.L3G4200D::.ctor [IP: 0012] ####
    #### LoveElectronics.Tutorials.Accelerometers.MicroApp.Program::Main [IP: 007c] ####
A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll

I belive this is because the I2CDevice class is trying to reserve pins A4 and A5 to use the I2C bus, but really it should share these pins, and it should be my responsibility to ensure thread saftey.

How can I get round this?




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.