EmbDev.net

Forum: FPGA, VHDL & Verilog DC motor with encoder


von Marco (pastaman71)


Rate this post
useful
not useful
Hello my dear friends,
Since i should complete a project for an Exam but my teacher (not a big 
brain) doesn't want to give me a DE-10 LITE to learn, is there a way to 
simulate a DC motor with Encoder in VHDL using Quartus Prime? This man 
really expect that us know everything about VHDL when he didn't give 
slide/material where to study? Also, there is a website where i can find 
examples to understand how to put down a script in VHDL? ( The most 
difficult script i made by my mind is a PWM :P, i want to make gradually 
something more difficult ). I apoligize if my english is kinda orrible 
and Thanks in advance.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Marco wrote:
> is there a way to simulate a DC motor with Encoder in VHDL
Usually VHDL is used for digtal systems. But of course you can simulate 
physical behavior of a dynamic system also.

Whats the input to a DC motor?
Correct: voltage.

Whats the output of this system?
Indeed: A and B quadrature pulses.

So the entity declaration of that module may look like this:
1
entity motor_with_encoder is
2
Port (
3
  U    : in  real range (-10.0 to +10.0); -- Volts
4
  A, B : out STD_LOGIC                    -- encoder
5
);
6
end motor_with_encoder;

And if you simply say "the polarity of the voltage sets the direction of 
the pulse train" and "the higher voltage is the higher the output 
frequency must be", then you are on a simple but correct way (when there 
are no other restrictions like maximum voltage, speed ramps, dynamic 
behavior and so forth...).

I would create a pattern for A and B and cycle through it related to the 
polarity and the value of the voltage.


But for all of that i do not see any need for a FPGA hardware...


In other words: what is your actual job to do? What part of it is the 
simulated dc motor?

: Edited by Moderator
von Marco (pastaman71)


Rate this post
useful
not useful
thank you for the answer.
Actually i don't have to simulate encoder and motor because the teacher 
bought them but he doesn't want to give them to me (he bought them for 
me 🤔). I decided to simulate it to start the project even if it's 
useless.
I have motor, motor driver and encoder mounted on the DC motor, all i 
have to do is making a digital system that works on two's complement 
that say the speed and direction of the motor and with the encoder make 
a feedback loop control.
If i had to use Arduino, that would be the easiest game of my life but i 
have no idea what i can/have to do with VHDL.

here's the teacher instructions:
Suppose you have available (they will be provided by the teacher) a DC 
motor equipped with a reduction gear and a digital quadrature encoder 
and a full bridge driver for powering the motor.

A digital system has to be designed which is able to maintain constant 
the rotational speed of the motor which is supposed to be encoded on an 
8-bit integer in two's complement notation.

The output of the digital system consists of the digital signals needed 
to drive the bridge, ie a bit to indicate the direction of rotation and 
a PWM signal with the duty cycle proportional to the power to be sent to 
the motor.

The system must continuously monitor the output of the quadrature 
encoder to estimate the direction and magnitude of the rotational speed. 
Based on the estimated value and the reference input, the duty cycle of 
the PWM output signal must be modified in order to reach the set 
rotation speed.

Once the design of the digital system has been completed and its correct 
behavior verified by means of MODELSIM simulation, this must be 
integrated as part of a peripheral for NIOSII with the predisposition of 
the control commands on serial following the system on chip model 
developed in class.

The characteristics of the motor with encoder and of the full bridge 
driver available are summarized in the figures.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Marco wrote:
> I decided to simulate it to start the project even if it's useless.
So its your own decision to simulate the mechanical part of that 
project?

I would never do that. There are much better tools to check out the 
dynamic behavior of a mechanical system than a VHDL simulator. My 
attempt would be to do calculate the parameters for the controller with 
Matlab.

> here's the teacher instructions: ...
> Once the design of the **digital** system has been completed and its correct
> behavior verified by means of MODELSIM
So what you have to do is simply to write code to generate the propriate 
pulses and signals for the motor driver.

And then your teacher wants you to implement a qaudrature counter for 
the position signal. But there you could use a shortcut: because only 
the speed (ant not the position!) has to controlled, it would be enough 
to look at only one track of the encoder signal as its frequency is 
relavite to the rotational speed.

And to get the speed to a desired value you will have to implement some 
kind of PI(D) controller.

That is what your teacher wants you to do.

: Edited by Moderator
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.