OneWire ALPHA
#81
Posted 19 September 2011 - 07:29 PM
#82
Posted 20 September 2011 - 03:27 PM
#83
Posted 20 September 2011 - 07:17 PM
#84
Posted 08 October 2011 - 07:24 PM
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
Posted 15 October 2011 - 02:21 AM
#86
Posted 25 October 2011 - 01:25 AM
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:
Is this correct? I thought it would have said something other than "SolutionReleaseInfo.solutionVendorInfo: Netduino (v4.1.1.0 b1) by Secret Labs LLC".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
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
Posted 25 October 2011 - 02:40 AM
#88
Posted 25 October 2011 - 03:44 AM
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
Posted 25 October 2011 - 03:51 AM
#90
Posted 10 November 2011 - 08:33 AM
#91
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
Posted 02 December 2011 - 02:47 PM
#93
Posted 11 January 2012 - 04:53 AM
_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
Posted 11 January 2012 - 10:39 AM
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.Is sleeping for 750 ms needed?
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
Posted 18 January 2012 - 10:25 AM
#96
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
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
Will be testing now!
#98
Posted 19 January 2012 - 02:21 AM
#### 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
Posted 20 January 2012 - 04:16 AM
#100
Posted 28 January 2012 - 07:16 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users