RS232 protocole settings on arduino

Hi there everyone
I'm working on a project using a IDAL VP250HD solid state video player to play different videos by pressing a bunch of buttons.
The player uses a RS232 interface so I've obtained a cheap TTL>RS232 board (using a MAX232 chip) to interface with the arduino 2560 which will control the whole caboodle via the serial1 UART.
My question concerns the settings of the serial port - the VP250HD specifies 19200 Bauds - 8 bits - No parity - 1 start bit - 1 stop bit.
No problems for the baud rate but I can't seem to find a setting for the rest - the arduino Serial_begin offers lots of options for the serial link but I can't see the correct one in the list.
The default is SERIAL_8N1 , and I'm wondering if SERIAL_8N2 would be right for me, but I can't find any clear explanation (for idiots like myself) of the different options.
The other option would be to use a software serial link but I prefer to use the standard library because I'm no genius when it comes to coding.
Any explanation would be welcome
Thanks in advance
jomo

The default should work for you. 8N1 is one start bit, 8 data bits, one stop bit, and no parity.

Thanks SurferTim for your quick response!
I'll try that out and post when I've got it all up and running (sometime this weekend)
Thanks again
jomo

Hi I’m back with more questions.
After spending several hours on my project I can’t get it to work.
I’ve checked the hardware side very carefully including snooping around with my oscilloscope and the hardware appears to function correctly - the RS232 port outputs what looks like a clean waveform at the correct voltage levels (I measured roughly +/- 12v peak to peak with a good clean square waveform)
So I now suspect some bad coding to be the culprit.
From the HD250 datasheet I need to output 3 bytes on the RS232 port - the first being a Hex value of 80 to synchronise the communication. The following byte orders the player to move to a file location specified by the last byte. Seems simple but I can’t seem to get it to work.
Could some kind person check that my code is not totally defective. I get the impression that I’m getting the syntaxe wrong with my Serial1.write(0x80); - is that how you output a hex value?
I’m including the code which I have whittled down to make it less cumbersome to read. I apologise in advance for my sloppy coding.
Any clues would be welcome.
Thanks in advance!
Jomo

VP250HD_1Light.ino (6.68 KB)

Sorry - I'm new to all this - I think it made a mistake when including the code on my previous post. I'll try again here
Thanks in advance!
Jomo

// VP250HD Controller Version 1
// This software is to control an IDAL VP250HD video player module using push buttons.
// An Arduino Mega 2560 communicates with the player via an RS232 interface board
// We have 7 different medias to play and a choice of 2 languages - french or english (subtitles)
// French is the default language, at setup and also after a timeout period of non use
// Each media has a button to press to start play. One leg to ground, one leg to the corresponding input pin
// A led is lit to show which media is playing
// The led goes out at the end of the video.
// A pair of leds indicate which language is active.
// Leds are attached directly to ouput pins via a 20mA current limiting resistor
// Transistors not necessary because only 2 leds are lit simultaneously.
// The media is interruptible - a press on a button terminates the current video and starts the chosen media.
// Developed by Jonathan McIntosh Jan 2016 for the Cité de l'espace in Toulouse.
// Stripped down version for posting to the arduino forum because I can't get the RS232 to work

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Define I/O
// Press Buttons attached to these pins
int Button1 = 53;
int Button2 = 51;
// etc down to Button 7
int ButtonFR = 39;
int ButtonGB = 37;

// Leds attached to these pins
int Led1 = 52;
int Led2 = 50;
//etc down to Led7
int LedFR = 38;
int LedGB = 36;

// RS232 interface attached to these pins using the Mega's Serial1 UART
int Tx = 18;              // Connected to the RX pin of the RS232 interface
int Rx = 19;              // Connected to the TX pin of the RS232 interface

// Variables
int Language = 0;        // Variable for storing the current chosen language, 0=FR & 10=GB. Default value is 0
int PressedButton = 0;   // Variable for storing current pressed button. 0 = no choice.
int DebounceDelay = 300;
int ChosenMedia = 0;      // Variable for stroring the current media to play. 0 = no choice.


//////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup()
{
  // Push buttons are inputs - pressing a button grounds the input
  pinMode(Button1, INPUT_PULLUP);
  pinMode(Button2, INPUT_PULLUP);
 
  pinMode(ButtonFR, INPUT_PULLUP);
  pinMode(ButtonGB, INPUT_PULLUP);
 
  // Leds are outputs - connected to ground thru a series resistor.
  // A HIGH on the pin lights the led.
  pinMode(Led1, OUTPUT);
  pinMode(Led2, OUTPUT);
 
  pinMode(LedFR, OUTPUT);
  pinMode(LedGB, OUTPUT);
  
  // Set up initial levels on the led pins
  digitalWrite(Led1, LOW);
  digitalWrite(Led2, LOW);
  
  digitalWrite(LedFR, HIGH);
  digitalWrite(LedGB, LOW);
  
  // Turn on serial communications
  Serial.begin(9600);      // this is for debugging purposes
  Serial1.begin(19200);    // this is for the RS232 port
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{
  ParseButtons();
  ChooseMedia();
  PlayMedia();
  
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This routine parses the buttons, debounces and updates the PressedButton & Language variables
// It also turns on the appropriate language led
void ParseButtons()
{
  if(digitalRead(Button1) == LOW)
  {
    PressedButton = 1;
    Serial.println("Button 1 was pressed");
    Serial.print("PressedButton = ");
    Serial.println(PressedButton);
    delay(DebounceDelay);
  }
  if(digitalRead(Button2) == LOW)
  {
    PressedButton = 2;
    Serial.println("Button 2 was pressed");
    Serial.print("PressedButton = ");
    Serial.println(PressedButton);
    delay(DebounceDelay);
  }
  // etc
  if(digitalRead(ButtonFR) == LOW)
  {
    Language = 0;
    digitalWrite(LedGB, LOW);
    digitalWrite(LedFR, HIGH);
    delay(DebounceDelay);
  }
  if(digitalRead(ButtonGB) == LOW)
  {
    Language = 10;
    digitalWrite(LedGB, HIGH);
    digitalWrite(LedFR, LOW);
    delay(DebounceDelay);
  }  
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This routine uses the PressedButton & Language variables to decide which media to play.
// Media is arranged as follows
// Each Media is stored in a different folder at the root directory of the storage device
// Each folder is named as a 3 digit number plus a marker for positioning the player onto the 000 folder after play
// Folder 000 contains a black video which loops endlessly if no button is pressed
// Folders 001 to 007 contain the 7 medias in French
// Folders 11 to 17 contain the medias in English
// This setup allows the routine to choose the proper media file number by adding the PressedButton and Language variables
void ChooseMedia()
{
  if(PressedButton > 0)
  {
   ChosenMedia = PressedButton + Language; 
   Serial.print("ChosenMedia = ");      // For debugging purposes
   Serial.println(ChosenMedia);         // For debugging purposes
  }  
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This routine writes the 3 bytes to the RS232 port to play the appropriate media
// Then resets the ChosenMedia and PressedButton variables.
// It also updates the status of the leds to indicate the current chosen media
void PlayMedia()
{
  if(ChosenMedia == 1)
  {
   Serial.println("Writing to RS232 port");  // For debugging purposes
   Serial1.write(0x80);      // This Status byte is necessary to synchronise the player to the RS232 command
   Serial1.write(0x01);      // This second byte tells the player to jump to a file number
   Serial1.write(0x01);      // This is the file number to be jumped to. Playing starts automatically.
   ChosenMedia = 0;
   Serial.print("ChosenMedia = ");      // For debugging purposes
   Serial.println(ChosenMedia);         // For debugging purposes 
   PressedButton = 0;
   TurnOffLeds();            // Turn off all the leds except for the language leds
   digitalWrite(Led1, HIGH);
   // We need to start timing here to catch the end of the media & turn off the led.
  }
  if(ChosenMedia == 2)
  {
   Serial1.write(0x80);
   Serial1.write(0x01);      
   Serial1.write(0x02);      
   ChosenMedia = 0;
   PressedButton = 0;
   TurnOffLeds();            // Turn off all the leds except for the language leds
   digitalWrite(Led2, HIGH);
   // We need to start timing here to catch the end of the media & turn off the led.
   
   // I'll write the rest of this routine when I get it working for the first two buttons
  }  
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

void TurnOffLeds()
{
  digitalWrite(Led1, LOW);
  digitalWrite(Led2, LOW);
// etc down to Led7
}

Hi there
just to say I ended up by understanding why my system wasn't running - the omnipresent human error as usual. I had connected the output of my arduino to the I/O connecter of the video player, not the RS232 connecter
So stupid..
Never mind - it works perfectly now
Thanks
Jomo