Need help with Load cell
azrael
Posts: 4
I am building a·scale using a load cell (LCL-040) from Omega, AD7730, and a basic stamp 2:
I have made the necessary connections, and i have no changes in the output on the debug screen, there is output in the load cell as i used a
voltmeter to check on it. I have tried to fix the problem but have reached a dead end, could there besomething missing in my connections?·I also made some chages in the code, renumbering the con pins. ·Please help me.
Aaron
Here is some of the information i have received by this forum (Mostly from Mohammed Refky):
AD7730 connctions BS2
(SCLK) pin1
pin12 (P7)
(DIN) pin22
pin13 (P8)
(DOUT) pin21
pin14 (P9)
(RDY) pin20
pin15 (P10)
To calculate the weight for 5kg load cell with 2mV/V o/p:
Input range = 10
16 bit mode
5V excitation voltage
weight = code**5000 'weight in grams
For full-scale calibration use your software to correct the value.
For Connecting the Load Cell to AD7730:
LCL is a four wire load cell
For single supply operation (unipolar)
Load Cell······················· AD7730
RED=+EXC····················· +5V
BLACK=-EXC···················AGND
GREEN=+SIGNAL············· AIN1 (+)
WHITE=-SIGNAL············· AIN1 (-)
···································REF IN (+) ---->+5V
·································· REF IN (-) ----> AGND
Program code:
'{$STAMP BS2}
'{$PBASIC 2.5}
'The AD7730 accepts LOW volt from load cell AND outputs serial digital Word.
'BS2 code reads the 16 Bit Word AND converts it TO weight so program should be set to
'a setpoint at certain weight NOT resistance of the load cell.
'codes of writing AND reading of registers:
ADdata····· VAR Word· 'variable to hold 16 bit result.
DATAin····· CON 2····· 'AD data input pin.
DATAout··· CON 3····· 'AD data output pin.
SCKL········ CON 4····· 'clock to AD.
RDY········· CON 5····· 'RDY input .
INPUT 5
Initial:
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$FFFF\16,$FFFF\16] 'write 32 ones will reset the AD7730 to the default state.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$02]· 'write to communication register setting next operation as write to mode register.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$3080\16] 'write to mode register starting continuous conversion for 10mV input range,unipolar,16 bit data word and 5V reference.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$21]· 'write to communication register setting next operation as continuous read from data· register.
LOW 2········ ' set DIN line low to insure part is not reset while in continuous reade mode.
ReadData:
waitRDY:
··· IF RDY = 1 THEN waitRDY·· 'wait for RDY to go low to indicate output update.
··· SHIFTIN DATAout,SCLK,MSBPOST,[noparse][[/noparse]ADdata\16] 'read conversion result from data register.
DEBUG DEC ADdata,CR··· 'display data in decimal.
PAUSE 500·················· 'wait 0.5 second between reading.
GOTO ReadData
END
I have made the necessary connections, and i have no changes in the output on the debug screen, there is output in the load cell as i used a
voltmeter to check on it. I have tried to fix the problem but have reached a dead end, could there besomething missing in my connections?·I also made some chages in the code, renumbering the con pins. ·Please help me.
Aaron
Here is some of the information i have received by this forum (Mostly from Mohammed Refky):
AD7730 connctions BS2
(SCLK) pin1
pin12 (P7)
(DIN) pin22
pin13 (P8)
(DOUT) pin21
pin14 (P9)
(RDY) pin20
pin15 (P10)
To calculate the weight for 5kg load cell with 2mV/V o/p:
Input range = 10
16 bit mode
5V excitation voltage
weight = code**5000 'weight in grams
For full-scale calibration use your software to correct the value.
For Connecting the Load Cell to AD7730:
LCL is a four wire load cell
For single supply operation (unipolar)
Load Cell······················· AD7730
RED=+EXC····················· +5V
BLACK=-EXC···················AGND
GREEN=+SIGNAL············· AIN1 (+)
WHITE=-SIGNAL············· AIN1 (-)
···································REF IN (+) ---->+5V
·································· REF IN (-) ----> AGND
Program code:
'{$STAMP BS2}
'{$PBASIC 2.5}
'The AD7730 accepts LOW volt from load cell AND outputs serial digital Word.
'BS2 code reads the 16 Bit Word AND converts it TO weight so program should be set to
'a setpoint at certain weight NOT resistance of the load cell.
'codes of writing AND reading of registers:
ADdata····· VAR Word· 'variable to hold 16 bit result.
DATAin····· CON 2····· 'AD data input pin.
DATAout··· CON 3····· 'AD data output pin.
SCKL········ CON 4····· 'clock to AD.
RDY········· CON 5····· 'RDY input .
INPUT 5
Initial:
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$FFFF\16,$FFFF\16] 'write 32 ones will reset the AD7730 to the default state.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$02]· 'write to communication register setting next operation as write to mode register.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$3080\16] 'write to mode register starting continuous conversion for 10mV input range,unipolar,16 bit data word and 5V reference.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$21]· 'write to communication register setting next operation as continuous read from data· register.
LOW 2········ ' set DIN line low to insure part is not reset while in continuous reade mode.
ReadData:
waitRDY:
··· IF RDY = 1 THEN waitRDY·· 'wait for RDY to go low to indicate output update.
··· SHIFTIN DATAout,SCLK,MSBPOST,[noparse][[/noparse]ADdata\16] 'read conversion result from data register.
DEBUG DEC ADdata,CR··· 'display data in decimal.
PAUSE 500·················· 'wait 0.5 second between reading.
GOTO ReadData
END
Comments
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$3080\16] 'write to mode register starting continuous conversion for 10mV input range,unipolar,16 bit data word and 5V reference.
You want the chip in bipolar mode rather than unipolar mode. I'm not familiar with the AD7730 chip, but it look similar the the AD7705. With the chip in unipolar mode you may not see a negative voltage out of your load cell.· It's possible, depending on the starting conditions for the cell, for the output to be negative.
I'm using and AD7705 with a 30 mv load cell and getting very good results and can send you the code, but cannot be sure if all the setup parameters would be compatable.
Post Edited (MSDTech) : 3/24/2008 12:04:12 PM GMT
·· ·I·have used Mohamed's·code and connected the unit using all of the connections suggested and still get a string of "0" [noparse][[/noparse]zeros] in the debug terminal.· Very frustrating.· Perhaps Mohamed Refky has a suggestion.· Any input on this one would be appreciated.· Merf
Bipolar/Unipolar Bit. A 0 in this bit selects bipolar operation and the output coding is 00 . . . 000 for negative full-scale input, 10 . . . 000 for zero input, and 11 . . . 111 for positive full-scale input. A 1 in this bit selects unipolar operation and the output coding is 00 . . . 000 for zero input and 11 . . . 111 for positive full-scale input.
Positive input of the differential, programmable-gain primary analog input pair. The differential analog input ranges are 0 mV to +10 mV, 0 mV to +20· V, 0 mV to +40 mV and 0 mV to +80 mV in unipolar mode, and ±10 mV, ±20 mV, ±40 mV and ±80 mV in bipolar mode.
I would suggest changing the parameter from $3080 to $2080 just to see if you still get all zeros. Its very possible the polarity on the cell output is backwards. In the unipolar mode, that would give you all zeros. The bipolar will show a value even if the load cell polarity is reversed. I had a struggle with the load cell on my scale until I realized that it output negative then shifted through 0 to a positive (based on the wire color codes) as the load was increased.
One other factor. The AD7730 is a 24bit converter that sends MSB First. Based on the code above, you are only reading the first 16 bits of the 24, so you may be getting an output but aren't reading it.
Post Edited (MSDTech) : 3/24/2008 9:46:11 PM GMT
· Did you need to use capacitors in conjunction with the crystal?·
· I occurs to me that my load cell is designed for 10 vDC excitation (the manufacturer indicates that 5 v excitation will work, but the resolution will be better with the highter excitation·voltage).· This load cell generates 3mV/V.· Were you able to decipher from the spec sheet whether someone could excite with 10VDC?·· If so, do you have a suggestion on how I might hook it up and write the code?···Would I need a separate power supply with + and - 5 VDC?
· Finally, what is the purpose of the "\16" in all of the code examples?
Thank you very much for your time and input.· Merf
You normally don't need to use capacitors with the crystals, but you do need to check the capacitance of the crystal with the value listed in the datasheet to make sure its compatible.
You might want to consider using the AD7705 rather than the AD7730. They are both by the same manufacturer, but for the basic stamp the AD7705 has a 16 bit data output. The AD7730 has a 24 bit data output, which is much harder to deal with using the 16 bit Basic Stamp family of processors. The way the code you've listed works, you will only be reading the 16 highest bytes of the result. I suspect under low load conditions that the reading is in the 8 bits you are not reading.
As far as the exitation voltage, if you can get the resolution you need for your application, then go for it with 5V. These load cells are just a wheatstone bridge and should work with any voltage that does not generate too much power in the 4 resistance elements.
It might help if you describe the application you are trying to build. IE what type of load and what is the maximum load for the load cell? The application I'm putting the final touches and debugging on is a weather station. The load cell is used to weigh the collected rainwater to determine the amount of rainfall (or water equivalent in snow). I had a hard time finding an acceptable load cell at a reasonable price. I finally found a cheap electronic scale at Wal-Mart with an adequate capacity/sensitivity·and stripped it. Inside was a cantiliever beam with a load cell. I threw away the original electronics to build my own that I could read with at BS2.
Post Edited (MSDTech) : 3/24/2008 10:43:05 PM GMT
The \16 tells the program to read (or write) 16 bits of data. As the converter is a 24 device, that will mean you will drop the 8 lower bits of your output, effectivly giving you only a 16 bit resolution.
Unfortunatly, the stamps max variable size is 16 bits. If you find you really need all of the 24 bits of resolution (the max I have ever needed was 12 bits, but that is off the point) use two variables in the same statement: SHIFTIN DATAout,SCLK,MSBPOST,[noparse][[/noparse]ADdata\16, ADdata2\8] This will tell the stamp to place the first 16 bits in the first variable and the remaining 8 bits of data into the second.
A value higher than \16 can be used. Lets say you have a word variable and use a \24 modifier - 24 bits will be read, but the UPPER 8 bits will be dropped due to overflow. I use this a lot when an ADC requires more clock cycles than data bits.
··The load cell I purchased is from Load Cell Central: model XTS4-1K (the "1k) means the one I bought has a capacity of 1000 pounds.· Here is a link to show you the unit and the specification sheet:·http://www.800loadcel.com/load_cells/stype_load_cell.html
· My idea was to receive the information from the AD7730 and process it with a BS2e and then convert the data in some manner so as to output the result in 1 pound increments to a 3 digit 7 segment LED display.· I want to use a MAX 7219 LED display driver--since I have used that unit to build a thermometer in the past.··So I would anticipate that I'll need the stamp to do some math and probably need to convert the information from the AD7730·in some form so that the MAX 7219 can understand it and display the weight.
···I'm not sure how one is to calibrate the scale, and so that will also be a task for this project.· I also wanted the ability to get a "tare" reading so that the lifting tackle (slings and line) can be zeroed out before weighing the boat.
· I am not an engineer but I can typically build circuits from schematics.· I have had some success using the MAX 7219 in the past, but I hope that this project isn't too over my head.
· Your ideas are appreciated and very helpful.· Thank you.· Merf
Exact AD7730 Code FOR BS2
ADdata var WORD 'variable to hold 16 bit result.
DATAin con 2 'AD data input pin.
DATAout con 3 'AD data output pin.
SCKL con 4 'clock to AD.
RDY con 5 'RDY input .
INPUT 5
INITIAL:
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$FFFF\16,$FFFF\16] 'write 32 ones will reset the AD7730 to the default state
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$03]'write to communication register setting next operation as write to Filter Register.
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$7040,$10]'output rate for 50Hz line frequency in CHOP mode and DC excitation
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$02] 'write to communication register setting next operation as write to mode register.
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$B0B0\16]'write to mode register initiating internal full scale calibration
pause 500
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$02]
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$D080\16]'write to mode register initiating system zero scale calibration
pause 500
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$02]
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$3080\16] 'write to mode register starting continuous conversion for 10mV input range,unipolar,16 bit data word and 5V reference.
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$21] 'write to communication register setting next operation as continuous read from data register.
LOW 2 ' set DIN line low to insure part is not reset while in continuous read mode.
ReadData:
waitRDY:
IF RDY = 1 THEN waitRDY 'wait for RDY to go low to indicate output update.
SHIFTIN DATAout, SCLK, MSBPOST, [noparse][[/noparse]ADdata\16] 'read conversion result from data register.
DEBUG DEC ADdata, CR 'display data in decimal.
PAUSE 500 'wait 0.5 second between reading.
GOTO ReadData
********************************
You may write the initial code like this:
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$FFFF\16,$FFFF\16]
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$03,$7040\$10]
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$02,$B0B0\16]
pause 500
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$02,$D080\16]
pause 500
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$02,$3080\16]
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$21]
LOW 2
********************************
The step of initiating system zero scale calibration remove tha pan weight and the display will show zero reading.This is performed after power up.
The AD7730 has a 24 bit or 16 bit data output,so :
Code = (Ain/Input Range)*2^n
Ain is the the analog input voltage and n = 16 in 16 bit mode and n = 24 in 16 bit mode of operation.
I use 10 mV input range for 2mV/V load cell
Weight = {Ain/[noparse][[/noparse]load cell sensitivty (mV/V) x excitation voltage]}*load cell capacity (kg)
Substitute Ain from code equation
The result is not exact value because neither the supply is exact 5V nor the load cell is exact 2mV/V.
So I use software to correct the weigh reading according to a knwon weight.
Re: Use of a loadcell to weigh your sailboat.
The best calibration is to physically apply weight to the loadcell. In the case of wanting to accurately weigh 500 to 600 lbs you can simply weigh several bags of, say, sand on an accurate scale, noting the exact weight of each bag and rig enough of them to be weighed with the loadcell. In the case of calibrating homebuilt loadcells [noparse][[/noparse]gaged sailboat stay turnbuckles] I have used the weight of the rear of a vehicle [noparse][[/noparse]a pickup] as hoisted [noparse][[/noparse]with the turnbuckle as part of the hoist] so as to raise the rear wheels off the ground. Of course you have to hoist using a secure attachment - a bumper won't do. And you have to have had the vehicle weighed, both front and rear, in order to calculate the CG, the vehicle weight and the moment arms about the front wheels.
A more accurate way to calibrate is to have the loadcell output measured along with that of a standard cell in a loading frame; which is rather expensive. Is the loadcell manufacturer's stated output to be believed? Strain gage based loadcells are generally quite linear; so any known weight check might be sufficient. How about having your Thistle weighed at a certified site and using this as a base weight? If the loadcell output returns to zero upon weigh removal, it is probably dependable.
In any regard it is best to note an equivalent 'simulated' output using a 'shunt' resistor across one arm of the loadcell's wheatstone bridge. This simulated output can then be used later to electronically recalibrate the instrumentation. This shunt calibration procedure is written up in tutorials on strain gage based loadcells.
Regarding tare weight: This can be nulled out using a 10-turn pot balancing circuit wired across two adjacent arms of the wheatstone bridge. Nowadays it is probable best to let the Stamp program subtract the tare weight.
I prefer to use an instrumentation amplifier [noparse][[/noparse]INA 125] with built-in bridge excitation, and a A/D converter [noparse][[/noparse]TLC2543] with it's extensive, Stamp related, documentation, thanks to Dr. Allen. This arrangement allows me to read the amplified loadcell analog output as a check.
Success with the Thistle weighing.
Sailboats aren't just for sailing anymore. ;o)
'This program reads tho power-on /reset default values of AD7730.
DATAin···· con 2··········· ·'AD data input pin.
DATAout·· con 3··········· 'AD data output pin.
SCKL········con 4··········· 'clock to AD.
X0··· var···· word
X1··· var···· word
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$FFFF\16,$FFFF\16]
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$10]
SHIFTIN DATAout, SCLK, MSBPOST, [noparse][[/noparse]X1]
DEBUG "STATUS REGISTER "," ",ihex2 X1,cr·····················'Value is $CB.
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$12]
SHIFTIN DATAout, SCLK, MSBPOST, [noparse][[/noparse]X1,X0]
DEBUG "MODE REGISTER "," ",ihex2 X1,hex2 X0,cr·············'Value is $01B0.
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$13]
SHIFTIN DATAout, SCLK, MSBPOST, [noparse][[/noparse]X1,X0\16]
DEBUG "FILTER REGISTER "," ",ihex2 X1,hex4 X0,cr·············'Value is $200010.
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$14]
SHIFTIN DATAout, SCLK, MSBPOST, [noparse][[/noparse]X1]
DEBUG "DAC REGISTER "," ",ihex2 X1,cr························· ···'Value is $20.
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$15]
SHIFTIN DATAout, SCLK, MSBPOST, [noparse][[/noparse]X1,X0\16]
DEBUG "OFFSET REGISTER "," ",ihex2 X1,hex4 X0,cr·············'Value is $800000.
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$16]
SHIFTIN DATAout, SCLK, MSBPOST, [noparse][[/noparse]X1,X0\16]
DEBUG "GAIN REGISTER "," ",ihex2 X1,hex4 X0,cr··················'Value is $593CEA.
END
··So it appears the AD7730 is communicating with the BS2e correctly.· Still, when I connect the load cell with the regular program you wrote, I·only get a string of 0s (zeros) in the debug screen.· Is it possible the AD7730 is not amplifying the signal from the load cell enough to register?· The load cell is designed for 10 VDC excitation,·but it works with less·voltage too (see comment below).··This has become quite frustrating. ··
I am also concerned that perhaps I am missing some resolution because of·bits being lost in the transfer (16 vs. 24).· I know the load cell is working because my DVM easily can sense millivolt fluctuations in voltage output with the load cell exited with the minimal 5 volts for·testing (I literally pulled·on either side of the load cell with my arms and this showed varying milivolt outputs from·the load cell·relative to·my physical straining···
· I normally don't encounter such a total failure on a project.· This is indeed a major bummer.· Your ideas are very much appreciated.· Merf
On 24/03/2008 you wrote you would work with an AD7705 and could send the code you used. Is this offer still open? Because I am trying the same CHALLANGE no allready for too long time and somehow I can not reach the goal!
I use the following code and most time the Drdy pin stays a logic one and if not it communicates some random nonsense! Can you see an obvious mistake in the code or give any other hints?
Cheers stuerm
Pin connection:
1: Clock -> pin 0 of B2
2&3: 4.9152MHz crystal
4:CS ->GND
5:Reset -> 1k Vdd
6:Ain2+ -
7:Ain1+->potentiometer 0-4V
8:Ain1-->GND
9:Ref+->1k Vdd
10:Ref-->GND
11:Ain2--
12[noparse]:D[/noparse]rdy->pin1 of B2
13: Dout-> pin2 of B2
14: Din-> pin3 of B2
15: Vdd = 5V
16:GND
' {$PBASIC 2.5}
'Communication with the analog digital converter AD7705
SCLK CON 0 'clock to AD.
READY CON 1 'AD ready pin number, if low, new output can be read
DATAout CON 2 'AD data input pin number
DATAin CON 3 'AD data output pin number
PINReady PIN 1 'AD ready pin
weight VAR Word
weightOld VAR Word
'write to communication register
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$20]'20 '0010|0000:ready (0), select clock register (010),write (0), not stand by (0),Channel AIN1 (00)
'write to the clock register
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$0c]'$0c '0000|1100[noparse]:([/noparse]0000),cristal freq devided by 2 (1),clock freq 4.9152MHz (1),outputrate 50Hz (00)
'write to communication register
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$10]'10 '0001|0000:ready (0), select setup register (001),write (0), not stand by (0),Channel AIN1 (00)
'write to setup register for calibration
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$40]'40 0100|0000:Mode self calibration (01),gain=1 (000), unipolar (0), buffer off (0),Fsync on (0)
PAUSE 1000
DO
GOSUB WaitRDY
'write to the communication register
SHIFTOUT DATAin, SCLK, MSBFIRST, [noparse][[/noparse]$38]'38 '0011|1000:ready (0), select data register (011), read (1),not stand by (0),Channel AIN1 (00),
'read from data register
weightOld=weight
SHIFTIN DATAout, SCLK, MSBPRE, [noparse][[/noparse]weight\16] 'read conversion result from data register.
IF weight<>weightOld THEN
DEBUG SDEC ? weight, CR
PAUSE 500
ENDIF
LOOP
END
WaitRDY:
DO WHILE (PinREADY)
DEBUG IBIN8 ? PinReady,CR
PAUSE 100
LOOP
RETURN
RogerN
Thanks for your fast answer. The ADC is used for a load cell with a voltage range of 0-5mV. I need a resolution of about 1 micro Volt. Do you think this works with LTC1298 coupled with an instrumentation amplifier? Which amplifier would you propose? Do I have to mind about noise that would result in a unsteady digital output?
Cheers stuerm
I looked at the chip they are discussing here and the resolution up to 24 bit sounds awesome, hopefully someone will be able to get the Basic Stamp working with that chip, it certainly looks worth the effort. I mentioned the LTC1298 because it and an instrumentation amp would fit most of my needs as far as tinkering with scales and force sensing, but I plan to order the AD7730 chip on my next Digi-Key order. I bought some eBay load cells suitable for a gun powder reloading scale. I may experiment with an automatic powder measuring system.
RogerN
RogerN
'AD7730
ADdata··· VAR· Word·· 'variable to hold 16 bit AD result.
SCLK····· CON· 9······ · 'clock to AD pin number.
DATAIN··· CON· 10···· ·'AD data input pin number.
DATAout·· CON· 11···· 'AD data output pin number.
RDY······ CON· 12······ ·'RDY input pin number.
wf··· DATA· Word $1388···· ·'store· weigh scale factor,5000.
INPUT 0····· 'make P0 an input
AD7730:
· SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$FFFF\16,$FFFF\16]
· SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$03,$7040\16,$30]· 'AC excitation,no
· delay.for·DC·change $30 to $10
· SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$02,$B0B0\16]
· PAUSE 1000·· 'wait for internal full scale calibration.
· SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$02,$D080\16]
· PAUSE 1000·· 'wait for system zero scale calibration.
· SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$02,$3080\16]
· SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$21]
· LOW 10
main:
··· IF IN0 = 0 THEN keypress······· ·· 'check for calibration key press.
··· IF timer >·50 THEN program········'0.5 sec between reading.
··· timer = timer + 1
··· GOTO main
program:
··· GOSUB getdata
··· GOSUB Maxdisplay··················· 'display data.
.
.
.
··· timer = 0
GOTO main
getdata:
waitRDY:
··· IF RDY = 1 THEN waitRDY
··· SHIFTIN DATAout,SCLK,MSBPOST,[noparse][[/noparse]ADdata\16]
··· dispVal = ADdata ** weighFactor···· 'weigh equation.
RETURN
******
Initiating zero scale calibration remove tha pan weight and the display will show zero reading.
This is performed after power up.
For full scale calibration·I put a known weight on the pan and on pressing a key, a routine is running to correct the "weighFactor" in weight equation until the the display reading match the known weight.