alexmohr / open-heat

Eqiva valve firmware for esp8266
GNU General Public License v3.0
4 stars 1 forks source link

The valve gets sort of stuck after some time, getting the commands but it is like frozen (which for a radiator is not good at all! HA HA HA!) #33

Open Anycubic opened 2 years ago

Anycubic commented 2 years ago

After hours running fine in heat mode, in one radiator measured temp was keeping increasing like if the valve was dead. Lowered temp by 2 degrees and the valve not reacting. Shut off command was issued but still no noise from the valve. Recycled the power and I heard the valve closing eventually. Going to serial log ...

alexmohr commented 2 years ago

no no no no :smile: there is a big difference between knowing what's necessary and knowing how to implement it :wink:

Anycubic commented 2 years ago

You are a real engineer 😄 and have to say a really nice person 😉 next time you come to Italy you need to pay me a visit as my guest

alexmohr commented 2 years ago

Thanks a lot :blush:

Actually after thinking about this for a while it should be possible to implement this with a push button and a sr-latch. (that does not mean I'm going to do this but I had to write it down somewhere :laughing: )

Anycubic commented 2 years ago

🤣 🤣 🤣

Anycubic commented 2 years ago

Good morning, I think there must be something wrong in the code, it is not possibile that even with m_finalRotateMillis = 15'000 the valve is not closing 100% in off position! So today I'm serial logging again.

Why are you doing this: openTime -= m_spinUpMillis; ? Should m_spinUpMillis go on top?

alexmohr commented 2 years ago

yes there is still something wrong but I won't try to fix this w/o stop detection anymore. openTime -= m_spinUpMillis is to reduce the open time by spin up time to prevent fluctuation. It goes on top in https://github.com/alexmohr/open-heat/blob/old_regulator/src/heating/RadiatorValve.cpp#L302

Anycubic commented 2 years ago

I'm sorry but I still can't understand why you are doing that. If there are spinups jitter (rotating less than it is supposed to do) when the valve starts I'd just would like to add some millis to nominal rotation millis, why are you actually rotating less on purpose? And then you do what I believe is right thing, delay(rotateTime + m_spinUpMillis); forgive me, but on monday I'm dumber than usual 😄

alexmohr commented 2 years ago

add some millis to nominal rotation millis

I'm doing that https://github.com/alexmohr/open-heat/blob/old_regulator/src/heating/RadiatorValve.cpp#L302

delay(rotateTime + m_spinUpMillis);

It's done here https://github.com/alexmohr/open-heat/blob/old_regulator/src/heating/RadiatorValve.cpp#L302

why are you actually rotating less on purpose

that's why https://github.com/alexmohr/open-heat/issues/33#issuecomment-980689338

Anycubic commented 2 years ago

that's why #33 (comment)

To me is like you are at first subtracting openTime -= m_spinUpMillis closeTime -= m_spinUpMillis and then adding the same millis in delay(rotateTime + m_spinUpMillis); and actually nothing changes at all in regarding of preventing jitter due to spinup, but I guess I just need to understand better your code

alexmohr commented 2 years ago

To me is like you are at first subtracting openTime -= m_spinUpMillis closeTime -= m_spinUpMillis and then adding the same millis in delay(rotateTime + m_spinUpMillis)

that is correct

and actually nothing changes at all in regarding of preventing jitter due to spinup

that's not correct. The difference here is that the additional time added in delay(rotateTime + m_spinUpMillis) is not added onto the current rotation time.

Anycubic commented 2 years ago

What I mean is that Mr. Algorithm doesn't know that he is rotating less than what is supposed to be (because he is dumb and can't now that there are jitters due to spinup torque etc etc) so I'm ok 100% here delay(rotateTime + m_spinUpMillis) (rotates more yet doesn't know because actually he also doesn't know he is rotating less) but still don't agree here openTime -= m_spinUpMillis closeTime -= m_spinUpMillis. I will experiment trying to understand 😉

Anycubic commented 2 years ago

