Hi everyone. I’m using matlab to communicate with an AL5A robotic arm. Communication is fine and arm is moving according to given instructions using printf. However I have a small problem. I need that the base rotates according to a given angle i.e. automatically. I did the following code however its not rotationg as it should (i.e. it only works for home position where printf is given manually but the automatic base rotation according to a given angle is not working)
clear all
clc
obj = serial(‘COM3’);
set(obj, ‘Terminator’, ‘CR’);
set (obj, ‘BaudRate’,115200,‘DataBits’,8,‘Parity’,‘none’,‘StopBits’,1)
obj.FlowControl = ‘none’;
fopen(obj)
%Robotic Arm Home Position
fprintf(obj, ‘#0P651’)
fprintf(obj, ‘#1P1700’)
fprintf(obj, ‘#2P2100’)
fprintf(obj, ‘#3P600’)
fprintf(obj, ‘#4P800’)
fprintf(obj, ‘#5P1500’)
%Automatic Base rotation according to angle
baserotate_angle = 90
In this case the output from the serial port is fine since I’m using a serial port monitor and the automatic base rotation is giving the same instruction to the arm…however it’s still not working:/ Anyone out there knows why??
For example considering the last two instructions given i.e. #0P2369 the last instruction was given manually which worked but the previous one was given automatically which didn’t work?? What’s wrong with it??? They are both the same:/
Now I’m continuning my testing and noticing something really strange. The instruction is fine as shown from the serial port monitor!!! Now when I open Rios the arm immediately moves to the given automatic angle!!! So its working when I open RIOS!! Really strange!!! Pls help. 10x
I’m not sure if the serial port monitor displays the CR but you do know the SSC-32 will not do anything until it receives a carriage return right? Also if you want to move a servo slowly then do it this way.
#0 P1500 T2000 CR
The T2000 forces the move to take 2 seconds, not as fast as the servo is capable of moving.
Yes I’m using this in my code:
set(obj, ‘Terminator’, ‘CR’);
When I removed it a fullstop was displayed at the end of each instruction in the serial port monitor and in this case the arm didn’t move and so I did it again!! I don’t know its meaning exactly!!
Well that’s all I have. It’s going to take the help of someone more experienced with mat lab. You might want to look for others who have posted here on the subject and email them. Some folks don’t keep in touch after their problem was corrected. Good luck!
I haven’t worked with Matlab, but since we use it here to test our robots, you’ve piqued my curiosity.
Seems very ‘C’-like. I’m not seeing any sort of “loop” structure. It appears that the program would only make one pass. And I only see one setting of baserotate_angle. What changes this parm?
Of course I could be way off point here, as I said, I haven’t worked with Matlab!
I’ll have to get with our software engineers when I get some time to check out Matlab.
What are you using for a manual? How close to ‘C’ is the grammer supposed to be?
Alan KM6VV
(I’ve probably asked more questions then I’ve answered). Thanks!
Hi. I solved the problem right now Yes I have a 500 line code which actually gives a parameter/ changes the angle according to a given object using a camera…but obviously I didnt post it here. I was trying to give it an angle and see if it moves accordingly which is now achieved. The problem was with the following line of code:
fprintf(obj, ‘#0P%d’, baserotate_asc)
This has to be as shown below
fprintf(obj, ‘#0P%d\n’, baserotate_asc) where \n is the terminator character signifying the carriage return. Although I had it in my frst few lines of code \n still needs to be written in this case. Now the arm is moving correctly