Page 1 of 1
Encoder impulse control time
Posted: Wed Sep 19, 2018 7:32 am
by Ferla
Hello guys
I ask you for a suggestion.
I want to drive a motor in Dc or Stepper this and connected to an encoder how do I perform a check in ms on the encoder pulses so that if the motor gets stuck it disconnects the supply of power to the motor?
I want to make an electronic lock for a security door with the exit of steel pistons.
Thank you all
Ferla
Re: Encoder impulse control time
Posted: Wed Sep 19, 2018 9:34 am
by medelec35
Hi Ferla
The rules
here state:
5. The “Tips and Tricks” sub forum is for sharing your knowledge and NOT for starting off with asking questions.
I have moved your post to a more suitable place.
I have assumed that you use Flowcode V7?
Re: Encoder impulse control time
Posted: Wed Sep 19, 2018 9:37 am
by Ferla
Sorry I thought the correct suggestions section.
Correct, I use FC7
Thank you
Re: Encoder impulse control time
Posted: Mon Sep 24, 2018 1:09 pm
by Benj
Hello
I would do something like when the motor is active enable a timer interrupt. The timer interrupt macro increments a variable. If the variable reaches a certain count value then disable the motors and maybe block using a while 1 loop.
Next enable a second interrupt that fires on a pin change from the encoder. Inside the second interrupt macro reset the counter to 0.
Hope this helps.
Re: Encoder impulse control time
Posted: Mon Sep 24, 2018 1:56 pm
by Ferla
Thanks Benj
You have to offer me a simple example please, I do not ask you to make me the program
Use anything at your convenience, then I adjust my project
Thank you
Ferla
Re: Encoder impulse control time
Posted: Tue Sep 25, 2018 5:30 pm
by Benj
Hi Ferla,
Here's a quick example.
I suggest you look at the interrupt enables to get the timer firing at the right rate and the encoder interrupt firing when the encoder output change state.
I also suggest you change the constant value from 20 to a suitable number of timer interrupts before engaging the safety cut off.
I am blocking when there is an error but you could instead set a variable and check for this in the main loop.
Re: Encoder impulse control time
Posted: Wed Sep 26, 2018 4:32 pm
by Ferla
Thanks, I'll check your project tonight. It is with these suggestions that I appreciate from day to day FC and all those who are part of it.
Ferla