Transport Control via RS232

I have a CF card recorder that can be controlled by RS232. I've been trying to control it with this sketch but without any luck:

int i;
void setup(){
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial2.begin(9600);
  i = 0;

}

void loop(){
  if(i==0){
    Serial2.println("@0?CD\n");
    Serial.println("message sent"); 
  }
  if(i==100){
    i=0; 
  }
  if (Serial2.available()){
    //Serial.print("MIDI:  ");
    Serial.println("we got stuff");
    int inByte = Serial1.read();
    Serial.println(inByte);


  }
    if (Serial1.available()){
    //Serial.print("MIDI:  ");
    Serial.println("serial 1 we got stuff");
    int inByte = Serial1.read();
    Serial.println(inByte);


  }

  i++;
}

I've gone over the manual a few times and this morning stumbled across this:

  1. The host requests data by setting RTS to L.
  2. Upon data request by CTS, the PMD570 responds
    by setting RTS to H if not busy.
  3. The host checks if CTS is H and stats data output
    on TxD.
  4. When data output finishes, the host sets RTS to H.
  5. The PMD570 checks if CTS is H and sets RTS to L.

The shield that I am using only has the following pins:

Tx
Rx
Vcc
Gnd

I would assume that since I am not able to set RTS low that my attempts to controll the device will not succeed. Is that correct?

Loren

Have you got RS232 level shifters / inverters in-circuit?

I'm not sure. I'm not able to find the schematic anymore.

Loren:
I'm not sure. I'm not able to find the schematic anymore.

Then I suggest you find out. If your CF reader needs RS232 and you aren't supplying RS232 signal levels, it's not going to work.

PeterH:
Then I suggest you find out. If your CF reader needs RS232 and you aren't supplying RS232 signal levels, it's not going to work.

My next step will be to see if I can generate a schematic by tracing pins. More to follow on that front...

This is what the manual says in terms of commands:

Command format
Start character: @
End character: 0Dh

Notes:
The receiving side ignores data received prior to "@". If code data is received without receiving "@", the data receive error code will be returned. The tolerance for send/receive clock error is ±10%. For sending a command, wait more than 20ms after reception of a response (OK, ERR or Status). Reception of 0Dh or timeout is used to determine the end of a command. Timeout occurs 1 second after the reception of the last byte.

The manual also lists a table of commands and request commands. This is the one I was trying to use as my test:

Card Condition .............. “@0?CD” + CR

Would the line Serial2.println("@0?CD"); fulfill the start and end characters?

Your next step should be to find and post a link to the card reader device.

AWOL:
Your next step should be to find and post a link to the card reader device.

I think it's been discontinued, but here is a link to the manual:

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CFcQFjAA&url=http%3A%2F%2Fwww.jingle.org%2FmarantzPMD570manual.pdf&ei=MM0LUc6KHMy10AH47YGIAg&usg=AFQjCNFUSecX8QBoKGxGHluo-O0MxmSc3Q&sig2=PjQmuONOSwNUyObHL7w_AA&bvm=bv.41867550,d.dmQ

OK, that looks fairly conclusive that you need RS232 converters.

Loren:
The shield that I am using

Is this the CF reader, or something else -and if so, what?

PeterH:

Loren:
The shield that I am using

Is this the CF reader, or something else -and if so, what?

The shield that I'm using is a TTL to serial converter. I did find some information. I cant find a schematic but I think I have some stuff figured out. Here is a picture:

Here is a close schematic of what I think is going on:

The main difference is that R1 and R2 pictured in the first image (both 1k) are between the TTL and the 232 chip. The rest of the circuit looks to be the same as the second image. Would those resisters be throwing a wrench in my works?

That picture doesn't show a shield - it shows a PCB. (In Arduino terminology, a 'shield' is a PCB with headers that align with the headers on an Arduino, which is designed to mount on top of the Arduino.)

It looks to me as if that device is designed to use 5-wire RS232 and your RS232-TTL converter provides 3-wire RS232.

I suppose it's possible that you could just pull the RTS (7) low and see whether the PMD570 will receive data. It ought to respond by setting CTS ( 8 ) high, which in your case would make DSR (6) and DTR (4) high - those aren't mentioned in the description of the PMD570 and perhaps it doesn't use them. The main issue I see is that according to your diagram none of these control signals are taken back to the logic level interface so the Arduino doesn't have any way to know whether the PMD570 is ready to receive data. I suppose you could just pull RTS (7) to ground and see if it makes any difference? It would be worth check what the PMD570 does to CTS ( 8 ) in response - hopefully that would confirm that you've identified the connections correctly and I'm reading the description properly.

I have connected pin 7 to ground. And nothing is different. Thoughts?????

Loren

PeterH:
It would be worth check what the PMD570 does to CTS ( 8 ) in response - hopefully that would confirm that you've identified the connections correctly and I'm reading the description properly.

