Emulator, can it handle OneWire ? - General Discussion - Netduino Forums
   
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

Emulator, can it handle OneWire ?

emulator onewire

  • Please log in to reply
8 replies to this topic

#1 netiness

netiness

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationNorway

Posted 04 December 2013 - 08:21 AM

After accidently turning at least three of the io-ports on my NP2 to output only, I moved into using the emulator for a while. I can use it to simulate my io connections, spi and i2c device all fine. But I also want to handle the onewire temperature-sensor. I've looked into the NetMF sources, and see that OneWire is mapped directly to a cpu pin, even though an OutputPort is passed to its constructor (which lead me to believe that I could use it in the emulator in the first case). Is it possible to debug/emulate OneWire devices in the emulator, or will I have to use a special class just for deplyment to the emulator ? This shouldn't be too hard to do, but I dont like to use defines depending on the "deployment platform". 

 

Thanks in advance,

 

Kjetil



#2 netiness

netiness

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationNorway

Posted 06 December 2013 - 01:59 PM

No one using the emulator ? Or trying/wanting to do OneWire ?

 

Little would I know how difficult this would be. One obvious answer as to why there is no 1-wire in the emulator is because of timing issues. The bus requires transitions with pulsewidths 15µs or less. Also, since there is no synchronization possibilities between the emulator and the NetMF code running, we are stuck. Or are we ?

 

I wanted to try it, see if it could be done;  so I embarked on an interesting and fantastic voyage.

The sources for the 1-wire master is in the NetMF sources, and examples can also be found at the Maxims integrated site. What's missing is sources for an emulated client. Since the protocol is well documented (http://www.maximinte...ndex.mvp/id/126) it should be relatively to implement a client.

 

There are some emulated 1-wire slave implementations for PIC chips and Arduino, one good example implementation can be found at

http://www.fabiszews...t/1-wire-slave/, and I have used this as the base for my 1-write slave implementation.

 

In short, I've managed to simulate this somehow, but it is really sloooow. It takes some seconds to send/receive a byte, so this might better serve as a proof of concept rather than a usable component. Anyway. So far the master can reset the bus, and issue a search command; and my emulated DS18B20 slave respond with a (fake) serial number. I'm not there yet, but I believe I should be capable of sending temperatures back to my Netduino program through the emulator really soon.

 

If anyone wants this I can make the sourcecode available when it is finished.

 

Kjetil



#3 netiness

netiness

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationNorway

Posted 13 December 2013 - 08:05 AM

In the attached zip-files I've included a NP2 project (DS18B20)which blinks the Led and then tries to read the temperature from a DS18B20 sensor. I've also included my naive emulator, which exposes the GPIO ports with leds so that you can see the state of the ports, and checkboxes which lets you set the state of a port. Also, there is a 1-wire slave implementation for the DS18B20 sensor (not fully implemented though), and the start of a I2C port extender. To use it, compile the emulator project, and in the Netduino project property pages for .NET Micro Framework add reference to My_NP2_Emulator as the emulator.

 

The emulator is a bit of a  quick hack, but it has helped me; so I hope it can be of use for someone else too.

 

Kjetil

Attached Files



#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 02 January 2014 - 08:57 AM

Hi netiness, The built-in emulator in NETMF was generally designed for SideShow-style hardware "back in the day". Most users just use real hardware on a Netduino--but it's definitely cool that you're hacking away with the emulator :) Chris

#5 robbypet

robbypet

    New Member

  • Members
  • Pip
  • 7 posts

Posted 12 March 2014 - 06:04 PM

hi, is there a software to search the address of ds18b20?



#6 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 12 March 2014 - 06:29 PM

hi, is there a software to search the address of ds18b20?

 

What exactly would you need to do? The 1-Wire protocol has built-in mechanism for enumerating the devices present on the bus, all implementations I've seen support that - in the particular case of .NET Micro Framework, have a look at OneWire.FindAllDevices() method.



#7 robbypet

robbypet

    New Member

  • Members
  • Pip
  • 7 posts

Posted 14 March 2014 - 12:14 PM

i have some probes ds18b20 but i don't know to find the address for each device 



#8 jrlyman3

jrlyman3

    Advanced Member

  • Members
  • PipPipPip
  • 67 posts
  • LocationNorth St Paul. MN

Posted 16 March 2014 - 12:30 AM

I thought that the address was printed on the device, but I looked at a DS1820 and the numbers on the device do not have any correlation with the address (so I guess not).  The way I got the address was to add the new device to the 1-wire network and use the FindAllDevices() function to get all the addresses.  The one I didn't know is the new device's address.  You could also choose to make it the only device on the net.



#9 robbypet

robbypet

    New Member

  • Members
  • Pip
  • 7 posts

Posted 20 March 2014 - 06:59 PM

HI Jrlyman3, i know few c#, where can i find an example of code about the FindAllDevices() function?







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.