Ok i have a bit of code which reads a -100A - 0 - +100A current sensor.

The sensor idles at 2.5v and swings rail to rail as current flows.

I use a 10 bit adc to capture the value. No issues with all of this.

Now I also capture a sensor offset value at program start up which is the 0A value. this doesnt change much perhaps by one number either way around 510 each day.

So my formula looks like the below.

Code:
	if BatCurrent < Offset then		'If BatCurrent is < Offset means system is Discharging
	BatCurrent = ((Offset - BatCurrent) * 2) / 10 	'Subtract offset to get a positive number (0-512 = 0-100A+) Max 99
	AmpSign = 45				'Set ascii Character 45 (-) to be displayed if Discharging
	goto ExitCurrent
	endif
The snippet checks which way the current is flowing and then calculates the value in amps. I cheated and just multiplied the value by 2 as i knew -100A would be an adc reading of 0 so in effect 512 became 1024 or -102.4A So it's a bit off, can anyone suggest some better maths. Vice versa applies and an adc reading of 1024 = +100A flowing