Serial config for blood pressure monitor UA767PC

I have a RS232 serial shield I bought from sparkfun for my Arduino Uno. I am trying to communicate with this blood pressure monitor the UA767PC but with no success. The documentation states the protocol they use from this data sheet.

UA767PC RS232 command set and format PDF

Transmission Protocol
Method: Asynchronous transmission, bi-directional
Baud rate: 9600 bps
Data bit: 8 bit
Parity: none
Start bit: 1 bit
Stop bit: 2 bits
Code: ASCII

I read the default# of start bit is 1 for the Arduino. Is this the right code to match the above transmission protocol?

Serial.begin(9600, SERIAL_8N2);

If it is correctly, what else do I need to do? I have no idea about start bit if it is 0 or 1 and the end bits as its not specified in the document. From what I see in the document, I am not always sending a 8-bit command code; I am sending 7 bits and sometimes 1 or 2 bytes.

byte wakeUp[] = {0x55};
byte commUp[] = {0x02,0x43,0x50,0x43,0x30,0x35,0x3B};

void setup() {
 // initialize serial communication at 9600 bits per second:
  Serial.begin(9600, SERIAL_8N2);
  Serial.write(wakeUp, sizeof(wakeUp));
  //delay(1000);
  Serial.write(commUp, sizeof(commUp));
}

I read the default# of start bit is 1 for the Arduino. Is this the right code to match the above transmission protocol?

Serial.begin(9600, SERIAL_8N2);

Yes.

Doing a search for 55 in the document you mention I find nothing. Searching for “wake” I find the following.

Communication Procedure
• UA-767PC will enter Communication Mode by detecting an active-low signal from the RS-232C
communication port. This can be achieved by send any command from the host to UA-767PC.
Basically, this command wakes up the UA-767PC and changes it from the “Stand-by Mode” to the
“Communication Mode”. This is the only time that UA-767PC will not respond an “ACK” or
“NAK” back to the host.

So I have to ask, where do you get the idea to send a 0x55 ? Also, since you have not accounted for this in your checksum, the chances are that the whole transmission will be ignored.

It says send any command initially to wake it up so I just chose 0x55 so no other code in HEX or ASCII is 55 on command set document.I can get the blood pressure monitor wake up and display dash marks randomly if I reset it but I cannot get it do open the communication port with commUp. The dash marks stay up for about 3 seconds once it is in wake up and I have tried with 100 ms delay to 1000 ms delay with no effect.

Is there something else I need to set perhaps the UCSR0C rather than using the 8N2 config?

I've read here that I can set it http://www.appelsiini.net/2011/simple-usart-with-avr-libc#registers

When I do the below without 8N2. I can consistently get the dash lines to appear (communication mode) after each reset on the Uno but I still cannot get the communication to open to make the dash lines move.

Serial.begin(9600)
UCSR0C = UCSR0C | 0111000.

I am not sure about bit 0 so I left it at 0 8-bit data frame size by setting bit1 and 2 to 11. 1 on bit 3 to enable 2 stop bits, 00 on bit 4 and 5 since there's no parity bits 00 on bit 6 and 7 for async

Why is it that doing Serial.begin(9600,SERIAL_8N2) doesn't work nearly as well without constantly resetting and hoping the dash lines appear?

What is the next step I can take to open the comm port? The pdf shows the example

Example: Request of open communication port (from PC to UA-767PC) |02|43|50+43|30+35|3B|

So that is what I have done with

byte commUp[] = {0x02,0x43,0x50,0x43,0x30,0x35,0x3B};
Serial.write(commUp, sizeof(commUp));

I don't think you need that wake up command.

UA-767PC will enter Communication Mode by detecting an active-low signal from the RS-232C communication port

Simply opening the port will do the job. Try it.

I have tried sending the commUp byte initially to get it to be in communication mode which it goes go into and then I've sent it again just to be sure but it never changes to show moving dash lines.

That documentation is terrible but after reading through it LOADS of times I think I've finally had an AHA! moment.

To break down that commUp string:

Every command you send to request data or a change of state needs to start with a 0x02 The following byte has to be the character code of "C" (ie 0x43) The next two bytes are the character code of the source (ie 0x50, 0x43 = "PC"); The next two bytes are the command (ie 0X30, 0x35 = 05 open communication port) Everything in the string (after that initial 2) is added together to come up with the checksum (only the least significant byte of the checksum is sent)

