Sometimes there are those who ask for an AIinto for your own idea. In this case, it stimulated me to experiment with a load cell. Cas you might imagine it is not really a complete project but only proof with an analog-digital converter specific for reading a load cell.
The development is based on a module that mounts an HX711. This module contains some components as they are presented in the diagram, therefore consider that they are not added.
According to the directives of those who asked me for help, I used a 16F877A MCU. Below I have mounted a set of seven-segment displays (Let's call it 7SD, that would 7Segments Display). There are other options for programming a different display. As can be seen in the diagram.
The integrated HX711 is an ADC a 24 bit, of which 23bit mark the positive and the others the negative. To read the collected data we need a synchronous serial communication for 25, 26 or 27 bit. The why comes to determine what the next reading gain will be. If communication is interrupted beyond 60 microseconds the integrated circuit enters energy saving mode and also disconnects the voltage from the external circuit, through the foot base. With 25 clock pulses determine the maximum gain a 128, mentre a 26 you have 32 and connected to the integrated channel B, last i 27 clock determine the gain a 64. Given the sensitivity and accuracy of the integrated, this is used for reading a bridge of Wheatstone which is created with the 4 resistances of the load cell.
About the 7SD, there are options for widths from a minimum of four digits or more. I would say that I have not considered more than six digits, I don't think it gives problems.
Among the various options there is the possibility to interface a UART device. For this I have mounted the bluetooth module, carefully to put the resistive divider to the TX pin of the micro.
As the diagram shows, it can be seen that there may be a direct connection with an LCD, following the indications of the labels on the connecting lines. There is no backlight control, but just a simple NPN transistor that brings the pin to ground 16 (cathode) del display.
You can also use an I2C interface module that are commonly found at online stores.
In the case of direct connection, there is no backlight control. Maybe just a transistor with a photoresistor.
The program is commented in English, as previous developments. For those who are not used to it, I could make a translated copy of it, while my ambition would be to be able to divulge it even for those who do not know Italian also because it is rational that it is written internationally.
The compiler used is the Proton Basic, which I feel good about for the various peculiarities. Including putting code into assembly. For this there is a case to note in the position of the variables, in special modo per i due array, since we use a method that does not accept memory bank jumps.
A method of separating the file into three parts was used in this project. One party takes charge of determining the variables and other definitions, leaving better visibility in the important part of the program. Another file is needed only if you want to use the display with I2C interface.
In the main program (Wscale??.Low) you notice a couple of $define of relief. These define which measurement quantity is to be implemented in kilograms. See the line 10. In fact it can be used for load cells from 5, 10 O 20 chili.
In the row 12 you decide the level of information you want to see during the process. In fact, to solve the problem, the level is increased and therefore communication via serial communication also becomes part of the program.
Below are the lines that allow you to choose whether to use a 7SD or an LCD, of which a following option determines the type of connection.
The program also includes energy savings. So if you don't use the system for a while 10 seconds the display is deactivated.
In some cases, electrical or mechanical disturbances can extend the ignition period. In fact, not only the activities with the keys renew the period, but also the variations of readings allow to keep the display active.
There is also a constant that chooses the number of samples to be performed for each cell reading. Twenty-five specimens have currently been scheduled. I believe it is the optimal value, because in case of fewer samples too many variations would take place, while in the case of high numbers, then the response to the reading would become somewhat long. Already with forty samples the answer is around the second of time.
Furthermore, there is a risk of disturbing the display of the 7SD, since a module reading is done without active interrupts.
Method of use
The way to use is made up of four buttons.
LOUD (connected to RD4) which is used in two and more stages.
At startup, press briefly to reset the value which then gives the tare point.
Pressing for at least 2 seconds you enter the calibration phase.
UP (connected to RD5) it is used to increase a value during calibration.
If briefly pressed, calibration is exited with the value only in memory.
DOWN (connected to RD6) as for UP, it is used to decrease a value during calibration.
If pressed after the confirmation phase it determines the saving of the calibration in EEPROM.
SETTING (connected to RD7) it has some function as appropriate.
If pressed briefly during the calibration phase, the value is accepted. Except that you have four seconds to accept or ignore saving in EEPROM.
If pressed for at least 2 seconds, then leave the calibration procedure and no changes will be implemented.
In case of fatal error, if pressed then it will reset the system. If it doesn't work out, will mean that there is damage to be verified.
During the presentation with 7SD, which flashes four times, you can stop by pressing any of the four buttons.
Even when energy saving comes into action, any key allows you to reactivate the operation.
As for the calibration, a known weight is placed for the verification and then its value is entered.
The entry shows six zeros (or less for those 7SDs with fewer digits). The decimal point (for 7SD) or the underscore (for LCD) determines the position you want to change. Then with the UP or DOWN keys you can change the value. To move to the next digit on the right, press TARE briefly. If you want to change a digit on the left, you will have to press TARE in succession until the positioning resumes from the first digit on the left.
The calibration factor could also be used as a convenience multiplier. Thus it could be a price or a variable of convenience that serves its purpose. The program does not include entering floating point numbers. The weighing value is also expressed in grams. The point for thousands will automatically be displayed. While for values less than a thousand there is no point.