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.

Genious's Content

There have been 10 items by Genious (Search limited from 20-April 23)


By content type

See this member's

Sort by                Order  

#6987 Lots of Serial

Posted by Genious on 04 January 2011 - 03:02 PM in Netduino 2 (and Netduino 1)

Using one port for two devices is a very good idea. Thanks for that! Just read through your linked thread - I'm also thinking about a sort-of-reverse-geocache project, but I also want to add a bit of logging so that I can see the route the box took to the destination.



#6975 Lots of Serial

Posted by Genious on 04 January 2011 - 12:34 PM in Netduino 2 (and Netduino 1)

Hi all, Thinking of doing a simple GPS project with the netduino. Usual sort of thing with GPS module, LCD display and a data logger. Was thinking of using the OpenLog logger from Sparkfun as it's cheap and very simple to use. I know the Netduino plus has an SD card available, but not sure when I can get one... Anyway, the problem is that GPS, Serial and LCD are all driven over serial. I'd prefer not to have to use a multiplexer or anything like that. Is it possible to do "software" serial on the Netduino - i.e. use some digital IO pins to bit-bash serial data? If so... How can it be done? Is there a limit to the number of software serial ports that can be used at a time? Cheers!



#6149 WiFly Shield

Posted by Genious on 16 December 2010 - 11:25 AM in Netduino 2 (and Netduino 1)

Thanks for the info on the 'H', Mustang.

In the end I got it booting into ad-hoc (by setting up ad-hoc with an Arduino program) and connected from the laptop. Was able to telnet in on port 80, enter command mode and send data as you'd expect.

Swapped the shield over to the netduino with a simple program to copy every received char to Debug.Write. Nothing happened.

Plugged back into Arduino and now the red comms light doesn't flash when the Arduino boots (so no comms at all from the SPI/Serial). Have I killed the WiFly..? probably. No clue how I managed it though, and the other lights still flash when it's powered.

Totally confused and quite miserable about the £60 I may have just flushed down the toilet!! ;)

Dan



#5851 WiFly Shield

Posted by Genious on 07 December 2010 - 02:30 PM in Netduino 2 (and Netduino 1)

To be honest, no clue what mode it's in - or even if there's data getting through! The code I've tried so far (see snippet in my first post) attempts to enter command mode to issue the appropriate commands to connect to my wireless, but nothing seems to happen.

I have been assuming up to now that it's because A: The serial commands I'm sending are garbled somehow or B: The unit fails to enter command mode.

Since I can't analyse the serial comms, there's not much more I can work out!

Dan



#5844 WiFly Shield

Posted by Genious on 07 December 2010 - 11:08 AM in Netduino 2 (and Netduino 1)

Hi all, thanks for the feedback on all this - I'll try and give it a go this week and see if I can get it up and running.

Power: Fine on my board as I use external power and was managing to read something back anyway.
SPI/Serial: Looks like I'm setting that up correctly as my init code matches Innovactive's.
Writing: The only difference is that I call _spi.Write twice but Innovactive just calls it once (which is much more elegant if nothing else!).

Quiche31: Maybe I have this problem too? I don't understand why I can't get it into command mode with the Netduino, but the Arduino running the Sparkfun demo code gets it right every time!

Has anyone managed to get commands into the module from the Netduino or is everyone just preconfiguring with a PC connection?

Innovactive: Can you post the body of your SpiUartReadByte method? Just want to check it matches mine!

Excellent work with the Silverlight GUI by the way. I'm a WPF developer for a living, so I like to see good looking WPF/Silverlight GUIs. I'd hoped to make a similar one for remote control of my little robot project.

Cheers,

Dan



#4655 WiFly Shield

Posted by Genious on 08 November 2010 - 04:01 PM in Netduino 2 (and Netduino 1)

Any luck so far? ;) Dan



#4244 WiFly Shield

Posted by Genious on 26 October 2010 - 06:08 PM in Netduino 2 (and Netduino 1)

Hi Chris, I'm in the UK. I got mine from... http://www.coolcompo...products_id=456 It means a lot that you're looking into this for me - many thanks and good luck finding a shield somewhere. I do think that the netduino and wifly is a great combination and I'm sure there'll be lots of other people interested in using them together when (if!) there's a driver. Cheers, Dan



#4178 WiFly Shield

Posted by Genious on 24 October 2010 - 05:22 PM in Netduino 2 (and Netduino 1)

I've worked on this for a few more hours and still not had any success.

* I know the SPI/Serial chip is outputting something because the activity light flashes.
* I know that the WiFly shield itself works because it works with my Arduino.
* I know that whatever activity I'm sending isn't working, because I can't get the chip to work!

I'm totally at a loss now really... I really want to make the shield work, but I just don't know what else to try. The current solution looks like I'll have to use the Arduino to act as a serial/WiFly bridge - a solution that takes up too much space, too much power and looks nasty!

Any help you guys can give would be massively appreciated.

Dan



#4066 WiFly Shield

Posted by Genious on 21 October 2010 - 06:56 PM in Netduino 2 (and Netduino 1)

Code as promised... getting desperate now!

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace WirelessTester
{
    public class Program
    {
        private static SPI _spi;

        private const byte LCR = 0x03 << 3;
        private const byte DLL = 0x00 << 3;
        private const byte DLM = 0x01 << 3;
        private const byte EFR = 0x02 << 3;
        private const byte FCR = 0x02 << 3;
        private const byte SPR = 0x07 << 3;
        private const byte RHR = 0x00 << 3;
        private const byte LSR = 0x05 << 3;
        private const byte THR = 0x00 << 3;
        private const byte DivL = 0x60;//0x50;
        private const byte DivM = 0x00;
        private const byte DataFormat = 0x03;
        private const byte Flow = 0x10;

        public static void Main()
        {
            // write your code here
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

            SPI.Configuration config = new SPI.Configuration(
                Pins.GPIO_PIN_D10,
                false,
                0,
                0,
                false,
                true,
                10000,
                SPI.SPI_module.SPI1);

            _spi = new SPI(config);

            Thread.Sleep(1000);

            _spi.Write(new byte[] { LCR, 0x80 });
            _spi.Write(new byte[] { DLL, DivL });
            _spi.Write(new byte[] { DLM, DivM });

            _spi.Write(new byte[] { LCR, 0xBF });
            _spi.Write(new byte[] { EFR, Flow });
            _spi.Write(new byte[] { LCR, DataFormat });
            _spi.Write(new byte[] { FCR, 0x06 });
            _spi.Write(new byte[] { FCR, 0x01 });

            SpiUartWriteChar('H');

            char c = (char) SpiUartReadByte(SPR);

            Debug.Print(c.ToString());

            //SpiUartWriteLine("");
            //SpiUartWriteLine("exit");
            //Thread.Sleep(500);

            SpiUartFlush();
            SpiUartWrite("$$$");
            Debug.Print(SpiUartReadLine());
            Thread.Sleep(500);
            led.Write(true);
            SpiUartWriteLine("reboot");
            Thread.Sleep(3000);
            led.Write(false);

            SpiUartWrite("$$$");
            Debug.Print(SpiUartReadLine());
            Thread.Sleep(500);

            SpiUartWriteLine("set w a 3");
            Debug.Print(SpiUartReadLine());
            Thread.Sleep(500);

            SpiUartWriteLine("set w p sdgvsfdsf");
            Debug.Print(SpiUartReadLine());
            Thread.Sleep(500);

            SpiUartWriteLine("set i l 80");
            Debug.Print(SpiUartReadLine());
            Thread.Sleep(500);

            Thread.Sleep(100);
            SpiUartFlush();
            Thread.Sleep(100);
            SpiUartWriteLine("join ManParadise");
            Thread.Sleep(10000);
            Debug.Print(SpiUartReadLine());

            SpiUartWriteLine("show c");

            Debug.Print("Setup done");

            while(true)
            {
                string s = SpiUartReadLine();
                if (s != "") Debug.Print(s);
            }
        }

        private static void SpiUartFlush()
        {
            int i = 0;
            while (i < 1000)
            {
                if ((SpiUartReadByte(LSR) & 0x01) == 0x01)
                {
                    SpiUartReadByte(RHR);
                }
                else
                {
                    i++;
                }
            }
        }

        private static string SpiUartReadLine()
        {
            int i = 0;
            string data = "";
            while(i < 1000)
            {
                if ((SpiUartReadByte(LSR) & 0x01) == 0x01)
                {
                    byte b = SpiUartReadByte(RHR);

                    //if (b == '\n' || b == 0xFF)
                       // break;

                    data += (char)b;
                }
                else
                {
                    i++;
                }
            }

            return data;
        }

        private static void SpiUartWriteLine(string data_)
        {
            SpiUartWrite(data_ + "\n");
        }

        private static void SpiUartWrite(string data_)
        {
            Debug.Print(data_);

            byte[] sendBuffer = new byte[data_.Length];
            for (int i = 0; i < data_.Length; ++i)
            {
                sendBuffer[i] = (byte) data_[i];
            }

            _spi.Write(new byte[] {THR, 0x01});

            _spi.Write(sendBuffer);

        }

        private static void SpiUartWriteChar(char c_)
        {
            _spi.Write(new[] { SPR, (byte)c_ });
        }

        private static byte SpiUartReadByte(byte addr_)
        {
            byte[] b = new byte[2];
            _spi.WriteRead(new byte[] { (byte) (addr_ | 0x80) }, B);
            return b[1]; 
        }
    }
}



#4059 WiFly Shield

Posted by Genious on 21 October 2010 - 11:52 AM in Netduino 2 (and Netduino 1)

Hi, this is my first post, so please be kind! I have been trying to get my Netduino to talk to a Sparkfun WiFly shield. I've been basing my code on the Arduino example on the Sparkfun website (the autoconnect example here: http://www.sparkfun....utorials_id=158). The Arduino code compiles, runs and works straight out of the box. However, my port to the Netduino doesn't. I manage to write a character out to the SPI/UART chip and get a response back as expected, so I assume my SPI connection is working (had to alter a baud rate setting to do this, as the shild I have has a different crystal). When I issue commands to the WiFly module via the SPI/UART chip the serial activity light flashes. However, the commands I send seem to be completely ignored! According to the WiFly manual and the example, sending "$$$" should enter command mode and the module should reply with "CMD". This doesn't happen though. I attempt to read characters back after sending "$$$" and get nothing. Is there some difference with reading and writing to the Netduino SPI port compared to the Arduino? I noticed that when I want to read a byte over SPI, I need to send the "read" command twice and get the return value in the second byte of the SPI data I get back. How is this handled with the Netduino's SPI? When is it safe to ignore the values returned on writes to the SPI port? Is there any documentation for SPI on Netduino? Also, has anyone managed to get this module working before? Many thanks! PS: Will post code when I get home!




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.