Sorting by Weight

Thread Starter

himre20

Joined Oct 30, 2024
5
Hello everyone!

I would like your help with something very big for me.

I want to recreate this project:
https://www.instructables.com/DIY-Sorting-by-Weight/

I am a complete beginner. I have no experience with circuits, nor with Arduino. However, what I do have is a big dose of motivation.

So I really want to make this machine, for two reasons:

1. Because I find it very useful and it could save me a lot of time. (I am an agricultural engineering student)

2 With this I want to get into the world of arduino and start learning.

My first question would be how can I make the basic wiring and connections to the breadboard?

If someone could give me some guidance, I would be very grateful, because I can't really find any information about this on the page linked above (or maybe I just don't understand it).

There is a picture at 0:28 in this video that may also help.


I already have the parts, but the difference is that I would use an Arduino Uno R3, not a Nano as in the link above.

Any answers would be appreciated!

Have a nice day everyone!

Best regards,
Imre
 

Thread Starter

himre20

Joined Oct 30, 2024
5
hi himre.
Are the objects you want to sort, are always nuts/bolts etc.

E

HI ericgibbs!

I would like to sort several things with this solution and it is not a priority to sort only nuts and bolts.

In fact, I would say it is not so important that I don't really need the shaker part on the machine. The very first thing I would like to know is how to make the servo move depending on the Load cell values. I think this would be the basis of the mechanism.

I want to make the servo rotate at a certain angle between certain gram intervals

E.g.:

40-50 grams = 15°
51-60 grams = 35°
and so on..
 

ericgibbs

Joined Jan 29, 2010
21,391
hi,
Check these 2 video's, for motor control examples.
E


Update:
By clicking on more.... under the video image, you can download the actual Arduino coding, in order to test your project modules.



 

Attachments

Last edited:

panic mode

Joined Oct 10, 2011
4,866
Sure. I'm over that. I've watched a few videos and I know the basics
sorry but that is a hard no...

that is not experience or even training. this only gives you a very glimpse of what it takes to do things - it is a very superficial summary of key steps, nothing more. watching videos and doing it yourself are two very different things... if you want to learn something - you got to actually do it ... yourself...

there is tons of videos out there on just about anything and the whole world is spending considerable amount of time watching them. yet those billions of observers are not even a smidge closer to being able to attempt what they saw, not to mention make it work ... even at the most basic level.
 

Reloadron

Joined Jan 15, 2015
7,857
E.g.:

40-50 grams = 15°
51-60 grams = 35°
and so on..
What you want to do is really not all that difficult. It's a matter of adjusting your code. Start by playing around with some basic servo motor code using your Arduino or similar micro-controller. You will be using some If and Case statements. The learning curve is not all that steep. Start with simple sketches and look at servo-motor example code.

Ron
 

Thread Starter

himre20

Joined Oct 30, 2024
5
hi,
Check these 2 video's, for motor control examples.
E


Update:
By clicking on more.... under the video image, you can download the actual Arduino coding, in order to test your project modules.




Hello again!

Thank you all
for the helpful tips and videos!

I've been working on the project as time allowed.

What I have achieved:
- I managed to get the load cell + hx711 combo to work. I was able to weigh with it.
- I managed to learn how to use the servo based on the code.

@ericgibbs
I managed to find a code that you helped a student with a similar problem.

This is it: https://forum.allaboutcircuits.com/threads/servo-motor-working-with-load-cell-on-arduino-uno.175904/

I downloaded the code you posted in this thread and it worked!

This is the code:


Code:
#include "HX711.h"
#include <Wire.h>
//#include <LiquidCrystal_I2C.h>
#include <Servo.h>

Servo myservo;

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = A1;
const int LOADCELL_SCK_PIN = A0;
int servoPin = 8;

float berat =123;

//LiquidCrystal_I2C lcd(0x27, 16, 2);
HX711 scale;

void setup() {
  Serial.begin(9600);
  Serial.println("Make sure there is no load okay?");
//  lcd.begin();
//  lcd.backlight();
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale(96.3);                      // this value is obtained by calibrating the scale with known weights; see the README for details
  scale.tare(50);                        // reset the scale to 0
  Serial.println("Go weight it");
  myservo.attach(8,600,2300);
}

void loop() {
 // Serial.print("Weight");
  float berat= scale.get_units(25);
  if(berat<=0.1)
  {
  berat=0.0;
 
  berat=0.0; // dummy for testing ONLY ***************
 // berat=567; // dummy for testing ONLY ***************
 
  }
  Serial.print("TestWt= " );
  Serial.println(berat);
 
  if(berat<500)
  {
     Serial.print(" Weight<500; g=");
     Serial.print(berat);
  /*
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Go weight it");
  lcd.setCursor(0, 1);
  lcd.print("Weight= ");
  lcd.print(berat,1);
  lcd.print(" g");
  */
  }
  if(berat>=500)
  {
      Serial.print(" Weight>=500; g=");
     Serial.print(berat); 
  /*
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Go weight it");
  float hasil=berat/1000;
  lcd.setCursor(0, 1);
  lcd.print("Weight= ");
  lcd.print(hasil);
  lcd.print(" kg");
  */
  }
  // scale.power_down();
  delay(1000);
  // scale.power_up();
 
  if(berat<200) {
    Serial.println("  Servo=180");
    Serial.println();
    myservo.write(180);
    delay(1000);
  }
  else {
     Serial.println("  Servo=000");
       Serial.println();
    myservo.write(0);
  }
}

And my current circuit looks like this:

https://app.cirkitdesigner.com/project/c31a9a57-208a-4f78-bace-1653b13358f6


With this code, it splits the servo nicely in two directions.

Weight<500 / Servo=180°
Weight>=500 / Servo=000°

Looks like I have the basics of the structure but I have 2 more questions:

1. How can I calibrate the load cell ?
2. How can I extend the code so that the servo can separate in several directions ?


As I mentioned before:

"I want to make the servo rotate at a certain angle between certain gram intervals

E.g.:

40-50 grams = 15°
51-60 grams = 35°
and so on.."


Thank you very much if you can help me again!

Best regards,
Imre
 

Beau Schwabe

Joined Nov 7, 2019
186
Just keep in mind that the HX711 takes a few seconds to stabilize... Even though it is nothing more than an onboard voltage regulator with an instrumentation amplifier feeding directly into an ADC with some odd communication requirements... it still takes awhile to settle.
 

Thread Starter

himre20

Joined Oct 30, 2024
5
Just keep in mind that the HX711 takes a few seconds to stabilize... Even though it is nothing more than an onboard voltage regulator with an instrumentation amplifier feeding directly into an ADC with some odd communication requirements... it still takes awhile to settle.
@Beau Schwabe
Thank you for your valuable advice. I will keep it in mind!

Could you help me with the code I posted recently?
 

Reloadron

Joined Jan 15, 2015
7,857
1. How can I calibrate the load cell ?
2. How can I extend the code so that the servo can separate in several directions ?
To accurately calibrate your load cell you will need known weights. Depending on how accurate you want to get. Normally I would do several points across the span of the cell. Just as an example if I have a 100 gram load cell I would apply 0, 20, 40, 60, 80 and 100 gram weights. Now I realize precision weight sets are not quite always available. The quick and dirty method is find some lead weights, like fishing sinkers. Most pharmacies have a precision scale so bring a few weights of approximately 10% and 90% of your full scale range. Ask very politely if the pharmacist will weigh your weights and note the values. This way you have a good idea of your actual weight. This is a cheapie transfer method, your weights become a transfer standard or a "known".

Look at using If or Case statements in your code. Such If something is > greater than and < less than do something. The something being go to your positions.

Over the weekend I might have time to give you some code samples.

Ron
 

ericgibbs

Joined Jan 29, 2010
21,391
Could you help me with the code I posted recently?
hi h20,
Is the Code you are requesting help with, is the Code I posted?, if yes, what help do you require.?
Give me the specification you are trying to achieve.
E
 
Top