diale.org

Bluetooth + Arduino
... code

2018/08/16-16:29:58

// Hardware
// BT module   Arduino
// GND ------- GND
// VCC ------- 5V
// TX-O ------ pin0honda eCUB 2
// RX-I ------ pin1

// Servo       Arduino
// GND ------- GND
// VCC ------- VCC
// signal ---- pin4

// TX arduino -> RX BT module
// RX arduino -> TX BT module

#define bluetooth Serial
#include <Servo.h>
Servo aServo;

void setup(){
  delay(1000); 
  Serial.begin(9600);
  aServo.attach(4);}


void loop(){
  int data = 0;

   if(Serial.available() > 0){
     data = Serial.read();        
     Serial.print(data);          
     Serial.print("\n");        
     if(data == '1')              
        aServo.writeMicroseconds(544);
      else if(data == '0')         
        aServo.writeMicroseconds(2400);}}

Etiquetas/Tags: arduino, bluetooth, code, example


Filtro Kalman 1D
... implementação simples de um filtro de Kalman usando Arduino (ou outra coisa qualquer)

2018/07/13-09:40:09

A ideia deste texto é explicar de uma forma simples a implementação de um filtro de Kalman num Arduino e construir um sensor de intensidade luminosa usando um LDR. O hardware necessário é o seguinte:

Hardware e código inicial

É fácil de encontrar um código exemplo para se ligar um LDR ao Arduino. Fica aqui uma versão simples ;)

int sensorPin = A0; 
int sensorValue = 0;

void setup(){ 
  Serial.begin(9600); 
} 

void loop(){ 
  sensorValue = analogRead(sensorPin); 
  Serial.println(sensorValue); 
} 

O gráfico seguinte mostra a variação da luminosidade quando tapo e destapo o LDR com a mão. Vê-se claramente as oscilações de 50Hz da rede eléctrica na luz do candeeiro.

Filtro de Kalman 1D

Quero então estimar o valor da luminosidade da sala onde me encontro. Para isso admito que a intensidade luminosa é constante (ou antes que necessita de ser "quase" constante de modo a que seja possível fazer uma medição) e que o valor medido y possa ser decomposto na soma de um valor médio m mais um termo de flutuação gaussiano v com variância r (valor inicial). Assim

y:=m+v

Admito também que para cada valor da luminosidade se tem a estimativa x dada por

x:=m+w

com o mesmo valor médio e flutuações gaussianas mas com variância q (valor inicial). Note-se que w e v são variáveis aleatórias gaussianas com média zero e independentes.

O filtro de Kalman admite que as sucessivas aproximações (modelo) são obtidas linearmente das anteriores, i.e. xf:=a xi . Como estou a admitir que os sucessivos valores da luminosidade são constantes ponho a:=1

x:=x

e

p:=p+q

onde p é variância da aproximação seguinte (são todas variáveis gaussianas independentes, a variância da soma é a soma das variâncias).

Ficam assim estabelecidas as regras de evolução da primeira parte do algoritmo de Kalman. Vamos à segunda parte. Esta segunda parte corresponde a estimar/prever a aproximação seguinte que é escrita em termos da aproximação anterior e o erro de previsão, i.e.,

x:=x+k(y-x)

onde k é um parâmetro a determinar, usualmente chamado de ganho do filtro, e y-x o erro de previsão. Como determinar então o valor de k? O valor de k é determinado de forma a minimizar a variância da nova estimativa x+k(y-x).

Calculando a variância desta última quantidade obtém-se

p:=(1-k)^2*p+k^2*r

É condição necessária para que se tenha um extremo relativo da variância que a derivada de p em ordem a k seja zero. Isto dá:

k:=p/(p+r)

e

p:=p*r/(p+r)

Curiosamente, ou talvez não, esta última fórmula corresponde formalmente ao valor do paralelo de duas resistências com valores p e r.

Fico assim com as duas últimas fórmulas que precisava:

k:=p/(p+r)
x:=x+k(y-x)
p:=(1-k)*p

O gráfico seguinte mostra o que acontece quando tapo e destapo o LDR (linha azul) numa escala de 0-1023. As linhas a verde e vermelho correspondem à implementação de filtros de Kalman com parâmetros diferentes.

Happy hacking!


/* Simply implementation of a 1D Kalman filter */
/* for Arduino using a LDR. */

/* Some other examples can be done with this file, */
/* e.g. sonar, temperature measurements, sky is the limit. */
/* Happy hacking! */
  
/* Author: Tiago Charters de Azevedo  */
/* Maintainer: Tiago Charters de Azevedo  */
/* URL: http://diale.org/ */
/* Version: 0 */

/* Copyright (c) - 2018 Tiago Charters de Azevedo */

/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3, or (at your option) */
/* any later version. */

/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
/* GNU General Public License for more details. */

/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, */
/* Boston, MA 02110-1301, USA. */

/* Commentary: */

int sensorPin = A0; 
int sensorValue = 0;

// 1st filter parameters
float q=0.125;
float r=32;
float p=1023;
float x=0;
float k=0;

// 2nd filter parameters
float q1=4;
float r1=100;
float p1=1023;
float x1=0;
float k1=0;

void setup(){ 
  Serial.begin(9600); 
} 

