Skip to content

Commit 22b994f

Browse files
committed
ServoBit-180 block. Initial draft
1 parent a377883 commit 22b994f

File tree

3 files changed

+459
-0
lines changed

3 files changed

+459
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
{
2+
"version": "1.1",
3+
"package": {
4+
"name": "ServoBit_180",
5+
"version": "0.1",
6+
"description": "Movimiento de un servo con 2 posiciones. El ángulo entre una posición y otra es de 180 grados",
7+
"author": "Juan Gonzalez-Gomez y Jesus Arroyo",
8+
"image": "%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%22-252%20400.9%2081%2050%22%20width=%2281%22%20height=%2250%22%3E%3Cpath%20d=%22M-188.44%20420.151l11.193-10.393-.829%2034.507-10.778%205.82z%22%20fill=%22#ccc%22%20fill-rule=%22evenodd%22%20stroke=%22#000%22%20stroke-linejoin=%22round%22/%3E%3Cpath%20d=%22M-243.571%20420.525v29.144h54.717v-29.518z%22%20fill=%22gray%22%20fill-rule=%22evenodd%22%20stroke=%22#000%22/%3E%3Cpath%20d=%22M-243.572%20420.567l11.607-10.394%2054.718-.415-10.778%2011.225z%22%20fill=%22#999%22%20fill-rule=%22evenodd%22%20stroke=%22#000%22%20stroke-linejoin=%22round%22/%3E%3Cellipse%20cx=%22-183.709%22%20cy=%22405.047%22%20rx=%2215.805%22%20ry=%226.814%22%20transform=%22matrix(.99976%20-.02173%20-.04249%20.9991%200%200)%22%20fill=%22#999%22%20stroke=%22#000%22%20stroke-width=%221.001%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22/%3E%3C/svg%3E"
9+
},
10+
"design": {
11+
"board": "icezum",
12+
"graph": {
13+
"blocks": [
14+
{
15+
"id": "4f53e73f-c314-40ef-8bb2-98150940959c",
16+
"type": "basic.code",
17+
"data": {
18+
"code": "\n\nparameter HIGH = 8'hF0;\nparameter LOW = 8'h00;\n\nreg [7:0] pos = LOW;\n\nalways @(posedge clk)\n pos <= pos_bit ? HIGH : LOW;\n\n\n//---\n//--- ServoMotor \n\nlocalparam M = 94; //-- 94\nlocalparam N = $clog2(M);\n\nreg [N-1:0] divcounter = 0;\nreg tic = 0;\n\n//-- Ticks generation. A pulse is emmited every M system clock cycles\nalways @(posedge clk)\n tic <= (divcounter == M - 2);\n\n//-- Module M counter\nalways @(posedge clk)\n if (tic)\n divcounter <= 0;\n else\n divcounter <= divcounter + 1;\n\n//-- Angle counter\nreg [10:0] angle_counter = 0;\n\nwire [8:0] pose = {1'b0, pos} + 9'd46;\n\nalways @(posedge clk)\n if (tic)\n angle_counter <= angle_counter + 1;\n\nalways @(posedge clk)\n servo <= (angle_counter < {3'b000, pose});\n\n",
19+
"params": [],
20+
"ports": {
21+
"in": [
22+
{
23+
"name": "clk"
24+
},
25+
{
26+
"name": "pos_bit"
27+
}
28+
],
29+
"out": [
30+
{
31+
"name": "servo"
32+
}
33+
]
34+
}
35+
},
36+
"position": {
37+
"x": 304,
38+
"y": 80
39+
}
40+
},
41+
{
42+
"id": "f9f4add8-1ca6-49c0-adae-0d1a45025fc1",
43+
"type": "basic.input",
44+
"data": {
45+
"name": "clk",
46+
"pins": [
47+
{
48+
"index": "0",
49+
"name": "CLK",
50+
"value": "21"
51+
}
52+
],
53+
"virtual": false
54+
},
55+
"position": {
56+
"x": 56,
57+
"y": 112
58+
}
59+
},
60+
{
61+
"id": "eac2d6e9-4a62-4aec-8ce8-0e6c54e14d22",
62+
"type": "basic.output",
63+
"data": {
64+
"name": "servo",
65+
"pins": [
66+
{
67+
"index": "0",
68+
"name": "D0",
69+
"value": "119"
70+
}
71+
],
72+
"virtual": false
73+
},
74+
"position": {
75+
"x": 816,
76+
"y": 176
77+
}
78+
},
79+
{
80+
"id": "e3e07bdb-9bb3-4afb-ace5-bcc99aecef0a",
81+
"type": "basic.input",
82+
"data": {
83+
"name": "pos_bit",
84+
"pins": [
85+
{
86+
"index": "0",
87+
"name": "D13",
88+
"value": "144"
89+
}
90+
],
91+
"virtual": false
92+
},
93+
"position": {
94+
"x": 56,
95+
"y": 240
96+
}
97+
}
98+
],
99+
"wires": [
100+
{
101+
"source": {
102+
"block": "4f53e73f-c314-40ef-8bb2-98150940959c",
103+
"port": "servo"
104+
},
105+
"target": {
106+
"block": "eac2d6e9-4a62-4aec-8ce8-0e6c54e14d22",
107+
"port": "in"
108+
}
109+
},
110+
{
111+
"source": {
112+
"block": "f9f4add8-1ca6-49c0-adae-0d1a45025fc1",
113+
"port": "out"
114+
},
115+
"target": {
116+
"block": "4f53e73f-c314-40ef-8bb2-98150940959c",
117+
"port": "clk"
118+
}
119+
},
120+
{
121+
"source": {
122+
"block": "e3e07bdb-9bb3-4afb-ace5-bcc99aecef0a",
123+
"port": "out"
124+
},
125+
"target": {
126+
"block": "4f53e73f-c314-40ef-8bb2-98150940959c",
127+
"port": "pos_bit"
128+
}
129+
}
130+
]
131+
},
132+
"state": {
133+
"pan": {
134+
"x": 0,
135+
"y": 0
136+
},
137+
"zoom": 1
138+
}
139+
},
140+
"dependencies": {}
141+
}
Lines changed: 75 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)