7bit aruino converter for scalees

Hi all

I am currently working on a project that involves taking the RS232 signal from a set of scales and converting it to an analogue signal for use in an PLC.

The RS232 output has a baud rate of 1200, 7 bits,1 stop bit and an odd parity.
to test this signal i used an example project from matlab for reading the serial data from the arduino to check that the values were correct as well as the serial monitor in arduino.
The code is copied from the example with the changes made to create the same signal

/*
SineWavePoints

Write sine wave points to the serial port, followed by the Carriage Return and LineFeed terminator.
*/

int i = 0;

// The setup routine runs once when you press reset:
void setup() {
// Initialize serial communication at 9600 bits per second:
Serial.begin(1200,SERIAL_7O1);
}

// The loop routine runs over and over again forever:
void loop() {
// Write the sinewave points, followed by the terminator "Carriage Return" and "Linefeed".
Serial.print(sin(i*50.0/360.0));
Serial.write(13);
Serial.write(10);
i += 1;
}

however when i read the signal in arduino it is gibberish and mstly question marks e.g.
⸮⸮⸮⸮7⸮
⸮⸮⸮⸮⸮7
⸮⸮⸮⸮⸮⸮
⸮⸮⸮⸮4⸮
⸮⸮⸮⸮⸮1
⸮⸮⸮⸮17
⸮⸮⸮⸮⸮⸮

however the matlab readings seem corret as it produces a decimalised string of numbers.
does anyone know how to read the correct data in the serial monitor i have checked the baud rate in the monitor and it is correct.

Do you have Matlab set to seven bit odd parity?

I am currently working on a project that involves taking the RS232 signal from a set of scales and converting it to an analogue signal for use in an PLC.

I note the use of RS232

What exactly is connected to what in your project ?
Is the RS232 signal being fed to the Arduino, for instance ?

The plan is to take the serial from the RS232 and plug it into the arduino to use a 4-20ma dac module with the arduino, the matlab script is
s = serial('COM1'); %set to relevant com port
s.DataBits = 7;
s.Baudrate = 1200;
s.Parity = 'odd';
s.StopBits = 1;
set(s,'timeout',10)
s.Terminator = 'CR';

then using commands such as fgets(s) to retrive data

and is set to 7 bit and the same parity and settings as the arduino,but my issue is that in the arduino serial monitor it does not appear to be reading the 7 bit string which is an issue as that is the job o the arduino in this project

The serial monitor in the IDE defaults to 8 bits no parity, you will need to change the settings in the preferences.txt file if you want to use 7 bits with odd parity, and I'm not sure what affect that might have on uploading code.

The other option is to use software serial for your scale and leave Serial for communications with the PC.

The plan is to take the serial from the RS232 and plug it into the arduino

I thought that might be what you were doing. The Arduino serial interface is not RS232 compatible. Do you have a converter fitted ?

oh i assuemed they would be if the setting were the same what is the issue and what would you recommend to get around this

Thanks David that worked