void loop(){ 
  sensorValue = analogRead(sensorPin); // read sensor value

  // 1st Kalman filter
  p=p+q; 
  k=p/(p+r);
  x=x+k*(float(sensorValue)-x);
  p=(1-k)*p;

  // 2nd Kalman filter
  p1=p1+q1; 
  k1=p1/(p1+r1);
  x1=x1+k1*(float(sensorValue)-x1);
  p1=(1-k1)*p1;

  
  //Print values
  Serial.print(sensorValue); // raw value
  Serial.print(", ");
  Serial.print(int(x)); // 1st filter output
  Serial.print(", ");
  Serial.print(int(x1)); // 2nd filter output
  Serial.println("");
} 

1.R. Kalmam, A New Approach to Linear Filtering and Prediction Problems, Transactions of the ASME–Journal of Basic Engineering, 82 (Series D): 35-45. 1960

Etiquetas/Tags: kalman, arduino, filtro


Ping-Pong Anemometer
3D printed...

2018/06/28-18:48:17

Sphere anemometers are simple devices that use the wind drag force on a sphere to determine the wind speed by equating the weight of the sphere with the drag force in a pendulum like configuration.

The drag force is the force that a sphere feels when traveling with a certain speed latex2png equation in a viscous fluid (relatively to the fluid, in our case air). This forces depends on the relative velocity between the air and the sphere, on the density of the air latex2png equation, effective area in contact with the fluidlatex2png equation and an adimensional coefficient latex2png equation called the drag coefficient. In this case this force amounts to

latex2png equation

Note that the drag coefficient latex2png equation is a geometric factor and is usually determined experimentally. For a sphere, for high enough Reynolds numbers, the drag coefficient is around 0.5.

Apparently this kind of anemometer was invented in 1900 by G. Daloz. Modern versions includes a ping-pong ball.

Equating the weight of the sphere

latex2png equation

with the drag force in a pendulum like configuration for a given equilibrium position one gets

latex2png equation

and for the velocity:

latex2png equation Where D=2 R is the diameter of the ping-pong ball.

Given that a ping-pong ball has mass of 2.7g and a typical diameter of 40mm one gets for the density rhoball=2.7/(4*pi/3*2^3)~0.081 g/cm^3

and thus

latex2png equation

Here's the OpenSCAD file:

// Author: Tiago Charters de Azevedo
// Maintainer: Tiago Charters de Azevedo 

// Copyright (c) - 2016 Tiago Charters de Azevedo (tca@diale.org)

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.


// Gravity aceleration
g=9.8; //(m/s^2)
rhoair=0.001225; // (g/cm^3)
// pi
pi=3.1415926;

/*Drag coeficiente
.5 sphere
see: https://en.wikipedia.org/wiki/Drag_coefficient
*/
Cd=.47;

// Ping-Pong
D=.04; // (m)
mball=2.7; // (g)
A=pi*pow(D/2,2);
rhoball=mball/(4*pi/3*pow(100*D/2,3));// 0.081; // (g/cm^3)

// Font size
fsize=4;

R=100;
h=2;

coef=1;//3.6*0.621371;
module slice(h=2){
    difference(){
        cylinder(h,R,R,center=true,$fn=64);
        translate([0,2.5*R/2,0]){
            cube([2.5*R,2.5*R,2*h],center=true);}
        translate([2.5*R/2,0,0]){
            cube([2.5*R,2.5*R,2*h],center=true);}}}

module vscale(){
    for(alpha=[0:5:89]){
        v=coef*sqrt(pi*g*rhoball*pow(D,3)*tan(alpha)/(3*A*Cd*rhoair));
        rotate([0,0,alpha]){
            translate([-R*.99,0,-0]){
                rotate([0,0,-0]){
                    linear_extrude(height=h,scale=1,twist=0,convexity= 0){          
                        text(str(floor(v*10)/10),size=fsize,font="Arial Black:style=Bold",center=true);}}}
            
            translate([-R*.8,-1*0,h/2]){
                sphere(h/2,center=true,$fn=64);}}}
    
    translate([-R*.7,-1*0,h/2]){
        sphere(h/2,center=true,$fn=64);}
    
    
    translate([0,-R+2,0]){
        rotate([0,0,90]){
            linear_extrude(height=h,scale=1,twist=0,convexity= 0){          
                text("m/s",size=fsize,font="Arial Black:style=Bold",center=true);}}}}

//difference()
{
    intersection(){
        union(){
            difference(){
                slice();
                cylinder(10,R*.7,R*.7,center=true,$fn=64);}
            translate([0,-R/2,0]){
                cube([6*h,R,h],center=true);}
            translate([-R/2,0,0]){
                cube([R,6*h,h],center=true);}}
        cylinder(10*h,R,R,center=true,$fn=64);}
    vscale();}


cylinder(h,3*h,3*h,center=true,$fn=64);

difference(){
    union(){
        cylinder(3*h,h,h,center=false,$fn=64);
        translate([0,0,3*h]){
    sphere(h,center=true,$fn=64);}}
    translate([0,0,2.5*h]){
        rotate([0,90,0]){
            cylinder(3*h,1,1,center=true,$fn=64);}}}

Etiquetas/Tags: anemometer, ping-pong, 3d printer


Stereographic projection
A simple hack using OpenSCAD.

2018/06/27-16:50:06

Stereographic projection similar do this one by Henry Segerman.

Notes

References

OpenSCAD code

// Author: Tiago Charters de Azevedo 
// Maintainer: Tiago Charters de Azevedo 

// Copyright (c) - 2017 Tiago Charters de Azevedo (tca@diale.org)

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.

