I'm wondering if there is a method to Drive the motor speed and read the output of the motor drive from the same Pin, or if there is an alternative solution. Currently the encoder is manually rotated to generate the PIN 5 output that determines speed. I'd like to drive the motor from PIN 5 automatically and also read from it to keep the logic the same. Below is the simulink model.
Why?
What arduino controller are you using?
What type of motor are you using?
What motor driver are you using?
Can you please tell us your electronics, programming, arduino, hardware experience?
As in, a knob? How do you imagine that working with a motor? Please take a few moments to describe the project more clearly.
For speed control of a motor connected to a shaft encoder, most people use PID. The speed setpoint can be transmitted to the control program in many different ways.
In the model presented above, I have the cap removed from the encoder and am manually rotating the disk. The counts seem correct and incrementally increase by 12 pulses per revolution, the position seems to be correct but without a reset pulse it just incrementally grows along with the count. I have since come up with a solution and removed the need for a button to reset the position.
I would eventually hope to develop an PID controller for the motor, however in order to do so and from what i have found, its necessary to have a Quadature decoder / encoder module to output RPM before getting to that point. I have tried implementing various encoders found in packages with no such luck and therefore I'm attempting to make my own.
I don't believe the current system to be reliable as when the speed is adjusted by increasing the duty cycle of the PWM into the motor (increase RPM) the simulation doesn't follow suit. I have struggled to find any information into what goes into developing an accurate encoder in simulink and may need to resort to learning how to code one in a S-function block.
Use a shaft encoder connected to the motor. The Arduino can read that and directly determine the RPM, as long as it is not too fast. "Too fast" depends on MCU clock speed, interrupt capability, etc.
Lots of tutorials and a PID library for Arduino are posted on line.
Unfortunately the project is strictly limited to be interfaced in Simulink. There does seem to be a lot of available resources to reading encoders and creating controllers in python code. I may need to refer to it in the attempt of making my own encoder block