Monitor DC motor velocity using arduino and simulink
13 views (last 30 days)
I'm trying to measure the rotation of a DC Motor connected to an arduino mega 2560 by means of an encoder wheel and an optointerrupter. I devised a model based on a Simulink example called arduino_external_interrupt. The idea was to connect the optointerrupter out port to an external interrupter pin in the arduino board, and get the number of changes in the pulsating signal (i.e., 1 to 0 or 0 to 1, from which I expect to estimate the rotation angle). I'm using an L293D H bridge to control de motor. I also include part of the model created for more details. The problem I'm having is that when I run the model on the arduino board in external mode, the signal has weird jumps, that is to say the increments in the pulse counting are not 1, even in some times it is as high as 10 from one cycle to other. But when I run the model as a normal simulink model, the signal appears consistent, but the number of counts remains unaffected by the size of the duty cicle of the PWM Modulation. I seems otherwise ok, though. Why does this happen? Is there a better way to control the motion of a DC motor using an L293D H bridge, an encoder wheel and an optointerrupter? Thanks in advance
The electronics I'm trying to control are somewhat like this, but the connections may vary from this picture to the conections used in the simulink model. The optointerrupters and encoder wheels are used to measure the rotation of the wheels, but are not shown. They are connected to the external hardware interrupter pins of the arduino mega 2560 board.