$fn=2*32;
phi=(1+sqrt(5))/2;
h=2;
R=40;
n=6;
delta=.2;

echo(R*(n-1));

module drawing(){
    for(i=[-(n-1)/2:(n-1)/2]){
        for(j=[-(n-1)/2:(n-1)/2]){
            translate([(1+delta)*i*R,(1+delta)*j*R,0]){
                square(.9*[R,R], center=true);
                //              circle(R/2,center=true);
            }}}

    difference(){
        square(1000*R*[1,1],center=true);
        square(((1+delta)*n*R+delta*R)*[1,1],center=true);}}

module drawingshadow(){
    for(i=[-(n-1)/2:(n-1)/2]){
        for(j=[-(n-1)/2:(n-1)/2]){
            translate([(1+delta)*i*R,(1+delta)*j*R,0]){
                square(.9*[R,R], center=true);
                //      circle(.9*R/2,center=true);

            }}}}

module drawingescher(){
    for(i=[-(n-1)/2:(n-1)/2]){
        for(j=[-(n-1)/2:(n-1)/2]){
            translate([6*i*6.8,j*R,0]){
                rotate([0,0,180]){
                    escher();}
                translate([3.*6.8,2.9*8.05,0]){escher();}
            }}}
        difference(){
        square(1000*R*[1,1],center=true);
        square(((1+delta)*n*R+delta*R)*[1,1],center=true);}}

module projection(l){
    linear_extrude(height=l, scale=10e-6, center=false){
        children();}}

module ball(r,h){
    difference(){
        union(){
            sphere(r=r, center=true);
            translate([0,0,-r/2]){
                cylinder(h=r,r=r*sqrt(2)/2,center=true);}}
        sphere(r=r-h, center=true);}}


module stproj(){
    render(){
        difference(){
            translate([0,0,R]){
                ball(R,h);}

            projection(2*R){
                drawing();}
            
            translate([0,0,2*R]){
                cylinder(h=R,r=R/2,center=true);
//              sphere(R/2,center=true);
            }
        }}}

module seeall(){
    stproj();
    color("red")
    translate([0,0,2*R]){
        sphere(R/32,center=true);}

    %projection(2*R){
        drawingshadow();}}

module squaregrid(l,m){
    difference(){
        square([l,l],center=true);
        for(i=[-(m-1)/2:(m-1)/2]){
            for(j=[-(m-1)/2:(m-1)/2]){
                translate([i*l/m,j*l/m,0])
                square([.5*l/m,.5*l/m],center=true);
            }}}
}




module grid(){
    color("black")
    render(){
        difference(){
            linear_extrude(height=.1, scale=1, center=true){
                square(((1+delta)*n*R+0*delta*R)*[1,1],center=true);}
            linear_extrude(height=10, scale=1, center=true){
                for(i=[-(n-1)/2:(n-1)/2]){
                    for(j=[-(n-1)/2:(n-1)/2]){
                        translate([(1+delta)*i*R,(1+delta)*j*R,0]){
                            square([R,R], center=true);}}}}}}}







module escher(s=.01){    
    polygon(s*
        [[-1022.58620689655,    -1206.46551724138],
            [-527.586206896552, -1701.46551724138],
            [192.413793103448 , -1386.46551724138],
            [462.413793103448 , -1116.46551724138],
            [597.413793103448 , -936.46551724138 ],
            [687.413793103448 , -756.46551724138 ],
            [732.413793103448 , -621.46551724138 ],
            [867.413793103448 , -756.46551724138 ],
            [957.413793103448 , -891.46551724138 ],
            [1002.41379310345 , -1071.46551724138],
            [1047.41379310345 , -1161.46551724138],
            [1317.41379310345 , -1116.46551724138],
            [1452.41379310345 , -1026.46551724138],
            [1632.41379310345 , -846.46551724138 ],
            [1452.41379310345 , -801.465517241379],
            [1227.41379310345 , -711.46551724138 ],
            [1092.41379310345 , -576.46551724138 ],
            [957.413793103448 , -441.46551724138 ],
            [867.413793103448 , -261.46551724138 ],
            [642.413793103448 , 143.53448275862  ],
            [552.413793103448 , 368.53448275862  ],
            [1047.41379310345 , 908.534482758621 ],
            [507.413793103448 , 1448.53448275862 ],
            [687.413793103448 , 1718.53448275862 ],
            [507.413793103448 , 1673.53448275862 ],
            [282.413793103448 , 1583.53448275862 ],
            [147.413793103448 , 1583.53448275862 ],
            [192.413793103448 , 1358.53448275862 ],
            [282.413793103448 , 1223.53448275862 ],
            [417.413793103448 , 1088.53448275862 ],
            [732.413793103448 , 908.534482758621 ],
            [282.413793103448 , 773.53448275862  ],
            [-392.586206896552, 1583.53448275862 ],
            [-392.586206896552, 728.53448275862  ],
            [-752.586206896552, 638.534482758621 ],
            [-977.586206896552, 548.53448275862  ],
            [-977.586206896552, 773.53448275862  ],
            [-1022.58620689655, 908.534482758621 ],
            [-1157.58620689655, 863.53448275862  ],
            [-1292.58620689655, 818.53448275862  ],
            [-1427.58620689655, 863.53448275862  ],
            [-1337.58620689655, 728.53448275862  ],
            [-1247.58620689655, 548.53448275862  ],
            [-1247.58620689655, 413.534482758621 ],
            [-1247.58620689655, 278.53448275862  ],
            [-347.586206896552, 278.53448275862  ],
            [-1157.58620689655, -396.46551724138 ],
            [-1067.58620689655, -846.46551724138 ],
            [-887.586206896552, -576.46551724138 ],
            [-752.586206896552, -396.46551724138 ],
            [-572.586206896552, -306.46551724138 ],
            [-392.586206896552, -261.46551724138 ],
            [-347.586206896552, -486.46551724138 ],
            [-257.586206896552, -666.46551724138 ],
            [-212.586206896552, -756.46551724138 ],
            [-257.586206896552, -801.465517241379],
            [-527.586206896552, -666.46551724138 ],
            [-1022.58620689655, -1206.46551724138]]);}


