Hi guys and gals,
I had posted a question regarding a piezo in the general electronics but with no real response or suggestions, I think maybe I'm taking the wrong approach and in the wrong forum? Below I will describe my situation. I'm really new to electronics and striking out so I'm open for any and all suggestions!
I'm trying to sort two screws that are nearly identical. They're very small, 3mm head diameter, 1.5mm major diameter. The only difference between them is one is 3.5mm thread length, the other is 4. I have a belt conveyor that holds the screws by the head, leaving them hanging down, making the thread tips there to be checked.I'm trying to get a reading on an Uno from a light dragging of a screw tip on the ceramic of a piezo. Attached is a model of the actual screw sizes and my initial idea for a piezo for recognition.
Using the piezo, the reading is incredibly inconsistent. Just the piezo alone with a 1M resistor and analogue input, I received reading around 1.0 an 2.0 occasionally but was very inconsistent. I can't the input to divide by 100 and started getting readings like .02, .40, .35, .10 etc at much better frequencies but was still not accurate all the time. I had asked the question in the general electronics forum about using an op amp to increase the signal but to no one seemed to know or think this would work? Below is the code I was using for this layout.
Next I tried the KY-036 touch sensor externally from the setup and thought it was good to go, holding the screws by the head with needle nose pliers making sure to only touch the rubber grips but I guess my hand was still conducting enough through to trigger the sensor? When I put the touch sensor in the setup and the belt was driving the sensor wouldn't read.
I had also thought of a load cell that could measure grains, as these are very light parts, but looking into a couple videos on how to make one like some of the YouTube "weigh an eyelash" ones it seems pretty tough for me to do with such limited electronic experience and I would have to redesign the mechanics of the setup and the scales seems pretty finicky too.
Does anyone think the KY-010 sensor is worth a shot? I don't know how "fine" the line is for breaking the sight?
I know there are vision systems that can distinguish this kind of difference but I was trying to build something for a couple hundred bucks tops, not spend $2000+. I thought about something like the Pixy cam through a magnifying glass or something, but that's really best for identifying color differences it seems, where as these two screws are both silver (titanium) so that seems out.
Like I said I'm open to any and all practical solutions. Thank you for any help you can provide!
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int ledRedPin = 13; // longParts red LED signal
const float redKnockSensor = A0; // input for long parts piezo
const int thresholdMin = 2.0; // min piezo voltage
const int thresholdMax = 25.00; // max piezo voltage
float longParts = 0; // Counter reset for long parts.
float redSensorReading = 0;
int ledRedState = LOW;
void setup() {
lcd.begin(16, 2);
lcd.setCursor(0,1);
lcd.print("Long parts:");
lcd.setCursor(13,1);
lcd.print(longParts);
pinMode(ledRedPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
lcd.setCursor(0,1);
lcd.print("Long Parts:");
lcd.setCursor(13,1);
lcd.print(longParts);
redSensorReading = analogRead(redKnockSensor);
//redSensorReading = redSensorReading /100 ;
Serial.println(redSensorReading);
if ((redSensorReading > 0) && (redSensorReading < thresholdMax))
{
++longParts;
ledRedState = HIGH;
digitalWrite(ledRedPin, ledRedState);
redSensorReading = 0;
ledRedState = LOW;
delay(1000);
digitalWrite(ledRedPin, ledRedState);
}
delay(300);
}