RS232 doesn't work with certain device

Hi

I have an arduino compatible uno32 and a waveshare ttl to RS232 board.

I try to control a tv one 1T-C2-750 video mixer so I have a fader. Everything works fine when using a usb to rs232 module (I capture the output data from the arduino) and the message is completely right (checked it in hex and 100% the same as it should be, if I send the same message with a computer program the video mixer responds) but the video mixer doesn't respond while connected to the arduino.

Baud rate is also right, there is a delay between the messages so that can't be the problem. I tried Serial.print and Serial.write, tried sending each character after each other in hex, tried sending a string with \r or \n (I don't know anymore what one was the right one).

Someone knows what could be wrong?

Thanks for the help!

Something to check is the dsr/dtr/rts/cts pins. Some hardware devices actually require the hardware flow control to work. I had one device that only worked if dtr went low for a certain time before going high again.

The manual says this: No flow control is used - however all control packets start with an ASCII 'F', end with carriage-return (13 decimal, 0x0D hexadecimal) and all such packets sent to the unit will be acknowledged (thereby provided software handshaking). Note that a line-feed (LF) should not be sent.

So this shouldn't be the problem or is it? I'll try tomorrow with flow controll, maybe that works

post your sketch, so we could have an eye on it...

This is the code.

The video mixer also sends messages, but when I write a test patch that displays all the serial inputs nothing gets displayed.

 #include <LiquidCrystal.h>

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
//lcd(12, 11, 5, 4, 3, 2);

int delayTime = 200; //milliseconds delay between commands (given by manual of Tv one, you might try lower)
int faderValue = analogRead(A0);
int faderValueOld = analogRead(A0);


void setup(){
  Serial.begin(57600); //start serial communication with baud rate 57600 (standard for 1T-C2)
  //Serial.println(""); //carriage return --> stop previous (not completed?) signal
  lcd.begin(16, 2);
 
}



void loop(){

  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());
      
    }
  }else{
  
  faderValue = map(analogRead(A0), 0, 1023, 0, 64); //read the new value of the fader and map it to 0 -> 64 (32 steps precision)
  
  if(faderValueOld+1 < faderValue || faderValue < faderValueOld -1) //if the fader has changed, send a new value to 1T-C2 (+1 and -1 are when the arduino doesn't register the value precise enough)
  {
    sendRS232(faderValue);
    faderValueOld = faderValue; //put the value of faderValue in faderValueOld
  }

  }
}


//this function gets a value for the opacity and sends the serial signal to the 1T-C2-750
void sendRS232(int opacity){
    String temp =""; //this string is for the extra 0
    
    if(faderValue < 3) faderValue=0; //sometimes the value halts on 1 and not on 0
    if(faderValue > 61) faderValue=64; //sometimes the value stops at 63 and not 64
    
     if(faderValue < 10) //if it's lower then 10, it will add an extra 0 (so it will be 04 and not 4)
    {
      temp="0"; //add an extra 0
    } 
    
    Serial.print("F040041010F0000"+temp+faderValue+"??\r"); //send to RS232: temp contains an extra 0 if needed, faderValue is our opacity, ?? is the debug checksum and \r is the carriage return for end of message
    //Serial.println(""); 
    delay(delayTime); //wait 100ms so the 1T-C2-750 can handle it
    
}
    Serial.print("F040041010F0000"+temp+faderValue+"??\r");

Ah, no. This is adding a few pointers together. Not what you are intending, I'm sure.

Better look up sprintf.

Hi

Tried with sprintf, now this is my code:

/*

  Eyesthetic Mixer Basic v1
 	--> a fader module for the 1T-C2-750 by Jannes De Brabandere
 
 */
 #include <LiquidCrystal.h>

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
//lcd(12, 11, 5, 4, 3, 2);

int delayTime = 200; //milliseconds delay between commands (given by manual of Tv one, you might try lower)
int faderValue = analogRead(A0);
int faderValueOld = analogRead(A0);
   char buffer[21] ; ///< This is the buffer for the string the sprintf outputs to



void setup(){
  Serial.begin(57600); //start serial communication with baud rate 57600 (standard for 1T-C2)
  //Serial.println(""); //carriage return --> stop previous (not completed?) signal
  lcd.begin(16, 2);
 
}



void loop(){

  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());
      
    }
  }else{
  
  faderValue = map(analogRead(A0), 0, 1023, 0, 64); //read the new value of the fader and map it to 0 -> 64 (32 steps precision)
  
  if(faderValueOld+1 < faderValue || faderValue < faderValueOld -1) //if the fader has changed, send a new value to 1T-C2 (+1 and -1 are when the arduino doesn't register the value precise enough)
  {
    sendRS232(faderValue);
    faderValueOld = faderValue; //put the value of faderValue in faderValueOld
  }

  }
}


//this function gets a value for the opacity and sends the serial signal to the 1T-C2-750
void sendRS232(int opacity){
 
    
    if(faderValue < 3) faderValue=0; //sometimes the value halts on 1 and not on 0
    if(faderValue > 61) faderValue=64; //sometimes the value stops at 63 and not 64
    

      
      sprintf(buffer, "F040041010F0000%02d??", faderValue); ///< This has 3 2-digit integers with leading zeros, separated by “:” . The list of parameters, hour, min, sec, provides the numbers the sprintf prints out with.
      buffer[19]= 13; //add the carriage return
     
      Serial.write(buffer);
      Serial.flush();
 
    delay(delayTime); //wait 100ms so the 1T-C2-750 can handle it
    
}

But still no response from the video mixer (and still the exact same messages it should send). I intercept the messages the arduino sends (with usb to RS232 for computer), and when I send them when the computer is connected to the video mixer, it works.
Only problem is with the arduino and the video mixer.

  sprintf(buffer, "F040041010F0000%02d??", faderValue); ///< This has 3 2-digit integers with leading zeros, separated by “:” . The list of parameters, hour, min, sec, provides the numbers the sprintf prints out with.

buffer[19]= 13; //add the carriage return

Who do this? Why not:

sprintf(buffer, "F040041010F0000%02d\r", faderValue);

Just put the carriage return in the string. Plus offset 19 was wrong.

///< This has 3 2-digit integers with leading zeros, separated by “:” . The list of parameters, hour, min, sec, provides the numbers the sprintf prints out with.

Your comment does not at all agree with what the code is doing. There is no “:” there and only one 2-digit integer.

Sorry, that part of the comment was from copy/paste.

Corrected the code, and it sends the right signals but still no response from the device.

There is no flow control, no parity, 8 bits and 1 stop bit on the device. So that shouldn’t be the problem. What can be the reason why it doesn’t respond even though it sends the right signals`?

Voltage levels? Rx/Tx swapped? Hard to say without being there with debugging devices. The device doesn't "know" what it is connected to, so if it doesn't work there is something different about what you are doing with the Arduino. Ground not connected maybe.

How can I check the voltage levels with a multimeter?

RX/TX should be connected ok (or the arduino couldn't send messages to the computer with serial connection through RS232, not USB?)

Ground should be connected (or also no messages possible to computer through RS232?)

I'd use an oscilloscope to check the voltage levels of your RS232 signal. If your mixer is a bit picky it might not accept the +5/-5V which some of the cheaper TTL->RS232 converters produce. Do you have a link to the datasheet of your converter?

I don't have an oscilloscope, is it possible to do this with a multimeter? (Always send 1 and check the ground/data line?)

This is the datasheet I got: http://www.mediafire.com/?i9vus64m5c7ot90

It's a max3232 chip or a SP3232E, I can't read it (the characters are to small). But the IC has 16 legs and there are 9 capacitators used.

alfaleader: I don't have an oscilloscope, is it possible to do this with a multimeter? (Always send 1 and check the ground/data line?)

No, that won't prove anything. The time a bit goes low at 57600 baud is 17.3 uS. You won't spot that.

Hi

Maybe this can be the problem? http://docwiki.gumstix.org/index.php/Serial_voltages

Maybe the MAX3232 doesn't give a high enough voltage (it gives +-7,5V). Might be the video mixer needs a higher voltage.

I'll try to get my hands on a oscilloscope.

If the information you provided is correct, it should give around +/-13V as the standard assumes. How do you get +/-7.5V? The MAX3232 is able to push the 5V input up to over 13V for up to 120kBaud, the supplied schematics connect the MAX3232 as the datasheet proposes so you should get a correct voltage level.

Ok, then I misread something ;)

It's really strange why it doesn't work.

Hi

I see that there aren't pins on the RS232 connector connected. (propably because the module has external RTS/CTS)

What pins should I connect? In the arduino softwareserial I have found the pins, but they are wrong.

Earlier you wrote there is no handshake at all. Why are you concerned now about RTS/CTS?

SoftwareSerial has no hardware handshake, so what pins are you referring to?

The manual says no handshake, but maybe the RTS and CTS pins should be constant high/low for the video mixer to read out.

I don't use softwareserial, but real serial (TX/RX). The softwareserial tutorial just shows how to connect the MAX3232 (that says to connect pin 7 and 8, and TX to 7 and RX to 8???)