Treefrog
Book Wheeler
Readability and slightly faster usually, less chance for weird interpretation behavior. At least if it is a linear relationship. And it can make it easier to do things like change the range.Yep, the potentiometer is linear! For the sake of my own learning, may I ask what the benefits are of the parameterized equation over just using the mapped values? I know I'm putting my lack of understanding on full display here, but it's a great way to learn haha.
For the non-linear thermometer, mapping may be better.
Different ways of doing things. If you find one more readable or easier to follow, that's the one you should use. On an extreme technical view, one may run slightly faster or use slightly less memory, but saving nanoseconds and bits is probably not important here. And what you're suggesting may be the faster one.Just blind intuition shooting from the hip, it seems like if I'm already going to have the temperature sensor mapped to relevant temperatures Fahrenheit, and then map the potentiometer to useful temperature values for tuning, I could come up with a simple code to just add the mapped potentiometer value to the preset min/max temp range. So essentially something like (not code, just theory)
mapped_potentiometer = full 0-1023 range mapped to a range of -30 to +30
Then
Minimum duty cycle temperature = 160 + mapped potentiometer
Maximum duty cycle temperature = 210 + mapped potentiometer
On a side note, it is probably a good idea to not hardcode any values in the code and instead use variables to hold any value that may need changing.
Also, some fans need an inverse pwm signal. It also could be that the fan and generator have a different understanding of what the pwm signal is. The fan could be looking at % high while the generator is % switch to ground.