Servo Propellor problem with Windows XP
I am trying to control a servo via Matlab using the Propellor Servo Controller USB. I'm accessing the USB port as a virtual COM port through Matlab. It works fine on a computer running Windows 7, 64-bit (altough the Matlab version is 32-bit) but it does not work on a computer just running Windows XP. Suggestions?
This is the code I use:
% Delete all instances that are connected to the COM ports
a = instrfind;
delete(a);
clear;
%Connect to the port
ComPort = serial('COM3');
fclose(ComPort);
% setup parameters
set(ComPort,'BaudRate',2400,'Databits',8,'Parity','none', 'StopBits',2)
fopen(ComPort);
servoPos = 900;
chan = 14;
sramp = 10;
% calculate lo and hi byte values
hiByte = floor(servoPos/256);
loByte = servoPos - hiByte * 256;
% display servoPos value
str = sprintf('servoPos = %6d Lo = %3d Hi = %3d', servoPos, loByte, hiByte);
disp(str);
% create string for the PSC, terminate with $0D
str = sprintf('!SC%c%c%c%c\r',chan,sramp,loByte,hiByte);
% write to PSC
fwrite(ComPort,str);
This is the code I use:
% Delete all instances that are connected to the COM ports
a = instrfind;
delete(a);
clear;
%Connect to the port
ComPort = serial('COM3');
fclose(ComPort);
% setup parameters
set(ComPort,'BaudRate',2400,'Databits',8,'Parity','none', 'StopBits',2)
fopen(ComPort);
servoPos = 900;
chan = 14;
sramp = 10;
% calculate lo and hi byte values
hiByte = floor(servoPos/256);
loByte = servoPos - hiByte * 256;
% display servoPos value
str = sprintf('servoPos = %6d Lo = %3d Hi = %3d', servoPos, loByte, hiByte);
disp(str);
% create string for the PSC, terminate with $0D
str = sprintf('!SC%c%c%c%c\r',chan,sramp,loByte,hiByte);
% write to PSC
fwrite(ComPort,str);
Comments