Pages: 1 [2]   Go Down
Author Topic: Precision check weigher  (Read 2907 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?  smiley-cry smiley-cry smiley-cry smiley-cry
thanks for your support
Fabio
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11196
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
#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
« Last Edit: January 24, 2013, 02:25:11 pm by rmartin » Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11196
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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....  smiley-confuse

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

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
« Last Edit: January 25, 2013, 08:38:46 am by rmartin » Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11196
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
http://i46.tinypic.com/2d801w.jpg

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
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11196
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11196
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: 1 [2]   Go Up
Jump to: