Hello, welcome to our forum.
It looks like you have registered but you have not yet posted and
messages. Our requirements are that you must post at least two
messages, to allow the moderators to review your registration, before
you will be allowed access to the full range of forum areas.
Please make a couple of posts, until then you may see a notice that
says you are banned from certain forum areas.
Thank you.

 5th April 2012, 14:29
#1
Still Struggling with the formula!
Hi All,
I am working with an ASC758 current detector and an LTC1298 A/D converter. The ASC758 has a manufacturers "offset" so that at 0.0 amps the A/D will put out a digital reading of 483 representing this offset. So it seems to me that you would create a formula that looks like amps= ((reading483) ** 8000) >>4. The highest output reading would be 2868. However at low readings such as 503 the results are still showing up as 0.0! Any ideas?
Thanks, Ed

 5th April 2012, 15:59
#2
Re: Still Struggling with the formula!
Your formula does this:
503483=20
20*8000/65536=2
2>>4=0
It works OK.
I think the formula is wrong.
Your ADC has 12bit resolution, so its output is 04095.
But your sensor has an offset of half the power supply since it measures AC and DC currents.
Question: Are measuring ONLY DC currents? If yes then do these:
Scale down the ADC: adc=adc>>3 'From 04095 to 0511
Then subtract the offset that is in the middle our new scale: adc=adc256
Now it should be OK.
Ioannis

 6th April 2012, 03:25
#3
Re: Still Struggling with the formula!
Hi Ioannis!
Thank you for the suggestion and I still seem to be missing something fundamental. At 0.0 amp (no load) the A/D gives a digital reading of 485 and after the >>3 this becomes the number 60. Therefore 60 I think becomes the offset value. At .461 amps the A/D gives 506 and after the >>3 this becomes 63. Last at .869 amps the A/D gives 516 and after the >>3 you now have 64! Just as an FYI, the spec sheet shows the offset to be 0.5 volts so the number 60 makes sense.

 6th April 2012, 06:08
#4
Re: Still Struggling with the formula!
Dave
Always wear safety glasses while programming.

 6th April 2012, 08:29
#5
Re: Still Struggling with the formula!
On page 4 of the data sheet in Quiescent Output Voltage it clearly indicates that the output voltage will be the half of the power supply. So if the Vcc is 5 volts then the output will stay at 2.5 volts.
Ioannis

 6th April 2012, 13:48
#6
Re: Still Struggling with the formula!
Thanks Ioannis and Dave!
Ioannis you are correct and the actual device is the 50U. I am not sure we are looking at the same spec sheet and if so then on page 6 it shows that with this sensor you get 60mv/A. Since the device is a 50 amp max. device then 60 x 50 would give 3000 or 3.0 volts. Subtract the 0.5 volt offset and then you get the 2.5 volts at 50 amps. It could very well be that there is an error in my ampmeter's scale as this is what I have been using to compare to the program results.
Best, Ed

 6th April 2012, 14:15
#7
Re: Still Struggling with the formula!
No you are not seeing the specs correct.
If there is no current the device just sits inthe middle of the Vcc. Ifyour Vcc is 3.3 volt then the Vcc/2 is 1.65volts. If it is 5 then the output sits at 2.5 volts.
It is made in such way because it measures AC and DC currents.
Ioannis

 6th April 2012, 15:30
#8
Re: Still Struggling with the formula!
Hi,
If it indeed is the 050U device then, if I read the datasheet correct it's an Unidirectional version and its output voltage at 0A is 0.6V  not Vcc/2.
So if VRef for your ADconverter is 5.000V and you're using 12 bits then you should get an ADC reading of 4096/5*0.6=492 at 0A current. In an earlier post you said that you got 485  that's pretty close. You'll then get 60mV per A.
So at 1A current you should get a reading of offset+4096/5*0.06=541. To convert this to a readable value, if that's what you want, you first subtract the offset (541492=49) and then multiply it by say 204 and then divide by 10. 49*204=9996, then divide by 10 = 999mA
If you have 3.75A then you'll get an ADC reading of offset+4096/5*(0.06*3.75)=492+184=676. Start by subtracting the offset to get the "real" value (184) multiply by 204 and divide by 10 and you get 3753mA.
If doing it this way watch out so you don't overflow you variables when multiplying. Another aproch would be to use the ** or */ operators as I showed you in another thread.
/Henrik.

 6th April 2012, 22:21
#9
Re: Still Struggling with the formula!
I had the old Data sheet where there was no such device.
Please accpet my appologies. Now downloaded the new pdf and see that indeed there is a variation of bidirectional device.
050U is unidirectional and has 0.6 volts offset.
So sorry.
Ioannis

 7th April 2012, 18:06
