I'm trying to measure a fork's lift battery by an ADC. The problem that the output voltage isn't predictable and not constant, so that I can make a constant voltag divider. What I have measure is it goes from 7 to 30VDC, and the max input voltage of my adc is 1.2V. How would I design the voltage dividers and the op-amps in that case?
It seems you want to measure a voltage that can be from 7 to 30 volts with a A/D converter with a full scale range of 0 to 1.2 V. What you need is a "voltage divider". This is just two resistors in the simplest case:
In this case, 30 V needs to be scaled down to 1.2 V, which is a factor of 25. That means R1 needs to be 24 times R2. For example, R2 could be 10 kΩ and R1 240 kΩ. That is exactly on mathematically, which doesn't leave room for tolerance of the parts. It would be best to make R1 a little higher, like the next higher up standard value 270 kΩ. In that case the divider will divide by (R1 + R2)/R2 = 28, so the input voltage range the A/D can measure will be 0 to 33.6 V.
That's the basic answer to the question you asked, but a few things seem strange. Are you really sure the A/D range is only 1.2 V? That is possible, but surprisingly low. Also, 7-30 V sounds like a very large range for a battery. That implies the battery can be drained down to less than 1/4 of its maximum charging voltage, which is very low and can damage most types of batteries. What kind of battery do you have? Where did you get the 7 and 30 volt figures from?
You need to make a signal conditioning circuit (I would include plenty of protection & a good bit of extra headroom for over-voltage conditions) that divides the voltage so that its maximum output is 1.2v. The core of this can be a simple potential divider.
You should read up on transient voltages, back-emf, etc. as any vehicle (especially electric) has lots of ways to generate nasty voltage spikes and harsh conditions for sensitive electronics.