Matlab & AL5D problem

Hello…
Am trying to do a simple cotroller in matlab to control the AL5D
I want to move the servos with slider and i have the follow problem

fprintf(S,’#0P’+value+‘S200’)

I put the value as the slider value that will control the 00 servo but +value+ matlab dont accept it.

Anyone can help me? Thanks alot!

Don’t know anything about your program, but perhaps you could try doing the math out of the print command.

I will try to explain you my basic idea.
I want to do something like Ssc 32, choose channel (servo) and with slider move the speciic servo
I can connect it etc… but for example i have this statement
fprintf(S,’#4P2000S200’)
i want 2000 to put it dynamic with a slider
my problem is i dont know how 2000 can be added with variable that slider will give
like
svalue = get(handles.slider1,‘Value’);
guidata(hObject, handles);
set(handles.text3,‘String’, num2str(svalue));
set(handles.text3,‘Value’,svalue);
in = get(handles.listbox2,‘Value’);

if(in==1)
S=serial(‘COM4’, ‘BaudRate’, 115200,‘Terminator’,‘LF/CR’);
fopen(S)
fprintf(S,’#0P’+svalue+‘S200’)
fclose(S)

svalue how can i put in the statement so the matlab can accept it…
Thanks alot:)

I don’t know matlab, but my guess is that it is pretty close to c and fprintf. So I would try something like:

fprintf(S,"#0P%dS200", svalue);

That is assuming that svalue is a number. If it is a string, it would probably replace the %d with a %s

Kurt

Thanks Kurte i dont have error but servo not moving:(

While debugging this I would have a tendancy to try to also output what strings you generate back to a terminal window or the like to make sure you are getting what you expect.

It could be as simple as you need to add a CR to the end of the command.

Maybe something like:
fprintf(S,"#0P%dS200\r\n", svalue);

Probably don’t need the line feed, but probably would not hurt

Thanks alot now is working fine:)

missing … the ‘\r’ is what resolved your problem. :wink: