Working With the Phidgets Scale Kit

by SnapOffensive in Circuits > Sensors

354 Views, 1 Favorites, 0 Comments

Working With the Phidgets Scale Kit

FJMYD4EKV77GWLL.jpeg

In this Instructable, I will be showing you how to set up and use the new Phidgets Scale Kit (KIT4015_0) as well as demonstrate some of the use cases. This thing is brand new, and getting to work with it was a super easy and fun experience.


You will also need a VINT controller like a HUB0000_0 or SBC3003_0. If you happen to already have a Phidgets Getting Started Kit you can use the hub that came with it for this.


The provided code is written in Python3, and this tutorial will assume you have a basic understanding of how to work with Python3. It is designed to be as easy to follow as possible, so if Python is not your language give a try at re-writing the program in your language of choice!

Supplies

Setup the Scale

Wiring.jpg
Wiring2.jpg

First, we will need to wire the scale to the Wheatstone Bridge Phidget. This Phidget is ultimately the brains of the scale, as it is responsible for sending and measuring voltage from the load cells.


There are four wires which come off the load cell and the order in which they are wired is important. For this tutorial I recommend you connect the wires to channel 0. The four wires should be connected as follows:

Red             +5V
Green		+
White		-
Black		G

Connect VINT Devices

This is one of the easiest steps. First, start by plugging the included VINT cable into the Wheatstone Bridge Phidget, then plug the other end into your VINT hub on port 0. Finally, if you haven't already, connect your VINT hub to your computer.

Test the Scale

PhidgetsControlPanel.PNG

Now that everything is connected up it is time to test the scale. If you haven't already installed the Phidgets control panel, you will want to do that now. The link to the windows download can be found here.


Once installed you can open up the control panel and find the Wheatstone Bridge Phidget. You will want to double click on the name, and again on Bridge Input 0. An additional window will appear.


In the Data section, your voltage ratio should look something like mine, provided you have nothing on the scale. For now we will leave all the values the way they are, but later on feel free to come back and mess with them to see how they affect your readings. Simply press down on the scale and observe how the voltage changes. For now this doesn't mean anything, but we will later convert these readings into a weight.

Calibrating the Scale

First, we will need to get the offset from the scale. How you do this is up to you, but I used the script written in Python below. You can either copy this to a file and run it, or paste it right into the Python3 interpreter and run it there.


You may need to import the Phidgets Python libraries first if you have never worked with Phidgets before by running

pip3 install Phidget22


Now run the following script:

# Import Phidgets Library
from Phidget22.Devices.VoltageRatioInput import *
# Import time library for sleep statement
import time

# Create Object
scale = VoltageRatioInput()

# Open Phidgets Scale with 1000ms timeout
scale.openWaitForAttachment(1000)

# Print Offset
while True:
    print("Scale Offset Value {}".format(scale.getVoltageRatio()))
    time.sleep(0.25)


You will want to record the value given in the output of the script, it may vary slightly so average it if you need to.

Using the Scale

Now that we know the offset the rest is easy. At this point, you may choose to write your own code for the scale, or you can look at my example below.


Continuing out of the same file used above we only have to add three lines of code to the program. For convenience, you may choose to copy and paste this into your current project to see it in action, or go through the code yourself and add the lines manually.


You will need to add your offset value in place of <offset value> first. Then you should be able to run the program and see the weight outputted to your screen.

# Import Phidgets Library
from Phidget22.Devices.VoltageRatioInput import *
# Import time library for sleep statement
import time


# Offset
offsetValue = <offset value>

# Create Object
scale = VoltageRatioInput()

# Open Phidgets Scale with 1000ms timeout
scale.openWaitForAttachment(1000)

# Print scale values
while True:
    # Calculate actual weight from voltage 
    scaleWeight = 4700 * (scale.getVoltageRatio() - offsetValue)
    # Display weight to terminal 
    print("{:.2f} kg".format(scaleWeight))
    time.sleep(0.25) 


I have also attached a script written in Python that will automatically calculate the offset of your scale every time it runs. Just make sure you remove anything placed on top of the scale before running the program, or else your results will be inaccurate.

Downloads

Run the Program

After running the program you should see 0.00kg outputting to the terminal, but keep in mind that we have not yet tuned the scale and so your mileage may vary.


Now try placing something on the scale and watch as the weight changes. You can see how accurate it is by placing something on the scale with a known weight. Something like your phone is great as you can easily find its weight online, although keep in mind if you have a case or any extra things stuck on your phone it may change the weight slightly.


You may wonder why we multiply by 4700 in order to get the weight of the scale. This value is used in order to translate the voltage from the scale into kg, and can be tuned to provide a more accurate measurement by using a known weight.

Change Load Cells

20210929_142202.jpg

The scale should come pre-installed with a 5kg load cell in it. Depending on what you want to use the scale for you may want to change out the load cell. To do this simply undo the four bolts with the provided hex key. It is best to tackle this in pairs, doing the top two first and then the bottom two. Make sure to note which direction the arrow is pointing when you remove and install the load cells.


Simply rewire the new load cell as described in step 1 and you should be good to go.

Conclusion

All in all the new scale kit is very easy to use, and will be a great addition to any hobbyists looking to play with IoT-based weight measurements. It is also really neat to gain a better understanding of one of the many ways we measure weight digitally. I encourage you to play around with the code provided and try making projects of your own.