//%square(.9*[R,R], center=true);


// henryseg
// https://www.thingiverse.com/thing:202774/
//color("green")

// translate([0,0,R+1.8]){
//     sphere(R+1.1,center=true);}
//1.8
//translate([0,0,R]){    import("stereographic_projection_wider_base.stl");}

Etiquetas/Tags: Stereographic projection, 3dprint, reprap


FastDome
FastDome is a set of 3D printed vertices to build an open source geodesic 2V dome using PVC tubes.

2018/06/26-14:48:43

I've used 16cm (outer diameter) PVC tubes. The 3D modeling was done using OpenScad and is under a GPLv3 license. Use the SCAD file to fit the vertices to any diameter tube.

Indoor geodesic dome (70cm radius)

For a 70cm radius we'll need 35cm tubes (30) and 45cm tubes (35). I'll put some math here in a couple of days (check the references below).

3D Printing

For a 2V geodesic dome we will need to print a total of 26 vertices

Number Vertex type
10 4
6 5
10 6

Printer settings

res. = 0.32mm

infill = 20%

References

Geodesic Dome Notes and Calculator

OpenSCAD code

// Author: Tiago Charters de Azevedo 
// Maintainer: Tiago Charters de Azevedo 

// Copyright (c) - 2017 Tiago Charters de Azevedo (tca@diale.org)

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.

// V2 dome vertices
// strut angle z axis
// https://simplydifferently.org/Geodesic_Dome_Notes?page=3#1V/L1%202/3%20Icosahedron%20Dome

// alpha1=15.86 (5 legs x6)
// alpha2=18.00 (6 legs x10)
// alpha2=18.00 (4 legs x10)

// Notes
//  Indoor r=70cm (door dimensions <=70cm)
// la=38.3cm
// lb=43.4cm
// A x 30: 0.54653 (15.86°)
// B x 35: 0.61803 (18.00°) 

// ------------------------------------------------------------
// GNU GPL v2
// nop.head@gmail.com
// hydraraptor.blogspot.com
// See http://hydraraptor.blogspot.com/2011/02/polyholes.html
// ------------------------------------------------------------
function sides(r)=max(round(4*r),3);
function corrected_radius(r,n=0)=0.1+r/cos(180/(n ? n : sides(r)));
function corrected_diameter(d)=0.2+d/cos(180/sides(d/2));

module poly_circle(r,center=false){
    n=sides(r);
    circle(r=corrected_radius(r,n),$fn=n,center=center);}

module poly_cylinder(h,r,center=false){
    n=sides(r);
    cylinder(h=h,r=corrected_radius(r,n),$fn=n,center=center);}
// ------------------------------------------------------------

$fn=2*16;
phi=(1+sqrt(5))/2;
ri=13/2+.2; //PLA
ro=16/2+.1;
h=2*1.2;


module hub(n=5,m=5,ri=13.2/2,alpha=15.86,h=h){
    rm=1.5*ri;
    height=ri*sin(alpha);
    R=ri*cos(alpha);
    v=[0,R+rm,0]-[0,rm,height];
    difference(){
        union(){
            for(i=[0:m-1]){
                rotate([0,0,i*360/n]){
                    hull(){
                        translate([0,rm,height]){
                            sphere(ri,center=true);}
                        translate(v+[0,R+rm,0]){
                            sphere(ri,center=true);}}}}    
            // Center
            hull(){
                for(i=[0:n]){
                    rotate([0,0,i*360/n]){
                        translate([0,rm,height]){
                            sphere(ri,center=true);}}}}}
        
        for(i=[0:m-1]){
            rotate([0,0,i*360/n]){
                hull(){
                    translate([0,rm,height]){
                        sphere(ri-h,center=true);}
                    v=[0,R+rm,0]-[0,rm,height];
                    translate(2*v+[0,R+rm,0]){
                        sphere(ri-h,center=true);}}}}
        // Center hole
        poly_cylinder(h=10*ri,r=ro,center=true);
        
        
        // Allow a nail to ground
        if(m==n-2){
            translate([1.5*ri,0,height])
            rotate([0,90,0]){
                poly_cylinder(h=3*ri,r=2.5+.15,center=true);}}
    }}
    
    

//Uncomment this 
//hub(5,5,ri,15.86);
hub(6,6,ri,18.00);
//hub(6,4,ri,18.00);

Have fun!

Etiquetas/Tags: reprap, 3dprint, dome, geodesic


3D printed bike flashlight mount
Made for CycleHack 2017 - Lisbon

2018/06/26-12:55:48

