I am want to display my weighing scale, so to make it I use max 3232 and communication running normal.
But i have some problem when I serial monitor, data appear not perfect, so I try to hyperterminal and the data appears perfect.
My arduino code is
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11 ); // RX, TX <------<<<< use the pins you want
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
}
void loop()
{
while (mySerial.available())
{
Serial.print((char)mySerial.read()); //Serial.write(mySerial.read()); // You can also use: Serial.print((char)mySerial.read());
//delayMicroseconds(200);
}
}
According to the image of the data format, there are only 7 databits and a parity; that's also how you configured your terminal program. You can't configure Serial monitor for that.
You should also setup your SoftwareSerial for that format but data formats it's not supported by SoftwareSerial. Best option for that is to use a board with two or more serial ports.
If you don't care about the parity bit, then set it to 0 before sending to the serial monitor. Software serial expects to see 8 bits, no parity, 1 stop bit, so the parity bit will be input as the most significant bit of an 8-bit value.
sterretje:
According to the image of the data format, there are only 7 databits and a parity; that's also how you configured your terminal program. You can't configure Serial monitor for that.
You should also setup your SoftwareSerial for that format but data formats it's not supported by SoftwareSerial. Best option for that is to use a board with two or more serial ports.
OK, what board with two serial port?
actually i want show the scale data to java program (netbeans)
david_2018:
If you don't care about the parity bit, then set it to 0 before sending to the serial monitor. Software serial expects to see 8 bits, no parity, 1 stop bit, so the parity bit will be input as the most significant bit of an 8-bit value.
mySerial.read() returns the ASCII character in the format of a parity bit in the most significant bit followed by seven data bits. The & symbol is the bitwise logical AND operator. 0x7F is hexidecimal for the binary number 01111111, which when ANDed with the ASCII character will set the most significant bit to 0 and leave the other bits unchanged.
The scale is sending ASCII characters as seven data bits, a parity bit, and a stop bit. Software serial expects eight data bits followed by a stop bit, which causes the parity bit to appear as part of the data, which is then removed by setting the parity bit to zero.
mySerial.read() returns the ASCII character in the format of a parity bit in the most significant bit followed by seven data bits. The & symbol is the bitwise logical AND operator. 0x7F is hexidecimal for the binary number 01111111, which when ANDed with the ASCII character will set the most significant bit to 0 and leave the other bits unchanged.
The scale is sending ASCII characters as seven data bits, a parity bit, and a stop bit. Software serial expects eight data bits followed by a stop bit, which causes the parity bit to appear as part of the data, which is then removed by setting the parity bit to zero.
mySerial.read() returns the ASCII character in the format of a parity bit in the most significant bit followed by seven data bits. The & symbol is the bitwise logical AND operator. 0x7F is hexidecimal for the binary number 01111111, which when ANDed with the ASCII character will set the most significant bit to 0 and leave the other bits unchanged.
The scale is sending ASCII characters as seven data bits, a parity bit, and a stop bit. Software serial expects eight data bits followed by a stop bit, which causes the parity bit to appear as part of the data, which is then removed by setting the parity bit to zero.
ahh, I see , thankyou for your help..
Is it possible I send data to serial without "ST,"
just take +0000.150 Kg to serial monitor?
Your current code (opening post) simply echoes to the PC what is received on mySerial. You can e.g. start the echoing after you have detected the the comma after ST and stop echoing after you have detected the linefeed.
Alternatively, as demonstrated in below linked thread, you can collect the data first (basically read till the linefeed) and next send the message starting at the character after the comma.
sterretje:
Your current code (opening post) simply echoes to the PC what is received on mySerial. You can e.g. start the echoing after you have detected the the comma after ST and stop echoing after you have detected the linefeed.
Alternatively, as demonstrated in below linked thread, you can collect the data first (basically read till the linefeed) and next send the message starting at the character after the comma.