Precision check weigher

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.

@PeterH

PeterH:
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......

Yes, of cource I'll can trace better after, now I'm interested only to show that my Arduino code work well and trace something received....
I'm interested to this because I immagine that if it work with my Software serial it'll work also with my weigher, but with the weigher I haven't trace nothing.... :~

PeterH:
You don't say what happens in the other scenario when you connect the SoftwareSerial to RS232-to-TTL to the weigher.

Wat do you mean? I can connect my software serial (with my USB to Serial converter) only to the weigher serial or to the RS232 Arduino shield..... what do you mean with connect the SoftwareSerial to RS232-to-TTL to the weigher

PeterH:
Have you tried crossing the SoftwareSerial Tx/Rx lines over?

I have tryed to chage my cable from pin 7 to 8 but and also in the code... but never change.
In my actually configuration pin 8 RX and pin 7 TX in this way when I connect the arduino with the RS232 shield to the USB Serial converter and I monitor the signal the HEX character sended are correct, is for this that I think this configuration work well....

I hope to be more clear now?

Fabio

rmartin:
Wat do you mean? I can connect my software serial (with my USB to Serial converter) only to the weigher serial or to the RS232 Arduino shield..... what do you mean with connect the SoftwareSerial to RS232-to-TTL to the weigher

I'm sure that isn't what you meant to write, and in situations like this it's important to be accurate. I don't see how the USB-to-RS232 converter is involved at all here.

I would expect to see the software serial pins connected to your TTL-to-RS232 converter, and that connected to the weigher - perhaps with a gender changer in between. But you haven't shown how you had them connected or what happened in this scenario.

Hi Peter

I don't understand exacltly your reply, I connect my RS232 shield to my USB serial converter for monitor the signal that my Arduino output

in this image you can see the connection

In this way I can to monitor what my shied output, or not. Is this system wrong?
How I can to be sure that my shield work well?
Fabio

Yes, you've explained and shown how you can connect to the PC. From what you've said, everything works as expected in that case.

However, the case you're trying to get working is when the Arduino is connected to the weigher.

Yes, I don't receive nothing from the weigher.... how I ca tobe sure that my code works well? And why mi weigher doesn't reply to me?
Are there some error in the code?

thanks
Fabio

I don't see any error in the code, but you haven't shown or explained how you're connecting the weigher to the Arduino. I don't mean in terms of 'plug the weigher's D-sub connector into the TTL-to-RS232 converter', but which terminals are connected to what? Have you identified the TX and RX pins? Does it use CTS/DTR? Are the data and signal lines crossed correctly? You have lots of adapters and connectors in there and I don't know what's going on inside them.

http://giocarduino.altervista.org/z0-selettore-di-peso.pdf