Powder trickler with Kern scale and rs232 comms

Hi,

i started work on powder trickler for charging rifle cartridges. Its a simple setup with KERN PCB100 scale (quite affordable in EU compared to some other brands) which has a RS232 communications port and various modes of data stream output.

Idea is to use arduino uno + rs232 shield + adafruit motor shield. One to read data stream off scale and another to control stepper motor to dispense powder at various speeds until final charge is met. I have been also considering using LCD screen to display and set charge however i would prefer to keep it simple.

Programming logic is something like this:

-ignore values - and 0 and if at those levels do nothing with motors
-if you read a stable weight in range between 20 and 110 grains for a period of time set this as charge that is to be dispensed
-until various (to be tuned) % of final charge move motor at different speed until inside certain area or at full charge
-rinse and repeat

Problems i discovered while trying to write the logic:

-scale outputs at certain speed (regardless of baud rate) and my RS232 reading code can (without delay(17) read 0.00 in between valid readings from scale (which of course hinders any accurate motor control based on those readings)
-scale reads weight in intermediate weights (you put for example 50grains it will go 0,20,35,46,50 which is good however when you remove weight it will go gradually down as well - which is absolutely not good as you need to have motor shut after charge is dropped)

The first issue i solved with delay command the second i’m thing of some kind of read delay however i want this to be robust, easy to use and fast and entering any kinds of hardcoded delays doesn’t really help.

So far i’m just testing the behaviour (without tuning various speeds) and if someone has a better approach than the one i have described i’d be very thankful. Just to add i’m completely new to the programming and ardiuno as well so bear with me…

#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>

Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_StepperMotor *motor = AFMS.getStepper(200, 2);

SoftwareSerial myserial(2, 3, false); //RX, TX

String readString;
boolean stable = false;
float teza = 0;
float load = 60;


void setup() {
  myserial.begin(9600);
  Serial.begin(9600);
  AFMS.begin(); 
  TWBR = ((F_CPU /400000l) - 16) / 2; // Change the i2c clock to 400KHz
  
}

void loop() {

    
      beriport();

if ((teza > 0) && ( teza <= load * 0.8)){ engineqstep();}



Serial.println(teza);Serial.println(stable);

//enginestop();
     
      stable = false; //resetira vrednost na nulo
      }
  

void beriport() {    //funkcija za branje porta

      while (myserial.available()) {
       delay(17);  //zaradi bufferja
      char c = myserial.read();  //preberi vrednost enega byta
        if (c == '\r') {break;}  //na carrier return končaj branje ker imaš en string od tehtnice
        readString += c; //prestavi sporočilo v string
        }

      if  (readString.charAt(13) == 'g') {   stable = true;   }   //preveri ali je sporočena teža stabilna ali ne
                
           teza = readString.toFloat();
           readString="";
}



void enginefast() {   //funkcija za hitro doziranje

  motor->setSpeed(60);  // Hitrost v RPM omejena s tipom motorja in močjo
  motor->step(150, FORWARD, INTERLEAVE);
  
 

}

void enginemed() { //funkcija za srednje doziranje

 motor->setSpeed(30);  // Hitrost v RPM omejena s tipom motorja in močjo
  motor->step(60, FORWARD, INTERLEAVE);
  



}


void engineslow() { //funkcija za počasno doziranje

 motor->setSpeed(10);  // Hitrost v RPM omejena s tipom motorja in močjo
  motor->step(20, FORWARD, INTERLEAVE);
 

}

void enginestep() { //funkcija za najbolj fino končevanje
   motor->setSpeed(10);  // Hitrost v RPM omejena s tipom motorja in močjo
  motor->onestep(FORWARD, INTERLEAVE);

}

void engineqstep() { //quickstep funkcija optimirana, potrebno popraviti library s quickstep funkcijo
     
    motor->quickStepInit();
    motor->quickstep(FORWARD);
    //delayMicroseconds(250);
    
}


void enginestop() {
  motor->release();
}

Are you certain that you need the scale to be part of the final project? You may find that if you perform a certain number of motor steps, that will reliably dispense a sufficiently accurate weight of powder.

No powder dispensers are precise things in the range of 0.02grain (up to one kernel of smokeless powder). Powder tricklers (part which dispenses) are not, they are usually just a tube with vibrating or rotating engine attached to it which pretty much randomly tricklers kernels of powder to container/scale, just google powder trickler, hornady dispenser etc... Basically a precise scale is 99.99% of entire project and usually used manually (which is obvously slow) hence the motor/computer to drive it like here-> https://www.youtube.com/watch?v=4eCIM8GQkWU

Pardon my ignorance. Why not use a more precise dispensing mechanism so that the scales are not needed? For an example something with an Archimedes screw? Is there a danger of explosion?

In the video, and in your project, a stepper motor does not seem to be the appropriate type of motor to operate the dispenser. An ordinary DC motor with gearbox is what I would have suggested. Much cheaper and easier to drive. The special properties of a stepper motor are wasted here.

Apologies for questioning your approach to the problem rather than helping you fix your code! But it's something most people on this forum would do first, I think.

I was considering also regular DC motor but figured stepper would have more options and was also readily available to me.

Problem with powder dispensing is that its of various types (not to go into details on smokeless powder but suffice it to say there are many different shapes, sizes of particles/kernels) and most of the general non motorized dispensers use volumetric methods (like you propose) but those are not precise (+- ~1 grain) enough. Powder will simply not meter consistently through any type of tubing, screw, shaker etc... The way scale based trickler does its job is that powder is taken into a tube which is then shaken or rotated at various speeds (farther from target faster you can trickle) until just about hitting the target charge where this tube is rotated for small amounts (stepper) so that in the most extreme kernel or two of smokeless powder drop on a scale. 1 kernel is usually around 0.02grains and the target for a quality long range powder load is +- 0.1 grain (or better as that translates to roughly 10fps speed difference at muzzle end).

What i need is and idea elegant not brute force like "don't read rs232 after hitting target charge for 2 seconds" since time is of an essence. Target trickle time from either zero or initial manual scoop dump is roughly 15s or less and every second added to this is counterproductive as idea is to do it while person is seating bullet on previous round (to get a steady rhythm and not waste time - making ammo is not really the fun part :) ). Also any input on RS232 comms would be welcomed as to why Arduino is reading more than the scale provides i find it difficult to debug with Serial.println only and not able to see values of variables on the fly.

