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.
Photo

OneWire ALPHA


  • Please log in to reply
167 replies to this topic

#81 bits_for_fun

bits_for_fun

    New Member

  • Members
  • Pip
  • 2 posts

Posted 19 September 2011 - 07:29 PM

Hi, I deployed the Netduino Plus version of the firmware 4.1.1 with OneWire attached to the first message of this thread. I put DS18B20.cs in my own project, copied the CW.NETMF.OneWire.dll into project sources and referenced it. Added declaration "static OneWire oneWire;" in the main class. No build errors. When I deploy on the Netduino, the deploy/debug session exits immediately, last output rows telling: Attaching deployed file. Assembly: CW.NETMF.OneWire (1.0.0.0) (236 RAM - 756 ROM - 429 METADATA) Invalid native checksum: CW.NETMF.OneWire 0x0!=0xA1BB949 Resolving. Link failure: some assembly references cannot be resolved!! Assembly: mi0283_test (1.0.0.0) needs assembly 'CW.NETMF.OneWire' (1.0.0.0) Error: a3000000 Tried both the Debug and the Release dll versions. (I cannot rebuild the OneWire solution, or the OneWireTestApp.csproj, this c# 2010 Express refuses to load them). Anyone now what I could do? -DS18B20 eagerly waiting to be read-

#82 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 20 September 2011 - 03:27 PM

Hi bits_for_fun, That error _seems_ to be indicating that the device doesn't have CW2's OneWire class in its firmware. The "0x0!=" part means that there is no assembly there, so the verification match is failing. Can you double-check that you flashed the correct firmware using MFDeploy? Chris

#83 bits_for_fun

bits_for_fun

    New Member

  • Members
  • Pip
  • 2 posts

Posted 20 September 2011 - 07:17 PM

Thanks for your quick answer Chris, Reloaded the NetduinoPlus_v4.1.1_beta1_CW.NETMF.OneWire-1.0.5.0.zip and deployed using MFDeploy. Then, Menu - Target - Device Capabilities says: SolutionReleaseInfo.solutionVendorInfo: Netduino Plus (v4.1.1.0 b1) by Secret Labs LLC SoftwareVersion.BuildDate: Mar 31 2011 Should there be some other indication of existence of the CW.NETMF.OneWire assembly? MFDeploy /Menu - Plug-in - Debug - Show Device Info / list of assemblies does not contain it anyway? Earlier in this thread, Stuart Crawshaw reported the same deployment problem (An error has occurred: please check your hardware.) He solved it by changing the referenced instance of CW.NETMF.OneWire.dll. I tried it too (Netduino_v4.1.1_beta1_CW.NETMF.OneWire-1.0.5.0\Solutions\Netduino\Interop\CW_NETMF_OneWire\ManagedCode\bin\) Debug and Release (even subfolders le) with no difference. The project contains an InterruptPort (ONBOARD_SW1) and a few lines using SPI_Devices.SPI1 (lcd display, some test drawing); nothing else OneWire-related than "using CW.NETMF.Hardware" and DS18B20.cs source. Compiles and deploys OK. When a reference to the OneWire.dll is added, deploy fails with this: --- An error has occurred: please check your hardware. Object reference not set to an instance of an object. Source: Microsoft.SPOT.Debugger.CorDebug Stack : at Microsoft.SPOT.Debugger.VsProjectFlavorCfg.Deploy() in c:\depot\current\CLIENT_V4_1\Framework\CorDebug\VsProjectFlavorCfg.cs:line 893 at Microsoft.SPOT.Debugger.VsProjectFlavorCfg.<Microsoft.VisualStudio.Shell.Interop.IVsDeployableProjectCfg.StartDeploy>b__0() in c:\depot\current\CLIENT_V4_1\Framework\CorDebug\VsProjectFlavorCfg.cs:line 634 ========== Deploy: 0 succeeded, 1 failed, 0 skipped ========== Must be something annoyingly simple missing here.. just can't see it. ------------ edit: I found the solution to this. Removed and reinstalled C# 2010 Express, .NetMF SDK 4.1, Netduino SDK 4.1, created fresh environment on another Win XP Pro /x86, removed and added reference of the CW_NETMF_OneWire.dll in the project etc. There were two things, first was the CW_NETMF_OneWire.dll instance that was somehow wrong. It really caused NotSupportedException / "please check your hardware" immediately on deploy, even without any code rows using it. The project defined the dll to be copied into the debug folder when project was compiled. That instance was ... not good. The second thing seems to have caused that the removing / re-adding reference did not affect. It _seems_ that the VS c# Express does not copy the file into the debug folder _if it already exists there_. So the wrong one is not replaced. When the dll is manually removed from debug folder, the next compilation updates it correctly. I was not aware of this VS "feature", but that "manual cleaning" fixed the problem. (Actually, the c# Express 2010 Menu - Debug has no "clean solution" option; that could have fixed the problem right away).

#84 Scott Green

Scott Green

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts

Posted 08 October 2011 - 07:24 PM

Valkyrie,

wondering if you have gotten the CRC code (after an all channel voltage read) working with a DS2450. I know that its a 16 bit CRC, and the datasheet says that its calculated from Command Byte, Address Bytes, and Data Bytes. But I cant get a calculated 16bit CRC that matches the one that is sent back from the 2450. Heres, some test code...

var response = new byte[8];
var res2 = new byte[2];

var commandaddrdata = new byte[11]; // Array used to calculate the CRC16
var status = _core.Read(response); // Data Bytes
var stat2 = _core.Read(res2); // CRC bytes

commandaddrdata[0] = 0xAA;
commandaddrdata[1] = 0;
commandaddrdata[2] = 0;
commandaddrdata[3] = response[0];
commandaddrdata[4] = response[1];
commandaddrdata[5] = response[2];
commandaddrdata[6] = response[3];
commandaddrdata[7] = response[4];
commandaddrdata[8] = response[5];
commandaddrdata[9] = response[6];
commandaddrdata[10] = response[7];

var crc = OneWire.ComputeCRC16(response, count: 8);
var crcwithcommand = OneWire.ComputeCRC16(commandaddrdata, count: 11);

_LowByte = res2[1];
_HighByte = res2[0];
float DSCRC16 = (((UInt16)_HighByte << 8) | _LowByte);

Using this code DSCRC16 never matches crc or crcwithcommand. Have tried it with both inverted and non inverted high and low bytes on the read CRC.

Any ideas?

Thanks,
Scott...


For instance with temperature sensors, I've found that there are 2 kinds of bogus values. Ones corrupted in transmission (will fail CRC) and incomplete calculations from the sensors (which returns a default value that passes CRC). So, what I do is maintain the last sensor value in a variable and give that when requested. While at the same time, I routinely try to update the value. Below is the actual code I use for the sensor read with CRC and uninitialized value checking...

                // Write command and identifier at once
                var matchRom = new byte[9];
                Array.Copy(_rom, 0, matchRom, 1, 8);
                matchRom[0] = OneWire.MatchRom;

                _core.Reset();
                _core.Write(matchRom);
                _core.WriteByte(DS18X20.ReadScratchpad);
                System.Threading.Thread.Sleep(5);  // Wait Tconv (for default 12-bit resolution)

                var response = new byte[9];

                var status = _core.Read(response);
                var CRCPass = OneWire.ComputeCRC(response, count: 8) == response[8];
                var Initialized = OneWireExtensions.BytesToHexString(response.Range(0, 1)) != "0550";

                if (status == 9 && CRCPass && Initialized)
                {
                    if (this.FamilyCode == 0x28)
                    {
                        _lastTemp = ((short)((response[1] << 8) | response[0])) / 16F;
                    }
                    else if (this.FamilyCode == 0x10)
                    {
                        _lastTemp = (float)(((short)((response[1] << 8) | response[0])) >> 1) - 0.25F + ((float)(response[7] - response[6]) / (float)response[7]);
                    }
                    
                    _lastTempTime = DateTime.Now;

                    Debug.Print("Getting DS18X20 Temp - " + this.Address + ", " + _lastTemp.ToString());
                }

Also, the .Range method is just an extension method that returns an arrange of the requested range.

-Valkyrie-MT



#85 Scott Green

Scott Green

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts

Posted 15 October 2011 - 02:21 AM

Ok, after a ton of research, and a ton of code tests I figured it out... The DS2450 returns the CRC with the bytes swapped, and it inverts the bits within each byte. i.e. 0xFF = 0x00. The following code results in a good CRC calculation... A little code cleanup and I'm golden! var response = new byte[10]; var status = _core.Read(response); var commandaddrdata = new byte[11]; // Array used to calculate the CRC16 commandaddrdata[0] = 0xAA; commandaddrdata[1] = 0; commandaddrdata[2] = 0; commandaddrdata[3] = response[0]; commandaddrdata[4] = response[1]; commandaddrdata[5] = response[2]; commandaddrdata[6] = response[3]; commandaddrdata[7] = response[4]; commandaddrdata[8] = response[5]; commandaddrdata[9] = response[6]; commandaddrdata[10] = response[7]; UInt32 _LowInt = (UInt32) ~response[8] & 0xFF; // CRC Bits are inverted. Take complement of bits. UInt32 _HighInt = (UInt32) ~response[9] & 0xFF; UInt32 DSCRC16 = (((UInt32)_HighInt << 8) | _LowInt); var crcwithcommand = OneWire.ComputeCRC16(commandaddrdata, count: 11); if (crcwithcommand == DSCRC16) { channelA = (((Int16)response[1] << 8) | response[0]) * ConversionFactor; channelB = (((Int16)response[3] << 8) | response[2]) * ConversionFactor; channelC = (((Int16)response[5] << 8) | response[4]) * ConversionFactor; channelD = (((Int16)response[7] << 8) | response[6]) * ConversionFactor; } else { if (errorProc != null) errorProc(0, "DS2450 CRC Error. Return:" + DSCRC16.ToString() + " Calc:" + crcwithcommand.ToString()); }

#86 megaman

megaman

    New Member

  • Members
  • Pip
  • 3 posts

Posted 25 October 2011 - 01:25 AM

Trying to read a temperature sensor: DS18B20.
I believe I need to do the following:
1. Flash netdunio with the firmware from page 1. I followed the directions in this youtube video: http://www.youtube.c...?v=1cybbSkNrWI.
2. Deploy the OneWire Test App
3. Attach a temp sensor and get a response.

From MFDeploy, my device capabilities are:

HalSystemInfo.halVersion: 4.1.2821.0
HalSystemInfo.halVendorInfo: Netduino (v4.1.1.0 b1) by Secret Labs LLC
HalSystemInfo.oemCode: 34
HalSystemInfo.modelCode: 177
HalSystemInfo.skuCode: 4096
HalSystemInfo.moduleSerialNumber: 00000000000000000000000000000000
HalSystemInfo.systemSerialNumber: 0000000000000000
ClrInfo.clrVersion: 4.1.2821.0
ClrInfo.clrVendorInfo: Netduino (v4.1.1.0 b1) by Secret Labs LLC
ClrInfo.targetFrameworkVersion: 4.1.2821.0
SolutionReleaseInfo.solutionVersion: 4.1.1.0
SolutionReleaseInfo.solutionVendorInfo: Netduino (v4.1.1.0 b1) by Secret Labs LLC
SoftwareVersion.BuildDate: Mar 26 2011
SoftwareVersion.CompilerVersion: 400902
FloatingPoint: True
SourceLevelDebugging: True
ThreadCreateEx: True
LCD.Width: 0
LCD.Height: 0
LCD.BitsPerPixel: 0
AppDomains: True
ExceptionFilters: True
IncrementalDeployment: True
SoftReboot: True
Profiling: False
ProfilingAllocations: False
ProfilingCalls: False
IsUnknown: False

Is this correct? I thought it would have said something other than "SolutionReleaseInfo.solutionVendorInfo: Netduino (v4.1.1.0 b1) by Secret Labs LLC".

If I have correctly deployed the firmware: When trying to deploy OneWireTestApp, I get:

TinyCLR Error
The project must have either an output type of 'Console Application', or an output type of 'Class Library' and the start action set to a valid .NET MicroFramework application.



Thanks for the help.

#87 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 October 2011 - 02:40 AM

Hi megaman, That error is actually trying to tell you something different. The Netduino app you're trying to deploy to your Netduino doesn't have anywhere to start running. If you look at the Solution Explorer (top-right pane of Visual Studio), you'll notice that one of the projects is bolded. This is your startup project. If it's a class and not a Netduino app, then Visual Studio doesn't know what to do with it (since it has no starting Main method). To fix this, right-click on the project which should be the startup project and set it to be the startup project. Does that fix things for you? Chris

#88 megaman

megaman

    New Member

  • Members
  • Pip
  • 3 posts

Posted 25 October 2011 - 03:44 AM

Chris Walker, you have made my night.
Now I have output:

1-Wire device present
Single device present
8A00000284A70228
Device is on the bus
85
Parasite powered



85 seems high. I have the 4.7kohm resistor between the signal and +5 Volts. The DS1820 is powered with +5V and Gnd from the netduino.
Have I done something else wrong with the wiring?

#89 megaman

megaman

    New Member

  • Members
  • Pip
  • 3 posts

Posted 25 October 2011 - 03:51 AM

Got it, it was my wiring. Now I am at 22.

#90 waltsteinchen

waltsteinchen

    New Member

  • Members
  • Pip
  • 2 posts

Posted 10 November 2011 - 08:33 AM

I'm a little confused ... will the OneWire implementation make it into the 4.2 Release ? I already flushed the 4.2.0.0 RC3 .. but there is no sign of OneWire support ... or do I miss something ? Many thanx a sorry if this is a newbie question! Waltsteinchen

#91 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 13 November 2011 - 02:50 PM

...will the OneWire implementation make it into the 4.2 Release ?


The current 4.2 RC3 firmware does not have 1-Wire support, but a version with 1-Wire support has been promised when the 4.2 Release is stable.

-Valkyrie-MT

#92 Paulo Norberto

Paulo Norberto

    New Member

  • Members
  • Pip
  • 5 posts

Posted 02 December 2011 - 02:47 PM

OneWire – When will it be available? Hello, I’m developing a system to take control of all pumps in my home heating system that is based on a solar installation and complemented by 3-Phase (400V) electric heaters (resistances). I need to read data on DS18B20 (One Wire Digital Temperature Sensor) and Pt1000 thermocouples. I will control my reef aquarium system with some probes (like PH, REDOX, http://www.adafruit.com/products/381, etc.) and PWM for LED lightning and relays (http://iteadstudio.c...products_id=449) for pumps. I will try to connect it to my SQL Server 2010 database to store all data from the probes and sensors. Since the beginning I chose the Netduino Plus to the project but now I’m with serious doubts about it. I will need to use OneWire sensors and after I had read a lot of posts about it I’m not sure if OneWire will be available soon (not as a beta release)! Do, anyone, had any information about this? Will OneWire be available to Netduino Plus? If yes, when it will be? I found FEZ Domino and it seems that OneWire works on it! Thank you very much Paulo

#93 cobolstinks

cobolstinks

    Member

  • Members
  • PipPip
  • 27 posts

Posted 11 January 2012 - 04:53 AM

im using your driver and firmware. Things work great, however I'm building out a 5 1-wire sensor project and will be serving the temps as json to a webapp. I see you have a wait for the ConvertT function as below:
_core.WriteByte(DS18B20.ConvertT);
System.Threading.Thread.Sleep(750);  // Wait Tconv (for default 12-bit resolution)

I have removed this wait and things seem fine. Is sleeping for 750 ms needed?

Thanks!

#94 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 11 January 2012 - 10:39 AM

Is sleeping for 750 ms needed?

That is max. conversion time for 12-bit resolution as specified in the device datasheet (p. 8, "Thermometer Resolution Configuration"). The sensor may finish temperature conversion in shorter time, or you are reading the result of previous measurement.


BTW, you can initiate temperature conversion for all devices on the bus at once by issuing Skip ROM command before ConvertT and then read the results by addressing individual sensors one by one...

#95 mutsop

mutsop

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts

Posted 18 January 2012 - 10:25 AM

Are the files in the first post still the experimental/unstable version? Regards

#96 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 18 January 2012 - 02:51 PM

Are the files in the first post still the experimental/unstable version?


Yes, they are the original experimental files. No they are not unstable. They turned out to be exceedingly stable.

-Valkyrie-MT

#97 mutsop

mutsop

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts

Posted 18 January 2012 - 05:30 PM

Yes, they are the original experimental files. No they are not unstable. They turned out to be exceedingly stable.

-Valkyrie-MT



Thanks for the reply :D
Will be testing now!

#98 cobolstinks

cobolstinks

    Member

  • Members
  • PipPip
  • 27 posts

Posted 19 January 2012 - 02:21 AM

I'm getting this in the immediate window during a debug session. I have tried to combine the NeonMika webserver and CW2's one wire driver so i can serve my temps on the LAN. Here is the error from my solution. Any help is greatly appreciated,

#### Exception System.Exception - CLR_E_PIN_UNAVAILABLE (1) ####
#### Message:
#### CW.NETMF.Hardware.OneWire::.ctor [IP: 0000] ####
#### OneWireTestApp.Program::Main [IP: 001f] ####
A first chance exception of type 'System.Exception' occurred in CW.NETMF.OneWire.dll

public class Program
  {
    private static OneWire oneWire;
    private static InterruptPort sw1;

    public static void Main()
    {
      sw1 = new InterruptPort(Pins.ONBOARD_SW1, true, ResistorModes.Disabled, InterruptModes.InterruptEdgeLow);
      sw1.OnInterrupt += new NativeEventHandler(sw1_OnInterrupt);
      
      // TODO: Change pin according to the actual wiring
      //this throws exception
      oneWire = new OneWire(Pins.GPIO_PIN_D7);
      
      //Server WebServer = new Server(PinManagement.OnboardLED, 50000);
      //WebServer.AddResponse(new XMLResponse("wave", new XMLResponseMethod(WebserverXMLMethods.Wave)));

      Thread.Sleep(Timeout.Infinite);
    }

This is the line that is throwing the exception, but it doesn't say anything meaningful...
oneWire = new OneWire(Pins.GPIO_PIN_D7);

I apologize if I am becoming annoying, I'm just looking for some advice on where to begin.

Thanks,
Chris

Attached Files



#99 cobolstinks

cobolstinks

    Member

  • Members
  • PipPip
  • 27 posts

Posted 20 January 2012 - 04:16 AM

removed post consolidating to the post above.

#100 bloughead

bloughead

    New Member

  • Members
  • Pip
  • 2 posts

Posted 28 January 2012 - 07:16 PM

Hello I am new to the NetduinoPlus and I've purchased the DS18b20 1-wire and when I go to deploy the sample onewire sample application I get the following exception: An error has occurred: please check your hardware. Object reference not set to an instance of an object. Source: Microsoft.SPOT.Debugger.CorDebug Stack : at Microsoft.SPOT.Debugger.VsProjectFlavorCfg.Deploy() in c:\depot\current\CLIENT_V4_2\Framework\CorDebug\VsProjectFlavorCfg.cs:line 893 at Microsoft.SPOT.Debugger.VsProjectFlavorCfg.<Microsoft.VisualStudio.Shell.Interop.IVsDeployableProjectCfg.StartDeploy>b__0() in c:\depot\current\CLIENT_V4_2\Framework\CorDebug\VsProjectFlavorCfg.cs:line 634 Also note I've flashed the firmware with the NetduinoPlus_v4.1.1_beta1_CW.NETMF.OneWire-1.0.5.0. Can anyone help me? Thanks Brian




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.