Interpretation of a logic analizer trace to a serial.write fuction.

I hope I get this across ok
I have the RS232 trace from a logic analyzer and have decoded the binary from it which was straight forwards. Now I need to feed that same signal back into another machine.
I have converted all the binary to decimal and need to serial.send it as far as I know.
Is it simply

' Serial.write ( mynumber in decimal ) '

I have no feed back from the machine so I'm shooting in the dark until it initializes and sparks into life.

It is IF you have the baud rate correct and the number of stop bits set correctly. I guess to just send one character, the stop bits don't matter. So, why have you not tried it?

Paul

I have the baud rate and worked out the stop bits and such like from my trace,
The question is do I have to send the data a single bit at a time or will the Arduino simply convert my decimal byte to a binary stream of 1 and 0`s and send that out down the serial line.
As an example how would I send the decimal numbers 234,123,54.
I have all may data setup in an array but this is the only snippet of the bit I'm stuck on right now.

void setup() {
Serial.begin(9600);
}
Void loop(){
serial.write(234);
serial.write(123);
serial.write(54);
}

Any chance that you swapped the bits around while analysing the output of the logic analyser?

Does the data that you send make sense if you check it against the documentation of the (for us) unknown other machine? If you swap the bits around, you get 0x67, 0x5F and 0x1B which are valid ascii characters and might make more sense.

All the data is valid and correct. Unfortunately its data to print 4 state bar codes with an industrial inkjet printer so it will never look like recognisable patern or even use ascii code in some cases.
The issue I have is how can I send decimal data down the serial line. Do I leave it as decimal ( like the example above ) or do I have to change it back to binary and send it a single bit at a time.
Im sure its really simple but Im so deep in it I just can't see the trees for the foresst.

The question is do I have to send the data a single bit at a time or will the Arduino simply convert my decimal byte to a binary stream of 1 and 0`s and send that out down the serial line.

What do you mean be a 'decimal byte'? A byte is 8 bits of binary, decimal doesn't come into it.
Yes, you have to sent a byte at a time, the Arduino will send 8 bits serial for each byte, plus associated start and stop bits.

You need to be clear about what you actually want to send, are you sending raw binary or are you sending ASCII ? For example, for your '234,123,54' which of the following do you want to send:
0x02 (b0000 0010) etc
0x03
0x04
etc
Or
0x32 (ASCII for 2)
0x33 (ASCII for 3)
0x34 (ASCII for 4)
etc
Or do you want to send 0x1653E82 (Hex for 234,123,54)
Or even, just possibly (but probably not)
0x23 (Binary coded decimal for 23)
0x41
0x23
etc

If you want to send ASCII then Serial.print("234,123,54"); will send 10 bytes of ASCII (8 bytes for the digits plus the commas between the digits.)

If you want to send binary then Serial.write(0x02); will send b0000 0010.

If you want to send BCD then Serial.write(0x23); will send b0010 0011.

You also have to consider whether to send the least or the most significant digit first, does the machine expect to receive 23412354 or does it expect 45321432? (I would suspect the first is correct, but you have to be sure).

I hope that helps.

Thats exactly the answer I was looking for.

0x23 (Binary coded decimal for 23)
Serial.write(0x02); will send b0000 0010.

I do realise this may be a simple question but from my point of view insurmountable. Now I can progress now I understand it all.
Thank you all very much so pleased you are there to help us.

I do realise this may be a simple question

I think it's a simple question with many possible answers!

Thank you all very much so pleased you are there to help us.

My pleasure :slight_smile: