Hi everybody,
I'm a beginner in Matlab/Simulink/App designer and I want to create an entire app which is capable of sending and reading a lot of CAN messages from a Speedgoat calculator.
I tried a lot of differents things and I read a lot of answer on topics inside Mathworks network but I didn't manage to solve my problems.
To sum up my situation a little bit, I create one timer which allows to read CAN messages from Speedgoat calculator every 100 ms and update some informations in the app according to the received messages, here is the code of the timer and its callback function :
app.receiveCANmsgsTimer = timer('Period', 100e-3, 'ExecutionMode', 'fixedRate');
app.receiveCANmsgsTimer.TimerFcn = @(~,~)receiveCANmsgsTimerCallback(app);
function receiveCANmsgsTimerCallback(app)
msg = receive(app.canChannelObj, Inf, 'OutputFormat', 'timetable');
getOutputModuleStatesCANmessage(app, msg);
getHOSOutputCANmessage(app, msg);
getESSGrBCmdCANmessage(app, msg);
getESSGrCCmdCANmessage(app, msg);
getESSGrDCmdCANmessage(app, msg);
geteDriveCascadiaInverterCmdCANmessage(app, msg);
geteDrive08DriveEnableCANmessage(app, msg);
geteDrive07DriveEnableCANmessage(app, msg);
geteDrive06DriveEnableCANmessage(app, msg);
geteDrive05DriveEnableCANmessage(app, msg);
geteDrive04DriveEnableCANmessage(app, msg);
geteDrive03DriveEnableCANmessage(app, msg);
geteDrive02DriveEnableCANmessage(app, msg);
geteDrive01DriveEnableCANmessage(app, msg);
My canChannelObj is well define and create because I can see all the messages received and sent on the CAN channel.
Following, you will find an example of one of my get "Can Message function", the message and signal name are well created in a dababase file and the database is well linked to the canChannelObj :
function getOutputModuleStatesCANmessage(app, msg)
outputModuleStatesSignals = canSignalTimetable(msg, "OutputModule_States");
if ~isempty(outputModuleStatesSignals)
EMS_Mode = outputModuleStatesSignals.EMS_Mode;
app.EMSModeEditField_7.Value = "EMS_INIT";
app.EMSModeEditField_7.Value = "EMS_WAKEUP";
app.EMSModeEditField_7.Value = "EMS_FAILURE_WAKEUP";
app.EMSModeEditField_7.Value = "EMS_START_PRECHARGE";
app.EMSModeEditField_7.Value = "EMS_WAIT_FOR_HV_ON";
app.EMSModeEditField_7.Value = "EMS_PRECHARGE";
app.EMSModeEditField_7.Value = "EMS_FAILURE_PRECHARGE";
app.EMSModeEditField_7.Value = "EMS_WAIT_FOR_PU_START";
app.EMSModeEditField_7.Value = "EMS_FAILURE_PU_START";
app.EMSModeEditField_7.Value = "EMS_POWER_ON";
app.EMSModeEditField_7.Value = "EMS_FAILURE_POWER_ON";
app.EMSModeEditField_7.Value = "EMS_WAIT_FOR_PU_STOP";
app.EMSModeEditField_7.Value = "EMS_WAIT_FOR_HV_OFF";
app.EMSModeEditField_7.Value = "EMS_STOP";
app.EMSModeEditField_7.Value = "EMS_IMPOSSIBLE_VALUE";
This is the way I read datas and update the app information according to the CAN signals received by app designer.
One of my problem is that my EMSModeEditField_7.Value isn't update according to the signal value. At the starting of the app, It works but just after the value is blocked and stop to update even if the value of CAN signal changes. For example, at the beginning I see in the app "EMS_WAKEUP" inside the EMSModeEditField_7.Value and stay to this value but inside the CAN message "OutputModule_States" , I see the value 2 inside the signal EMS_Mode but I always have "EMS_WAKEUP" in the app instead of "EMS_FAILURE_WAKEUP".
Someone have some ideas to fix this problem, please ?
I'm really blocked since some days and all things that I tried didn't work.
If you have noticed, in the first code I added in the message, the fact that one of my get function is commented inside the function "receiveCANmsgsTimerCallback" :
If I uncomment this line and if I launch the my application with a USB to CAN connection between my PC and the Speedgoat, I have the following errors message in orange which never stops and continues all the time (my command window stil scroll down indefinitly), I don't have other choice to kill all matlab's windows through the windows tasks manager. I don't understand the link because the errors message seems to be linked to the transmits function that are completly independent compare to the line that I commented. Do you have any ideas on this problem ? 
I hope you have enough informations to help me, if it's not the case, don't hesitate to ask me for more details.
I thank you a lot in advance,
F.G.