This is a hack that enables the use of any regular flashlight as a bike light. Made for CycleHack 2017 - Lisbon (https://cyclehacklisboa.tumblr.com/).

Barrier This Solves: Reuse regular flashlight's to improve bike safety.

Step 1: measure the flashlight's diameter and your bike handlebar

Step 2: edit the OpenScad file and generate the STL file

Step 3: call a friend with a 3d printer or go to the nearest Makerspace/Fablab

Step 4: with 4 zip ties firmly secure it to your bike!

Step 5: Ride you bike safely.

This is similar to https://www.thingiverse.com/thing:250899

I've clean the OpenScad code and now it supports various zip ties and dimensions. Use the OpenScad file for your hack.

Happy CycleHacking!

Materials and methods

infill: 20%

res.: 0.2mm

OpenSCAD code

// Author: Tiago Charters de Azevedo 
// Maintainer: Tiago Charters de Azevedo 
// URL: http://diale.org/
// Version: *

// Copyright (c) Tiago Charters de Azevedo

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.

// Commentary:

$fn=64;
phi=(1+sqrt(5))/2;
dflasglight=24;
dbar=22.34;


zip=6; //Width of your zip tie.
height=max(25,dbar,dflasglight);


module holder(){
    difference(){ 
        cube([dbar+zip, dflasglight+zip, height],center=true);
        translate([0,0,height/phi]) rotate([0,90,0]){
            cylinder(r=dflasglight/2, h=1.1*(dbar+zip), center=true);}
        translate([0,0,-height/phi]) rotate([90,90,0]){
            cylinder(r=dbar/2, h=1.1*(dflasglight+zip), center=true);}}}

module ziptietop(){
    translate([0,0,height/phi]){
        rotate([0,90,0]){
            difference(){
                cylinder(r=dflasglight/2+zip, h=zip, center=true);
                cylinder(r=dflasglight/2+zip/2, h=dbar+20, center=true);}}}}

module ziptiebottom(){
    translate([0,0,-height/phi]){
        rotate([90,90,0]){
            difference(){
                cylinder(r=dbar/2+zip, h=zip, center=true);
                cylinder(r=dbar/2+zip/2, h=1.1*(dbar+zip), center=true);}}}}

translate([0,0,(dbar+zip)/2]){
    rotate([0,0,0])
    difference(){
        holder();
        translate([(dbar+zip/2)/4,0,0]){
            ziptietop();}
        translate([-(dbar+zip/2)/4,0,0]){
            ziptietop();}
        translate([0,(dflasglight+zip/2)/4,0]){
            ziptiebottom();}
        translate([0,-(dflasglight+zip/2)/4,0]){
            ziptiebottom();}}}

Pics

Etiquetas/Tags: cyclehack, 3dprint, reprap


OpenSCAD
... the Programmers Solid 3D CAD Modeller

2018/06/26-12:29:02

Some examples of OpenSCAD models (check the OpenSCAD CheatSheet) and ask away at the forum.

Check here for some files: ./openscad/

Happy hacking!

Etiquetas/Tags: cad, openscad, examples, 3d, 3d printing, reprap, opensource, freesoftware


LAMP - Amplificador 1W com um Mosfet
... e uma lâmpada.

2018/06/23-09:43:43

A construção de um amplificador de guitarra pode ser uma das experiências mais gratificantes no DIY. Vamos então construir um amplificador de guitarra usando apenas um componente activo: um Mosfet a trabalhar em classe A.

É um amplificador minimalista inspirado nos projectos desenvolvidos e partilhados por Nelson Pass, o guru do hi-fi em classe A - https://www.passdiy.com

Quanto ao material, resume-se a 6 componentes (mais ou menos)

A ideia deste texto é construir um pequeno power amp que soa bem quando se faz o overdrive. Note-se que apenas vamos construir um power-amp com um fantástico 1W usando um mosfet.

Circuito simplificado, circuito completo

A figura seguinte mostra o circuito completo do amplificador. Tal como está o Mosfet vê qualquer coisa como 3.5V no drain e tem um ganho para uma corrente de repouso igual a 600mA da ordem de 8 (ganho máximo para diferentes valores do potenciómetro P1).

Quer isto dizer que se o sinal de entrada for 0.1V à saída teremos 0.8V, o ganho é um factor multiplicativo.

A impedância de entrada é da ordem dos 50 kOhms que é mais do que suficiente para ser ligada a qualquer output de um pedal de distorção ou booster e cá temos o nosso pré-amplificador para desenrascar.

Os condenadores de acoplamento, de 220nF e de 1000uF, entrada e saída respectivamente, controlam a resposta em frequência do circuito. Outros pares de valores seriam possíveis para a mesma resposta em frequência mas, ao meu ouvido, soa melhor a distorção (quando se faz o overdrive) ao deixar passar graves à entrada e cortá-los à saída com um valor mais baixo de C2.

Qual o bom valor para C2? Isto é DIY, basta experimentar!

O mosfet tem o seu ponto de funcionamento garantido através da rede de feedback composta pela resistência R2 e o potenciómetro P1, chamada rede de Schade (1938), que liga o drain à gate.

O potenciómetro P1 é opcional e permite controlar o ponto de funcionamento do mosfet. Um trimpot escondido dentro da caixa também serve para ajustar o ponto de funcionamento e que ficará fixo neste caso.

E fez-se luz

Como resistência de potência vamos usar um lâmpada de carro, é a carga do componente activo, e especifica a impedância de saída do circuito. À semelhança do que acontece com os amplificadores a válvulas este amplificador tem uma impedância de saída elevada o que faz transparecer as qualidade do speaker.

Uma lâmpada comporta-se como uma resistência não linear. Quanto mais quente está maior é a resistência. A resistência aos terminais da lâmpada não obedece à lei de Ohm.

Os gráficos anteriores mostram o valor da resistência de várias lâmpadas de carro de que se podem comprar.

As lâmpada típicas de médios/macha-atrás e de pisca (âmbar) têm usualmente 21W e devem ser alimentadas as 12V (curvas a preto e vermelho). Arranjei também uma lâmpada de 10W (curva a verde) e ofereceram-me uma lâmpada de empilhadora de 24V de 25W (ou será de camião?).

O amplificador funcionará bem qualquer uma das lâmpadas. A resistência das lâmpada de 21W é menor e por isso deverá arranjar-se um dissipador maior. A minha escolha foi a lâmpada de 24V/25W.

Ilustração dos diversos passos de montagem

O suporte para a lâmpada é de reboque:

O dissipador:

Optei por fazer a caixa em madeira. Tem dimensões (12cmx16cm) e as laterais (4.3cmx16cm). Têm espessura de 1.5cm).

E usei umas calhas de alumínio de 4.3cm para colocar os jacks:

E confirma-se que está tudo bem:

Fura-se o dissipador. Note-se no círculo interior onde se vai colocar o mosfet.

Optei por montar tudo numa linha de contactos que tinha para aqui, mas podia ter usado uma stripboard:

E um spaceinvader que teimou em ajudar. Ficou tudo mais fácil a partir daqui ;)

A montagem do transístor requer algum cuidado. É necessário massa térmica e um isolador de cerâmica (ou outro) .

Costumo colocar massa térmica entre o isolador e o dissipador e o transístor.

E já me esquecia... a fonte de alimentação é um carregador de portátil 18V 2.23A, mas qualquer outro serve.

Notas finais

E já está! As fotografias seguintes mostram a clara vantagem de usarmos uma lâmpada: não ser necessário instalar um led on-off.

O plástico vermelho dá aquela sensação quente que tanto gostamos em amplificadores de guitarra :P.

Os circuitos simples, e este é um caso desses, permitem identificar muito bem os efeitos que se obtêm quando se varia um parâmetro. O potenciómetro P1 permite controlar o ponto de funcionamento do mosfet permitindo controlar a distorção e compressão do sinal final amplificado.

E como soa? Bom melhor mesmo é montar um!

Boas construções!

Etiquetas/Tags: audio, amplificador, guitarra, 1W, mosfet, diy


Arquivo
Arquivo do Blog

2018/06/22-15:24:39

Etiquetas/Tags: página pessoal, blog, arquivo


This might work!
... testing.

2018/06/21-11:51:35

For the polyholes lib check: http://hydraraptor.blogspot.com/2011/02/polyholes.html

It does!

OpenSCAD code

// Author: Tiago Charters de Azevedo 
// Maintainer: Tiago Charters de Azevedo 
// URL: http://diale.org/
// Version: *

// Copyright (c) - 2018 Tiago Charters de Azevedo

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.

// Commentary:

include <../utils/polyholes.scad>

x1=[[1.0000000E+01,0.0000000E+00],
[1.0580019E+01,6.7237996E-01],
[1.1027136E+01,1.4072740E+00],
[1.1264505E+01,2.1710554E+00],
[1.1243887E+01,2.9173856E+00],
[1.0953411E+01,3.5974472E+00],
[1.0418914E+01,4.1711040E+00],
[9.6987187E+00,4.6166103E+00],
[8.8728952E+00,4.9367463E+00],
[8.0290475E+00,5.1599555E+00],
[7.2472695E+00,5.3360514E+00],
[6.5870181E+00,5.5271645E+00],
[6.0782335E+00,5.7955839E+00],
[5.7181895E+00,6.1908273E+00],
[5.4744510E+00,6.7384946E+00],
[5.2931497E+00,7.4331887E+00],
[5.1108104E+00,8.2370557E+00],
[4.8673272E+00,9.0844478E+00],
[4.5175449E+00,9.8920435E+00],
[4.0392424E+00,1.0572696E+01],
[3.4360885E+00,1.1050534E+01],
[2.7351726E+00,1.1274535E+01],
[1.9798078E+00,1.1228048E+01],
[1.2192426E+00,1.0932424E+01],
[4.9750951E-01,1.0444010E+01],
[-1.5621939E-01,9.8449567E+00],
[-7.3374158E-01,9.2294536E+00],
[-1.2491217E+00,8.6878326E+00],
[-1.7349084E+00,8.2913930E+00],
[-2.2340628E+00,8.0806586E+00],
[-2.7892959E+00,8.0591413E+00],
[-3.4320694E+00,8.1936686E+00],
[-4.1736211E+00,8.4211207E+00],
[-5.0000000E+00,8.6602540E+00],
[-5.8723074E+00,8.8263748E+00],
[-6.7323033E+00,8.8461432E+00],
[-7.5124415E+00,8.6698197E+00],
[-8.1484735E+00,8.2787990E+00],
[-8.5921862E+00,7.6872088E+00],
[-8.8217391E+00,6.9374923E+00],
[-8.8474611E+00,6.0910316E+00],
[-8.7117953E+00,5.2157795E+00],
[-8.4831763E+00,4.3733814E+00],
[-8.2447908E+00,3.6082937E+00],
[-8.0801739E+00,2.9409428E+00],
[-8.0582396E+00,2.3661126E+00],
[-8.2205085E+00,1.8566837E+00],
[-8.5729330E+00,1.3717663E+00],
[-9.0839051E+00,8.6740776E-01],
[-9.6889046E+00,3.0756377E-01],
[-1.0301026E+01,-3.2699490E-01],
[-1.0825533E+01,-1.0337131E+00],
[-1.1175845E+01,-1.7882616E+00],
[-1.1288087E+01,-2.5495269E+00],
[-1.1131620E+01,-3.2685385E+00],
[-1.0713679E+01,-3.8994601E+00],
[-1.0077378E+01,-4.4103170E+00],
[-9.2935327E+00,-4.7911491E+00],
[-8.4478729E+00,-5.0577683E+00],
[-7.6260705E+00,-5.2501657E+00],
[-6.8993228E+00,-5.4256874E+00],
[-6.3131028E+00,-5.6481712E+00],
[-5.8810242E+00,-5.9750845E+00],
[-5.5847732E+00,-6.4451718E+00],
[-5.3798905E+00,-7.0690936E+00],
[-5.2060939E+00,-7.8250223E+00],
[-5.0000000E+00,-8.6602540E+00],
[-4.7077111E+00,-9.4987548E+00],
[-4.2948331E+00,-1.0253417E+01],
[-3.7520633E+00,-1.0840875E+01],
[-3.0954135E+00,-1.1196185E+01],
[-2.3612250E+00,-1.1284656E+01],
[-1.5971750E+00,-1.1108596E+01],
[-8.5125755E-01,-1.0707642E+01],
[-1.6109989E-01,-1.0152526E+01],
[4.5412881E-01,-9.5333369E+00],
[9.9752138E-01,-8.9443452E+00],
[1.4931558E+00,-8.4681073E+00],
[1.9800062E+00,-8.1616965E+00],
[2.5023190E+00,-8.0475111E+00],
[3.0984820E+00,-8.1102609E+00],
[3.7907554E+00,-8.3005964E+00],
[4.5780943E+00,-8.5446194E+00],
[5.4336990E+00,-8.7574529E+00],
[6.3079885E+00,-8.8583304E+00],
[7.1366024E+00,-8.7844347E+00],
[7.8519987E+00,-8.5010068E+00],
[8.3964473E+00,-8.0059963E+00],
[8.7338707E+00,-7.3285877E+00],
[8.8581357E+00,-6.5221071E+00],
[8.7960232E+00,-5.6528608E+00],
[8.6040923E+00,-4.7871884E+00],
[8.3598121E+00,-3.9792880E+00],
[8.1484446E+00,-3.2621451E+00],
[8.0480112E+00,-2.6432218E+00],
[8.1150871E+00,-2.1055742E+00],
[8.3740691E+00,-1.6139695E+00],
[8.8119599E+00,-1.1245750E+00],
[9.3797150E+00,-5.9609843E-01],
[1.0000000E+01,-2.4492936E-15]]

;x2=[[-1.0000000E+01,0.0000000E+00],
[-9.4032668E+00,5.4699554E-01],
[-8.8586147E+00,1.0159488E+00],
[-8.3949861E+00,1.5455589E+00],
[-8.1029387E+00,2.1838625E+00],
[-8.0447476E+00,2.8688422E+00],
[-8.1677418E+00,3.5063433E+00],
[-8.3697939E+00,4.0985505E+00],
[-8.6040416E+00,4.7927838E+00],
[-8.7886845E+00,5.6967582E+00],
[-8.8032275E+00,6.6716202E+00],
[-8.6486850E+00,7.4658016E+00],
[-8.4045751E+00,7.9976032E+00],
[-8.0285873E+00,8.3793495E+00],
[-7.3740031E+00,8.6743293E+00],
[-6.4461723E+00,8.8176655E+00],
[-5.4518251E+00,8.7544859E+00],
[-4.5942009E+00,8.5432205E+00],
[-3.8853713E+00,8.2923350E+00],
[-3.2084512E+00,8.0918479E+00],
[-2.5060360E+00,8.0463763E+00],
[-1.8340098E+00,8.2308361E+00],
[-1.2765823E+00,8.6052594E+00],
[-8.3937187E-01,9.0566830E+00],
[-4.1350524E-01,9.5594600E+00],
[1.6602110E-01,1.0154853E+01],
[9.5204828E-01,1.0735238E+01],
[1.7803219E+00,1.1121777E+01],
[2.4519979E+00,1.1271971E+01],
[2.9796526E+00,1.1238240E+01],
[3.5249445E+00,1.0974452E+01],
[4.1283816E+00,1.0390583E+01],
[4.6597321E+00,9.5509121E+00],
[5.0000000E+00,8.6602540E+00],
[5.1753454E+00,7.8699702E+00],
[5.3091448E+00,7.1638109E+00],
[5.5359864E+00,6.4974918E+00],
[5.9427498E+00,5.9254195E+00],
[6.5068640E+00,5.5325346E+00],
[7.1204533E+00,5.3203002E+00],
[7.7343458E+00,5.1991788E+00],
[8.4526933E+00,5.0549267E+00],
[9.3278796E+00,4.7628450E+00],
[1.0179406E+01,4.2880085E+00],
[1.0789916E+01,3.7570802E+00],
[1.1128415E+01,3.2797740E+00],
[1.1271023E+01,2.7632858E+00],
[1.1199191E+01,2.0489093E+00],
[1.0859408E+01,1.1737162E+00],
[1.0307520E+01,3.4417605E-01],
[9.6957464E+00,-2.9291556E-01],
[9.1240585E+00,-7.8133722E-01],
[8.6119714E+00,-1.2673237E+00],
[8.2213843E+00,-1.8528973E+00],
[8.0451181E+00,-2.5271190E+00],
[8.0906644E+00,-3.1970770E+00],
[8.2630035E+00,-3.8014242E+00],
[8.4854878E+00,-4.4216239E+00],
[8.7113498E+00,-5.2212048E+00],
[8.8209647E+00,-6.1921170E+00],
[8.7415803E+00,-7.1026924E+00],
[8.5358144E+00,-7.7594780E+00],
[8.2427747E+00,-8.1995747E+00],
[7.7416824E+00,-8.5399177E+00],
[6.9343180E+00,-8.7705749E+00],
[5.9414664E+00,-8.8109024E+00],
[5.0000000E+00,-8.6602540E+00],
[4.2279214E+00,-8.4169657E+00],
[3.5494699E+00,-8.1797598E+00],
[2.8589998E+00,-8.0430507E+00],
[2.1601889E+00,-8.1092820E+00],
[1.5378835E+00,-8.4013769E+00],
[1.0472885E+00,-8.8266435E+00],
[6.3544804E-01,-9.2977294E+00],
[1.5134831E-01,-9.8477105E+00],
[-5.3919509E-01,-1.0459603E+01],
[-1.3761789E+00,-1.0959629E+01],
[-2.1412313E+00,-1.1222882E+01],
[-2.7238400E+00,-1.1277377E+01],
[-3.2424359E+00,-1.1142635E+01],
[-3.8251880E+00,-1.0723239E+01],
[-4.4132361E+00,-9.9913817E+00],
[-4.8556947E+00,-9.0986620E+00],
[-5.1015455E+00,-8.2503049E+00],
[-5.2386871E+00,-7.5109978E+00],
[-5.4035202E+00,-6.8245242E+00],
[-5.7153483E+00,-6.1934790E+00],
[-6.2111083E+00,-5.7037171E+00],
[-6.8140821E+00,-5.4081824E+00],
[-7.4236316E+00,-5.2552589E+00],
[-8.0719826E+00,-5.1378360E+00],
[-8.8773708E+00,-4.9336478E+00],
[-9.7730130E+00,-4.5431210E+00],
[-1.0521902E+01,-4.0190844E+00],
[-1.0987812E+01,-3.5124931E+00],
[-1.1222427E+01,-3.0386650E+00],
[-1.1266627E+01,-2.4345347E+00],
[-1.1062700E+01,-1.6200081E+00],
[-1.0601199E+01,-7.4000964E-01]];

$fn=4*64;
phi=(1+sqrt(5))/2;
p1=6.0000000E+00;
p2=-6.0000000E+00;
alpha=-4*360/(p1*p2);
l=50;
r1=10;
r2=r1;

d=.4;
thickness=3*.4;

rd=3.7/2;
module rotor1(l){
    translate([0,-r1,0]){difference(){
            linear_extrude(height=l, center=true, convexity=10, twist=alpha*p2){polygon(x1);}
            poly_cylinder(h=l+1,r=rd,center=true);}}}

module rotor2(l){
    translate([0,r2,0]){difference(){
            linear_extrude(height=l, center=true, convexity=10, twist=alpha*p1){polygon(x2);}
            poly_cylinder(h=l+1,r=rd,center=true);}}}

module box(){
    difference(){
        difference(){
            hull(){
                translate([0,-r1,0]){
                    cylinder(h=l+2*thickness+2*d,r=r1+phi+thickness+2*d,center=true);}
                
                translate([0,r2,0]){
                    cylinder(h=l+2*thickness+2*d,r=r1+phi+thickness+2*d,center=true);}}
            
            hull(){
                translate([0,-r1,0]){
                    cylinder(h=l+2*d,r=r1+phi+2*d,center=true);}
                
                translate([0,r2,0]){
                    cylinder(h=l+2*d,r=r1+phi+2*d,center=true);}}}
    
        translate([-(r1+r2+6*thickness)/2,0,0]){
            cube([(r1+r2+6*thickness),2*(r1+r2+4*thickness),l+4*thickness],center=true);}
        
        translate([0,r2,0]){
            poly_cylinder(h=2*l,r=rd,center=true);}
        translate([0,-r1,0]){
            poly_cylinder(h=2*l,r=rd,center=true);}
        


        translate([2*r1-(1-sqrt(2)/2)*(r1+thickness),0,0])
        {
            cube([r1,2*(r1+r2+4*thickness),l+4*thickness],center=true);}}}

module show(){
    
    rotor1(l);
    
    rotor2(l);
    
    box();}



module print(){

    translate([0,-2,0])
    rotor1(l);
    translate([0,2,0])
    rotor2(l);
}

!print();
show();
box();

Etiquetas/Tags: 3DPrinting, openscad, reprap


Palavras chave/keywords: página pessoal, blog

Criado/Created: NaN

Última actualização/Last updated: 16-08-2018 [16:30]


Voltar à página inicial.


GNU/Emacs Creative Commons License

(c) Tiago Charters de Azevedo