What about using something like that for motor stall detection? It is I2C so should work nicely with BMP/BME sensor, right? https://www.aliexpress.com/item/32805446652.html?spm=a2g0o.productlist.0.0.3bf572e3LxV4wE&algo_pvid=d0ba30ae-9156-4fde-b37c-1bc10d72c730&algo_exp_id=d0ba30ae-9156-4fde-b37c-1bc10d72c730-1&pdp_ext_f=%7B%22sku_id%22%3A%2264370002790%22%7D

alexmohr commented 2 years ago

You'd need two because it only can output positive voltage but it is probably easier than the design I was going to use.

Anycubic commented 2 years ago

Do you need to know both of the physical extremes? i.e. knowing only when it is closed would not work?

alexmohr commented 2 years ago

It would make a mess in the code in my opinion. If you know both extremes the whole time measurement could be removed and you can open/close until the limit is reached

Anycubic commented 2 years ago

This one has got 2 channels.... https://www.aliexpress.com/item/32681651512.html?spm=a2g0o.detail.0.0.44b85b4257rRjV&gps-id=pcDetailBottomMoreThisSeller&scm=1007.13339.169870.0&scm_id=1007.13339.169870.0&scm-url=1007.13339.169870.0&pvid=1025685e-7e13-4d17-ba40-c2d0d622959e&_t=gps-id:pcDetailBottomMoreThisSeller,scm-url:1007.13339.169870.0,pvid:1025685e-7e13-4d17-ba40-c2d0d622959e,tpp_buckets:668%232846%238111%231996&&pdp_ext_f=%7B%22sceneId%22:%223339%22,%22sku_id%22:%2260301285944%22%7D

alexmohr commented 2 years ago

That could work

Anycubic commented 2 years ago

I'm going to buy a couple of them, just in case 😄

Anycubic commented 2 years ago

Uhmmm, but it reads only voltages, we need to measure currents, right?

alexmohr commented 2 years ago

Uhm yes sorry I didn't read the datasheet properly. Yes current measurement is what is necessary

Anycubic commented 2 years ago

Uhm yes sorry I didn't read the datasheet properly. Yes current measurement is what is necessary

Ok but why do we need two of the first one? It says "bi-directional" so I guess can read both negative and positive amps. So when you close for example you know you will read positive values and when you close negative values, that's it. Maybe this one is a little bit better:

https://www.aliexpress.com/item/32377617416.html?spm=a2g0o.detail.0.0.696721a6piIhAB&gps-id=pcDetailBottomMoreThisSeller&scm=1007.13339.169870.0&scm_id=1007.13339.169870.0&scm-url=1007.13339.169870.0&pvid=b5fcc4fd-5b15-4d98-aea2-4997d2178210&_t=gps-id:pcDetailBottomMoreThisSeller,scm-url:1007.13339.169870.0,pvid:b5fcc4fd-5b15-4d98-aea2-4997d2178210,tpp_buckets:668%232846%238111%231996&&pdp_ext_f=%7B%22sceneId%22:%223339%22,%22sku_id%22:%2212000021113776036%22%7D

alexmohr commented 2 years ago

Bidirectional referes to the i2c communication. If you take a look at the data sheet you'll see that the input voltage is from 0 to 26V. The current is calculated via a shunt resistor.

The INA219 senses across shunts on buses that can vary from 0 to 26 V.

I already took a look into these modules before I started to design a circuit with op Amps because I couldn't find one that fits my needs. I have the circuit design more or less ready but I have to build it on a breadboard to test it. But I don't have the time to do that

Anycubic commented 2 years ago

I'll give this thing a try: https://www.14core.com/wiring-the-i2c-ina219-zero-drift-bidirectional-currentpower-monitor-with-mcu/ At the end of the day even one eye only is better than 100% blind 😄 Your code is good, as I said I'm using 4 "smart" valves as we speak. Sometimes it happens one pretends it is closed while it is not, that module could help me in answering to the question "am I really closed?" and act accordingly. I will buy a couple of those little boards and play with them

alexmohr commented 2 years ago

good luck :+1:

Anycubic commented 2 years ago

It would make a mess in the code in my opinion. If you know both extremes the whole time measurement could be removed and you can open/close until the limit is reached

I don't want to abuse your kindness and patience, but my heart breaks if I think abandoning this project while it is so close to be working 100%. Actually there are two issue tied to the same root cause (whose nature we know very well...):

  1. once set temperature is reached, the code "thinks" the valve is closed and in reality will stay in a open position (so it will overshoot eventually);
  2. the code will not close the valve 100% because once again the "full close" position is wrong;

To address 1. I'd use a isReallyClosed() function to return real close valve position. But what to do if the time measurement code says "closed" and the valve is not? Which is the better way to handle this?

  1. should be pretty straightforward, instead of closing using calculated millis just close using a doFullClose() function which is doing it by detecting motor stall. Could this function be useful also in other scenarios?

I don't think not detecting real full open valve position will be much of an issue, unless room temp is 0 and you want to reach 25 degrees.... 😄 I know this is a tricky solution, but it is cheap & dirty and I hope it will work at 99%.

Please bear with me, with your suggestions and help maybe I could do it.

alexmohr commented 2 years ago

I don't get where the difference is between 1 and 2. It is most likely the same reason where the time measurement is off to some reason. Instead of stopping to close when the time limit is reached you could somehow measure current of the motor and only do open time base. But when you do this you'll probably have the issue with opening sooner or later.

If you don't care about battery lifetime too much you can just remove the check for the lower limit and just always rotate when you close. Maybe it's worth a shot to test this to really pinpoint the issue to the time measurement.

isReallyClosed should also be done by detecting if the motor is stalled.

I'm not abandoning this project (yet) but I really don't have the time to do any coding on this at the moment due to a multitude of personal reasons. I'm doing this thing in my free time and there is just not enough of that as even my weekends are fully booked. Asking over and over again for suggestions and solutions is not going to change that, sorry to be blunt here...

The main reason why things INA219 are not going to work out of the box is that you have to power the motor through the module. See https://learn.adafruit.com/assets/10941 You need at least a diode to protect the INA219 against reverse polarity. Then you'd have to turn on the module when closing with a gpio to prevent drawing current all the time. Furthermore you need a capacitor to smooth the current consumption of the motor at spinup.

To cite adafruit here:

Be careful inserting noisy loads that can cause a sharp current draw, such as DC motors, since they can cause problems on the power lines and may cause the INA219 to reset, etc. When using a DC motor or a similar device, be sure to include a large capacitor to decouple the motor from the power supply and use a snubber diode to protect against inductive spikes.

So it's not as easy as wiring up a BME/P module and needs at least some engineering.

The circuit I have in mind is not easier but it works in both directions. stop_Detection

alexmohr commented 2 years ago

An alternative circuit is the one below and that's the one I'll try first as I have all parts for that. index

Anycubic commented 2 years ago

I don't get where the difference is between 1 and 2. It is most likely the same reason where the time measurement is off

Actually there is no difference, you are right. The only different thing is when it happens: 1 it happens while heat is on (so needs to be checked during normal operation every time the valve thinks reached the off position). 2 it's not a real problem, just closing with stall detection will be fine.

to some reason. Instead of stopping to close when the time limit is reached you could somehow measure current of the motor and only do open time base. But when you do this you'll probably have the issue with opening sooner or later.

That's exactly what I want to accomplish 😉

If you don't care about battery lifetime too much you can just remove the check for the lower limit and just always rotate when you close. Maybe it's worth a shot to test this to really pinpoint the issue to the time measurement.

You mean without measuring motor current just force let's say 20000 millis close rotation when the valve thinks "I'm already closed do not rotate anymore"

isReallyClosed should also be done by detecting if the motor is stalled.

Of course otherwise will be useless

I'm not abandoning this project (yet) but I really don't have the time to do any coding on this at the moment due to a multitude of personal reasons. I'm doing this thing in my free time and there is just not enough of that as even my weekends are fully booked. Asking over and over again for suggestions and solutions is not going to change that, sorry to be blunt here...

