RS232 to TTL module Problem

I have been trying to send protocol(data frame) to a camera using arduino uno which is operated by RS232 protocol, for that i used RS232 to TTL module.

https://www.google.co.in/imgres?imgurl=https%3A%2F%2Fstatics3.seeedstudio.com%2Fimages%2Fproduct%2FConverter%2520Module.jpg&imgrefurl=https%3A%2F%2Fwww.seeedstudio.com%2FRS232-to-TTL-Converter-Module-p-1684.html&docid=0KiAxgJVYSIyGM&tbnid=bnAxS981QaHArM%3A&vet=10ahUKEwjGzY7xiPvbAhUHfisKHWExBxMQMwhPKAMwAw..i&w=700&h=525&bih=596&biw=1366&q=rs232%20to%20ttl&ved=0ahUKEwjGzY7xiPvbAhUHfisKHWExBxMQMwhPKAMwAw&iact=mrc&uact=8

My task was to send a data frame to the camera so i can operate its settings over RS232 protocol,

I know it is not a rocket science, simply i just had to send hex bytes through arduino to the RS232 to TTL converter module and the module is connected to the camera,

I have used arduino 0(Rx) pin and 1(Tx) pin for Serial.write() to send data to the RS232 module.

i had to send the following hex values to the camera so that i could zoom in;

0xF0, 0x03, 0x26, 0x02, 0x00, 0x28, 0xFF

so for this i used a simple code for this

 byte zoomIn[]  =  {0xF0, 0x03, 0x00, 0x02, 0x26, 0x28, 0xFF };   
 

 
 
void setup() {

   Serial.begin(19200);

   Serial.write(zoomIn, sizeof(zoomIn)); 
   delay(1000);

}
 
void loop() {
}

I don't know if that should be a big deal to send this data to the module, and what i think is that the Serial.write() converts hex data into binary and the RS232 module converts it back into the RS232 data.

but unfortunately i can not write settings to the camera even i tried many different baud rates but nothing worked.

please, help is needed and tell me if there is something wrong that i have done.

1. The following is the physical/logical wiring connection among UNO, TTL<---> RS232 Converter,
and the Camera.

2. You want to transfer the following binary/hex numbers (hex is a compact form of binary) to the Camera: 0xF0, 0x03, 0x26, 0x02, 0x00, 0x28, 0xFF

3. When you use Serial.write(0xF0) command just to send 1-byte binary data (the first one), it takes over the following electrical forms at the TTL side and RS232 side. Similar electrical pattern will happen for each of the remaining hex bytes. Each form is known as asynchronous data frame. Here frame length is: Start bit(1) + data Bits (8) + No parity (0) + Stop Bit (1) = 10. the Camera will recover the TTL version from the received RS232 version of frame. In the Arduino, Serial.begin(9600) command uses frame length = 10, Bd = 9600; this setting must be matching with your camera setting. So, please consult your Camera Manual for the frame setting.

4. I would like to suggest you to use Software Serial UART Port to transmit your data from the Arduino; because, it creates problem to upload sketch when there is something connected with the hardware UART Port (TX, RX) of Arduino.

5. I have used the following codes (Master : MEGA; Slave : UNO) using Software Serial UART Port to check the data communication. They work fine and may be useful for you!
Master : MEGA Codes:

#include<SoftwareSerial.h>
SoftwareSerial mySerial(4, 5); //SRX, STX
void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
  byte zoomIn[]  =  {0xF0, 0x03, 0x00, 0x02, 0x26, 0x28, 0xFF };

  mySerial.write(zoomIn, sizeof(zoomIn));
 // delay(1000);

}

void loop()
{

}

Slave : UNO Codes

#include<SoftwareSerial.h>
SoftwareSerial mySerial (4, 5); //SRX, STX
byte dataArray[7];
int i = 0;
byte x;

void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop()
{
  if (mySerial.available() > 0)
  {
    x = mySerial.read();
   Serial.println(x, HEX); //testing
    if (x != 0xFF)
    {
      dataArray[i] = x;
      Serial.println(dataArray[i], HEX); //testing
      i++;
    }
    else
    {
      dataArray[i] = x;
      Serial.println(dataArray[i], HEX); //testing
    }

  }
}

Thank you Mr. Mostafa for you time and help, yes i tried the software serial too and sent the hex values but the camera didn't work and to verify what's the problem I used an rs232 to usb converter cable to the computer and used a third party serial software(Termite as well as HERCULES) to read the response output at the end of ttl to RS232 module.

I obtained ASCII values on the serial software and found that RS232 did not transmitted hex values of 0x00, 0x03,0x02 and it read the rest of the Hex values.

my camera works on baud rate of 19200 as specified in the camera manual.

and i tried to send just 0x03 for which there was no any output ?

can you provide your opinion on this, it will be appreciated.

Thank You.

Serial.write() is the correct function to send an array of bytes.

Have you any means to prove that you have the correct byte values in your array?

If you are working at 9600 baud it will be easier (assuming you are using an Uno) to communicate with the camera using SoftwareSerial so as to leave pins 0 and 1 free for debugging messages and uploading code.

Post a link to the datasheet or user-manual that describes the communication protocol.

Post a link to the datasheet for your RS232 module

Post a diagram showing how you have connected the module to your Arduino. See this Simple Image Guide

...R

You can try a new wiring between your TTLtoRS232 Converter Module and the Cameral Cable as er following diagram.

Procedures:

1. Take out the 9-Pin connector of the Camera Cable from the RHS of the TTLtoRS232 Converter Module.

2. Take a DVM and check the the following pin conditions at the 9-Pin Camera Cable.
(a) Pins: 1, 4, 6 are shorted together; if not, shot them together using suitable jumper wires.
(b) Pins: 7, 8 are sorted together; if not, shror them together using suitable jumper wires.

3.
(a) Short Pin-2 of TTLtoRS232 Converter Module with Pin-2 of Camera Cable
(b) Short Pin-3 of TTLtoRS232 Converter Module with Pin-3 of Camera Cable
(c) Short Pin-5 of TTltoRS232 Converter Module with Pin-5 of Camera Cable

Now, give a try.

Good luck!

Thank you Mr Mostafa and Robin for your interest.

Mr Mostafa i don't think that it is required to short the connector pins of the camera as it only utilizes rx,tx and GND pin of RS232 connector.

For a better understanding I have attached few images which might clear up the things to you guys.

Mr robin yes i have an image attached showing the data transmitted by the TTL to RS2232 converter module on termite software.

Your Camera is using asynchronous serial data frame protocol which consists of the following signals:
Data Lines (TXD, RXD)
Modem Control Lines (RTS/-CTS; DTR/-DSR/-CD/)

If external Modem is not used, the Modem Control lines are always shorted (RTS/-CTS); (DTR/-DSR/-CD)' This is known as "Loop Back Connection of the Modem Control Lines".

You can try doing this; there is no harm to make a try when we are not sure about a connection diagram. Can you make a link to the Technical Reference Manual of your camera?

There is no signal signatures in the Operational Manual for the Interface Connector of the Camera. It looks like that the Camera's interface connector is not using the Modem Control Lines and they should have terminated properly inside the Camera. Now, few queries:

1. Can you operate/change the port settings of the Camera using the Software Supplied with the Camera and a COM Port driven device Like PC or a terminal?

2. Why do you want to operate/change the settings using Arduino?

Thanks.

BTW: You may send an email to the Manufacturer/Supplier of the Camera in Singapore to send a copy of the signal signatures of the interface connector. The email is given in the Operational Manual.

Yes i can perform changes on the camera using the software along with it and the third party serial software.
I am using arduino with the intention to change the settings remotely.

Can you operate/change Camera Setting using the hand-made cable that you have shown in file arduino_3.jpg of your Post#5?

In file arduino_2.PNG of your Post#5, there is something like Polarity?. Can you please check with Manufacturer -- what is this? Is it Parity? If not, what does it mean? I have not seen this signal name in the asysc serial protocol.

