Latest SDK 4.2 - Onewire Fails

Correct I have 11 temperature sensors DS18S20.

No parasitical powering.

At the moment I cannot say whats the value of the pull up resistor, I use a off the shelf “hub”

We will run more testing and let you know.

No, I have not noticed any issues with OneWire on Cerb-Family. Works fine on Cerb-Family. Just making sure.

I tried using 1wire with the G120 on the latest 4.2 firmware, and I experience the same issue (it does not detect all devices all the time).
I will give more information on my current setup if needed monday, but here is the output of jf_miata test prorgam connected to 4 1-wire module (1 DS2413 and 3 DS2408):

=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
Count: 1
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
Count: 2
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
Count: 2
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
Count: 2
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
Count: 2
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
Count: 2
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
Count: 1
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4

So the problem seems to be there for G120 as well (I will test on EMX monday).
Same hardware works really well on EMX 4.1
Thanks for the ongoing troubleshooting!

Just tested EMX spider + 4.2 this morning and using the same 1-wire hardware that works very reliably on 4.1, it still does the same problem.
Here’s the output of the program:

=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
Count: 1
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
Count: 2
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
Count: 3
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
Count: 2
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
Count: 1
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
Count: 1
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
Count: 1
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
Count: 3
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
Count: 0
=======================================
TouchReset: 1
58.199.229.5.0.0.0.12
41.216.198.17.0.0.0.79
41.242.194.17.0.0.0.41
41.233.194.17.0.0.0.138
Count: 4

This is the test code I used:

using System.Collections;
using GHI.Premium.Hardware;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
 
namespace onewire
{
    public class Program
    {
        public static void Main()
        {
            OutputPort port = new OutputPort(EMX.Pin.IO20, false);
            OneWire onewire = new OneWire(port);
            ArrayList list = new ArrayList();
 
            while (true)
            {
                Debug.Print("=======================================");
                Debug.Print("TouchReset: " + onewire.TouchReset());
 
                list = onewire.FindAllDevices();
 
               foreach (byte[] s in list) {
                            Debug.Print(s[0].ToString() + "." +
                                s[1].ToString() + "." +
                                s[2].ToString() + "." +
                                s[3].ToString() + "." +
                                s[4].ToString() + "." +
                                s[5].ToString() + "." +
                                s[6].ToString() + "." +
                                s[7].ToString()
                                );
                        }
 
                Debug.Print("Count: " + list.Count);
                list.Clear();
 
                System.Threading.Thread.Sleep(2000);
            }
        }
 
        public static ulong ConvertToLong(byte[] input)
        {
            return (ulong)input[0] | (ulong)input[1] << 8 | (ulong)input[2] << 16 | (ulong)input[3] << 24 | (ulong)input[4] << 32 | (ulong)input[5] << 40 | (ulong)input[6] << 48 | (ulong)input[7] << 56;
        }
 
    }
}

This is the method I used to connect 3.3V 1wire master signal to 5V 1wire slave signal:
“MOSFET (Pass Transistor) Interface” from this link: http://www.savagecircuits.com/forums/content.php?309-Mixed-Voltage-Systems-Interfacing-5V-and-3-3V-Devices.
The hardware setup was 1 DS2408 and 1 DS2413 device.

Also directly connecting the 3.3V master 1wire to the 1wire devices worked.
That setup was 2 1wire DS2408, externally powered 5V. (not parasitic supply), with a 1.7k ohm resistance on both devices.

Finally I tried another test (which is the results I posted above), that connects all 4 devices (1 DS2413 and 3 DS2408), all 3 setups has unreliable results with “onewire.FindAllDevices();”, but works perfectly on EMX 4.1

@ PhilM -

Thanks for your feedback. Yes, the problem on EMX has been fixed.
But on G120, I used your code exactly but it is giving me perfect value, and I am testing with 8 one-wire device.
Then i modified a little bit to show the temperature to make sure all of them are working. I used 8 devices DS18B20 and 4.7k resistor pullup.

And here is code that i used:


using System;
using Microsoft.SPOT;

using GHI.Premium.Hardware;
using Microsoft.SPOT.Hardware;
using System.Threading;
using System.Collections;

namespace one_wire_premium_42_libs_check
{
    public class Program
    {

