6 years, 5 months ago.

I am trying to mimic encoder output

Is there a way of using an ST to output a pulse which would mimic the turns of an encoder.

I don't want to read encoder output from an encoder, I want to be able to define a pin to output a pulse.

DigitalOut channelA(PC_9); DigitalOut channelB(PB_8); DigitalOut PB(PB_9);

int main() {

channelA = 0; wait_ms(200); channelA = 1; wait_ms(2000); channelA = 0; wait_ms(200); channelA = 1; wait_ms(2000); channelA = 0; wait_ms(200); channelA = 1; wait_ms(2000); the channels do not respond to button presses. What do do tomorrow is look at how to generate encoder turns.

while(1);

}

The above code works, by causing a light to turn on and off, when I set the output to the pushbutton, DigitalOut PB(PB_9) . This does not work with the pin connected to a encoder channel on an encoder faceplate.

Can anyone help please?

It would help if you could clarify the end goal is. What is the input? What is the output?

Is a push button the input? So that a single push of the button generates a certain train of output pulses? Or does the micro just generate an output on its own every time it’s restarted? Or is it in a loop generating output continuously? Is the output just one digital channel? There are different types of encoders. Can you be specific about the type of encoder you are trying to emulate? What is your output pin connected to? This could affect loading on the output pin and may change the pin mode you want to use. What is an Encoder Faceplate?

If the output pulses are in the 200 to 2000ms range you generally have the right idea. Flip the output pin and then wait. You would probably want to set it up in a way where it doesn’t block the whole program though. Could use a ticker or event queue or a thread.

posted by Graham S. 12 Apr 2019
Be the first to answer this question.