moha_sa Posted November 30, 2021 Posted November 30, 2021 once I interface MATLAB with PMAC by the generated c-code package from MATLAB, it includes math.h, as I am using sinus block input in the Simulink. However, I am not sure what would be the best way to include the required math.h or any general static library into PMAC IDE. I tried to manually include a math.h file, but once I compile the PMAC IDE it still gives me error (see attachment). Does anyone know how to fix this? Quote
Omron Forums Support Posted December 1, 2021 Posted December 1, 2021 I would be surprised if you needed to include math.h. I am able to use the basic trig functions it provides anywhere in PMAC. Are you sure it is needed? It looks like there is only one "#endif". Could this be responsible for the error? 1 Quote
moha_sa Posted December 2, 2021 Author Posted December 2, 2021 Excellent. You are right! The project builds successfully even without including . We are using PMAC 3.1.2.2. I know that it would be possible to include a directory manually in PMAC. But I am still wondering how to include general header files directory in PMAC similar to what we do in visual studio through project properties link platform? At least I could not find such option on the version of PMAC we are using. Has this option become available on recent PMAC versions? Another question is after being able to successfully compile the MATLAB generated simulink model (a simple sinusoidal trajectory), when commanding this trajectory (sinTraj) for motor#6 through sinTraj_flag(6)=1, I do not see any change would happen (please see attachment). Any comment on these two questions will be greatly appreciated. Quote
Omron Forums Support Posted December 2, 2021 Posted December 2, 2021 I know that it would be possible to include a directory manually in PMAC. But I am still wondering how to include general header files directory in PMAC similar to what we do in visual studio through project properties link platform? At least I could not find such option on the version of PMAC we are using. Has this option become available on recent PMAC versions? You should be able to right click the folder your code is in or the include folder, select add new item and choose header file. Another question is after being able to successfully compile the MATLAB generated simulink model (a simple sinusoidal trajectory), when commanding this trajectory (sinTraj) for motor#6 through sinTraj_flag(6)=1, I do not see any change would happen (please see attachment). sinTraj_flag(6) looks like a user declared variable. Did it come from matlab? Is there a PLC watching the flag to run a motion program? Can you show this code? Quote
moha_sa Posted December 2, 2021 Author Posted December 2, 2021 I know that it would be possible to include a directory manually in PMAC. But I am still wondering how to include general header files directory in PMAC similar to what we do in visual studio through project properties link platform? At least I could not find such option on the version of PMAC we are using. Has this option become available on recent PMAC versions? You should be able to right click the folder your code is in or the include folder, select add new item and choose header file. Many thanks Eric. What if there would be many header files or some of them would reference to sub-header files existing out of PMAC folders? Another question is after being able to successfully compile the MATLAB generated simulink model (a simple sinusoidal trajectory), when commanding this trajectory (sinTraj) for motor#6 through sinTraj_flag(6)=1, I do not see any change would happen (please see attachment). sinTraj_flag(6) looks like a user declared variable. Did it come from matlab? Is there a PLC watching the flag to run a motion program? Can you show this code? Thanks again. Yes. It is part of the c-code (Bmdl_sin.c) generated by MATLAB Simulink embedder coder. *sinTraj* is the name of input sinus block defined in Simulink. I attached the image-I hope the whole image could be captured here after uploading.sinusTrajectoryCommand.pdf Quote
Omron Forums Support Posted December 6, 2021 Posted December 6, 2021 I don't think we support that trajectory generation function. Trajectories are usually controlled through motion programs written in PMAC script. Can you tell me more about what type of trajectory this is? Quote
moha_sa Posted December 6, 2021 Author Posted December 6, 2021 I don't think we support that trajectory generation function. Trajectories are usually controlled through motion programs written in PMAC script. Can you tell me more about what type of trajectory this is? Thanks much Eric. This trajectory name *sinTraj_flag(6)* is what we have ourselves defined in MATLAB Simulink as you can see in the attachment based on manual. It just generates code for a step signal to motor#6. I let Simulink coder generate the c-file package and then add them up to real-time routine folder on PMAC IDE. We are using IDE 3.1.2.2. My wonder is when we execute this user-defined command *sinTraj_flag(6)*, although we do not get any error on the terminal, we do not see any motion or change on the encoder position window. However, the only change we are able to see is on the IDE encoder error window which most probably means there has no DAQ output for motor#6 built up. Any help would be appreciated.Matlab motor step input.pdf Quote
Omron Forums Support Posted December 7, 2021 Posted December 7, 2021 If the motor sees some following error, it sounds like something is getting there. Are you able to jog the motor? Quote
moha_sa Posted December 7, 2021 Author Posted December 7, 2021 If the motor sees some following error, it sounds like something is getting there. Are you able to jog the motor? Thanks a lot Eric. Can you please take a look at the attachment files that I created. To answer your excellent question: most of the times, i am not able to run jog commands like #6j=0 right after running the MATLAB-defined trajectory/servo algorithm command, for example *sinTraj_flag()* here. I do not know why. That seems reasonable that the following error signal window can read the desired position which is 10 encoder counts for the programmed step input by MATLAB/Simulink embedder code, but the actual position of the motor still does not change that means the DAQ signal is not active and I probably miss compiling some sort of Deltatau servo algorithm. I am not quite sure why though. Any idea welcome.matlab defined servo trajectory.pdfsimulink step input trajectory for c code generation to pmac IDE.pdf Quote
leandro.martins Posted February 1, 2022 Posted February 1, 2022 Hello moha_sa I think the problem could be in the assignment in which motor is being executed the trajectory, in your case it's executing on Motor[6] The trajectory should be executed in a virtual motor (e.g. Motor[0]), because it writes on the Motor[x].DesPos, being x the number of the motor declared in sinTraj_flag(). The Motor[6] needs to be maintained its own servo routine (Sys.ServoCtrl by default) to send properly the DAQ signal. You can click on "clear all" and set "Trajectories" for Motor[0] in the "User servo setup" window. I don't know if I was clear, but I hope it helps. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.