Tuesday, April 29, 2014

Calc time

Ti timers are perfect for second level timing:
This can be used to measure computations permutation timr , as an actual timer etc.(the possibilities are endless).

Magnesfluid Builder Mk 1


MOSFETS and the Arduino for High Voltage PWM


A MOSFET(Metallic Oxide Semiconductor Field Effect Transistor) looks like this:

There are 3 pins, 1 for ground, drain, and source. Schematically the setup can be explained easily. Notice in the schematic that  the 1 pin looks as though it could press down and allow current to flow between 2 and 3. This is exactly how the MOSFET works. It is a lot like a thrysistor. Notice the little Zener diode at the bottom? For those not familiar with schematics it is the Triangle with a 3 line segments on one point.

A Zener Diode
The Zener allows flow of current( in this diagram to the right) constantly but only allows flow backwards if it is over a certain amount. This little addition to the mosfet, though it is small, is groovy for us, because our mosfet won't fail if things go South. So, you may be wondering where this is going, well today I will be covering High Power control circuits using Arduino, Mosfets, and the C language Family.
///////////////////////////////////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
The MOSFET uses a small input voltage(pin 1), not a full circuit, in order to allow a much larger voltage to pass through the Transistor(for this post transistor will mean MOSFET). This is useful for many reasons.

Currently for an ROV my team and I are working on, a large amount of "tether" seperates the Arduino controller from the Servos it controls. This is problematic for the following reasons:
  1. The Servos being used have chips inside them which can execute programs when no PWM is detected for a sufficient time span. However the robot is sent commands via a CS(Control System) using a USB to Arduino protocol which then sends pwm on the digital 9 pin(keep this in mind, only certain pins can handle pwm, there are actually only 8 on the Arduino Uno which is the board of choice).
  2. The voltage for power was too low but this was boosted with a simple parallel circuit solution, we will replace an op amp.
  3. The PWM is not reaching the Servos(it is only 5V and the current of the Arduino pins).
In order to fix this dilemma, the MOSFET will be utilized to use pulse width modulation with a "stronger" electrical source. In this case we will capture our energy from a 25 amp, 12-14.38 volt source.
Basic code outline:
Outline of program in C++

Wiring:
First wire the pwm (pin 9) into the gate of the MOSFET. This signal controls electrical flow through te MOSFET.