So have you tried following up your commUp string with the Request for Measurement data (then checking Serial.available() to see if it sends anything)

{0x02, 0x43, 0x50, 0x43, 0x31, 0x30, 0x37} //request CPC10

I did do that but it doesn't send anything and it probably shouldn't since the comm port hasn't been opened. The device is in communication mode for a few seconds but communication is not open

//Open communication port Checksum:43+50+43+30+35=13B
byte commUp[] = {0x02, 0x43, 0x50, 0x43, 0x30, 0x35, 0x3B};
//Request measurement Checksum = 43+50+43+31+30=137
byte reqMeasure[] = {0x02, 0x43, 0x50, 0x43, 0x31, 0x30, 0x37} ;

void setup() {
 Serial.begin(9600,SERIAL_8N2);
 Serial.write(commUp,sizeof(commUp));
 Serial.write(reqMeasure,sizeof(reqMeasure));
 }
}

void loop() {
    if(Serial.available()){
    int inByte = Serial.read();
    Serial.write (inByte);
}

But you're using serial to communicate directly with the device AND the serial monitor? It's quite possible that you're getting something from your device but you won't see it as your Serial monitor is interfering.

Do you have any other device to output your recieved data on?

I have a HD44780 based LCD I can output on would that be sufficient?

sjc9: I have a HD44780 based LCD I can output on would that be sufficient?

That would be more useful.

I will get one tomorrow the one I have stopped working but for now I am doing some simple trial and error with the LED on the Arduino and Serial.availble().

It seems like Serial.available() is always equal to zero, does that mean the blood pressure monitor is not sending anything?

sjc9: I will get one tomorrow the one I have stopped working but for now I am doing some simple trial and error with the LED on the Arduino and Serial.availble().

It seems like Serial.available() is always equal to zero, does that mean the blood pressure monitor is not sending anything?

It would appear so.

I wonder if you could give me a bit more info on how the setup is all connected. So far the only thing I've seen is that datasheet.

UA-767PC will enter Communication Mode by detecting an active-low signal from the RS-232C communication port. This can be achieved by send any command from the host to UA-767PC. Basically, this command wakes up the UA-767PC and changes it from the “Stand-by Mode” to the “Communication Mode”. This is the only time that UA-767PC will not respond an “ACK” or “NAK” back to the host.

So in communication mode initially it will not respond with anything it seems since I have been able to successfully not open communication.

I have the serial shield connected onto Arduin Uno and a DB9 cable from the blood pressure monitor to the shield.

should I manually set the registers instead of using the serial config 8N2? I have also read somewhere on this forum before that UART does not support more than 1 stop bit is that true?

Aha I see you're using a separate shield for the RS232. Do you have any datasheet for that?

I suspect your problems are probably around the conflict of the level converter AND the onboard serial to USB using the same pins. I don't think this shield is an ideal solution.

A better solution would have been to use a mega2560 and then you could connect one of the alternative Serial ports to the RS232.

KenF: Aha I see you're using a separate shield for the RS232. Do you have any datasheet for that?

It uses the MAX232 driver/receiver max232 datasheet

RS232 V2 sheild on sparkfun

linksprite RS232 shield v2 product page

My jumpers are in the original position as pictured here.

RS232 shield jumper explanation

Using a terminal I have been able to successfully open the communication port, I see the dash lines move so I can confirm the command code is correct (weirdsymbolhere)CPC05;

I sent it ASCII in a serial terminal so I should be sending it not hex but ascii. What is the easiest way to convert?

As I explained in Answer #6 Your "commUp" string is already sends the ASCII for "CPC05" but this should also have the checksum appended (the 0x3b) and should be proceeded by a byte with the value of 2 (not ascii) to indicate that the string is a request for data.

So, according to the datasheet, your attempt to request data through the serial monitor should not work as the required leading 2 and the terminating checksum bytes are missing.

One other thing you could try is using Serial.print rather than Serial.write.

The leading 02 is a symbol or special character that can't be pasted here. 3B checksum is ; is ASCII which is what I pasted in the serial terminal as well. I am using the terminal called Termite . I pasted it exactly (STXsymbol)CPC05; , without the ; it will not open the comm port as expected.

How can I use Serial.print to print a byte array? I cannot cast a byte array as a string like I would for a char array to use Serial.print

Got it to work, it was the cable. I had to use a null modem cable, my original code works