PaulRB: Pardon my ignorance. Why not use a more precise dispensing mechanism so that the scales are not needed? For an example something with an Archimedes screw? Is there a danger of explosion?

In the video, and in your project, a stepper motor does not seem to be the appropriate type of motor to operate the dispenser. An ordinary DC motor with gearbox is what I would have suggested. Much cheaper and easier to drive. The special properties of a stepper motor are wasted here.

Apologies for questioning your approach to the problem rather than helping you fix your code! But it's something most people on this forum would do first, I think.

It is obvious that you have never done much reloading. The amount of powder needs to be measured very very accurately and the grains don't always have a uniform size distribution. The scale really is necessary in this operation.

There's not any danger of explosion, but you do want all the shells you reload to have the same properties and fire the same. If my shots are all over the place I want it to be because I'm a shitty shot and not because my ammo has variations.

There's not any danger of explosion,

Well, how about an uncontrollable rapid expansion of gases?

I've never been partial to a trickler, just for the reasons already stated. Instead of trying to modify a trickler, perhaps it would be easier to make a simple unit. Maybe a vibration motor could be used using pwm.

tinman13kup: Well, how about an uncontrollable rapid expansion of gases?

Well I meant in the sense of any extra danger coming from having slightly more or less powder.

Well I meant in the sense of any extra danger coming from having slightly more or less powder.

Oh, than no, I agree with you. I took you as saying there was no danger with a pound of powder out..

This one takes a slightly different approach. Maybe there's an idea here you could use.

dougp:
This one takes a slightly different approach. Maybe there’s an idea here you could use.

Whats a nylon warsher?

That looks to be about what I was talking about. A vibration motor moves the powder down the tube. Perhaps if you can get the scale to talk to the arduino, you could automate the charging process to where the arduino dumps the main charge (big servo?), then activates the trickler until a preset weight is reached.

When you get it all figured out, let me know and I’ll send you a bunch of brass to make whole again.

Actually i managed to solve a problem with "delay" built into a while loop. I had problem since i didn't realize that when you enter another while loop branch the rs232 stay out of it so i simply moved code for weight reading inside the while loop which now checks weight as in "while weight is in target interval do nothing and when it drops below jump out of the loop with a delay of two seconds" and main code kicks back in and reads weight at 0 or negative (as powder has been removed).

Delay won't affect anything as it takes more than two seconds to drop powder into the brass and return pan to scale so everything is good.

What i didn't write is that this scale has also underside weighting option which might come in handy in next stage where this contraption will be upgraded to hang above the reloading press and drop metered charge into the powder die...