0
디지털 잠금을 위해 서보를 FPGA에서 실행하려고합니다.Servo가 FPGA에서 멈추지 않습니다.
My code is as follows:
`timescale 1ns/1ps
/*
1 pin for servo--ORANGE CABLE
red cable-- 5V, brown cable-- GND.
Position "0" (1.5 ms pulse) is middle,
"90" (~2ms pulse) is all the way to the right,
"-90" (~1 ms pulse) is all the way to the left.
servo stuff:
http://www.micropik.com/PDF/SG90Servo.pdf
*/
//All i need to do is set SERVOPWM to 1 and 0 with delays i think
module ServoTestNShit(input M_CLOCK,
output [7:0] IO_LED, // IO Board LEDs
output reg SERVOPWM);
assign IO_LED = 7'b1010101; // stagger led lights just cause
reg [15:0] counter;
reg [15:0] counter1;
initial begin
counter1 = 0;
counter = 0;
end
//use counter to have a 1ms or 2ms or 1.5ms duty cycle for a while inorder to actually run
//because run it this way is asking the servo to move for 1.5ms so it cant atually move that fast
always @ (posedge M_CLOCK)
begin
counter <= counter+1;
counter1 <= counter1+1;
end
always @ (negedge M_CLOCK)
begin
//if (counter1 > 500)
//begin
SERVOPWM <= (counter <= 1);
//end
end
endmodule
현재 2ms 또는 1ms 여부와 상관없이 모든 것을 오른쪽으로 돌릴 수 있습니다. 내가 겪고있는 커다란 문제는 오른쪽으로 돌아서 작동을 멈추게하려고하는 것입니다. 내가 시도한 모든 것이 전혀 작동하지 않거나 처음부터 핀에 0을 보낸 적이없는 것처럼 논스톱으로 작동합니다.
누구나 한 방향으로 완전히 회전 할 수있는 충분한 시간을 보낸 후 가장 좋은 방법을 제안 할 수 있습니까?
감사합니다!
내가 혼란 스러워요. 나는 그것이 도움이되는 방법을 보지 못한다. 마치 voltage_percentage를 10으로 바꾸면 정확한 시간만큼 핀을 높게 설정하지 않으므로 실제로 핀을 설정하지 않고 서보를 움직이지 않게한다. . 또한 왜 servo = counter = voltage_percentage를 설정합니까? 3 명 모두를 평등하게 설정 한 뒤에 나온 아이디어는 무엇입니까? –
아니요, 우리는 모두를 동일하게 설정하지 않습니다. '(counter <= voltage_percentage)'는 비교됩니다 (크거나 같음). 즉, 과 같이 생각할 수 있습니다. if (counter <= voltage_percentage) –
if (counter <= voltage_percentage) SERVOPWM <= 1; else SERVOPWM <= 0; –