        static OutputPort port; 
       // static InputPort button;
        static OneWire ow ;
        public static void Main()
        {
             port = new OutputPort((Cpu.Pin)27, false); //32// socket 9, pin 9
            // button = new InputPort((Cpu.Pin)33, false, Port.ResistorMode.PullUp);
            ////while (button.Read()) { Thread.Sleep(100); };
             ow = new OneWire(port);
            ArrayList list;

            while (true)
            {
                Debug.Print("=======================================");
                Debug.Print("TouchReset: " + ow.TouchReset());

                list = ow.FindAllDevices();

                foreach (byte[] s in list)
                {
                    Debug.Print(s[0].ToString() + "." +
                        s[1].ToString() + "." +
                        s[2].ToString() + "." +
                        s[3].ToString() + "." +
                        s[4].ToString() + "." +
                        s[5].ToString() + "." +
                        s[6].ToString() + "." +
                        s[7].ToString() + "Temperture: " + GetTemperture(s)
                        );
                    
                }

                Debug.Print("Count: " + list.Count);
                list.Clear();

                System.Threading.Thread.Sleep(2000);
            }
        }
        static String GetTemperture(byte[] ow_address)
        {
            byte[] scratchpad = new byte[9];
            ushort tempLow = 0;
            ushort tempHigh = 0;
            ushort temp = 0x0;
            int temptemp;
            float TemperatureC = 0;
            ow.TouchReset();
            ow.WriteByte((byte)Command.MatchROM);
            for (int i = 0; i < 8; i++)
            {
                ow.WriteByte((byte)ow_address[i]);
            }
            ow.WriteByte((byte)Command.StartTemperatureConversion);
            while (ow.ReadByte() == 0) { }
            ow.TouchReset();
            ow.WriteByte((byte)Command.MatchROM);
            for (int i = 0; i < 8; i++)
            {
                ow.WriteByte((byte)ow_address[i]);
            }
            ow.WriteByte((byte)Command.ReadScratchPad);
            for (int i = 0; i < 9; i++)
            {
                scratchpad[i] = (byte)ow.ReadByte();
            }
            tempLow = scratchpad[0];
            tempHigh = scratchpad[1];
            byte config = scratchpad[4];
            temp = tempLow;
            temp |= (ushort)(tempHigh << 8);
            temptemp = (((int)(tempHigh) << 8) | tempLow);
            TemperatureC = temptemp * 0.0625f;
            return TemperatureC.ToString();
        }
        enum Command
        {
            SearchROM = 0xF0,
            ReadROM = 0x33,
            MatchROM = 0x55,
            SkipROM = 0xCC,
            AlarmSearch = 0xEC,
            StartTemperatureConversion = 0x44,
            StartVoltageConversion = 0xB4,
            ReadScratchPad = 0xBE,
            WriteScratchPad = 0x4E,
            CopySratchPad = 0x48,
            RecallEEPROM = 0xB8,
            ReadPowerSupply = 0xB4,
            ScratchPadPage0 = 0x00,
            ScratchPadPage3 = 0x03
        }
    }
}


@ Dat

When can we expact a SDK update with the bugfix for the emx?

Ok found new stuff!
I tried a new bench test:
1 DS2408 with a 4.7k pullup on a G120 at pin 1.31
I tried with a mosfet to translate 3.3V to 5V first, it mostly worked (sometimes it detect the chip sometimes not).
Then I had some help to sniff the 1wire port using an oscilloscope, I found interesting results.
With the mosfet, I had weird results (sometimes working sometimes not), so I tried just connecting to the 3.3V signal.

Here’s some pictures on what’s happening.
While running:
http://img26.imageshack.us/img26/7845/img0620me.jpg
On Stop:
http://img705.imageshack.us/img705/1858/img0621bc.jpg
Notice the little “steps” that is half the voltage after each square wave.
I don’t think this is normal!

Tomorow, I’ll try using the oscilloscope on EMX 4.1, and I’m pretty sure it won’t do that…
Please let me know what you think or if I can give more information to help resolve the issue!
This is because 1wire communication is an important part of a current project, so we need a reliable solution!

Note:To get those results on the oscilloscope, I used the last program but just removed the sleep, so it keeps asking for the device non-stop.

Just tried unplugging the DS2408,
so now it’s only the microcontroller, with a 4.7Kohm pullup to 5V, the program in a loop trying to search for devices.
http://img834.imageshack.us/img834/3517/img0622y.jpg
Conclusion: the notches on the square wave comes from the microcontroller.
Also I just ran the test again in a loop:
with only “ow.TouchReset()” → only square waves.
With only ow.FindAllDevices(); → Square waves with notches.

Edit: I think the notches are actually 3.3V

Can you try to zoom more in?

Thanks for testing this.
Can you try to remove the sleep(2000); and see if you can find all 8 devices 100% of the time ?
On EMX 4.1, I can “bombard” the 1 wire non-stop for hours, and I find all the devices always, and no bad checksum
On EMX 4.2 and G120, I get very unreliable results.

Soon oosting new pictures to compare the oscilloscope output…

I don’t have a picture of that particular setup right now, but it looks like a very short drop from 5V to 0V, then immediatly it goes back to 3.3V, and the waves are not very “square”

Ok first, the good waves!
EMX 4.1 IO18, DS2413 with a 4.7kohm pullup to 3.3V:
http://img805.imageshack.us/img805/2320/emx41333.jpg
EMX 4.1 IO18, DS2413 with a 4.7kohm pullup to 5V:
http://img23.imageshack.us/img23/4624/emx4152.jpg

Extra note on 4.1 EMX, I have tried many combination of pullup (from 1.8k to 4.7K) to 3.3V or 5V
I also have tried with or without a mosfet translation from 3.3V to 5V
All combinations always worked, no matter what or how many devices I’ve plugged, with no CRC error.

Now the bad waves:
EMX 4.2 IO18 or G120 P1.31 with a 4.7kohm pullup to 3.3V:
http://img694.imageshack.us/img694/6281/emx42331.jpg
http://img404.imageshack.us/img404/8643/emx42332.jpg
http://img4.imageshack.us/img4/9936/emx42334.jpg
http://img844.imageshack.us/img844/9560/emx42335.jpg
http://img809.imageshack.us/img809/1299/emx42336.jpg
http://img685.imageshack.us/img685/2563/emx42337.jpg
http://img201.imageshack.us/img201/8138/emx42338.jpg
http://img834.imageshack.us/img834/1272/emx42339.jpg

EMX 4.2 IO18 or G120 P1.31 with a 4.7kohm pullup to 5V:
http://img94.imageshack.us/img94/8893/emx425v1.jpg
http://img692.imageshack.us/img692/5418/emx425v2c.jpg
http://img94.imageshack.us/img94/7962/emx425v3.jpg
http://img17.imageshack.us/img17/4565/emx425v4.jpg

Note: Both EMX 4.2 and G120 4.2 is showing the exact same behavior.

I think it’s pretty clear that there is something weird going on :slight_smile:

Yes, that image is correct if there is only 4.7K pullup 5.V. I tried here and G120 is same with Cerberus (Cerberus is faster, so the period is shorter but the waves are same).

I tried about 10 mins, it is still working well on G120, pin p1.31.

Here is when I pull up 3.3V with DS18B20 - on G120.

If you can, send us your one-wire devices so we can test them.

Just to compare, I just tested what the signal looks like with EMX 4.1 with a 4.7Kohm pullup on 5V and no 1wire devices
http://img37.imageshack.us/img37/5683/emx415nodevices.jpg
Again steady square waves, no little steps at 3.3V like on EMX/G120 4.2

[quote]
I tried about 10 mins, it is still working well on G120, pin p1.31.
Here is when I pull up 3.3V with DS18B20 - on G120.[/quote]

But from your oscilloscope graph, I can see that you seem to have some abnormal inverted spikes (4 of them).
On EMX 4.1, I never see spikes like that, the square waves are very solid.
I see those little spikes only on EMX 4.2 and G120 4.2, with the exact same hardware.

Is it possible that the DS18B20 is a bit less sensitive than other 1wire devices, so it still can works?

Yes it would be certainly possible to send to you two partially assembled board with a DS2413 and another with DS2408 on them for further testing, along with the code to talk to them.
However I think just by looking at the differences from the signal between Firmware 4.1 and 4.2 from the previous oscilloscope graph that there is definitly something going on how the pins are setup by the firmware.

Again thanks for testing, I’m sure we’ll find the cause of the problem.

@ PhilM -

Yes, you are right. That is what I was thinking and I will focus on that to improve our one-wire driver. Don’t worry, I know how to kill this bug, but I am not sure that is main issue or not.

Yes, probadly.

Sure. We will.
Thanks for your feedback.

I don’t want to push too much on this issue, but do you have any updates?
Also if it would help, we are still open to send you 2 boards with a DS2408 and a DS2413 to test on your end.
We could also provide the code to test those modules.