Encoder connection to simplified c block

reza hakimi_20486
reza hakimi_20486 Altair Community Member
edited July 2023 in Community Q&A

Hello
When connecting the encoder directly to the C block, the software gives an error. What is the reason for this problem and what solution do you suggest?

I have identified the problem in the picture.

Tagged:

Answers

  • Rhonda_20369
    Rhonda_20369 New Altair Community Member
    edited July 2023

    What error message did you see?

    Your attached picture does not show how the encoder is connected to the C block.

    This picture shows that all the input ports of your C block are floating, not connected to any signal. 

    Doesn't your C code need any input signal? If not, why do you have 3 input ports for the block?

     

    Please attach you PSIM schematic to this question. The details in the components' parameter settings provide useful information for finding your problem.

  • reza hakimi_20486
    reza hakimi_20486 Altair Community Member
    edited July 2023

    Hello
    Thank you for your reply
    The encoder is connected to block C. I removed this connection to make sure that the mentioned error will be fixed or not
    Now I will show you the picture of the circuit with the complete connection and the corresponding error
    Of course, I think that there should be an element between the encoder and block C, but I don't know what it is?

  • Rhonda_20369
    Rhonda_20369 New Altair Community Member
    edited July 2023

    Hi, Reza,

    In the 2nd picture, you have connected the 3 input signals of the C block "SSCB1" to the 3 signals outside the F28335 MCU. Those 3 signals are from a mechanical encoder.

    The output signal of this C block "SSCB1" is connected to "SSCB2" which is obviously is inside of the F28335 MCU.

    The question is: Is this block SSCB1 outside or inside of the F28335 code?

    If this block is outside of F28335, you should connect its output to a F28335 port.

    If this block is inside of F28335, you should use F28335 ports to bring the 3 input signals inside F28335. You may use the F28335 blocks such as ADC, Digital Input, Encoder, Capture, and etc.

     

    Any signal outside of a MCU must be brought inside via some kind of port. The code inside of a MCU CANNOT read the outside signals without assigned connections. 

    Even if your MCU supports wireless connections, you must assign the signals to the wireless ports.

  • Albert_Dunford
    Albert_Dunford
    Altair Employee
    edited July 2023

    as rhonda mentions this connection is not possible.

    image

    if you remove the PWM block this will run. For every signal that will be compiled with the code gen it needs to go through a target peripheral like GPIO, ADC, SPI etc. then out through the PWM or GPIO. You need to be careful with this sort of signal if you put it through a GPIO you will likely require a high interrupt rate to properly resolve the encoder, this is why there is a purpose built encoder block, which is to the right of you c code. The peripherals of these targets are setup to deal with the issues of interrupt rates and edge detection.