0
Offline
Jr. Member
Karma: 0
Posts: 94
Arduino rocks
|
 |
« on: February 01, 2013, 06:46:00 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 136
Posts: 18990
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: February 01, 2013, 06:51:17 am » |
Have you got RS232 level shifters / inverters in-circuit?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 94
Arduino rocks
|
 |
« Reply #2 on: February 01, 2013, 07:00:39 am » |
I'm not sure. I'm not able to find the schematic anymore.
|
|
|
|
|
Logged
|
|
|
|
|
Milton Keynes UK
Offline
Tesla Member
Karma: 88
Posts: 6277
-
|
 |
« Reply #3 on: February 01, 2013, 08:16:15 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 94
Arduino rocks
|
 |
« Reply #4 on: February 01, 2013, 09:06:41 am » |
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?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 136
Posts: 18990
I don't think you connected the grounds, Dave.
|
 |
« Reply #5 on: February 01, 2013, 09:11:02 am » |
Your next step should be to find and post a link to the card reader device.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 94
Arduino rocks
|
 |
« Reply #6 on: February 01, 2013, 09:13:11 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 136
Posts: 18990
I don't think you connected the grounds, Dave.
|
 |
« Reply #7 on: February 01, 2013, 10:16:52 am » |
OK, that looks fairly conclusive that you need RS232 converters.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Milton Keynes UK
Offline
Tesla Member
Karma: 88
Posts: 6277
-
|
 |
« Reply #8 on: February 01, 2013, 01:51:26 pm » |
The shield that I am using
Is this the CF reader, or something else -and if so, what?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 94
Arduino rocks
|
 |
« Reply #9 on: February 01, 2013, 09:02:59 pm » |
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?
|
|
|
|
|
Logged
|
|
|
|
|
Milton Keynes UK
Offline
Tesla Member
Karma: 88
Posts: 6277
-
|
 |
« Reply #10 on: February 01, 2013, 09:43:57 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 94
Arduino rocks
|
 |
« Reply #11 on: February 03, 2013, 05:34:45 pm » |
I have connected pin 7 to ground. And nothing is different. Thoughts?????
Loren
|
|
|
|
|
Logged
|
|
|
|
|
Milton Keynes UK
Offline
Tesla Member
Karma: 88
Posts: 6277
-
|
 |
« Reply #12 on: February 03, 2013, 05:47:07 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 94
Arduino rocks
|
 |
« Reply #13 on: February 03, 2013, 09:24:04 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 94
Arduino rocks
|
 |
« Reply #14 on: February 04, 2013, 06:32:41 am » |
I have both RTS and CTS (pins 7 and  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?
|
|
|
|
|
Logged
|
|
|
|
|
|