PeterH:

PeterH:
It would be worth check what the PMD570 does to CTS ( 8 ) in response - hopefully that would confirm that you've identified the connections correctly and I'm reading the description properly.

I'm going to check that next. But first let me ask one more question. If the manual says this:

. 1. The host requests data by setting RTS to L.
2. Upon data request by CTS, the PMD570 responds
by setting RTS to H if not busy.
3. The host checks if CTS is H and stats data output
on TxD.
4. When data output finishes, the host sets RTS to H.
5. The PMD570 checks if CTS is H and sets RTS to L.

Step one seems simple, I should setup a pin as an output and write it low.
For step two should I wire Pin 8 directly to digital pin? If so are there steps that I need to take to protect the arduino from getting fried?

Thanks again folks!

Loren

I have both RTS and CTS (pins 7 and 8) connected now and have this code running:

int i;
#define RTS 22
#define CTS 23

void setup(){
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial2.begin(9600);
  i = 0;
  pinMode(RTS,OUTPUT);
  pinMode(CTS,INPUT);
  digitalWrite(RTS,HIGH);
  Serial.println("Starting");
  delay(1000);
  digitalWrite(RTS,LOW);
  Serial.println("RTS is now low");
  

}

void loop(){
  int state;
  state = digitalRead(CTS);
  
  if(state == 1){
    Serial.println("We have gone High");
  }
  //Serial.println(state);
}

I'm going to double check all the connections but so far the CTS is not going High.

Any thoughts?

Step one seems simple, I should setup a pin as an output and write it low.
For step two should I wire Pin 8 directly to digital pin? If so are there steps that I need to take to protect the arduino from getting fried?

Do not wire the CTS & RTS pins on the 9 pin D-sub connector directly to the arduino pins as this will probably knacker your arduino. The MAX232 board you have has a spare RX/TX pair so you could try and connect relevant wires onto these spare pins so the MAX232 does your TTL/RS232 level conversion needed for the RTS/CTS signals. Another option is to buy another TTL/RS232 converter that breaks out CTS/RTS like this http://www.ebay.co.uk/itm/MAX232-RS232-Serial-To-TTL-Output-Converter-Board-RXD-TXD-RTS-CTS-F-PIC-Atmel-/290712442058?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item43afcfd4ca

Loren:
I'm going to double check all the connections but so far the CTS is not going High.

Any thoughts?

Make sure you fully understand how RS232 is connected and the relationship between pin numbers and signals at either side of the connection. Note that the connections are (usually) not made directly between the numbered pins on each connector but are crossed in pairs (txd and rxd are crossed, and so on). You need to follow through the sequence of steps described in that spec, relating it to control signals and hence to specific pins on each side of the connection. I thought it made sense, but I could be wrong. Once you are clear what the sequence means, you should be able to see the signal levels of all pins in the expected state with RTS inactive and then take RTS active and see the CTS become active in response. If that doesn't happen then either there's a hardware problem, or the description in that spec is wrong, or you (and I) have misunderstood it. I don't believe you need to actually send or receive anything over the serial port at this stage - you're testing the signaling preamble that precedes the data transfer.

PeterH:
Make sure you fully understand how RS232 is connected and the relationship between pin numbers and signals at either side of the connection. Note that the connections are (usually) not made directly between the numbered pins on each connector but are crossed in pairs (txd and rxd are crossed, and so on).

Yup... Got it... The manual does say that the cable should be a one to one or a straight through cable.

PeterH:
I don't believe you need to actually send or receive anything over the serial port at this stage - you're testing the signaling preamble that precedes the data transfer.

This makes sense to me. Make sure that the recorder is looking for data first and then once thats complete move on to bigger and better things!

Riva:
Do not wire the CTS & RTS pins on the 9 pin D-sub connector directly to the arduino pins as this will probably knacker your arduino. The MAX232 board you have has a spare RX/TX pair so you could try and connect relevant wires onto these spare pins so the MAX232 does your TTL/RS232 level conversion needed for the RTS/CTS signals.

So db9 pin 7 to pin 7 on the chip, and db9 pin 8 to pin 8 on the chip. Then connect the chip pins 10 and 9 respectively to my arduino?

So db9 pin 7 to pin 7 on the chip, and db9 pin 8 to pin 8 on the chip. Then connect the chip pins 10 and 9 respectively to my arduino?

Yes that's right. The MAX232 chips pin 10 will be your arduino RTS and 9 will be CTS. Be aware there logic may be reversed so when the arduino pin connected to RTS is LOW the MAX232 output (pin 7) will be HIGH. Reading CTS will confirm if this is the case.

I was just trying to get an old PMD560 at our station automated... I was lucky to find this thread
but I also wanted to use the status sent back from the recorder
did using the second set of max 232 drivers for (CTS or DTS) status work?
now it just records and you never know if it "really" happens