Next is the source, from the + of our  input power,( the source is where the electrons flow from. They have come from the p to make a bridge connecting the n material within the MOSFET, or the entire situation is reversed as is your mosfet's function.

Drain is to the load.


Robot update 2

Thursday, April 24, 2014

Arduino with sensor and ec probe controlled via Python on rpi




//C and C++ code for Arduino

#include <Servo.h>

float Count;

float Voltage;

float SensorReading;

int TimeBetweenReadings = 500; // in ms

int ReadingNumber=0;

float Time;

char Sensor[]="Hand Dynamometer";

float Intercept = -19.295;

float Slope = 175.416;

Servo myservo;  // create servo object to control a servo

Servo claw;               // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

int b=0;

int posit=0; //var for storing claw position

 

void setup(){

  Serial.begin(9600); //initialize serial communication at 9600 baud

Serial.println("Vernier Format 2");

Serial.print(Sensor);

Serial.print(" ");

Serial.println("Readings taken using Ardunio");

Serial.println("Data Set");

Serial.print("Time");

Serial.print("\t"); //tab character

Serial.println ("EC"); //change to match sensor

Serial.print("seconds");

Serial.print("\t"); // tab character

Serial.println ("μS"); //change to match sensor

  myservo.attach(8);

  claw.attach(7); //  the servo on pin 7

 

void loop(){

Serial.print(ReadingNumber/1000.0*TimeBetweenReadings);

Count = analogRead(A0);

Voltage = Count / 1024 * 5.0;// convert from count to raw voltage

SensorReading= Intercept + Voltage * Slope;

Serial.print("\t"); // tab character

Serial.println(SensorReading);

delay(TimeBetweenReadings);// delay in between reads for stability

ReadingNumber++;

  if(Serial.available()>0){

    b=Serial.read();

    serial.print("Data Received System functional");

    if (b="4") {

      for(pos = 0; pos < 360; pos += 1)  

  {                                 

    myservo.write(pos);              

    delay(15);  }

    }

    if (b="6") {

      for(pos = 0; pos < 360; pos += 1)  

  {                                 

    myservo.write(pos);              

    delay(15);  }

    }

   if (b="2") {

      for(pos = 0; pos < 360; pos += 1)  

  {                                 

    claw.write(posit);              

    delay(15);  }

    }

   if (b="6") {

     for(pos = 0; pos < 360; pos += 1)  

  {                                 

   claw.write(posit);              

    delay(15);  }

    }

    

    

 

##script to send keystrokes to arduino

import sys

import serial

Cereal=serial.Serial('/dev/AMCY0/',9600);

 

while 1:

print(Cereal.readline());

   char = sys.stdin.read(1)

Cereal.write(char);

Monday, April 21, 2014

The Ph~F rift/ripht

Photograph, fotografia, φωτογραφία(fotografia for you Latin alphabet lovers),Foto...

European languages are said to have only a few indoeuropean ancestors, except for distinct local flavors such as basque. If this is true, the differences in the use of the allmorphs f and pH are striking. If one geographically maps the use of the allomorphs it is clear that various nations utilize different morphemes regardless of regions.

The two languages which have come to dominate Europe and the world in terms of root graphemes and phonemes are Latin and Greek. The Latin word for photograph is literally photograph, while the Greek version( when written in the Latin alphabet) is fotografia, just as it is in Spanish.
//add theory

This selection theory explains the cause of the difference in Fn language generations where n is greater than 1(meaning after the parent langisges , Latin or Greek) but it does not explain why Greek and Latin had such different philosophies(filosofias or philosofiam) regarding the glyphs.

Logically,oral language almost always precedes its Lexigraphical equivalent. This is why oral languages such as Navajo or Navaho exist without a written counterpart, but there are no known major languages which are written and have no oral equivalent. Therefore ph~f rift must have occured early on long before any later event such as the East-West schism of 1054 could have so divided the Latin and Greek worlds.

The Greek alphabet weighs in at a low 23 letters(letters in the traditional sense of English-Cryllic alphabet species) whileiys Latin also came in at 23 during the classical period.

Greek came before Latin, naturally it may have less features, and would integrate less languages( although now its monoculturizing towards English) with less lexiconic isomers such as ph and f.

Saturday, April 19, 2014

Novel Smoothing Algorithm:Morley Pinturia Naturaleza Muerta Smoothing Algorithm(Cluster Bomb Smoothing)

Cells
In the cellular automata the Morley Algorithm allows for a static "object" to occur in the above formation, however that is not the focus of this post. Instead we will be using the above geometry in order to create a basic smoothing algorithm using PImage in Processing. This post continues the Algorithm outlined in the previous post Statistically Viable Time Based Smoothing and Deconvolution Algorithm
PImage img;
int a, b,r,u;
 This sets up the image variable and the 4 vars we will be using.

void setup() {
  size(500, 500);
  img = loadImage("cat.jpg");
  a = 1;
  b = 1;
  r=img.width;
  u=0;
  imageMode(CENTER);
  noStroke();
  background(0);
}
Loading the image and setting up our variables. a & b are for rect sides or in terms of the above image they are the size of the white pieces.

void draw() { 

  float pixel = map(11, 0, width, a, b); //creating pixel variable
  int x = int((img.width)-r); // sets the x pt equal to image width minus the
                              //size of the r val which paints the image

  int y= int(u);//u as the y val due, tis necessary due to language syntax
  color pix = img.get(x, y);//captures pixel color
  fill(pix, 128);//color,alphamask
  rect(x-1, y, pixel, pixel);
  rect(x+1, y, pixel, pixel);
  rect(x, y-1, pixel, pixel);
  rect(x, y+1, pixel, pixel);//these rect lines create our Cells diagram
  r=r-1;//moves painting along the x axis
  println(r);//outputs current pos
Now there must be an if statement in order to move along the y axis once a row is completed:


if(r==1000){
  r=img.width;
   u=u+1;
}
}
And so the symphony all together:


PImage img;
int a, b,r,u;

void setup() {
  size(500, 500);
  img = loadImage("cat.jpg");
  a = 1;
  b = 1;
  r=img.width;
  u=0;
  imageMode(CENTER);
  noStroke();
  background(0);
}

void draw() { 

  float pixel = map(11, 0, width, a, b);
  int x = int((img.width)-r);
  int y= int(u);
  color pix = img.get(x, y);
  fill(pix, 128);
  rect(x-1, y, pixel, pixel);
  rect(x+1, y, pixel, pixel);
  rect(x, y-1, pixel, pixel);
  rect(x, y+1, pixel, pixel);  
  r=r-1;
  println(r);
  
if(r==1000){
  r=img.width;
   u=u+1;
}
}
The Cat's Ear without smoothing


The Cat's Ear with Cluster Smoothing

A place where the smoothing is perhaps most noticeable is in blue background, notice the falloff occurs quickly on the smoothed image but not nearly as quickly on the non-smoothed image. That is because the novel method ensures blending of the regions which guarantees blending and the elimination of noise in the image.

Statistically Viable Time Based Smoothing and Deconvolution Algorithm


Algorithm for image smoothing
PImage img;
int a, b,z,u;

void setup() {
  size(1000, 900);
  img = loadImage("sun.png");
  a = 1;
  b = 1;
  z=img.width;
  u=0;
  imageMode(CENTER);
  noStroke();
  background(255);

}

void draw() { 

  float pixel = map(11, 0, width, a, b);
  int x = int(random(img.width));
  int y = int(random(img.height));
  color pix = img.get(x, y);
  fill(pix, 128);
  rect(x-1, y, pixel, pixel);
  rect(x+1, y, pixel, pixel);
  rect(x, y-1, pixel, pixel);
  rect(x, y+1, pixel, pixel);  
  rect(x, y, pixel, pixel); 

}