It is currently 21 Oct 2018 13:19

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 31 Mar 2017 23:13 
Offline

Joined: 31 Mar 2017 22:03
Posts: 2
Hello everyone
I am new here and beginner programming pic16f877 with mikroC :D . I try to realize an electronic scale and here are the results that I obtained at the output of the amplifier of the sensor.
But I hesitate on the conversion of voltage / weight.
Please help me
*******************************
Weight(Kg) Output Voltage(V)
0 -------------------- 3.162
1 -------------------- 3.200
2 ---------------- 3.241
3 ------------------- 3.281
4 ------------------- 3.324
.. -------------------- ....
10 ----------------- 3.535

Equation of straight line
Y= sX + C
At X=0 and Y=3.162
so C=3.162

The slope of straight line is :
s=(3.535−3.241)/(10−2)

s=0.022
Now,
X = (Y-C)/s
X=(Y−0.997)/0.022

*************
codeMikroC
..............
adc_rd=ADC_Read(0);
adc_val=adc_rd*5.0/1024;
wg=(adc_val-C)/s; //how to convert hire value of C and s ?
........
Thanks.
Best regard
boul52.


Top
 Profile  
 
PostPosted: 11 Apr 2017 07:10 
Offline

Joined: 11 Apr 2017 06:17
Posts: 11
Location: Italy
Hi,
there is a formula that may help you based on straight lines:

//load "temp" with your reading

temp = (temp - tempBS) / (tempES - tempBS) *
            (outputES - outputBS) +  (outputBS);
//where suffixes : BS is "begin scale" and ES is "end scale"

//your formula becomes:

temp = (temp - 3.162) / (3.535 - 3.162) * (10 - 0) + 0;



All the best


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: