xPC Target - RS-232 Interface w/ USB-Serial Converter?
Show older comments
I'm currently trying to connect to my xPC Target via RS-232 Interface (BaudRate: 19200). I have a Serial Port on the Target PC's motherboard, but not one on the host computer. I am currently having no luck connecting to the Target using a USB-Serial Converter (Prolific PL-2303). This is my current setup:
host PC -> USB-PL2303 -> Serial Cable w/ wires flipped to match null modem cable -> TargetPC's Serial Port
The PL-2303 config is this: BitsPerSecond: 19200 DataBits:8 Parity: None StopBits: 1 FlowControl: Hardware Port: Com1
I set xpcexplr to COM1 & 19200, made a boot disk, and now I'm getting an error when I try to ping or connect: COM port access failed.
Has anyone had any experience/luck with this sort of scheme or is using this USB converter a lost cause? If it's worked before, I'll go back and re-re-check my wiring.
2 Comments
Walter Roberson
on 29 Jun 2011
Hey, someone who still remembers what a null modem cable is! And hand-wired, too!
Raymond Chiu
on 24 May 2016
I have had success configuring the PL2303HX serial-over-USB cables to Simulink / MATLAB on Win10. I suggest that using a simple terminal program (Termite) to smoke test communications over the serial port. Drivers in Win10 can be tricky because the OS is designed to update drivers (which causes failures).
Accepted Answer
More Answers (1)
William
on 3 Feb 2014
Edited: Walter Roberson
on 3 Feb 2014
Any ideas? I'm having problems keeping my connection with a hardware device. USB to RS232. Code below. After an unexpected termination (error), I can't reestablish connection. instrfind doesn't find. I disconnect then reconnect. No find COM4. Do a hardware reset. No find COM4. Sometimes a reboot is required. Sometimes not. I'm wondering if, when an error occurs, the COM4 port doesn't close properly. Any ideas?
% OPEN COM4
com_check = instrfind ;
if isempty(com_check)
handles.com1 = serial('COM4');
set(handles.com1,'BaudRate',2400,'Terminator','','DataBits',8,'Parity','none','StopBits',1, 'Timeout',1);
fopen(handles.com1);
% PING DEVICE
fwrite(handles.com1,[hex2dec('5A') hex2dec('A5')],'uint8');
% CHECK RESPONSE
BoxGoStr = fread(handles.com1,2);
if ~isempty(BoxGoStr)
if BoxGoStr(1) == hex2dec('88') && BoxGoStr(2) == hex2dec('77')
GoodComs=1;
break
else
GoodComs =0;
end
else
GoodComs =0;
break
end
else
set(handles.ComAlarm, 'String', 'COMMs Initiated', 'BackgroundColor', 'g');
GoodComs = 1;
end
% STOP STREAMING
fwrite(handles.com1,[hex2dec('80') hex2dec('00') hex2dec('00')],'uint8');
1 Comment
Walter Roberson
on 3 Feb 2014
I recommend you open a new Question for this. You can make reference to this Question.
Categories
Find more on System Configuration in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!