Worry not! I fully understand

Then you'd have to turn on the module when closing with a gpio to prevent drawing current all the time.

I was thinking to use GPIO 13 in parallel with BME/BMP

To cite adafruit here:

Be careful inserting noisy loads that can cause a sharp current draw, such as DC motors, since they can cause problems on the power lines and may cause the INA219 to reset, etc. When using a DC motor or a similar device, be sure to include a large capacitor to decouple the motor from the power supply and use a snubber diode to protect against inductive spikes.

Now that's indeed interesting. There are also other modules, like this one with 3 channels, I'll have a look at tech specs as well

https://www.aliexpress.com/item/32828796768.html?spm=a2g0s.8937460.0.0.509d2e0eYxa8ch

EDIT: I need at least two of these because this board actually powers the devices that is measuring. BUT with 2 diodes it should work, one board powers the motor while closing and the other one with reversed polarity will power while opening. EDIT 2: because the 2 modules will be plugged to GPIO 12 and 14 this will also solve power consumption issues. Will it work?

So it's not as easy as wiring up a BME/P module and needs at least some engineering.

The circuit I have in mind is not easier but it works in both directions.

I think understanding it is beyond what I can do. What I can do is ordering the PCB if I have a layout and soldering the components 😄

alexmohr commented 2 years ago

Why a 3 channel module? That makes it only more expensive but you only need one

alexmohr commented 2 years ago

If you do the (tedious) work of finding a matching module I'll order it too 'cause it's probably (much) easier than my suggested circuit. fyi if you are interested in a turn off button you can order https://de.aliexpress.com/item/1005003027936356.html?spm=a2g0s.9042311.0.0.1d9d4c4d1pAUmj CD4043BE . It's the same SR-Latch I've ordered for the reset button. Or you wait until I've implemented it. Have you made any progress on your case cad?

Anycubic commented 2 years ago

Don't know why but you can find it only with 3 channel. BTW it is 1,62 € each, circa 3€ for each valve. If you consider all of the time and material you save instead of making an ad hoc board....I'd say it is very cheap.

So do you think it will work? If the answer is "oh yeahh!" I'll ask you only a wiring diagram on how to connect them, were to put the diodes and maybe a capacitor (or 2?). Than I'll order the pieces and will start assembling a prototype + measuring current in a real environment

Anycubic commented 2 years ago

fyi if you are interested in a turn off button you can order https://de.aliexpress.com/item/1005003027936356.html?spm=a2g0s.9042311.0.0.1d9d4c4d1pAUmj CD4043BE . It's the same SR-Latch I've ordered for the reset button.

I think i can afford it, I'll buy them 😄

Have you made any progress on your case cad?

Unfortunately not, I didn't start yet, all of my time was spent in debugging the valves. But my next priority is the case, the one I'm using right now is, how can say, too fragile? 🤣

IMG_20211208_202923

Anycubic commented 2 years ago

....and btw I think I found another reason why the valve will go intrinsically out of sync. Measured closing time is approximately 40 seconds, full opening just 37. That's not surprising at all since while closing it has to counteract a spring force and while opening the same force on the contrary will help the motor spinning.

alexmohr commented 2 years ago

....and btw I think I found another reason why the valve will go intrinsically out of sync. Measured closing time is approximately 40 seconds, full opening just 37. That's not surprising at all since while closing it has to counteract a spring force and while opening the same force on the contrary will help the motor spinning.

That's actually quite a good reason why things are going out of sync.

So do you think it will work? If the answer is "oh yeahh!" I'll ask you only a wiring diagram on how to connect them, were to put the diodes and maybe a capacitor (or 2?). Than I'll order the pieces and will start assembling a prototype + measuring current in a real environment

Before measuring current there is some software necessary. You can write a prototype but the currents for "normal" operation are arround 15mA and for "locked" arround 40mA so there is not that much measurement necessary. I'd go for the INA219 but I first have to make a schematic to see if it really works. Maybe I get around to do it on sunday or so

alexmohr commented 2 years ago

