Problem with mils not working with max6675 library.

Post here first, or if you can't find a relevant section!
ozcar
Posts: 143
Joined: Wed Apr 29, 2020 9:07 pm
Answers: 5

Re: Problem with mils not working with max6675 library.

Post by ozcar »

Ciceron wrote: Fri Sep 29, 2023 12:00 am
ag123 wrote: Thu Sep 28, 2023 6:15 am in setup() add

Code: Select all

timer = millis();
you forgot to initialize the variable. And use \[code\] blocks to enclose the code in posts here, that makes it much more readable.
(global) variables that are uninitialised takes an undefined value, not necessary 0 (zero). imagine that it is 0xffffff, then that loop is never run.
I'll try to add it this evening.
however, I thought it was enough -
unsigned long timer;
in the variables section

Edit:did not work
I’m no C++ language expert, but I’ve seen it said that declared like that it will be set to zero, and in fact I had to deliberately prevent that from happening to something once by adding

Code: Select all

__attribute__ ((section (".noinit")))
to a declaration. That is why I suspected that would not help, given that for your use, it would not matter whether it was set to zero or to the millis() value in setup().

It sounds like you are making some progress though.
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Problem with mils not working with max6675 library.

Post by dannyf »

this is less of an issue on the actual code but the approach to coding.

I would suggest that you think about the key building blocks of what you are trying to do, and then figure out how to integrate the code.

I would divide the code into 1) read the probe; 2) convert that probe reading into a duty cycle and use that duty cycle to drive a pwm genrator; 3) update your display.

you should write each of the blocks into a well define function and debug each one. that would make your life much easier.

you can then figure out how to integrate the code. for example, you don't update the duty cycle unless you have read the probe; and you don't update the display unless the duty cycle has changed, etc.

the code you have is a bow of spagatti. you want instead individual blocks with specific / well defined functionality and input / output. that would be where I start.
Post Reply

Return to “General discussion”