Precision check weigher

Dear friends I'm an informatic ing. but completly new to the arduino platform. I'm interested to realize a check weigher. The target is to realize a machne that value the weight of a product and if it's in the right range push it in a direction, if its' outside the range push it in another direction.

inspired to the industrial check weigher https://www.google.it/search?q=check+weigher&um=1&ie=UTF-8&hl=it&tbm=isch&source=og&sa=N&tab=wi&ei=EHYvUJbFBqbP4QTr4oH4Cw&biw=1024&bih=506&sei=E3YvULeQJ but more more easy

my idea is a sensor that check the weight and send the value tu arduino, if the value is inside a range a small electric motor move the product outside the wheight platform.

my product are 10g / 20g the i think that te problem is the hight precision of the sensor (I need 0.1 - 0.5g) I think that I need: -Arduino - Scale sensor - Amplifier signal - 2 Electric motor

Do you think that arduino can make this? Can you suggest me how to begin? thanks for all Fabio

Start by Googling Arduino and scales..

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1231217442/0 http://ebookbrowse.com/electronic-scale-arduino-doc-d202119380

There are certainly a lot of ways to make a scale, and if you have the time and ambition to try some go for it. I myself would probably try to find a cheap scale online that has some sort of com port that sends out data. Many scales have serial ports that I wouldn't think would be too hard to connect to.

My dear Friends
after Googling alot I have decided to buy a precision weigher with rs232 serial port.
Now the problem is how to receive by Arduino the right weight from the weigher?

If i’ll connect the weigher to my pc with serial and send the EXADECIMAL command 01 73 I obtain like response a string with thw weight for example 0023.05g

I buy a RS232 shield with max 3232 I connect to the weigher, but nothing…
Can you help me?
How can I send to my weigher the HEX 01 73 string and listen the reply?
thanks a lot
Fabio

Hi I give you more information, can you help me? I use Arduino UNO, comnnected to a RS232 shield http://dx.com/p/jy-r2t-v1-2-rs232-serial-port-converter-104325 you can see the connection in this photo http://i49.tinypic.com/3038rqq.jpg

For the rs232 shield i connect the VCC to the +5v of the arduino and the ground to the Arduino Ground For the trasmission I connect the 7 and 8 pin.

I try all examples found in internet by using serial and serial library, but never.

First question: in the code I need to open one or 2 serial port? How i can to be sure that I can write and read on the serial? When I connect the shield to the arduino my pc make a "pling" like i connect a new usb device, is this correct?

thanks for youe support Fabio

The page you linked to for the JY-R2T V1.2 RS232 Serial Port Converter says "It is powered through a mini USB port", but you don't appear to be supplying power to the mini USB port.

Hi Peter
thanks for your reply
I think that the mini usb is an alternative way to power the shield, I think that I can give 5V in 2 ways…
-in my situation the led on the shield power on, and when I try to send a command the tx led power on…bt I can to read (have one output) the serial message from the wigher
tanks
Fabio

rmartin: I think that the mini usb is an alternative way to power the shield, I think that I can give 5V in 2 ways...

Is there any documentation to support that? How much current does it draw from the 5V supply if powered like that? More importantly, what voltage does it drag the Arduino's 5V supply down to in practice?

Hi Peter I found a solution
I try to connect my arduino and shield to a serial COM3 and with another serial converter COM4, I monitor the COM4 and I show that the arduino send correctly the string!!!

This code work!

#include <SoftwareSerial.h>
 
//New serial port for my shield
SoftwareSerial Mx3232Serial =  SoftwareSerial(7, 8);
 
//variabile
//char EchoChar = 'A';
char Str1[ ] = "s";

//String Str1 = " s";
//String Str1 = String(' s',HEX);


String Buffer; unsigned long T;

void setup()  {
//pin7(RX) Input
pinMode(7, INPUT);
//pin8(TX) Output
pinMode(8, OUTPUT);

Mx3232Serial.begin(9600);

Serial.begin(9600); 
}
 
void loop() {
//leggo dalla seriale(pin7)
//EchoChar = PortaSeriale.read();
//invio il dato letto
Mx3232Serial.print(Str1);

//Serial.println(Mx3232Serial.read());
 
Buffer = "";
T = millis();

  while (millis() - T < 10)  {         // read all the chars on the serial 
    while (Mx3232Serial.available() > 0) {
      Buffer += char(Mx3232Serial.read());
    }
  }
  
  if (Buffer.length() > 0) {           // transmit to Serial Monitor        
    Serial.print(Buffer);
  }

delay(1000); 

Serial.print(Str1);

}

Now the problem is, how to send the HEX 01 73 string to my weigher and receive the weight?
If with my serial monitor I send this HEX string it work, with arduino NO!

I try to send this

Mx3232Serial.print(0x01,HEX);
Mx3232Serial.print(0x73,HEX);

but dosen’t work! Now my question is how to dend in HEX this string?
thanks
Fabio

Why are you using print() to send binary data? That is what write() is for. Your value, 0x73, is being converted to a string in HEX format, and that string is being sent to the scale, which, of course, doesn't recognize it.

Hi Pauls tryed also with

Mx3232Serial.write(0x01,HEX);
Mx3232Serial.write(0x73,HEX);

But doesn't work. Is there a way for send all the 2 commands in one way, or it's correct in this way? thanks Fabio

rmartin: But doesn't work.

Of course it didn't work. Look at the documentation for Serial.write() - you are calling it incorrectly.

OH yes, but unfurtunately it don't work =( =( =( =(

Mx3232Serial.write(0x01);
Mx3232Serial.write(0x73);
Mx3232Serial.println(""); // carriage return

have you another idea? my weigher don't reply me, but if I try with a serial port monitor to send 01 73 HEX it reply me!

thanks Fabio

but if I try with a serial port monitor to send 01 73 HEX it reply me!

Which Serial Port Monitor? Post a screen shot of before the send and after the send (the reply).

It's possible that your understanding of what the scale expects could be all wrong. Perhaps it IS expecting "01" and "73", not 0x01 and 0x73.

PaulS:

but if I try with a serial port monitor to send 01 73 HEX it reply me!

Which Serial Port Monitor? Post a screen shot of before the send and after the send (the reply).

It’s possible that your understanding of what the scale expects could be all wrong. Perhaps it IS expecting “01” and “73”, not 0x01 and 0x73.

I have tried wit more and with all work well. Now I use a demo version of Eltima software Serial port monitor 4.0, here you can see a screenshot where with the Serial Port Monitor software I send a string to the Arduino and you can see the string in the Arduino serial Monitor.

After this I think that Arduino and RS232 shield are right connected!

I think that it ll be a problem in the sending or in the reception of the string

thanks for your support
Fabio

I have try to connect another time the serial output of the pc to the Arduino serial, and apparently it work

here you can see the result by sending the aaaa (string) and the 01 73 (hex) with a serial port monitor the Arduino echo serial show aaaa and "space" + s exactly the encoding of the HEX value in string ... and now??? why my weigher don't make me and echo on the Arduino monitor? =( =( =( =( thanks for your support Fabio

Can you help me how I can be sure that my Arduino read correctly on his serial port? I connect the arduino to the weigher but i doesn't receive anithing! thanks Fabio

rmartin: Can you help me how I can be sure that my Arduino read correctly on his serial port? I connect the arduino to the weigher but i doesn't receive anithing! thanks Fabio

It has never been clear to me exactly how these devices are connected together and what each serial connection is being used for.

Perhaps it would be helpful if you could draw a simple block diagram showing how the scales and Arduino are connected to each other and to the PC, and then describe the sequence of messages that you expect to occur between these devices?

I try to explain another time whta I’ll try to do:
My target is read a weigth from My Weigher that have a serial port.

For understand what my serial shield write and read I have used a USB-Serial converter and I monitor It with a serial port monitor software.

If I connect my Serial port monitor software (COM4) directly to the weigher and I send the right HEX command #01 #73 I receive from the weigher the right wheight

now with my Arduino I try to replicate the same command for obtain the weight

#include <SoftwareSerial.h>
SoftwareSerial Mx3232Serial(7, 8);
String Buffer; unsigned long T;
void setup()  {
  Mx3232Serial.begin(9600);
  Serial.begin(9600); 
}
 
void loop() {
Buffer = ""; T = millis(); 
Serial.print("B "); 
Mx3232Serial.write(0x01);
Mx3232Serial.write(0x73);
//Mx3232Serial.write(0x0D);

  while (millis() - T < 10)  {         // read all the chars on the serial 
    Serial.print("D1");
    while (Mx3232Serial.available() > 0) {
      Buffer += (Mx3232Serial.read());
      Serial.print("Dentro");
    }
  }
  if (Buffer.length() > 0) {           // transmit to Serial Monitor        
    Serial.print("Trovato: "); Serial.print(Buffer);
  }

delay(5000);
Serial.print("E"); Serial.print(Buffer); Serial.print("\r\n");
}

Now If I connect the Arduino Serial to the weigher I doesen’t receive nothing.

For verify that my code work I have connected the arduino COM3 to the Usb Serial Converter COM4 and use my serial port monito for show what My arduino send

If i send someting on the port my arduino find it…

Now the question is why I can’t receive anithing from my wheigher?

I hope to be clear
thanks a lot for your support!
Fabio

It’s not a great deal clearer, to be honest, but I think I can follow what you’ve done.

You have a USB-to-RS232 converter which you can connect to the weigher and prove that the weigher works.

You also have a TTL-to-RS232 converter and an RS232 gender-changer so you can connect a SoftwareSerial on the Arduino either to the USB-to-RS232 converter, or to the weigher.

When you connect it to the USB-to-RS232 converter (the case shown in your picture) you can see that the Arduino is writing the expected sequence 0x01 0x73 which arrive at COM4, and characters typed into COM4 are received at the Arduino. Your trace code doesn’t seem to print out the received characters properly, perhaps because SoftwareSerial returns an integer and you are using the String append operator to add that to a string so they are getting decimalised. Your trace code really needs to be sorted out so that it prints the bytes received, and not some mangled representation of them. You’d do yourself a favour by getting rid of the String class as well.

You don’t say what happens in the other scenario when you connect the SoftwareSerial to RS232-to-TTL to the weigher. Presumably it tries to send out 0x01 0x73. Does the Arduino receive anything back at all? Have you tried crossing the SoftwareSerial Tx/Rx lines over? I don’t know which of your cables are crossover cables and I don’t know what’s going on inside that gender changer, but these lines need to be crossed somewhere along the way.