Main Site Documentation

Mountaineer Board and OneWire?


#1

Hello experts,

I recently bought a Mountaineer Ethernetboard and consider it for implementing a brewing controller. So I need to measure temperature and want to use a OneWire sensor.
Does the Mountaineer’s firmware support Microsoft’s OneWire Implementation? Each time when I try to access some OneWire method an exception is thrown ( System.NotSupportedException).

In my project I am referencing the following related assemblies:

  • Microsoft.SPOT.IO
  • Microsoft.SPOT.Hardware
  • Microsoft.SPOT.Hardware.OneWire
  • Mountaineer.Gadgeteer.MountaineerEth

Here comes a part of the code:

 
    public class DS1821
    {
        OneWire m_Pin;

        /// <summary>
        /// Initializes a new instance of the <see cref="DS1821"/> class.
        /// </summary>
        /// <param name="p">The CPU pin that is connected to the DS1821 sensor.</param>
        /// <remarks></remarks>
        public DS1821(Cpu.Pin p)
        {
            m_Pin = new OneWire(new OutputPort( p, true));
        }


        public DS1821(OutputPort p)
        {
            m_Pin = new OneWire(p);
        }

        /// <summary>
        /// Reads the temperature in high resolution.
        /// </summary>
        /// <returns>Temperature in Celsius</returns>
        /// <remarks></remarks>
        public double ReadTemperature()
        {
            double temp = 0.0;

            m_Pin.TouchReset();
            m_Pin.WriteByte(0xEE);

            bool done = false;
            while (!done)
            {
                m_Pin.TouchReset();
                m_Pin.WriteByte(0xAC);
                Byte status = (Byte)m_Pin.ReadByte();
                done = (status & (1 << 7)) != 0;
            }

            m_Pin.TouchReset();
            m_Pin.WriteByte(0xAA);
            int t = m_Pin.ReadByte();

            m_Pin.TouchReset();
            m_Pin.WriteByte(0xA0);
            int r = m_Pin.ReadByte();

            m_Pin.TouchReset();
            m_Pin.WriteByte(0x41);

            m_Pin.TouchReset();
            m_Pin.WriteByte(0xA0);
            int c = m_Pin.ReadByte();

            /* Calculate temperature
             */
            if (t > 0x80)
            {
                t = t - 256;
            }
            double delta = c - r;
            delta = delta / c;

            temp = t - 0.5 + delta;
            return temp;
        }

    }

HaveI done something wrong or is OneWire not supported by Mountaineer boards? If it is not supported, any hints, what to do in order to get OneWire support on Mountaineer?

Cheers,
Stefan


#2

I thought it did have it. Do you have the latest SDK?


#3

Hi Gus,

I checked the installed .NET MF SDK. It is version 4.2 QFE2 and I got the following device information when querying my mountaineer board:

DeviceInfo:
  HAL build info: 4.2.0.0, Copyright Oberon microsystems, Inc.
  OEM Product codes (vendor, model, SKU): 255, 0, 65535
  Serial Numbers (module, system):
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  Solution Build Info: 4.2.0.0, Mountaineer Group
  AppDomains:
    default, id=1
  Assemblies:
    mscorlib,4.2.0.0
    Microsoft.SPOT.Native,4.2.0.0
    Microsoft.SPOT.Hardware,4.2.0.0
    Microsoft.SPOT.Hardware.PWM,4.2.0.1
    Microsoft.SPOT.Hardware.SerialPort,4.2.0.0
    Microsoft.SPOT.Net,4.2.0.0
    System,4.2.0.0
    System.Xml,4.2.0.0
    Microsoft.SPOT.IO,4.2.0.0
    Gadgeteer,2.42.0.0
    Microsoft.SPOT.Graphics,4.2.0.0
    AnalogOutput,4.2.0.0
    Microsoft.SPOT.Net.Security,4.2.0.0
    Microsoft.SPOT.Touch,4.2.0.0
    System.Http,4.2.0.0
    Mountaineer.Gadgeteer.MountaineerEth,4.2.0.0
    BrewingHardwareTest,1.0.0.0
    System.Net.Security,4.2.0.0
    Microsoft.SPOT.TinyCore,4.2.0.0
    System.IO,4.2.0.0
    Microsoft.SPOT.Hardware.OneWire,4.2.0.0

Or did you mean the .NET MF 4.3 beta with the “latest” SDK? I think there is no Mountaineer firmware for the .NET MF 4.3 beta.

Cheers,
Stefan


#4

No 4.3 is not out yet. I asked Oberon as maybe one wire is not part of the build. We should hear back soon.


#5

Interesting, what kind of setup are you going to use to brew? 1 kettle, or two, water chiller? - how much will be controlled? etc.


#6

Hi Gus,

Thanks for you intestigations. I am looking forward to hear the response from Oberon.

Cheers,
Stefan

@ Dr9:

OK, this is off-topic for this forum, but here some infos about my idea: Currently I have automated only the mashing process i.e. heating up the worth in multiple temperature steps. I am working with one kettle and using an Arduino in conjunction with a small .NET Winform Application in order to controll the temperature. Now I want to put everyhing onto a Microcontroller and get rid of the Notebook that runs my Winform Application. I have put some more information on my homepage, unfortunately only in German. But Google is your friend and can do a pretty reasonable translation into English :wink: Here some links giving some insights into my beer brewing activities:

http://heesch.net/neujahrsbier-2011.aspx
http://heesch.net/helles-weizenbier.aspx

