Дек 062018
 

Работает, но не очень.

Драйвер для двигателей.

Источник: http://theamateurprogrammer.blogspot.com/2014/02/revitalizing-old-hard-drive-motors.html

int phase1 = 9;
int phase2 = 6;
int phase3 = 5;

int A = 9;
int B = 6;
int C = 5;

int led = 13;

unsigned long stepLength = 40000;
int minStepLength = 7000; //1400
int steps = 50;

void setup() {
  pinMode(led, OUTPUT);  
  pinMode(phase1, OUTPUT);
  pinMode(phase2, OUTPUT);
  pinMode(phase3, OUTPUT);
  analogWrite(led, LOW);
}

void loop() {
  switchStep(1);
  switchStep(2);
  switchStep(3);
 
  if(stepLength > minStepLength)
  {
    stepLength = stepLength - steps;
  } else {
    // set the minimum pulse length
    stepLength=minStepLength;
  }
 
  if (stepLength < 39950) {
    analogWrite(led, HIGH);   // second gear
    steps = 300;
  }
   
  if (stepLength < 20000) {
    analogWrite(led, LOW);      // third gear
    steps = 50;
  }

  if (stepLength < 3000) {
    analogWrite(led, HIGH);      // fourth gear
    steps = 2;
  }
}


// CB, AB, AC, BC, BA, CA

void switchStep(int stage)
{
  int PWM = 64;
 
  switch(stage)
  {
  case 1:
    analogWrite(phase1, PWM); // 100 ok
    analogWrite(phase2, 0);
    analogWrite(phase3, 0);
    myDelay(stepLength);
    break;
   
  case 2:
    analogWrite(phase1, 0);
    analogWrite(phase2, PWM);
    analogWrite(phase3, 0);
    myDelay(stepLength);
    break;
   
  default:
    analogWrite(phase1, 0);
    analogWrite(phase2, 0);
    analogWrite(phase3, PWM);
    myDelay(stepLength);
    break;
  }  


}

void myDelay(unsigned long p) {
if (p > 16380) {
  delay (p/1000);
  } else {
  delayMicroseconds(p);
  }
}
 Posted by at 11:14
Июл 192018
 

#include 

#define ONE_WIRE_BUS 5 // PD5

OneWire ds(ONE_WIRE_BUS);

/* ROM = 28 D4 38 F7 2 0 0 4    */
/* ROM = 28 FF 63 BE B1 16 3 20 */

byte addr[8] = { 0x28, 0xFF, 0x63, 0xBE, 0xB1, 0x16, 0x03, 0x20 };

byte data[12];

#define LED 6

#define A A4
#define B A2
#define C 10
#define D 8
#define E 7
#define J A3 // Это F
#define G 11

#define CA2 A0
#define CA1 13
#define CA3 A1

#define DP 9      // Точка

const int segs[7] = { A, B, C, D, E, J, G };

const byte numbers[10] = {
  0b1000000,
  0b1111001,
  0b0100100,
  0b0110000,
  0b0011001,
  0b0010010,
  0b0000010,
  0b1111000,
  0b0000000,
  0b0010000
};

const byte m[1] = {
  0b1000000
};

long previousMillis = 0;
long interval = 1000;
unsigned long currentMillis;

boolean run = false;

int thousands = 0;
int hundreds = 0;
int tens = 0;
int ones = 0;


void setup() {

  pinMode(LED, OUTPUT);

  pinMode(13, OUTPUT); // Digital 1
  pinMode(A0, OUTPUT); // Digital 2
  pinMode(A1, OUTPUT); // Digital 3

  pinMode(A4, OUTPUT); // SEG A
  pinMode(A2, OUTPUT); // SEG B
  pinMode(10, OUTPUT); // SEG C
  pinMode(8, OUTPUT); // SEG D
  pinMode(7, OUTPUT); // SEG E
  pinMode(A3, OUTPUT); // SEG F
  pinMode(11, OUTPUT); // SEG G

  pinMode(DP, OUTPUT); // DP

  digitalWrite(LED, HIGH);

  Serial.begin(9600);

}

int16_t raw;
int celsius;
int pcelsius;

byte i;
bool minus = false;

