Last active
August 29, 2015 14:02
-
-
Save afjk/099eed35c0e4d8d64fa5 to your computer and use it in GitHub Desktop.
Defying Gravity - A Minimal Cognitive Sensorimotor Loop Which Makes Robots With Arbitrary Morphologies Stand Up からの引用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reg [17:0] voltage; | |
reg [16:0] timer; | |
always @(posedge ADC_CLK) | |
case (state) | |
0 : begin // sense ----------------------------------- | |
if (ADC_DAT == 1) | |
begin | |
if ($signed(voltage) < $signed(18'h1FFFF)) | |
voltage <= voltage + 1; // if not saturated | |
end | |
else if ($signed(voltage) > $signed(18'b20001)) | |
voltage <= voltage - 1; // if not saturated | |
timer <= timer - 1; | |
if (timer == 0) | |
begin // end of sense-phase | |
{MOT_A, MOT_B} <= {~voltage[17], voltage[17]}; | |
if (&voltage[17:13] | ~|voltage[17:13]) | |
timer <= 0; // below min. voltage | |
else | |
timer <= voltage[17:1]; | |
state <= 1; // switch to drive-phase | |
end | |
end | |
1 : begin // drive ----------------------------------- | |
if (timer[16]) | |
timer <= timer + 1; // count up to zero | |
else | |
timer <= timer - 1; // count down to zero | |
if (timer == 0) | |
begin // end of drive-phase | |
timer <= 17'd99999; // prepare T = 10ms | |
{MOT_A, MOT_B} <= 2'b11; // float motor outputs | |
state <= 0; // switch to sense-phase | |
end | |
end | |
endcase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.neurorobotik.de/downloads/publications/2013%20Hild%20-%20Defying%20Gravity.pdf