ATTiny85; order of magnitude loss of speed when enabling map AnalogRead function

lost_bro:
I will attach screen shots of the 'pwmMin' value working at 630mv float voltage.
The 'pwmMin' does work, just in the shots I posted it was set at pwmMin=0 so the float voltage is Zero.

When you're debugging something, don't just play around in the same range of values that make sense. You also can't only rely on making a few random changes to your parameters and seeing if that works. There is a place for that, but to be systematic about it you should be actively looking for edge cases, parameters that are unusual or extreme in some way, but still legal.

The first place to start is with your adjustable parameters. The limits for these parameters are defined in your map statements, so you test those limits out by commenting out the pot read statements and fixing each value to every combination of the maximum and minimum values. With 3 values, that's 8 combinations. Know before-hand exactly how the output is supposed to look for each, and hook the scope up to verify all 8 of the value combinations.

But don't do that yet. That will be for your final validation checks after we think everything is working. You have an issue where changing the pwmmax value does not change your waveform like it should. Focus on that first.

You might need to be a bit more creative when debugging a specific issue, but the basic premise is the same: don't just use ordinary, safe values, step outside the norm and use values that are unusual, but still legal.

I suspect the problem is that, because you are setting Dir to +2 immediately before incrementing Pwm every loop cycle, your code is ignoring Pwmmax and blowing past it, overflowing past the top of a uint8_t and going back to 0. It stops for the delay when it goes back up (not down) to Pwmmin.

To test this, fix INTERVAL and rampLength to some sensible values, them screenshot a scope trace with PWMmin set to 0 and mx set to 50. Take another trace with min set to 200 and max set to 255. Optionally, take third scope trace with min = 100 and max = 150. Since I'm suspecting overflow, the point of these debug tests is to get the pwm limits as far away from the limits of the integer type as possible, so if the value is straying outside that limit in some way, it becomes blindingly obvious.

For all the shots you post, be precise about how what you are seeing is different from what should be created. Use numbers that you expect to measure. Mathematical expressions of the relationships of the measurements are fine too, as long as you are precise about it. For the second one of the tests, it might be like "Ramp from pwmmin (about 4V) to pwmmax (5V) in x microseconds, then ramp down from max to min in the same amount of time. Hold the min voltage for INTERVAL milliseconds, then repeat the cycle." That is a properly precise description.