My intuition is this -- It would be possible to control your Camera using Arduino UNO. We are just missing some vital information, and my doubt is still on the issue of the termination of the Modem Control Lines. If the Camera is not using the Modem Control Lines, they must have been terminated inside. We need to have documentary evidence that they are indeed terminated; this can be known from the Manufacturer after receiving the signal signatures script of the Interface Connector.

I would like to request you again to check the shorting conditions of the Modem Control Lines that I have shown in my Post#4.

Thanks.

zabbie:
Yes i can perform changes on the camera using the software along with it and the third party serial software.
I am using arduino with the intention to change the settings remotely.

What "third party serial software" are you using?

...R

Ok Mr Mostafa i will just contact the company to ask the question about signal signature and will be back to you as soon as I get information from their behalf,

About camera cable in arduino_3 image- the camera get its power through the connector. (there are 7 total connection wire in connector, 2 wire for power and ground to camera, 3 wire for Tx Rx GND to RS232 and rest two wires for video output and its ground)

Mr. Robin here is the link to the termite software:

i tried to use another software name hercules:

https://www.hw-group.com/software/hercules-setup-utility

zabbie:
Mr. Robin here is the link to the termite software:

That looks like a very ordinary terminal program. If you can communicate with the camera with that then there should be no problem doing the same with an Arduino.

What is the hardware connection between your PC and the camera when you are using Termite?

...R

Here is a block diagram of Hardware connection between the camera and the PC(termite software)

camera -> connector ->rs232(db-9 connector) ->RS232 to USB converter cable ->Computer port via USB end of the cable.

Image from Reply #13 so we don't have to download it. See this Simple Image Guide

...R

Your diagram mentions DB9 connector. Is that the same thing that is in the first link in your Original Post?

If so, and based on the diagram in Reply #14 it seems to me you just need to replace the 3 connections between the RS232-TTL cable and the DB9 connector with a connection between the Arduino and the DB9 connector.

AND, can you give an example of one or two of the commands that you type into Termite and which work properly to control the camera.

...R

If Post#13 is the cable that works with PC and the Camera, it is TRUE that the Modem Control Lines are terminated inside the Camera.

Now, you may follow these steps to connect Arduino (UNO) with your Camera.

1. Take out the RS232 <---> USB converter Cable from the DB9 connector side of the Camera.

2. Place a MAX232 chip on the breadboard and make connection among DB9 Connector, MAX232, and UNO as per following diagram.
]

3. I would like to suggest you using the software UART Port for the Camera Interface instead of the the hardware UART Port (RX, TX) as the later is used for uploading Sketch and communicating with Serial Monitor. If extra circuits are found connected with the UART Port, problems were observed during the uploading phase of the the sketch. However, if you really need to connect some circuitry with UART Port then temporarily remove these circuits during uploading. After uploading, put back the circuits/jumpers.

#include<SoftwareSerial.h>
SoftwareSerial  myCamera (6, 7); //SRX, STX

4. Write your Arduino Codes; upload them into the UNO; check that camera is responding!

BTW: Did you connect the DB9 connector signals with the Arduino pins while you were trying before? DB9's signal levels are close to +/-10V; whereas, UNO signal levels are 5V!

We would be glad to see what Arduino codes you tried before or you will be trying now.

@GolamMostafa, I think you are making this too technical and too complicated. Reply #13 seems to me to imply that the control of the camera is straightforward.

@zabbie, please answer Reply #15 - it may have overlapped with your edit of Reply #13.

...R

I just used serial software named hercules to send the hex values to the camera.

Here is the response after providing the first Command Frame(you can see the HEX values under the image in hercules software)

The response i get after sending the second command frame

You can always control your Camera using PC or any other Commercial Hardware/Software Terminals; thta is not your problem?

Your problem is that you can not control your Camera using Arduino. Is it correct?

You were asked to answer few questions - did you try with the Arduino? If so, post the codes that you wrote. And also, please post the connection diagram that you made between the Arduino and the Camera via the DB9 pin connector side of the Camera Cable. We wanted to learn something having had a joining with your thread; but, the chance is extinguishing?