Get values from c++ using S-function builder
이전 댓글 표시
Hi, I'm new to coding and I was asked to study the s-function builder for a project and I can't seem to find a way to assign the pointers to the values I want for the input and the output of the block. Or maybe I'm just lacking some fundamental logical knowledge on this?
The project I'm working on is to study Speeduino, an open source code. This is a very small portion of the project that I'm studying currently.
inline uint32_t div360(uint32_t n) {
#ifdef USE_LIBDIVIDE
return libdivide::libdivide_u32_do(n, &libdiv_u32_360);
#else
return n / 360U;
#endif
}
unsigned long angleToTime(int16_t angle, byte method)
{
unsigned long returnTime = 0;
if( (method == CRANKMATH_METHOD_INTERVAL_REV) || (method == CRANKMATH_METHOD_INTERVAL_DEFAULT) )
{
returnTime = div360(angle * revolutionTime);
}
else if (method == CRANKMATH_METHOD_INTERVAL_TOOTH)
{
if(triggerToothAngleIsCorrect == true)
{
unsigned long toothTime = (toothLastToothTime - toothLastMinusOneToothTime);
uint16_t tempTriggerToothAngle = triggerToothAngle; // triggerToothAngle is set by interrupts
returnTime = ( (toothTime * angle) / tempTriggerToothAngle );
}
else { returnTime = angleToTime(angle, CRANKMATH_METHOD_INTERVAL_REV); } //Safety check. This can occur if the last tooth seen was outside the normal pattern etc
}
return returnTime;
}
I put this code in the wrapper in the output section along with the appropriate headers
This is the block that I created

I couldn't mex
How will I be able to assign the variables in the codes to the inputs and the outputs of the block so I can run it?
Thank you
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Simulink Coder에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!