Skip to content

Commit 93983b5

Browse files
committed
ServoBit-180: Test2 example: 1-button, a NOT gate, an the servo
1 parent 1c527bc commit 93983b5

File tree

1 file changed

+362
-0
lines changed

1 file changed

+362
-0
lines changed
Lines changed: 362 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,362 @@
1+
{
2+
"version": "1.1",
3+
"package": {
4+
"name": "",
5+
"version": "",
6+
"description": "",
7+
"author": "",
8+
"image": ""
9+
},
10+
"design": {
11+
"board": "icezum",
12+
"graph": {
13+
"blocks": [
14+
{
15+
"id": "d92ff5cc-b23f-48b0-acf6-aea5288be227",
16+
"type": "basic.input",
17+
"data": {
18+
"name": "clk",
19+
"pins": [
20+
{
21+
"index": "0",
22+
"name": "CLK",
23+
"value": "21"
24+
}
25+
],
26+
"virtual": false
27+
},
28+
"position": {
29+
"x": 256,
30+
"y": 40
31+
}
32+
},
33+
{
34+
"id": "4394362a-06dd-4590-8104-0e31ca863e05",
35+
"type": "c91ccaa367351314fdd1ed7784836fe9155f7ecc",
36+
"position": {
37+
"x": 464,
38+
"y": 136
39+
}
40+
},
41+
{
42+
"id": "9feb2740-2ac5-4a4d-b5e3-c0634516d719",
43+
"type": "basic.output",
44+
"data": {
45+
"name": "Servo",
46+
"pins": [
47+
{
48+
"index": "0",
49+
"name": "D0",
50+
"value": "119"
51+
}
52+
],
53+
"virtual": false
54+
},
55+
"position": {
56+
"x": 608,
57+
"y": 136
58+
}
59+
},
60+
{
61+
"id": "19b09324-e39a-48f2-89cb-a6d8148a7471",
62+
"type": "basic.input",
63+
"data": {
64+
"name": "Boton",
65+
"pins": [
66+
{
67+
"index": "0",
68+
"name": "D13",
69+
"value": "144"
70+
}
71+
],
72+
"virtual": false
73+
},
74+
"position": {
75+
"x": 32,
76+
"y": 152
77+
}
78+
},
79+
{
80+
"id": "0c98e6e0-d391-4f12-9efa-aff76f0b22ea",
81+
"type": "32200dc0915d45d6ec035bcec61c8472f0cc7b88",
82+
"position": {
83+
"x": 256,
84+
"y": 152
85+
}
86+
},
87+
{
88+
"id": "42b9a39c-9c80-4330-a123-591bafaecf6a",
89+
"type": "basic.info",
90+
"data": {
91+
"info": "ServoBit-180 : Ejemplo 2\n------------------------\n\nVisualizacion de 1 bit negado\n\nAhora el servo está mirando hacia la izquierda\ncuando el pulsador NO está apretado\n\nAl apretarlo se mueve hacia la derecha\n\nJusto lo contrario del ejemplo 1\nEs lo que hace la puerta NOT"
92+
},
93+
"position": {
94+
"x": 32,
95+
"y": 240
96+
}
97+
}
98+
],
99+
"wires": [
100+
{
101+
"source": {
102+
"block": "4394362a-06dd-4590-8104-0e31ca863e05",
103+
"port": "eac2d6e9-4a62-4aec-8ce8-0e6c54e14d22"
104+
},
105+
"target": {
106+
"block": "9feb2740-2ac5-4a4d-b5e3-c0634516d719",
107+
"port": "in"
108+
}
109+
},
110+
{
111+
"source": {
112+
"block": "d92ff5cc-b23f-48b0-acf6-aea5288be227",
113+
"port": "out"
114+
},
115+
"target": {
116+
"block": "4394362a-06dd-4590-8104-0e31ca863e05",
117+
"port": "f9f4add8-1ca6-49c0-adae-0d1a45025fc1"
118+
},
119+
"vertices": [
120+
{
121+
"x": 432,
122+
"y": 112
123+
}
124+
]
125+
},
126+
{
127+
"source": {
128+
"block": "0c98e6e0-d391-4f12-9efa-aff76f0b22ea",
129+
"port": "664caf9e-5f40-4df4-800a-b626af702e62"
130+
},
131+
"target": {
132+
"block": "4394362a-06dd-4590-8104-0e31ca863e05",
133+
"port": "e3e07bdb-9bb3-4afb-ace5-bcc99aecef0a"
134+
}
135+
},
136+
{
137+
"source": {
138+
"block": "19b09324-e39a-48f2-89cb-a6d8148a7471",
139+
"port": "out"
140+
},
141+
"target": {
142+
"block": "0c98e6e0-d391-4f12-9efa-aff76f0b22ea",
143+
"port": "18c2ebc7-5152-439c-9b3f-851c59bac834"
144+
}
145+
}
146+
]
147+
},
148+
"state": {
149+
"pan": {
150+
"x": 0,
151+
"y": -27
152+
},
153+
"zoom": 1
154+
}
155+
},
156+
"dependencies": {
157+
"c91ccaa367351314fdd1ed7784836fe9155f7ecc": {
158+
"package": {
159+
"name": "ServoBit_180",
160+
"version": "0.1",
161+
"description": "Controlador de 1 bit para mover un servo a 2 posiciones. El ángulo entre una posición y otra es de 180 grados",
162+
"author": "Juan Gonzalez-Gomez y Jesus Arroyo",
163+
"image": "%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%22-252%20400.9%2081%2055%22%20width=%2281%22%20height=%2255%22%3E%3Cdefs%3E%3Cmarker%20orient=%22auto%22%20id=%22a%22%20overflow=%22visible%22%3E%3Cpath%20d=%22M1.926%201.21L-1.352.005l3.278-1.206a2.05%202.05%200%200%200%200%202.411z%22%20fill-rule=%22evenodd%22%20stroke-width=%22.1875%22%20stroke-linejoin=%22round%22%20stroke=%22#00f%22%20fill=%22#00f%22/%3E%3C/marker%3E%3Cmarker%20orient=%22auto%22%20id=%22b%22%20overflow=%22visible%22%3E%3Cpath%20d=%22M-1.926-1.21L1.352-.005l-3.278%201.206a2.05%202.05%200%200%200%200-2.411z%22%20fill-rule=%22evenodd%22%20stroke-width=%22.1875%22%20stroke-linejoin=%22round%22%20stroke=%22#00f%22%20fill=%22#00f%22/%3E%3C/marker%3E%3C/defs%3E%3Ctext%20style=%22line-height:125%25%22%20x=%22-249.529%22%20y=%22455.924%22%20font-weight=%22400%22%20font-size=%2217.5%22%20font-family=%22sans-serif%22%20letter-spacing=%220%22%20word-spacing=%220%22%3E%3Ctspan%20x=%22-249.529%22%20y=%22455.924%22%20style=%22-inkscape-font-specification:'sans-serif%20Bold'%22%20font-weight=%22700%22%20font-size=%2210%22%3EServoBit%3C/tspan%3E%3C/text%3E%3Cpath%20d=%22M-237.619%20434.263v-.395h-8.13a.697.677%200%200%201-.698-.677v-19.076a.697.677%200%200%201%20.697-.677h8.131v-.395a.697.677%200%200%201%20.697-.678h45.415a.697.677%200%200%201%20.697.678v.395h8.13a.697.677%200%200%201%20.698.677v19.076a.697.677%200%200%201-.697.677h-8.13v.395a.697.677%200%200%201-.698.678h-45.415a.697.677%200%200%201-.697-.678%22%20fill=%22gray%22%20fill-rule=%22evenodd%22%20stroke=%22#191919%22/%3E%3Cellipse%20cy=%22-417.953%22%20cx=%22-242.614%22%20transform=%22scale(1%20-1)%22%20rx=%222.497%22%20ry=%222.427%22%20fill=%22#fff%22%20stroke=%22#191919%22/%3E%3Cellipse%20cy=%22-429.353%22%20cx=%22-242.614%22%20transform=%22scale(1%20-1)%22%20rx=%222.497%22%20ry=%222.427%22%20fill=%22#fff%22%20stroke=%22#191919%22/%3E%3Cellipse%20cy=%22-417.953%22%20cx=%22-185.815%22%20transform=%22scale(1%20-1)%22%20rx=%222.497%22%20ry=%222.427%22%20fill=%22#fff%22%20stroke=%22#191919%22/%3E%3Cellipse%20cy=%22-429.353%22%20cx=%22-185.815%22%20transform=%22scale(1%20-1)%22%20rx=%222.497%22%20ry=%222.427%22%20fill=%22#fff%22%20stroke=%22#191919%22/%3E%3Cg%20transform=%22matrix(1.16152%200%200%20-1.12877%20-214.214%20423.653)%22%20stroke-width=%221.184%22%3E%3Ccircle%20cx=%229.45%22%20r=%227.079%22%20fill=%22none%22%20stroke=%22#191919%22%20stroke-width=%22.873%22/%3E%3Ctitle%3EFusion009002001_cs001%3C/title%3E%3C/g%3E%3Cpath%20d=%22M-195.227%20424.523c.075-2.967-1.397-5.746-3.854-7.278a7.738%207.738%200%200%200-8.02-.122c-2.5%201.456-4.05%204.19-4.06%207.157l7.972%2020.04z%22%20fill=%22#4d4d4d%22%20stroke=%22#191919%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22/%3E%3Cpath%20d=%22M-195.227%20421.661c.075%202.967-1.397%205.747-3.854%207.278a7.738%207.738%200%200%201-8.02.123c-2.5-1.456-4.05-4.19-4.06-7.158l7.972-20.039z%22%20fill=%22none%22%20stroke=%22#191919%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%20stroke-dasharray=%22.99999994,1.99999986%22/%3E%3Cpath%20d=%22M190.52%20443.876a18.725%2020.747%200%200%201-16.528-10.035%2018.725%2020.747%200%200%201-.278-20.88%2018.725%2020.747%200%200%201%2016.255-10.571%22%20transform=%22scale(-1%201)%22%20fill=%22none%22%20stroke=%22#00f%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%20marker-start=%22url(#a)%22%20marker-end=%22url(#b)%22/%3E%3Ctext%20style=%22line-height:125%25%22%20x=%22-191.089%22%20y=%22456.196%22%20font-weight=%22400%22%20font-size=%2217.5%22%20font-family=%22sans-serif%22%20letter-spacing=%220%22%20word-spacing=%220%22%20fill=%22red%22%3E%3Ctspan%20x=%22-191.089%22%20y=%22456.196%22%20style=%22-inkscape-font-specification:'sans-serif%20Bold'%22%20font-weight=%22700%22%20font-size=%2210%22%3E180%3C/tspan%3E%3C/text%3E%3C/svg%3E"
164+
},
165+
"design": {
166+
"graph": {
167+
"blocks": [
168+
{
169+
"id": "111d9859-6de5-4608-9176-ed8359ffebc5",
170+
"type": "basic.code",
171+
"data": {
172+
"code": "//-- ServoBit-180\n\n//-- Control de un servo Futaba 3003\n//-- con un bit. Se mueve a dos posiciones\n//-- que se corresonden con 0 / 1\n//-- El angulo total recorrido es de 180 grados\n\n//-- ENTRADAS:\n//-- clk: Señal del sistema (12Mhz)\n//-- bitpos: Bit de posicion (0 - posicion derecha, 1 - posicion izquierda)\n \n// Bitpos 0 Bitpos 1\n// ___ ___\n// | o----> <----o |\n// | | | |\n// |___| |___|\n\n//-- SALIDAS:\n//-- servo : Señal PWM para controlar el servo\n\n//-- Constantes para el angulo del servo\nlocalparam ANG_0 = 8'h01;\nlocalparam ANG_180 = 8'hE4;\n\n\n//-- Posicion del servo cuando el\n//-- bit de entrada es 0\n//-- La corona del servo mira a la derecha\nparameter BIT0 = ANG_0;\n\n//-- Posicion el servo cuando el bit\n//-- de entrada es 1\n//-- La corona del servo mira a la izquierda\nparameter BIT1 = ANG_180;\n\n\n//-- Posicion de 8 bits del servo\nreg [7:0] pos;\n\n//-- Asignar la posicion de 8 bits\n//-- segun si lo recibido es 0 ó 1\nalways @(posedge clk)\n pos <= bitpos ? BIT1 : BIT0;\n\n\n//---\n//--- ServoMotor \n\n//-- M es el valor del divisor para\n//-- obtener tics de M / 12.0 micro-segundos\nlocalparam M = 94; \nlocalparam N = $clog2(M);\n\n//-- Contador para generar los tics\nreg [N-1:0] divcounter = 0;\n\n//-- Flag para indicar que un tic\n//-- ha ocurrido\nreg tic = 0;\n\n//-- Generacion de los tics. Cada\n//-- M ciclos del reloj se genera 1\nalways @(posedge clk)\n tic <= (divcounter == M - 2);\n\n//-- Contador modulo M\nalways @(posedge clk)\n if (tic)\n divcounter <= 0;\n else\n divcounter <= divcounter + 1;\n\n//-- Contador de la posicion del \n//-- servo\nreg [10:0] angle_counter = 0;\n\n//-- A la posicion destino hay que\n//-- sumarle un offset, correspondiente\n//-- a los 0.3ms de la posicion inicial\nwire [8:0] pose = {1'b0, pos} + 9'd46;\n\n//-- Con cada tic se incrementa el\n//-- contador de angulo del servo\nalways @(posedge clk)\n if (tic)\n angle_counter <= angle_counter + 1;\n\n//-- Cuando el contador es menor que el \n//-- valor objetivo, la señal de PWM\n//-- del servo se pone 1, y 0 en \n//-- caso contrario\nalways @(posedge clk)\n servo <= (angle_counter < {2'b00, pose});\n\n",
173+
"params": [],
174+
"ports": {
175+
"in": [
176+
{
177+
"name": "clk"
178+
},
179+
{
180+
"name": "bitpos"
181+
}
182+
],
183+
"out": [
184+
{
185+
"name": "servo"
186+
}
187+
]
188+
}
189+
},
190+
"position": {
191+
"x": 304,
192+
"y": 80
193+
}
194+
},
195+
{
196+
"id": "f9f4add8-1ca6-49c0-adae-0d1a45025fc1",
197+
"type": "basic.input",
198+
"data": {
199+
"name": "clk"
200+
},
201+
"position": {
202+
"x": 56,
203+
"y": 112
204+
}
205+
},
206+
{
207+
"id": "eac2d6e9-4a62-4aec-8ce8-0e6c54e14d22",
208+
"type": "basic.output",
209+
"data": {
210+
"name": "servo"
211+
},
212+
"position": {
213+
"x": 816,
214+
"y": 176
215+
}
216+
},
217+
{
218+
"id": "e3e07bdb-9bb3-4afb-ace5-bcc99aecef0a",
219+
"type": "basic.input",
220+
"data": {
221+
"name": "bitpos"
222+
},
223+
"position": {
224+
"x": 56,
225+
"y": 240
226+
}
227+
}
228+
],
229+
"wires": [
230+
{
231+
"source": {
232+
"block": "f9f4add8-1ca6-49c0-adae-0d1a45025fc1",
233+
"port": "out"
234+
},
235+
"target": {
236+
"block": "111d9859-6de5-4608-9176-ed8359ffebc5",
237+
"port": "clk"
238+
}
239+
},
240+
{
241+
"source": {
242+
"block": "e3e07bdb-9bb3-4afb-ace5-bcc99aecef0a",
243+
"port": "out"
244+
},
245+
"target": {
246+
"block": "111d9859-6de5-4608-9176-ed8359ffebc5",
247+
"port": "bitpos"
248+
}
249+
},
250+
{
251+
"source": {
252+
"block": "111d9859-6de5-4608-9176-ed8359ffebc5",
253+
"port": "servo"
254+
},
255+
"target": {
256+
"block": "eac2d6e9-4a62-4aec-8ce8-0e6c54e14d22",
257+
"port": "in"
258+
}
259+
}
260+
]
261+
},
262+
"state": {
263+
"pan": {
264+
"x": 0,
265+
"y": 0
266+
},
267+
"zoom": 1
268+
}
269+
}
270+
},
271+
"32200dc0915d45d6ec035bcec61c8472f0cc7b88": {
272+
"package": {
273+
"name": "NOT",
274+
"version": "1.0.0",
275+
"description": "NOT logic gate",
276+
"author": "Jesús Arroyo",
277+
"image": "%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%2291.33%22%20height=%2245.752%22%20version=%221%22%3E%3Cpath%20d=%22M0%2020.446h27v2H0zM70.322%2020.447h15.3v2h-15.3z%22/%3E%3Cpath%20d=%22M66.05%2026.746c-2.9%200-5.3-2.4-5.3-5.3s2.4-5.3%205.3-5.3%205.3%202.4%205.3%205.3-2.4%205.3-5.3%205.3zm0-8.6c-1.8%200-3.3%201.5-3.3%203.3%200%201.8%201.5%203.3%203.3%203.3%201.8%200%203.3-1.5%203.3-3.3%200-1.8-1.5-3.3-3.3-3.3z%22/%3E%3Cpath%20d=%22M25.962%202.563l33.624%2018.883L25.962%2040.33V2.563z%22%20fill=%22none%22%20stroke=%22#000%22%20stroke-width=%223%22/%3E%3C/svg%3E"
278+
},
279+
"design": {
280+
"graph": {
281+
"blocks": [
282+
{
283+
"id": "5365ed8c-e5db-4445-938f-8d689830ea5c",
284+
"type": "basic.code",
285+
"data": {
286+
"code": "// NOT logic gate\n\nassign c = ~ a;",
287+
"params": [],
288+
"ports": {
289+
"in": [
290+
{
291+
"name": "a"
292+
}
293+
],
294+
"out": [
295+
{
296+
"name": "c"
297+
}
298+
]
299+
}
300+
},
301+
"position": {
302+
"x": 256,
303+
"y": 48
304+
}
305+
},
306+
{
307+
"id": "18c2ebc7-5152-439c-9b3f-851c59bac834",
308+
"type": "basic.input",
309+
"data": {
310+
"name": ""
311+
},
312+
"position": {
313+
"x": 64,
314+
"y": 144
315+
}
316+
},
317+
{
318+
"id": "664caf9e-5f40-4df4-800a-b626af702e62",
319+
"type": "basic.output",
320+
"data": {
321+
"name": ""
322+
},
323+
"position": {
324+
"x": 752,
325+
"y": 144
326+
}
327+
}
328+
],
329+
"wires": [
330+
{
331+
"source": {
332+
"block": "18c2ebc7-5152-439c-9b3f-851c59bac834",
333+
"port": "out"
334+
},
335+
"target": {
336+
"block": "5365ed8c-e5db-4445-938f-8d689830ea5c",
337+
"port": "a"
338+
}
339+
},
340+
{
341+
"source": {
342+
"block": "5365ed8c-e5db-4445-938f-8d689830ea5c",
343+
"port": "c"
344+
},
345+
"target": {
346+
"block": "664caf9e-5f40-4df4-800a-b626af702e62",
347+
"port": "in"
348+
}
349+
}
350+
]
351+
},
352+
"state": {
353+
"pan": {
354+
"x": 0,
355+
"y": 0
356+
},
357+
"zoom": 1
358+
}
359+
}
360+
}
361+
}
362+
}

0 commit comments

Comments
 (0)