PWM Period: No Control

I’ve been playing with the software for a couple of weeks and was ready to start incorporating hardware.
Last night I hooked up a chest freezer I’ve been using to ferment with and store beer in.
Currently, there are 3 kegs in there.
Only the compressor is controlled at the moment.

I set the cooling PWM period to 1 hour.
I saw varying periods as it dropped temp, but nothing over 45min.
This morning, I can see that it has settled at temp (35*F) and a period of ~8minutes.
The constraints are min off 5 min & min on 3 min.
It’s as if it is running on the constraints and ignoring the period setting.

I wanted a long period to avoid the rapid switching.
Why am I seeing this behavior?

If it matters, I did adjust the period value while the system was live.
I adjusted the PID values as well.
Right now, PID values are only P.


Here’s the graph:

I stopped and restarted services, no effect.
I changed the period to 15 minutes… that stretched the period out from 8 minutes to 10 minutes.
I guess I am puzzled why it’s not 15 minutes?

While playing with mock sensors, I was able to establish a 6 hour period without issue (for a different function; defrost).

This does sound like a bug in the PWM period stretching it applies if it’s blocked from achieving the setting.
Could you please export your blocks? (Spark service page actions)

If this easily triggers the bug, your blocks will be helpful.

Export blocks fails with status code 500.
I can export individual blocks fine.
I have ~40 blocks.

Do you get the same information if I export them all individually?

You can also run:

brewblox-ctl http get https://localhost/spark-one/objects | nc 9999

Thanks, can you check the response of the network request that failed with 500?
Hit F12, network tab, find the red one with 500.

Does this give you what you need?

You probably want this:

Upon closer inspection, it appears the period lining up with the min on and min off times was pure coincidence.
The actuators turn on/off when the PWM value hits ~30%.
The PWM doesn’t seem to care at all about the period setting.

I can create external disturbances that lengthen the on time (opening the lid).
Sure, the period lengthens when that happens, but that’s just caused by the actuators triggering on/off around 30%.

PID tuning does not affect this behavior.

Any ideas yet on this issue?
I was planning on brewing this weekend.
Right now, I have P & I maxed out and 30 minutes min off times on the actuator. It’s not ideal, but works about as well as the inkbird.

Should I blow away all my blocks and start over?
Or would I end up right here again?

The termbin export of my blocks resulted in a txt file.
If I rename that extension to json, will it import via the UI?

Yes, that’s a JSON file. Sorry didn’t have time yet to look at it.

You could indeed try to wipe blocks and run the wizard again. You can always import them again.

I’ll import them myself tomorrow and look at the behaviour.

Your blocks export cannot be imported because of the alternative way it was generated.
Can you provide an eeprom dump instead?

sudo pip3 install -U --no-cache-dir brewblox-ctl
brewblox-ctl particle --release develop -c eeprom


I think I have fixed the PWM issues. I think next release will work a lot better for you :slight_smile:

1 Like

I’ll stand by then.
I put a good amount of time into the blocks and would rather not do it over.
Thanks for looking into my issue.

@Elco any idea why I am getting to 500 error when exporting blocks?

It might be an out of memory bug. I’ll try again later with your eeprom dump.
I noticed the memory use was quite high. The latest release will show it on the display.
Removing unused blocks will help.

I hope the latest release fixes all the PWM issues.

It looks like you have a corrupt object stored in EEPROM. It has only an ID, but no data.

The object ID is 114. I think I was able to delete it through the debug API. I did some more things, but I think this worked.

Give it a shot. The URL for the debug API is this:


Replace localhost with the IP address of your pi.
After deleting object 114 with the ‘Try it out’ button, try exporting your blocks again.

No PWM joy.

Enabled control of the freezer, set it to 50F and got 14 minute periods.
PWM period is set to 30min.
Set it to 32
F and got 15 minute periods.
Completely disregards the period setting and turns on/off when the PID crosses ~30%.

The 500 error turned into: “Failed to fetch stored blocks from spark-one: Internal Server Error” after the update.
After deleting 114, the export works!

That’s an improvement. I will try erasing everything and starting from scratch to see if that helps any.