orgua / OneWireHub

OneWire slave device emulator
GNU General Public License v3.0
343 stars 86 forks source link

Master unable to read emulated DS2438 #43

Open drtrigon opened 6 years ago

drtrigon commented 6 years ago

I tested the DS2438 from M-o-a-T [1] to find that this is actually a fork of the code here. So I also tested this [2] and have the same issue that I cannot read from the sensor.

[1] https://github.com/M-o-a-T/OneWireHub/blob/master/examples/DS2438_battMon/DS2438_battMon.ino [2] https://github.com/orgua/OneWireHub/blob/master/examples/DS2438_battMon/DS2438_battMon.ino

Details:

Issue:

[3] https://cdn.shopify.com/s/files/1/0164/3524/files/The_LINK_Family_Manual_1.7.pdf?7145028656254187831 e.g. pages 10 and 11

orgua commented 6 years ago

just a happy guess: maybe your problem is connected to issue #35 and #23? and please try the "help"-section in the the readme first. It was heavily extended since v.2.0-fork from m-o-a-t. unfortunately i have no linkHubE to test it myself

orgua commented 6 years ago

this linkHubE costs 240 bucks? Would be nice to know if it uses a ft232R like the linkUSB. Do you mind opening the case? maybe there is an additional FT4232H with a quad serial.

Both seem to support DS9097U emulation and can be used by the same software. so it could be. i should extend the help section and warn more about certain masters and offer solutions.

if the timing adaptation works it would be nice if you narrow the value down a bit more. Try half of the value, and so on.

drtrigon commented 6 years ago

Thanks for the answers! I am keen on testing this as soon as possible, but might take some days.

Yes I payed about 240 euros for that guy, but it is actually quite good and claims to do adaptive timing based on the line length, impedance, etc. I cannot promise anything, don't know how the case is closed (hope for screws and not glue), but I am willing to open it if possible.

Will report back my findings.

drtrigon commented 6 years ago

Your "happy guess" solved my issue almost! (Thanks a lot!) I can work with it now but some of the values still cannot be read by owfs. Sometimes they are humidity, temperature and vis sometimes VAD and humidity. ("Error: Invalid argument" in web interface) I was not yet able to pin down the exact factor that is needed. I played with 2x, 5x and the suggested 10x all work better than the default value, but none solves all reading errors.

Writing pages (0-7) one at a time does work well but writing all pages at the same time does not work, I guess that is related to the fact that page 0 contains the sensor data and thus is reserved.

drtrigon commented 6 years ago

I switched to DS2433 as my intention is to build a LCD/OLED for 1wire. The memory is more suited. Is it normal that I have to read the memory after writing in order to trigger an update?

Will move on to the hardware build phase now, and then consider to open my master. Meanwhile I found [1] where is stated:

[1] http://owfs.org/index.php?page=linkhub-e

Generally I wanted to thank you for this really, really, really great library - I was looking for something like that for years! Thanks - great job! :)

orgua commented 6 years ago

i have seen this behaviour with the failing long writes / reads before. there are some more timing-issues on your side. good news: they are fixable. a scope or logic analyser would help a lot. but here are possible fixes to try without knowing what is going on:

drtrigon commented 6 years ago

Actually I found that your timings are very robust. My code was bad in terms of every loop with update (blinking() == True) took way too long. And still it was kind of usable! Now I changed basically to only take a lot of time if the whole display changes (e.g. initial write). This initial write then kind of makes the device freeze, but as soon as I read the memory the device starts running (looping and updating) again. So I think this is a good explanation for the behaviour. For sure it makes me happy as your code is robust and in cases it has issues (due to bad timing of MY additional code), it even recovers... very nice!

I do have an (old) analog scope which is not suited for these things, I would love to buy a logic-8 and thus am looking around for a good price (~ 500 bucks is too much). I would like to look bit more into these timings (and other stuff). The scope needs to be linux compatible ;))

When changing timing values how do you determine whether the communication becomes "better" or "worse"? Do you take statistics or is a scope needed for that?

orgua commented 6 years ago

the saleae-brothers give you student-discount. or maybe you can buy a used old logic 8 or 16port. the first generation should be available for <100 bucks. chinesium knockoffs come for about 5$. the software is a blast! and for the timings: earlier in the development i tried to write big chunks of memory, around 32 byte on some devices. the initial values were 0xFF. when writing something to these banks with a bad timing there were only some of the first of the 32 bytes written (to something different than 0xFF). with better timing-values the success rate was getting higher and higher. i thought this could be a test for you too.

drtrigon commented 6 years ago

Yes this sound like an "easy" test, will give that a try! Thanks for the hints, will try to ask for a discount this is a good idea - "forgot" to think about this, however I don't think they give a 50% or more discount... ;)) Today I tested the DS2438 on an Arduino Nano, with factor 10x it basically works BUT again I have a lot "Error: Invalid argument" when trying to read e.g. voltages. Actually only the temperature works sometimes. This was done on an other master, an OW-SERVER [1].

[1] http://www.embeddeddatasystems.com/OW-SERVER-1-Wire-to-Ethernet-Server-Revision-2_p_152.html

Currently I cannot test on Arduino Uno as I used my last one (need to reorder) for this: https://www.instructables.com/id/Arduino-1-wire-Display-144-Chars/ :))