-
-
Notifications
You must be signed in to change notification settings - Fork 96
(v2) ESP8266 & ESP32 UART optimizations #398
Comments
@MichaelDvP With the latest version 2.0.0a18 with your UART changes I can only get tx_mode 1 working. tx_mode 2 gives me:
I noticed there is also no echo. With tx_mode 1 I would get the echo after the send, like
|
Michael, are you also using the same platformio.ini file with the ESP8266 running at 160Mhz instead of 80Mhz ( |
Yes i'm running 160 MHz, but i tested the timer before with dummy counts, |
only tx_mode 1 is working. 2,3 4 give failures. not even a single Tx makes it through. I think I just need to bring out the scope and see what is actually happening on the line. For tx_mode 3 this was a special modification I worked with @philrich on last year. See #103 (comment). The timings are slightly different for Junkers/HT3. |
In this comment he wrote:
So we need a gap of 3-9 bittimes for HT3, 10 for EMS+, and a low value for EMS1.0?
All modes can be changed without reboot. You know, i don't like the modes 1-3, where the processor making millions of nop-loops to wait for tx done, There are other usefull things to do. I've also merged your latest commit. Should i make a pr, or wait for feedback from hans? In my system all modes work. Mode 1 has very few rx-crc-errors only if roomcontrol is activated and a roomcontrol poll-ack is right before a incoming telegram (it's always the UBAMonitorFast to all) . Then i get a 19 as additional first value in this telegram. |
I like the approach. Plenty of modes to test with, and we can ask some of the Junkers users to also test. I'd say push the PR with the changes you made for Hans as you also fixed a lot of silly mistakes I made so thanks again for that. I agree the original rx/tx code is not efficient and blocking other important cycles and your approach is cleaner and makes use of the hardware interrupts. |
As long as you never need a timer, 8266 have only 2 timers and one is used by wifi, the other here. Esp32 has more resources. |
did a quick test, still only tx_mode 1 works on my system. I'll try all the other combinations later tonight. |
something strange, seems the timer is now used, blocked, or reconfigured by logger for debug and trace. In both log modes tx fails in all timer-controlled modes, with log info the timer works, also if watch is on. As soon i switch log to info or lower tx works again and show emsbus counts no more errors, also i can see the reply to me in watch on/raw. This log shows only the relevant lines. I checked the logs from before merging your latest changes, all modes works in debug/trace modes. |
Hmm, can’t think of what that could be. And Log Level INFO with ‘watch on’ works you say? I’ll check the code when I’m back home. |
Oh, good, mode 5 working. My issues with mode 1 come from the poll. Poll uses I deleted logging from emsuart, but that doesn't help. It is the |
tx_mode 5 uses the same code as tx_mode 1 (the legacy stuff) but with 1.5 bitstops? I can't see why the logs would affect the timings, the LOG_DEBUG just appends the message to a message queue. I think these messages are important (for debugging!) so does it work if you move them after the transmit() ? |
No, mode 5 uses the same code as mode 4, but with 1,5 stopbits: Pushing all in the fifo and the hardware sends it out and appends the break. The transmit-function doesn't have to wait and returns instantly. I think it is the best mode for ems1.0. |
ah, I see what I did wrong now. I modified some of the esp8266 uart code, let me revert and test again. I don't expect tx_mode 5 will work sadly. |
ok, tx_mode 5 doesn't work. Only tx_mode 1 on my setup. |
I have tested a bit more and think i understannd better. I tried to measure the time from start sending to complete echo received, but with confusion results. I realize, that you havve modified the Therefore i changed the modes once again, leaving 1..4, but set from 5 on timer as number of delay between bytes: mode 5 is 1bytetime+5bittimes until next byte, If there is no delay needed, mode 4 will do, HT3 will work with 5,6,7, ems+ 20, 21, 22. My system resposes to all modes, also 50 works. With esp32 i can't get the modes with |
The reason for implementing I'll test your changes, thanks |
quickly tested. I couldn't get any of the modes to work. tx_mode 1 also now shows errors so I need to check what was changed
Also I think it's time we have other people test to rule out something strange in my environment. |
Change in tx mode 1 since a19 is the old timeout (22 bittimes) back and change the poll-ack to the same logic, before poll uses tx_brk, but tx_brk has not wait defined for mode 1, causing some crc errors for me. |
Here is a log with nearly all modes on my system, you can see the different timings. The roomcontroller simulation is on, the 0xAF from 0x19 is from that function, so ems-esp answers all polls to 0x0B and 0x19. |
nice can clean. You know, perhaps its my circuit. I have a few older and newer ones which bbqkees gives me to try. I'll go back to an earlier board and try the jack interface with a shorter cable and see if it makes any difference. |
@bbqkees we have a similar setup. When you find time could you grab the latest v2 and test tx_mode 1, 4 and 5? Instructions are in https://github.com/proddy/EMS-ESP/tree/v2#uploading-the-firmware |
I'm already running v2 with tx_mode 1 on a Premium II Gateway with a Lolin ESP8266. This is from about 12 hours or so: Will do some logging when I'm at home. |
is this using the latest a21 version with Michael's new tx modes? |
No you're too fast for me :-). |
on a21 all modes give TX errors. |
Oh, i'll look what is the change in mode 1, i thought nothing was changed, can please also try mode 10, or 12 with longer timer delays? |
for my EMS2 system, the least amount of errors with b8 are now apparently with tx_mode 22 (tried 0-5, 18, 22). On b7, tx_mode 2 & 3 didn't produce any errors but on b8 now quite regular. |
@MichaelDvP as mentioned above. I think for tx_mode 1 we stick to the new @joanwa are you comfortable changing a file, building and upload the firmware yourself? |
@bbqkees when the boiler starts you'll see a UBAMaintenanceData message appear in the console (telegram type 0x15). You could watch for this telegram in a console so see how often it happens ( |
yes, already forked and committed some cosmetics in my fork. Just seeing that you build a newer b8 binary. Shall I gives this a go? Or what are you interested in that I can build myself? |
change EMSUART_TX_WAIT_BRK back to using 11 bits in #define EMSUART_TX_WAIT_BRK (EMSUART_TX_BIT_TIME * 11) and test with tx_mode 2 |
Yes, i updated the uart branch. For we know:
For the timer modes i set the break to a bit more than 10 bit, maybe this works on both worlds. |
I switched to EMSUART_TX_BIT_TIME * 11 on the commit that is now the b9 build. Update: tx_mode 1 appears to produce no Tx read errors. tx_mode 1 never worked for me before:
|
ok that looks promising, although not sure why tx_mode 1 works better than tx_mode 2 on your HT3 system. I'll look into the USB/LED issue tonight. @MichaelDvP tx_mode 1 works fine with both the ESP8266 and ESP32 on my system EMS1.0 system. This is bus-powered. When I plug in a USB from the desktop PC (which is a stable 5v) I start to see errors. My focus is on bus-powered to be compliant with BBQKees's independent circuits. I think now we need some Buderus EMS2.0 and more Junkers/HT3 guinea pigs to try this out. |
@proddy if you power from usb, do you have the dcdc-converter from the gateway removed? If powered from both sides it could make strange efffects. |
yes, the buck is removed in the ESP32. Ideally I would need to do a logic analyzer scan of bus-powered vs USB (via a powerbank) and compare the charts. And also do a test with the mqtt disabled and then later the complete wifi to see if the wifi is somehow affecting it. And lastly maybe we should look into isolating some of the commands to a single-core on the ESP32 (using SemaphoreHandle_t). |
I'm now on v2.0.0b9 (not the uart one) and mode 1 works fine with zero errors. |
I've been running ESP8266, bus-powered on tx_mode 2 with 0 errors for the last 24hrs. Weird. |
On ESP8266, TxMode 1, USB powered I'm getting a 100% success rate with Rx and Tx. But as soon as I change it use bus-powered I get the odd corrupted/incomplete Rx. e.g.
because its missing the last byte of the telegram. A correct telegram looks like:
@MichaelDvP this is since the last UART updates from d6c5321 @bbqkees this is also what you've been experiencing testing the latest v2_cmd branch. I'll make a capture from USB vs bus-powered with the logic analyzer to see what the differences are. |
Are you sure it's the uart-update? There is no change in rx and i used it before without crc-error, but now i also get some (3 in 36 h). I'm logging now every crc error to syslog to see if there is a system (same src/dest/type). |
I'm seeing this also with USB power (only 5 incompletes in 20hrs) and it only started to happen in the last days when I pushed the big change with commands (v2_cmd), so I agree I don't think it is related to these UART changes. I'm tracing too to syslog to find a pattern |
I have a suspicion its due to the NTP server which I re-enabled for the ESP8266 build. When removed I'm not getting Rx errors but it's only been running for the last 2 hrs so need to leave it a while longer to confirm. It may be that the lwip and sntp service is conflicting with the interrupts we use in the UART. |
I had 2 errors yesterday with very strange telegrams, thermostat don't send these messages.
Than i updated platformio and framework and get no errors since that (NTP activated, tx_mode 1, virtual roomcontrol-thermostat activated), maybe it was something in the framework. |
@MichaelDvP just tried the latest v2 (which was v2_cmd) on an ESP32 and it crashes. Error says "Debug exception reason: Stack canary watchpoint triggered (emsuart_recvTas)" pointing to somewhere in the UART code. Are you seeing the same? |
Tried the latest v2 code. When connected to the bus the esp32 restarts after around half a minute. |
same here. Something in the Tx code I think because when I use tx_mode 0 it works. My first thought was because of the dual-core calling the callback functions too fast at the same time now that there is no Rx queue. So may need need to stick in some mutex calls (or use std::atomic). Still investigating. |
I moved
|
thanks Michael. I'll try this too and push a fix |
We can merge later. My system is also EMS 1.0 and all modes working. Maybe it is uncritical because all components are on the boiler and the ems-bus lines are less than 1m (no roomcontroler, only weather controlled), No emc problems, no reflections, etc.
Can you check with less delay, set
emsTxWait = 5 * EMSUART_BIT_TIME * 11;
for 11 bittimes.Also you can check with break ended by timer in the isr uncommend the last lines but set the timer to
timer1_write(5 * EMSUART_TX_BRK_WAIT
.Originally posted by @MichaelDvP in #397 (comment)
The text was updated successfully, but these errors were encountered: