Encoder impulse control time

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
Ferla
Flowcode v5 User
Posts: 126
Joined: Sun Jan 06, 2013 8:58 pm
Location: Italy
Been thanked: 19 times
Contact:

Encoder impulse control time

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Encoder impulse control time

Post 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?
Martin

Ferla
Flowcode v5 User
Posts: 126
Joined: Sun Jan 06, 2013 8:58 pm
Location: Italy
Been thanked: 19 times
Contact:

Re: Encoder impulse control time

Post by Ferla »

Sorry I thought the correct suggestions section.
Correct, I use FC7
Thank you

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Encoder impulse control time

Post 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.

Ferla
Flowcode v5 User
Posts: 126
Joined: Sun Jan 06, 2013 8:58 pm
Location: Italy
Been thanked: 19 times
Contact:

Re: Encoder impulse control time

Post by Ferla »

Thanks Benj
You have to offer me a simple example please, I do not ask you to make me the program :wink:
Use anything at your convenience, then I adjust my project
Thank you
Ferla

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Encoder impulse control time

Post by Benj »

Hi Ferla,

Here's a quick example.
MotorSupervisor.fcfx
(14.17 KiB) Downloaded 238 times
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.

Ferla
Flowcode v5 User
Posts: 126
Joined: Sun Jan 06, 2013 8:58 pm
Location: Italy
Been thanked: 19 times
Contact:

Re: Encoder impulse control time

Post 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

Post Reply