OneWire ALPHA
#101
Posted 20 February 2012 - 10:56 PM
#102
Posted 27 February 2012 - 10:51 PM
I discovered that I have 18S20 sensors ("S" not "B"), and they output different. I goggled some and think this is the correct solution. I don't have any 18B20 that I can compare to.
Hi! I have a DS18S20+, and it seems that it is also different. Although I get better results with your method, the temperature reading is still off by circa 3 degrees Celsius. Didn't have time to test it with lower temperatures yet (tomorrow).
Do you think it is possible I damaged my sensor when I reversed it? (pin1->pin3, pin3->pin1)? I misread the datasheet at first...
Regards,
Miha.
#103
Posted 28 February 2012 - 08:39 AM
Hi! I have a DS18S20+, and it seems that it is also different. Although I get better results with your method, the temperature reading is still off by circa 3 degrees Celsius. Didn't have time to test it with lower temperatures yet (tomorrow).
It measures 3 degrees below using either parasite or direct power.
I'm also having problems using OneWire in my own program. I copied OneWire.cs, DS18B20.cs and OneWireExtensions.cs (though not needed) to my project and it compiles fine, but when I run it, it breaks on instantiating OneWire with:
#### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) ####
I'll buy a DS18B20 senzor and see what kind of results I'll get with this one.
Regards,
Miha.
#104
Posted 04 March 2012 - 09:24 PM
#105
Posted 22 March 2012 - 08:02 PM
#106
Posted 28 March 2012 - 11:15 AM
#107
Posted 03 April 2012 - 05:02 PM
Here is my updated code for DS2408 and DS18B20 onewire devices:
/// <summary> /// DS18B20 Programmable Resolution 1-Wire Digital Thermometer /// </summary> public class DS18B20 : OneWireDevice { public const byte FamilyCode = 0x28; // Commands public const byte ConvertT = 0x44; public const byte CopyScratchpad = 0x48; public const byte WriteScratchpad = 0x4E; public const byte ReadPowerSupply = 0xB4; public const byte RecallE2 = 0xB8; public const byte ReadScratchpad = 0xBE; internal DS18B20(OneWire core, byte[] rom) : base(core, rom) { } private float Temperature() { // 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(DS18B20.ConvertT); System.Threading.Thread.Sleep(750); // Wait Tconv (for default 12-bit resolution) _core.Reset(); _core.Write(matchRom); _core.WriteByte(DS18B20.ReadScratchpad); // Read just the temperature (2 bytes) var tempLo = _core.ReadByte(); var tempHi = _core.ReadByte(); return ((short)((tempHi << 8) | tempLo)) / 16F; } public static float getTemperature(string oneWireAddress) { foreach (var item in Program.deviceNetwork) { if ((item.Address == oneWireAddress) && (item as DS18B20) != null) { return (item as DS18B20).Temperature(); } } return -100; } } /// <summary> /// DS2408 8 I/O /// </summary> public class DS2408 : OneWireDevice { public const byte FamilyCode = 0x29; internal DS2408(OneWire core, byte[] rom) : base(core, rom) { } private void Set(string activatedPorts) { // 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.WriteByte(OneWire.SkipRom); _core.WriteByte(0x5A); // Channel Access Write command byte statusSet = ActivatePorts(activatedPorts); _core.WriteByte(statusSet); _core.WriteByte((byte)(~statusSet)); var verification = _core.ReadByte(); var status = _core.ReadByte(); if (verification == 0xAA) { // status should be 0xFE (?) } _core.Reset(); } public static void setActivePorts(string ports, string oneWireAddress) { foreach (var item in Program.deviceNetwork) { if ((item.Address == oneWireAddress) && (item as DS2408) != null) { (item as DS2408).Set(ports); } } } private byte ActivatePorts(string ports) { if (ports == null || ports == "") { return 0xFF; } else { var portsArray = ports.Split((",").ToCharArray()); Hashtable ht = new Hashtable() { { "0", 1 }, { "1", 2 }, { "2", 4 }, { "3", 8 }, { "4", 16 }, { "5", 32 }, { "6", 64 }, { "7", 128 } }; int number = 255; for (int i = 0; i < portsArray.Length; i++) { number = number - int.Parse((ht[portsArray[i]]).ToString()); } return byte.Parse(number.ToString()); } } }
I'm using OneWireNetwork.cs class from OneWireTestApp sent by Valkyrie-MT here:
http://forums.netdui...4488#entry14488
I've made small change to Discover method by replacing
_devices.Add(new DS2408(this.core, newrom));
with
if (rom[0] == DS2408.FamilyCode) { _devices.Add(new DS2408(this.core, newrom)); } if (rom[0] == DS18B20.FamilyCode) { _devices.Add(new DS18B20(this.core, newrom)); }
OneWire deviceNetwork variable which defines OneWire port must be set to public static to make my classes to work.
Sample of usage:
This sets port nr 2 to on:
DS2408.setActivePorts("2", "000000058D06");This sets port nr 2 and 5 to on:
DS2408.setActivePorts("2,5", "000000058D06");
This reads temperature:
Debug.Print(DS18B20.getTemperature("0000039F6BB9").ToString());
Probably this could be done better but for me it works. Of course if someone could make it batter then it would be great.
#108
Posted 12 April 2012 - 12:04 PM
tony
#109
Posted 25 April 2012 - 02:35 AM
How do i get my netduino to support 1wire ( onewrire) protocol?
Did you load the firmware from the first post?
#110
Posted 25 April 2012 - 02:38 AM
#111
Posted 25 April 2012 - 03:42 AM
Do I need to have the shielding connected to ground?
#112
Posted 25 April 2012 - 06:12 AM
This is a silly question, but do you actually perform the temperature measurement (i.e. issue 'Convert T' 0x44 command) before reading the scratchpad?Why do I ALWAYS get the power on default of 85C when reading temp? I've seen this mentioned in some other places and people allude to it being wiring but never state what was wired wrong. I can read all bytes the scratchpad, but never get a temperature other than 85C. I should add that I'm a hardware noob.
#113
Posted 25 April 2012 - 10:25 AM
This is a silly question, but do you actually perform the temperature measurement (i.e. issue 'Convert T' 0x44 command) before reading the scratchpad?
Looking over my code again I see when I moved it into a loop I wasn't calling Reset before ConvertT.
Argh! Thanks for making me double check myself.
#114
Posted 26 April 2012 - 07:22 AM
#115
Posted 27 April 2012 - 05:44 PM
#116
Posted 27 April 2012 - 05:49 PM
Hello,
Just wanted to make sure. With the onewire firmware which I can get to work. Is there no support for SD/micro sd which doesnt work for me.
It appears a rebuild of the firmware would be required. I tried using an add-on sd card shield but the IO library to support is part of 4.2 (I think).
#117
Posted 27 April 2012 - 06:32 PM
#118
Posted 04 June 2012 - 08:29 AM
Hi phantom, grimbouk:
When the .NET MF 4.2 firmware is finished in the next month or so, we'll be happy to build a custom version with CW2's latest OneWire feature...for Netduino, Netduino Plus, and Netduino Mini.
Chris
Hi Chris,
I appreciate all the work you do, but I am waiting almost a year for firmware with OneWire support and extra memory for my Netduino Plus project. So far I can use the only available firmware with OneWire based on v4.1.1 beta 1 and get out of memory exceptions from time to time which make my device unstable and due to lack of memory for bigger buffers also slow. I know your answer will be to wait for release of final 4.2 firmware, but for how long? 38K+ RAM or even less would help me definitely. I think OneWire support is also the most demanded feature according to poll I remember seen somewhere on the forum or other Netduino pages.
Thanks,
Jakub
#119
Posted 08 July 2012 - 06:34 AM
I'm new to Netduino but not c#.
I've tried implementing the oneWire application - without much luck.
I've installed the CW firmware on the Netduino.
For some reason it's not picking up the correct dll - but I'm mystified as to why it doesn't as it is there in the path where it should be
- and it compiles OK.
------ Rebuild All started: Project: OneWire_test, Configuration: Debug Any CPU ------
OneWire_test -> C:\Users\Me\Documents\Visual Studio 2010\Projects\OneWire_test\OneWire_test\bin\Debug\OneWire_test.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
deploys OK
Incrementally deploying assemblies to device
Deploying assemblies for a total size of 9200 bytes
Assemblies successfully deployed to device.
but when going through debug to isolate why it's not working:
Rebooting...
Found debugger!
Create TS.
Loading start at 13cc08, end 14fee8
Attaching file.
Assembly: mscorlib (4.1.2821.0) (3880 RAM - 33236 ROM - 19134 METADATA)
Attaching file.
Assembly: Microsoft.SPOT.Native (4.1.2821.0) (1144 RAM - 6516 ROM - 4479 METADATA)
Attaching file.
Assembly: Microsoft.SPOT.Hardware (4.1.2821.0) (1760 RAM - 11552 ROM - 7395 METADATA)
Attaching file.
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.1.2821.0) (512 RAM - 3488 ROM - 1543 METADATA)
Attaching file.
Assembly: Microsoft.SPOT.IO (4.1.2821.0) (740 RAM - 4620 ROM - 2522 METADATA)
Attaching file.
Assembly: System.IO (4.1.2821.0) (1548 RAM - 13292 ROM - 5862 METADATA)
Attaching file.
Assembly: Microsoft.SPOT.Hardware.Usb (4.1.2821.0) (580 RAM - 3740 ROM - 1844 METADATA)
Attaching file.
Assembly: SecretLabs.NETMF.Hardware (4.1.0.0) (256 RAM - 1108 ROM - 491 METADATA)
Attaching file.
Assembly: SecretLabs.NETMF.Diagnostics (4.1.0.0) (180 RAM - 440 ROM - 166 METADATA)
Attaching file.
Assembly: SecretLabs.NETMF.IO (4.1.0.0) (220 RAM - 564 ROM - 279 METADATA)
Loading Deployment Assemblies.
Attaching deployed file.
Assembly: SecretLabs.NETMF.Hardware.Netduino (4.1.0.0) (268 RAM - 796 ROM - 423 METADATA)
Attaching deployed file.
Assembly: OneWire_test (1.0.0.0) (588 RAM - 7648 ROM - 2331 METADATA)
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: OneWire_test (1.0.0.0) needs assembly 'CW.NETMF.OneWire' (1.0.0.0)
Error: a3000000
Waiting for debug commands...
The program '[16] Micro Framework application: Managed' has exited with code 0 (0x0).
This is really frustrating! Any clues what to do?
When is onewire support going to be implemented in firmware?
#120
Posted 24 August 2012 - 06:47 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users