#10
Re: Still Struggling with the formula!
No problem Ioannis it happens to the best of us. Lol It is actually my fault if I had been thinking I would have included the spec sheet rather than just referencing it. It turns out from trial and error that the A/D readings includes the offset so in the calculations you have to subtract it.
Best, Ed

 7th April 2012, 18:13
#11
Re: Still Struggling with the formula!
Yes, thats right. It is a constant value that has to be subtracted. The only little matter is that this constant is not so constant and may change with temp or other factors (aging etc.)
So a complete zero after calculation cannot be guaranteed. Even worse,the calculation can result in a negative number, that in absolute valu can be very large positive.
So a regular update of the offset value could be a good idea.
Ioannis

 8th April 2012, 16:13
#12
Re: Still Struggling with the formula!
Hi Ioannis!
Thank you and you are very correct. What will probably be necessary is to add an external 3 second delay to measure the zero point each time time circuit is powered up. That is, power up the PIC, wait 3 seconds, then add the load. Where I have become very stuck is in what I call 4994 land. At 50 amps the A/D will be giving you value of 2987. Subtract a zero point of 490 and you get 2497. Times 2 and you get 4994. It seems no matter what I do this number keeps showing up!

 8th April 2012, 20:40
#13
Re: Still Struggling with the formula!
Taking into account that your power supply is 5Volts and the max output of the device is 3.6 volts in respect with the flowing current, the reading of the ADC I think is correct.
I don't understand why you double it.
Ioannis

 9th April 2012, 00:37
#14
Re: Still Struggling with the formula!
When things go wrong is that yes (2987 divided by 10 gives 298 49 = 249. 249 x 200= 49800. 49800 /4096 = 12. 12 x 4167 = 50004 close enough to 50.00 amps. Now do the same with an A/D OF 700 which is very close to 4.24 amps measured and 700 / 10 = 70. 70  49 = 21. 21 x 200 = 4200. 4200 /4096 = 1 (in a PIC) 1 x 4167 = 4167 or .4167 amps not the 4.24. What I am trying to say is that if I get the high end of the scale to work the low end does not! Even at a change to 800 the results will not change. Other approaches such as ((700490) ** 8000) >>4 = 1 so it does exactly the same!

 9th April 2012, 09:37
#15
Re: Still Struggling with the formula!
At 50A: ADC=2987, offset=485. (2987485) * 20 = 50040mA (50.04A)
At 4.24A: ADC=700, offset=485. (700485) * 20 = 4300mA (4.3A)
At 1A: ADC=534, offset=485. (534485) * 20 = 980mA (0.98A)
Not perfect. However, there are some things that doesn't quite add up here... You should be getting 60mV per A so at 50A you should get 3V or a count of 2457+offset. Now, you say that the offset is 485 which should give you a total of 2942 at 50A, yet you say that you get 2987 but never mind.
In theory, provided that your VRef is exactly 5.000V you will get 49.152 'counts' per A. If you get yoursefl a voltage reference of 4.096V then your ADC will report the measured voltage in units of 1mV instead which means that you'll get 60 counts per A  might make it easier for you.
/Henrik.

 9th April 2012, 21:44
#16
Re: Still Struggling with the formula!
Hi Henrik!
Thank you, thank you, thank you! Yes you are correct and it ended up being a low battery which gave the 485 value. After changing the 9 volts battery which was feeding a 5.0 volt regulator the 0.0 amp reading became 490. Before the battery failure, I placed an external ampmeter is series with the load which was two automobile brake lights. This external ampmeter was showing 4.224.24 amps. The other test load was two resistors which gave a load of .869 amps. To estimate what the A/D reading would be (without a known 50.0 A load) I have been testing the formula in Excel. Now that I plug in your formula Excel shows the A/D would be 2989. It is very clear after working on this for about a month I completely over complicated the math! The other part is that you tend to believe your PIC information as being more accurate than an external meter, amp or volt. What also did not help was calling Allegro and being told the 0.0 amp voltage to the A/D would be 0.5 volts and not 0.613 volts measured! Anyone need a approximate 1/4 bottle of 350 count bottle of Excedrin?

 10th April 2012, 05:20
#17
Re: Still Struggling with the formula!
Anyone need a approximate 1/4 bottle of 350 count bottle of Excedrin?
Why? Are you giving up programming?
Dave
Always wear safety glasses while programming.

 10th April 2012, 06:58
#18
Re: Still Struggling with the formula!
I do not really know why, but such prescriptions are very rare here. Maybe it is the sun, the sea, the frappe or the good heart most we have. Not for me, thanks!
Ioannis
Members who have read this thread : 0
You do not have permission to view the list of names.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts
Forum Rules
Bookmarks