![]() You may also write them to hold the value of ' 0'. To change the output variables enter the variable name to the left of the ' =' in the first line (right image).ĭeclaring that the variables CW and CCW have the value of Not a Number ' NaN' allows for this code to run smoothly when there are no changes in the values of PA to CA or PB to CB. Simulink will start you off automatically with a blank function template (left image), begin to type your code underneath the %#codegen line. Initialization of this code is important. The gain in this case happens to be 4.5 degrees, the angle of each increment of the Keyes-040 Rotary Encoder. Before those signals are summed a gain value is assigned to it. ![]() These two (2) counting blocks are then summed together with respect to their angle (CW ++ and CCW -). The outputs of the MATLAB fcn block feed into two (2) separate COUNTER blocks that increase their output value by one (1) increment each time a TRUE signal is received. The inputs of this particular block are: PAST A ' PA', PAST B ' PB', CURRENT A ' CA', CURRENT B ' CB', and TRIGGER ' T', and the outputs: Clockwise ' CW' and Counter-Clockwise ' CCW' boolean values. This happens to be the brains of the operation as it compares values and determines their output. The MATLAB Function block connects the running Simulink model to a MATLAB. This logic will activate TRUE (return a '1') when either input is TRUE. Both inputs A and B have these blocks attached to them which feed into a LOGICAL OPERATOR (set to OR operation). m fcn block to read the PAST and CURRENT values. The DETECT CHANGE block's job is to tell the MATLAB.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |