Goodmorning my dear friends, it's me again. I started to code the PI controller for my project to calculate the error between the PWM and the motor's encoder and the GHDL gives me an error that i can't fix( or better, i have no idea of how should i fix it). I'll attach the code and put the error down here: PI.vhd:30:30: no function declarations for operator "-" PI.vhd:36:72: no function declarations for operator "*" what that means? what i did wrong? thanks a lot in advantage <3
Marco wrote: > what i did wrong?
1 | ** Error: pl.vhd(30): Type error resolving infix expression "-" as type ieee.NUMERIC_STD.SIGNED. |
Your types didn't match:
1 | error <= to_integer(ref) - to_integer(feed); |
2 | signed <= integer - integer; |
See the defined functions in numeric_std: https://tams-www.informatik.uni-hamburg.de/vhdl/doc/faq/FAQ1.html#4.8.1
If you change the code to
1 | process(reference_signal, encoder_signal)is |
2 | begin
|
3 | -- Calcolo dell'errore tra velocità di riferimento e velocità effettiva
|
4 | error <= ref - to_integer(feed); |
5 | |
6 | -- Calcolo del termine integrativo
|
7 | integral_term <= integral_term + error; |
8 | |
9 | -- Calcolo del segnale di controllo
|
10 | pwm_output <= resize( encoder_signal + natural(Kp) * error + natural(Ki) * integral_term, pwm_output'length); -- è l'equivalenente di (7 downto 0) ma più skillato |
11 | end process; |
It will compile, but you need to check with a testbench if it will work.
BTW: you don't need no process here. These are simply 3 concurrent statements.
First o all, I want to thanks everyone for the answers, but i have another question about this. If i don't need a process here, where do i need a process? It's only where there are more statements or what? Thank you. P.S. i will post more as update about the work
Marco wrote: > If i don't need a process here, where do i need a process? You don't need the process here because inside it are only 3 statements which are calculated without any relation to each other. Or in other words: a concurrent statement has an implicit process with an implicit sensitivity list. This concurrent statement here:
1 | a <= b + c; |
Is the very same like that chatty process:
1 | process (b,c) is |
2 | begin
|
3 | a <= b + c; |
4 | end process; |
Marco wrote: > IT COMPILES!!! but why? Hint: look as said for the defined functions of the operators. E.g. for the - operator there is no overloaded functions for integer-integer with a signed as a result. This would work also: error <= to_signed(to_integer(ref) - to_integer(feed)),8);
:
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
Log in with Google account
No account? Register here.