I want to continue with brewing in a semi automated style and focus more on developing my own beer recipies. But especially the mashing process is quite boring so I want to automate that. So my aim is to develop a small brewing controller that helps to automate the mashing and logging some process data. As soon as I have everything together I will publish it on my homepage and maybe partly or in full here in the “Codeshare” section …

Regards,
Stefan


#7

Any news from Oberon?


#8

As far as I know, one wire is not included in their current firmware and not sure when it will be added.

You can load our cerberus firmware on your board instead and use one wire if you like http://wiki.tinyclr.com/index.php?title=Firmware_Update_FEZ_Cerberus


#9

OneWire is part of the base firmware now, I wonder why it wouldn’t be included?


#10

Stubed out.


#11

Sorry for the delay in responding, but I’ve been on a vacation in the beautiful (albeit somewhat wet) Seattle area :slight_smile: Just got back before the hurricane would get in the way.

Regarding OneWire:

On the one hand, we generally minimized the Flash space used up by the firmware. On the other hand, we’ve never needed OneWire devices in our customer projects so far, and therefore have never tested it.

If this is a common need, we could add the code to the 4.3 release. Would someone be willing to test it if and when we have a prerelease firmware version with it? We hope to have such a prerelease before the end of the year.


#12

Hi Cuno, thanks for your answer. I Hope you could enjoy your vacation. If and when you have a prerelease firmware version I would be happy to test it with a Mountaineer Ethernet board. I think OneWire-Sensors are quite often use - at least in the beer brewery scenery: DS1820 is a cheap and pre-calibrated temperature sensor that comes in a nice housing.

Cheers,
Stefan


#13

In the Mountaineer 4.3 beta 1 release, we have included the OneWire library. As we have no suitable hardware for testing, would it be possible for you to give this feature a try?

https://www.ghielectronics.com/community/forum/topic?id=13619


#14

Hi Cuno, glad to here that the 4.3 beta Version is out supporting RTC and Onewire :slight_smile: Just the two features I was waiting for in order to implement a beer brewing Controller.

For now I will try to implement a small thermometer using the OneWire library and send you my feedback probably until the end of this week.

Cheers,
Stefan


#15

Short update: Today I updated one of my Montaineer Ethernet boards to the new Firmware Version. I followed exactly the instructions and everything worked fine without any Problems

I also managed to create a new Project for Gadgeteer with .NET MF 4.3 and could compile my class for accessing a DS1821 Onewire device. I had to reference the Assembly “Microsoft.SPOT.Hardware.OneWire”.

For the next step I Need to connect a DS1821 to the Montaineer board, today I am tired. Since I am invited to a Party for tomorrow, I will probably continue with my thermomet on the Weekend. I had also the idea to additionally implement a small REST Service - that would make a really nice Network Thermometer :wink:


#16

Good news: I was able to implement a small Thermometer using a DS1821 connected to the Mountaineer Ethernet Board.

For accessing the DS1821 temperature sensore I am using the OneWire protocol. At least for this sensor the implementation in the .NET MF 4.3 Firmware is working fine. I used a small selfmade adapter that is compatible with the GHI OneWire X1 Module.

Here is my source code that deals with the DS1821:



 public class DS1821 : Module
     {
         OneWire m_Pin;

         public DS1821(int SocketNumber) 
         {
             Socket socket = Socket.GetSocket(SocketNumber, true, this, null);
             socket.EnsureTypeIsSupported('Y', this);
             m_Pin = new OneWire( new OutputPort( socket.ReservePin(Socket.Pin.Three,  this), true ));
         }

         public double ReadTemperature()
         {
             double temp = 0.0;

             m_Pin.TouchReset();
             m_Pin.WriteByte(0xEE);

             bool done = false;
             while (!done)
             {
                 m_Pin.TouchReset();
                 m_Pin.WriteByte(0xAC);
                 Byte status = (Byte)m_Pin.ReadByte();
                 done = (status & (1 << 7)) != 0;
             }

             m_Pin.TouchReset();
             m_Pin.WriteByte(0xAA);
             int t = m_Pin.ReadByte();

             m_Pin.TouchReset();
             m_Pin.WriteByte(0xA0);
             int r = m_Pin.ReadByte();

             m_Pin.TouchReset();
             m_Pin.WriteByte(0x41);

             m_Pin.TouchReset();
             m_Pin.WriteByte(0xA0);
             int c = m_Pin.ReadByte();

             /* Calculate temperature
              */
             if (t > 0x80)
             {
                 t = t - 256;
             }
             double delta = c - r;
             delta = delta / c;

             temp = t - 0.5 + delta;
             return temp;
         }
     }


#17

@ Gus - I unmarked your answer since things have changed: The beta 1 firware for .NET MF 4.3 supports now the OneWire Interface and seems to work fine :slight_smile:


#18

The code I used for testing the new Mountaineer Firmware is already posted in this thread, just look at my Posts from today. Mountaineer’s OneWire Support seems to work fine - at least I did not run into any Problems when I did my Little test.

I want to play a Little bit more with the Mointaineer & OneWire and plan to implement a REST Thermometer using a OneWire Sensor. When I am finished, I will put that Project into CodeShare …

PS: I hat autocorrections - they never work correclty and usually make things worse :frowning:


#19

OK, I have put it on CodeShare. You can find the snippet by using the tag DS1821, some time ago I had also posted the Thermometer Project …