index The case I designed isn't too bad just a bit too small

Anycubic commented 2 years ago

the INA219 but I first have to make a schematic to see if it really works. Maybe I get around to do it on sunday or so Ok, np, I'll wait, take your time

Anycubic commented 2 years ago

The case I designed isn't too bad just a bit too small

Am I wrong or the batteries are not in the case? 🤔

Anycubic commented 2 years ago

Out of curiosity, these are 3 of my valves today. 2 of them closed 100% at off mode, one didn't but was almost there. So I guess it's up to valve spring force and the other mechanical factors. In general I'd say the regulator algorithm works very well.

2021-12-08_21-07-52 2021-12-08_21-07-11 2021-12-08_21-06-22

Anycubic commented 2 years ago

Interesting, 7 Sensors tested: Measuring Current with Microcontrollers https://www.youtube.com/watch?v=cG8moaufmQs&ab_channel=AndreasSpiess

alexmohr commented 2 years ago

The case I designed isn't too bad just a bit too small Am I wrong or the batteries are not in the case? thinking

They are mounted below

index

The graphs look great I even have less fluctuations than you

The INA3321 has the abitilty to switch a channel off.

Channel enable mode. These bits allow each channel to be
independently enabled or disabled.
0 = Channel disable
1 = Channel enable (default)

https://github.com/beast-devices/Arduino-INA3221/blob/main/Beastdevices_INA3221.cpp#L261 So I guess one module could be used to measure both directions and only the required channel will be enabled. I'm not 100% sure this also means the output is disabled to I read the datasheet like that

Maybe you can take a look too and tell me I'm correct :rofl: https://www.ti.com/lit/ds/symlink/ina3221.pdf?ts=1638920630869&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FINA3221

Anycubic commented 2 years ago

They are mounted below

I see but my 4 years son would take them apart in 1, 2, 3 seconds 😄 I'm going to try to put everything in a box

The graphs look great I even have less fluctuations than you

Consider than my temp sensors are in the "open air" so there are also micro fluctuations due to just me passing by a radiator

Maybe you can take a look too and tell me I'm correct 🤣

In theory this is correct 😛 but those chinese boards are limited to only one input voltage bus BUT there is a solution:

https://www.youtube.com/watch?v=EjGhbiudRgg&ab_channel=RobotPad

So yes, if we modify the board it should be possible using only one board. The Expert (me) said it! 🤣

alexmohr commented 2 years ago

https://www.youtube.com/watch?v=EjGhbiudRgg&ab_channel=RobotPad

That doesn't look too bad. I'll order one

Anycubic commented 2 years ago

If I were you I'd order at least 2, with chinese goods you'll never know...I'll do the same

Anycubic commented 2 years ago

What about diodes? I need to buy them as well. I have some capacitors at home but don't know if I have the right ones

alexmohr commented 2 years ago

If I were you I'd order at least 2, with chinese goods you'll never know...I'll do the same

yep done that :)

What about diodes? I need to buy them as well. I have some capacitors at home but don't know if I have the right ones

Any diode will do, I won't recommend one until I've tested it with them. There is no specific requirement. They are only necessary to protect the ina from input voltage through the motor. Same goes for capacitors any electrolyte capacitor will do. Maybe around 100uf or so

Anycubic commented 2 years ago

How are you? Just to let you now I bought everything needed and waiting for delivery

alexmohr commented 2 years ago

Same here. We are in the process of moving and I packed up all my electronic development stuff so it will take a while until I've set up my workbench again 😅

Anycubic commented 2 years ago

I see, so in the future new radiators to work with! 🤣 I went back to old "dumb" but working valves, in the meanwhile I'll focus on the case in my spare time.

Happy moving! 😉

Anycubic commented 2 years ago

Hello! How are you? Everything ok with your move? Today I received 4 of these babies, it seems they are the modded version (3 independent inputs): IMG_20220114_143246

alexmohr commented 2 years ago

That's awesome. I've received mine too already but they are still packed up. Probably it will be summer until I've set up my workbench and can work on this again. :(