void loop() {

  currentMillis = millis();

  if (thousands > 0) {
    lightDigit1(numbers[thousands]); // temp%10]);
    delay(5);
  }

  if (minus) {
    dis_minus();
    delay(5);
  }

  lightDigit2(numbers[hundreds]); // int(temp/10)]);
  delay(5);
  lightDigit3(numbers[tens]); // int(8)]);
  delay(5);

  if (currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;

    if (run) {
      ds.reset();
      ds.select(addr);
      ds.write(0xBE);
      for (i = 0; i < 9; i++) data[i] = ds.read();
      run = false;

      raw = (data[1] << 8) | data[0];
      
      // raw = 0xFFF8;  // -0.5
      // raw = 0xFE6F;  // -25.12

      celsius = ((float)raw / 16.0) * 100;

      // celsius = -99;
      
      pcelsius = celsius;
     
      if (celsius < 0) { celsius = celsius * -1; pcelsius = pcelsius * -1; if (pcelsius > 999) celsius = celsius / 10;
        minus = true;
      } else {
        minus = false;
      }

      thousands = celsius / 1000;
      hundreds = (celsius % 1000) / 100;
      tens = (celsius % 100) / 10;
      ones = celsius % 10;
    }

    if (!run) {
      ds.reset();
      ds.select(addr);
      ds.write(0x44, 1);
      run = true;
    }

    if (digitalRead(LED) == 1) {
      digitalWrite(LED, LOW);
    } else {
      digitalWrite(LED, HIGH);
    }
  }

}

void dis_minus() {
  digitalWrite(CA1, HIGH);
  digitalWrite(CA2, LOW);
  digitalWrite(CA3, LOW);
  digitalWrite(DP, HIGH);
  digitalWrite(segs[6], 0);
  digitalWrite(segs[5], 1);
  digitalWrite(segs[4], 1);
  digitalWrite(segs[3], 1);
  digitalWrite(segs[2], 1);
  digitalWrite(segs[1], 1);
  digitalWrite(segs[0], 1);

}

void lightDigit1(byte number) {
  digitalWrite(CA1, HIGH);
  digitalWrite(CA2, LOW);
  digitalWrite(CA3, LOW);
  digitalWrite(DP, HIGH);
  lightSegments(number);
}

void lightDigit2(byte number) {
  digitalWrite(CA1, LOW);
  digitalWrite(CA2, HIGH);
  digitalWrite(CA3, LOW);
  if (!minus) {
    digitalWrite(DP, LOW);
  } else {
    if (pcelsius <= 999) {
      digitalWrite(DP, LOW);
    } else {
      digitalWrite(DP, HIGH);
    }
  }
  lightSegments(number);
}

void lightDigit3(byte number) {
  digitalWrite(CA1, LOW);
  digitalWrite(CA2, LOW);
  digitalWrite(CA3, HIGH);
  digitalWrite(DP, HIGH);
  lightSegments(number);
}

void lightSegments(byte number) {
  for (int i = 0; i < 7; i++) {
    int bit = bitRead(number, i);
    digitalWrite(segs[i], bit);
  }
}
 Posted by at 13:48
Мар 292017
 

Elecrow Mega32U4 with A7 GSM GPRS GPS Module A6 A6C
DIY Kit Newest Development Board Integrated Circuits GPS GSM Antenna

Схема32u4 with A7 GPRS GSM GPS v1.0

The new 32U4 with A7 GSM/GPRS/GPS Board is based on mega32U4 and A7 GSM/GPRS/GPS module. Compare to 32u4 with A6 GPRS GSM Board, it adds a GPS function,it also can call and send text message even via GPRS to upload data to server. At the same time it leads to an analog interface, an IIC interface and 2 digital interface. which you can connect to other module more easily.
Remote control and data acquisition will be more convenient.It is worth mentioning that this module can be powered by battery, and comes with a battery charging circuit, some IOT projects will make it take a leading role.
Add three GPS commands as follows:
AT+GPS=1 :OPEN GPS function
AT+GPSRD=1 : Get GPS information
AT+GPS=0: Close GPS function

Features

32U4 combine with A7 module
Multiple interfaces
3.7V Battery power supply
GSM/GPRS/GSM function
Support the GSM / GPRS four bands, including 850,900,1800,1900MHZ
Support China Mobile and China Unicom’s 2G GSM network worldwide
GPRS Class 10
Support GPS and AGPS
Support ROHS, FCC, CE, CTA certification
Specifications

Operating temperature -30 ℃ to + 80 ℃
Operating Voltage 3.3V-4.2V
Sensitivity <-105
Standby average current 3ma less
Working Voltage:3.7V
Sizes: 50mm x 35mm
Package list

32u4 with A7 GPRS/GSM/GPS Board x1
GSM antenna x 1
GPS antenna x 1

Wiki & External links

Купить в Aliexpress.

 Posted by at 15:55
Окт 272016
 

987654321

  • 10DOF modules (three-axis gyroscope + triaxial accelerometer and three-axis magnetic field + atmospheric pressure)
  • Means of communication: IIC Communication protocol(fully compatible with 3-5V system containing LLC circuit)
  • Acceleration,Gyroscope and magnetometer
  • chip:MPU6050+HMC5883+BMP180
  • power supply :3.3V-5V
  • size:2.2cmx1.7cm

qwertyuiop 1234567890

Описание.

Для включения компаса HMC5883L нужно следующие.
// Bypass Mode
Wire.beginTransmission(0x68); // Address of MPU5060
Wire.write(0x37);
Wire.write(0x02);
Wire.endTransmission();

Wire.beginTransmission(0x68);
Wire.write(0x6A);
Wire.write(0x00);
Wire.endTransmission();

// Disable Sleep Mode
Wire.beginTransmission(0x68);
Wire.write(0x6B);
Wire.write(0x00);
Wire.endTransmission();

Июл 082016
 

 

2560-arduino-home-made

Вот решил Arduino собрать на ATmega2560, вот что получилось.

p.s. Плата переходник для подключения WG12864B

U8GLIB_KS0108_128 u8g(22,23,24,25,26,27,28,29,34,30,39,33,32,31);

// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16,rst=31

Тест программка.

#include <openGLCD.h>

void setup()
{
  GLCD.Init();
  GLCD.SelectFont(System5x7);
  GLCD.ClearScreen();

  pinMode(A15, OUTPUT);
  pinMode(44, OUTPUT);
  digitalWrite(44, HIGH);    
  digitalWrite(A15,HIGH);
}

byte pos = 0;
byte r;
void loop()
{
  while(1) {
    GLCD.ClearScreen();

    for(byte x=0;x<11;x++) {
      r = random(1,63);
      if (pos==0) {
        Bar(pos,0,10,r);
      }
      else {
        Bar(pos+(x*2),0,10,r);
      }
      pos=pos+10;
    }
    delay(200);
    pos =0;
  }

}

void Bar(int x,int y, int w, int h) {
  GLCD.FillRect(x,63-h,w,h,BLACK);
}
Авг 182015
 

oled-dimension

oled-main

Разрешение: 128*64
Угол обзора: > 160 градусов
Ультра-низким энергопотреблением: 0.08 Вт
Рабочее напряжение: 3-5 Вольт
Рабочая температура: от-30 до 70 градусов Цельсия
Размер: 27.0 мм * 27.0 мм * 4.1 мм
I2c/интерфейс
SSD1306

Arduino Library. (backup download:OLED_I2C)

SPI

oled128x64spi

Библиотеки для микроконтроллеров (Arduino, и.т.д.)

u8glib – https://code.google.com/p/u8glib/

Для Arduino

D/C =>11, RST=>13,SDA=>9,SCL=10

U8GLIB_SSD1306_128X64 u8g(10, 9, 12, 11,13);

12=Не подключаем.

VCC = 3.3v !!! ( На этом модуле нет преобразователя 3.3в )

U8GLIB_SSD1306_128X64 u8g(10,9,12,11,13); // Arduino Fio

 Posted by at 15:47  Tagged with:
Апр 222015
 

BB-VNH3SP30-1

– Нагрузка до 30А;
– Напряжение питания 5.5-36В;
– LED индикатор состояния ШИМ;
– LED индикатор состояния направления;

Купить.

 

    |---------------------------------------------------------------------------|
    |            The hardware connections are as follows:                       |
    |--------------------------------|------------------------------------------|
    |  Connector at Olimexino-328    |      Connector at BB-VNH3SP30            |
    |--------------------------------|------------------------------------------|
    |    Not connected!              |          CTRL<1>,  VIN                   |
    |    Power<3>, 5V                |          CTRL<2>,  +5V                   |
    |    Power<4>, GND               |          CTRL<3>,  GND                   |
    |    Digital<9>                  |          CTRL<4>,  INA                   |
    |    Digital<13>                 |          CTRL<5>,  INB                   |
    |    Digital<11>                 |          CTRL<6>,  PWM                   |
    |    Digital<10>                 |          CTRL<7>,  ENA/DIAGA             |
    |    Digital<12>                 |          CTRL<8>,  ENB/DIAGB             |
    |--------------------------------|------------------------------------------|