블로그 이미지
훅크선장

카테고리

분류 전체보기 (362)
사진이야기 (23)
펭귄컴퓨팅 (121)
컴퓨터보안 (84)
절름발이 프로그래머 (59)
하드웨어개조 (23)
아두이노(Arduino) (7)
RC비행기(FPV) (3)
HackRF One [SDR] (3)
USRP B210 [B2x0] (0)
3D 프린팅 (1)
멀알려줄까 (35)
홈베이킹&홈쿠킹 (2)
잡다한것들 (15)
Total
Today
Yesterday

달력

« » 2024.4
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

공지사항

태그목록

최근에 올라온 글

이전에 리모콘만으로 설정 가능한 LED 벽시계의 리모콘 분실로 인하여, 아두이노를 가지고 IR 리모콘을 만들어보는 별 쓸모없는 작업을 해보았다. 그런데, 가지고 있는 잡동사니 보드 중에 예전 DEFCON 컨퍼런스를 갔을때, Sparkfun 워크숍을 참가해서 받아온 Roshamglo Badge Kit을 발견했다. Roshamglo 배지 키트는 IR 송신부와 수신부, 그리고 5축 스위치를 가졌기에, 간단한 IR 리모콘으로 만들기에 최적인 보드라고 생각한 것이 실수였다!!!

 

일단 Roshamglo 배지 키트는 2017년에 만들어졌고, 일종의 재미로 만든 보드이다보니, 이젠 더이상 아두이노 IDE 상에서 소프트웨어 라이브러리 지원이 안된다. (아두이노 IDE 소프트웨어를  1.6.10~1.8.x 버전대를 사용하더라도, 보드에 대한 기본적인 소프트웨어 지원 패키지가 없기 때문에, 아두이노 IDE에서 도저히 보드를 연결할 수가 없다.)

 

여기서 포기하면, 하드웨어쟁이가 될 수 없다.

그래서, Roshamglo의 기본이 되는 ATtiny84 MCU를 기준으로 아두이노 ISP를 사용하여 프로그래밍을 시도하였다.

 

Roshamglo Badge Kit 에 대한 정보는 아래의 링크들에서...

https://learn.sparkfun.com/tutorials/roshamglo-hookup-guide/all

 

Roshamglo Hookup Guide - SparkFun Learn

Introduction <!--- ###Attributes Before you begin, make sure you have filled out all required fields found under the Attributes tab. The author is responsible for for the following: * **Title** - Pick a title that makes sense for Search Engine Optimization

learn.sparkfun.com

https://learn.sparkfun.com/tutorials/hack-your-roshamglo-badge/all

 

Hack Your Roshamglo Badge - SparkFun Learn

Introduction So you've put together your Roshamglo badge, and now you want more? Well, we can help you with that. In addition to playing infrared (IR) Rock-Paper-Scissors, the Roshamglo board can be reprogrammed with user-created code. This will allow you

learn.sparkfun.com

https://learn.sparkfun.com/tutorials/roshamglo-project-tv-b-gone/introduction

 

Roshamglo Project: TV-B-Gone - SparkFun Learn

Retired KIT-14130 The SparkFun Roshamglo is the new and fun way to play Rock-Paper-Scissors with your friends! The board uses the ATtiny84, and…

learn.sparkfun.com

 

ATtiny84  프로그래밍에 대한 정보는 다음 링크들에서...

https://github.com/SpenceKonde/ATTinyCore

 

GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8

Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8 - GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8

github.com

https://www.instructables.com/Arduino-Uno-to-Program-ATTINY84-Arduino-V-185/

 

Arduino Uno to Program ATTINY84 (Arduino V. 1.8.5)

Arduino Uno to Program ATTINY84 (Arduino V. 1.8.5): Using the Arduino Uno to program ATTINY84-20PU (Digikey item # ATTINY84-20-PU-ND). This Instructable shows how to use the Arduino platform to work with physically smaller processors, such as the ATtiny84

www.instructables.com

https://www.instructables.com/Program-an-ATtiny44458485-with-Arduino/

 

Program an ATtiny44/45/84/85 With Arduino

Program an ATtiny44/45/84/85 With Arduino: This tutorial gives provides the steps to set up, program, and test an ATtiny44/45/84/85 with an Arduino. It is also provides some explanations as to the inner workings of AVR chips in general.

www.instructables.com

https://www.hackster.io/350166/getting-started-with-attiny84-c920ee

 

Getting started with Attiny84

learn how to program Attiny84 with this custom Breakout board with ams1117 for basic level projects like blinking LED and stuff. By Arnov Sharma and JLCPCB.

www.hackster.io

---------------------------------------------------------------------------------------------------------------------

ATtiny84 MCU 프로그래밍 순서

 

0. ATtinyCore 보드 지원 라이브러리 설치 

Preferences... 에서 Additional boards manager URLs : 에  http://drazzy.com/package_drazzy.com_index.json를 추가해주고, Boards Manager에 가서  ATTinyCore by Spence Konde 를 설치해준다.

(이 글을 쓰는 시점에서 Arduino IDE 2.0.4에서 ATTinyCore version 1.5.2 가 설치되어 잘 동작한다.)

1. Arduino Uno를  Arduino ISP로 만든다. (File -> Examples -> 11. ArduinoISP -> ArduinoISP 선택하고, 스케치 업로드)

2. Arduino Uno와 ATtiny84(Roshamglo Badge Kit)와 연결 

    Arduino Uno의 RESET 핀과 GND 핀 사이에 10uF 커패시터를 연결 (커패시터의 짧은 다리가 GND 쪽에)

 

    Arduino Uno 핀 번호                                         Roshamglo 핀 번호 

                3.3V                <----------------->          3.3V

                GND                <----------------->          GND

                  13                  <----------------->           4 (SCK)

                  12                  <----------------->           5 (MISO)

                  11                  <----------------->            6 (MOSI)

                  10                  <----------------->            RESET

 

3. Roshamglo 에 동작시킬, ino 아두이노 프로그램 작성 

Blink 예제는 다음과 같다.

// Blinking Example

int GREEN_LED = 7; // Green LED가 연결된 핀 7번
int RED_LED = 8; // RED LED가 연결된 핀 8번

void setup(){
pinMode(GREEN_LED, OUTPUT); // Green LED를 출력으로 설정합니다.
pinMode(RED_LED, OUTPUT); // RED LED를 출력으로 설정합니다.
}
 
void loop(){
digitalWrite(GREEN_LED, HIGH); // Green LED 켜기
digitalWrite(RED_LED, LOW); // RED LED 끄기
 
delay(1000); // 1초간 유지합니다.
 
digitalWrite(GREEN_LED, LOW); // Green LED 끄기
digitalWrite(RED_LED, HIGH); // RED LED 켜기
delay(1000); // 1초간 유지합니다.
}
 
4.  Tools -> Board 설정에서  ATtinyCore -> ATtiny24/44/84(a) (No Bootloader) 선택 
                     Port는 Arduino Uno 가 연결된 포트를 지정 (/dev/cu.usbmodemXXXXXX 로 표시됨)
                     나머지 칩 설정은 기본을 그대로 둔다. 다만, Clock Source 가 8MHz (Internal) 인것을 반드시 확인한다.
      Programmer 설정에서 “Arduino as ISP”  반드시 지정 
 
5. Tools -> Burn Bootloader 선택 실행 후,
6. Sketch -> Upload using Programmer 로 프로그램을 업로드한다.
 
에러가 없이 다 정상적으로 수행되었다면, Okay~~!!  

  

Posted by 훅크선장
, |

리모콘을 잃어버린 중국제 LED 벽시계의 시간설정을 위해서, 

아두이노 우노와 만능 멤브레인 키패드 3x4, 그리고 IR 송수신 모듈을 가지고  시계용 IR 리모콘을 한번 만들어 보았다.

 

제일 어려운 것이 리모콘의 송신 신호를 알아내는 것이었다. 리모콘이 있다면, 신호를 송신해보고 그 신호를 복제하는 방법으로 하면 쉽게 갈 수 있지만, 리모콘이 없으므로 모든 코드 신호를 다 보내보면서 시계쪽의 변화를 봐야했기에 완전 쌩노가다였다.

 

무아스 퓨어 39cm 슬림형 LED 벽시계
리모콘 키
1) 전원버튼  
0x1C :  LED 전원 On/Off
2) 화면전환, 디스플레이모드 설정(시간, 날짜, 온도)
0x40 :  시간 -> 날짜  -> 온도 
 x1 x1  -> 22 oC
3) 자동밝기 모드 on/off  
0x08 : 자동밝기모드  
L-01 (자동밝기모드 Off)  -> L-AU (자동밝기모드 On)
0x08, sRepeates 20 : 시간구분점 페이드인 아웃 설정정
 Fd --  -> Fd 0n
4) 알람 ON/OFF
0x44 : AL -- (알람 Off)  ->  AL On  (알람 On)
5) 길게 눌러 시간설정  
0x5E, sRepeates 20 : 
6) 알람시간 확인, 길게 눌러 알람시간 설정
0x4A   6:30
7) 수동밝기모드에서 밝기 올림, 설정모드에서 숫자 올림  
0x18 : up
8) 수동밝기모드에서 밝기 내림, 설정모드웨서 숫자 내림
0x52 : down 

 

아두이노 IDE에 keypad 라이브러리와 IRremote 라이브러리를 설치해서 아래 코드를 아두이노 우노에 업로드하면 된다.

물론 키패드와 송수신 모듈을 아두이노와 연결해야 되는데, 연결방법은 인터넷에 다 있다. (검색하면 된다.)

 

참조 사이트:

https://www.makerguides.com/ir-receiver-remote-arduino-tutorial/

 

IR Remote and Receiver with Arduino Tutorial (4 Examples)

Learn how to use an infrared (IR) sensor/receiver and remote with the Arduino. Wiring diagrams and many example codes included!

www.makerguides.com

https://github.com/Arduino-IRremote/Arduino-IRremote#sending-ir-codes

 

GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple

Infrared remote library for Arduino: send and receive infrared signals with multiple protocols - GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive in...

github.com

https://mechatrofice.com/arduino/keypad-interfacing-with-arduino

 

Keypad Interfacing with Arduino 4x4, 4x3 with LCD connection and code

A Matrix Keypad is a very useful module for embedded systems and a variety of projects. This tutorial briefly explains the interface of 4×3 and 4×4 keypads with Arduino and few programs using keypad...

mechatrofice.com

https://lastminuteengineers.com/arduino-keypad-tutorial/

 

In-Depth: Interface 4x3 & 4x4 Membrane Keypad with Arduino

Learn about 4x3 & 4x4 Membrane Keypad along with its Working, Pinout, Wiring, Library, Arduino Code for Reading Key Presses.

lastminuteengineers.com

keypad 라이브러리에는 한번 누름만 존재하고, 길게 누름에 대한 함수가 존재하지 않기 때문에,

그냥 길게 누름의 신호를 별도의 키 하나에 할당해서 간단하게 구현하였다.

LED 벽시계의 키는 8개뿐이지만, 길게 누름이 3개 할당되어 있어서, 키를 11개만 쓰면 되기 때문에.

// Code for IR controller of Mooas LCD Digital Wall Clock
// coded by HooK7346
// 2023. 3. 8.
/*
* Key # : LED On/Off
* Key * : Change Display
* Key 1 : Brightness Auto On/Off
* Key 2 : Time dot Fade In/Out setting
* Key 3 : Alarm On/Off
* Key 4 : Settings Menu
* Key 5 : OK, Next
* Key 7 : Alarm Time Check
* Key 8 : Alarm Setting
* Key 6 : Up
* Key 9 : Down
*/

#include <Arduino.h>
#define DISABLE_CODE_FOR_RECEIVER // Saves 450 bytes program memory and 269 bytes RAM if receiving functions are not used.
//#define SEND_PWM_BY_TIMER // Disable carrier PWM generation in software and use (restricted) hardware PWM.
//#define USE_NO_SEND_PWM // Use no carrier PWM, just simulate an active low receiver signal. Overrides SEND_PWM_BY_TIMER definition
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
#include <IRremote.hpp>
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[ROWS] = {2, 3, 4, 5};
byte colPins[COLS] = {6, 7, 8};

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

uint8_t sCmd_LED_On_Off = 0x1C;
uint8_t sCmd_Change_Display = 0x40;
uint8_t sCmd_Bright_Auto_On_Off = 0x08;
uint8_t sCmd_Alarm_On_Off = 0x44;
uint8_t sCmd_Setting = 0x5E;
uint8_t sCmd_Alarm_Setting = 0x4A;
uint8_t sCmd_Up = 0x18;
uint8_t sCmd_Down = 0x52;

uint8_t sRepeats_short = 0;
uint8_t sRepeats_long = 30;

void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
 
IrSender.begin(DISABLE_LED_FEEDBACK); // Start with IR_SEND_PIN as send pin and disable feedback LED at default feedback LED pin

Serial.print(F("Send IR signals at pin "));
Serial.println(IR_SEND_PIN);
}

void loop() {
char key = keypad.getKey();
switch (key) {
case '#':
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_LED_On_Off, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_LED_On_Off, sRepeats_short);

break;
case '*': // Change Display button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Change_Display, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Change_Display, sRepeats_short);

break;
case '1': // Brightness Auto On/Off button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Bright_Auto_On_Off, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Bright_Auto_On_Off, sRepeats_short);

break;
case '2': // Time dot Fade In/Out setting button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Bright_Auto_On_Off, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_long);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Bright_Auto_On_Off, sRepeats_long);

break;
case '3': // Alarm On/Off button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Alarm_On_Off, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Alarm_On_Off, sRepeats_short);

break;
case '4': // Settings Menu button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Setting, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_long);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Setting, sRepeats_long);

break;
case '5': // OK, Next button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Setting, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Setting, sRepeats_short);

break;
case '7': // Alarm Time Check button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Alarm_Setting, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Alarm_Setting, sRepeats_short);

break;
case '8': // Alarm Settings button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Alarm_Setting, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_long);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Alarm_Setting, sRepeats_long);

break;
case '6': // Up button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Up, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Up, sRepeats_short);

break;
case '9': // Down button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Down, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Down, sRepeats_short);

break;
}
}
Posted by 훅크선장
, |

Arduino Uno + gShield v5b Board + GRBL 1.1 


※ 모터 결선방법은 다음에 잘 나와있다.

  http://www.diymachining.com/diy-cnc-controller-how-to-setup-your-arduino-gshield/


내가 테스트하고 있는 사진과 영상에선 모터전원을 맨 왼쪽에 두고 보드를 보았을때,

왼쪽부터, 노랑 - 흰색 - 녹색 - 검정 순이다.

         B  - B' -  A' - A 순으로 된 것 같은데...

         

위 링크에서는 B' - B - A' - A 순 으로 결선하라고 되어 있다. 

그러면, 내 모터는  흰색 - 노랑 - 녹색 - 검정 인데, 이렇게 결선하면, 

Z축의 이동이 GRBL Controller 상에서 보이는 스위치와 상하 반대로 움직이던데???? (반드시 확인 필요!)

리미트 스위치는 어느 방향에 있어야 하는가? 시작점? 종료점?


X,Y,Z 축이 +와 - 일때, 움직여야 하는 방향은 어디쪽?  모터와 멀어지는 쪽? 모터와 가까워지는 쪽?

이 방향이 참 애매합니다!!!?? 확인하세요!!



1. grbl 다운로드

   2019년 2월 현재, grbl은 1.1 버전이 나와있으며,

   https://github.com/gnea/grbl/releases 에는 2017년 8월 1일부로 v1.1f 가 있다고 하나, 

   업데이트후에 확인해본 결과, 1.1g 버전으로 업데이트된 상황임.

    

   https://github.com/grbl/grbl 에서,

   우측편에 있는 “Clone or download”를 선택하여, zip 파일로 다운로드 받음.

   

   다운로드된 파일명은 grbl-master.zip 파일이며, 이 파일의 압축을 풀어준다.

   하위에 build, doc, grbl 디렉토리가 있다. 중요한 것은 grbl 디렉토리이다.


2. 아두이노 IDE 설치

   아두이노 IDE 최신버전을 설치하고, 

   https://www.arduino.cc/en/Main/Software 에서 다운로드, 2019년 2월 현재 최신버전은 1.8.8


※ 이미 다른 이전 버전의 grbl이 설치되어 있다면, 미리 제거해야 한다. (grbl 이라는 폴더 이름이 충돌하기 때문에...)   

   기존 설치된 라이브러리를 제거하려면,

   ~/Documents/Arduino/libraries 폴더로 이동한 다음에 해당 grbl 디렉토리를 삭제하고,

   Arduino IDE를 다시 시작하면, 해당 라이브러리가 없어진 것을 확인할 수 있다.

   (최상위 메뉴에서 “스케치” -> “라이브러리 포함하기” 에서 grbl 이름이 없는 것을 확인!)   

   

3. grbl 라이브러리 설치

   최상위 메뉴에서 “스케치” -> “라이브러리 포함하기” -> “ZIP 라이브러리 추가...” 를 선택

   파일선택 다이얼로그가 뜨면, 1번의 과정에서 확인된 grbl 디렉토리가 보이는 곳으로 이동하여, 

   grbl 디렉토리를 선택한 다음 “선택” 버튼 클릭


4. grbl 컴파일 및 업로드

   최상위 메뉴에서 “파일” -> “예제” 에서 아래쪽 “사용자 지정 라이브러리의 예제”쪽에 있는 

   “grbl” -> “grblUpload” 를 선택하면, 파일이 열립니다.

   

   다시, 최상위 메뉴에서 “툴” -> “보드” -> “Arduino/Genuino Uno” 

   “툴” -> “포트” -> “/dev/cu.usbmodem14201”  ※포트명은 컴퓨터에 따라 달라질 수 있음!

   각각을 잘 선택하고, 업로드(오른쪽방향 화살표 동그란 아이콘 클릭)하면 됩니다.

   

   ※ 미리 컴파일이 잘 되는지만 확인해보고(체크 표시 동그란 아이콘 클릭), 업로드하는 것이 좋습니다.


------------------------------------------------------------------------------------------   

Grbl Controller 와 Universal G-Code Sender 를 다운받아서 설치한다.

※ GrblController-3.6.1.7z 파일을 다운받는다. https://github.com/zapmaker/GrblHoming/releases

※ UniversalGcodeSender-v2.0.0-stable2.zip 을 다운받아서 사용한다. 엉뚱한 버전 받으면 고생한다! https://winder.github.io/ugs_website/download/


Port name은 “/dev/cu.usbmodem14201”

Baud Rate는  115200 으로 설정


Open 버튼을 클릭했을때, 다음과 같은 메시지가 나와야 정상이다.


Grbl 1.1g['$'for help]

>$G

...

>$$

$0=10

...

...

...

$132=200.000




Spindle Motor를 켜는 명령어는 M05,  끄는 명령어는 M03 이며, (Spindle On 토글박스 체크와 언체크로 제어할 수 있다.)

Spindle의 속도제어는 S100 ~ S1000 까지로 제어할 수 있다.


---------------------------------------------------------------------------------------

추가 : 

CNC 장비의 Limit 스위치는 포토커플러를 이용한 최상의 방법을 선택할 수 있다.


별도의 GRBL Buffer Board가 판매되고 있으나, 매우 심플하게 구성할 수 있다.

https://www.tindie.com/products/eccentricwkshp/cnc-optical-limit-switch-isolator-grbl/


LTV-817과 1K, 220 오옴 저항으로 구성할 수 있다. 

https://github.com/gnea/grbl/wiki/Wiring-Limit-Switches









Posted by 훅크선장
, |

0-1. 24v 사용을 위해서, D1 제너다이오드 제거

※   D1 제너다이오드는 ramp 1.4보드에서 아두이노 메가보드로 전원이 공급되도록 하는 역할을 함.

  단, ramp 1.4 보드가 12v 전원만을 사용하도록 되어 있기 때문에

  이것을 연결한 채로 아두이노 메가가 사용되면 아두이노 메가가 24v 전원이 공급되어서 타버림~~!!!!!

  

0-2. 24v 사용을 위해서, 11A용 전원단에 붙은 휴즈 교체 

   http://www.mythoughtspot.com/2017/09/18/modify-ramps-for-24-volts/ 참조

   베드가열을 위한 전원 입력부에 과열방지를 위해서 MF-R1100 폴리 퓨즈가 달려있는데, 이것은 16v 용이라서,

   24v 전원에서는 아마 타버릴 것이기 때문에, 자동차용 32v 10A 퓨즈로 교체(퓨즈홀더를 직접 기판에 납땜하는 방식으로)

   http://www.devicemart.co.kr/goods/view?no=1153151

   http://www.devicemart.co.kr/goods/view?no=11510 

   이상 두 부품을 사용함


1. Arduino Mega 2560 을 위한 grbl 다운로드

   2019년 2월 현재, grbl은 1.1 버전이 나와있으며,

   https://github.com/gnea/grbl-Mega/releases 에는 2017년 8월 2일부로 v1.1f 가 있다고 하나, 

   업데이트후에 확인해본 결과, 1.1g 버전으로 업데이트된 상황임.

    

   https://github.com/gnea/grbl-Mega 에서,

   우측편에 있는 “Clone or download”를 선택하여, zip 파일로 다운로드 받음.

   

   다운로드된 파일명은 grbl-Mega-edge.zip 파일이며, 이 파일의 압축을 풀어준다.

   하위에 build, doc, grbl 디렉토리가 있다. 중요한 것은 grbl 디렉토리이다.


2. 아두이노 IDE 설치

   아두이노 IDE 최신버전을 설치하고, 

   https://www.arduino.cc/en/Main/Software 에서 다운로드, 2019년 2월 현재 최신버전은 1.8.8

   

3. EEPROM 청소

   grbl을 업로드하기 전에 꼭 반드시 EEPROM을 깨끗이 청소하는 작업이 필요하다고 함!!!!

   최상위 메뉴에서 “파일” -> “예제” 에서 중간쯤  

   “EEPROM” -> “eeprom_clear” 를 선택하고 파일이 열리면, 한번 업로드 실행을 해주면 됨.

   

4. grbl mega 라이브러리 설치

   최상위 메뉴에서 “스케치” -> “라이브러리 포함하기” -> “ZIP 라이브러리 추가...” 를 선택

   파일선택 다이얼로그가 뜨면, 1번의 과정에서 확인된 grbl 디렉토리가 보이는 곳으로 이동하여, 

   grbl 디렉토리를 선택한 다음 “선택” 버튼 클릭

   

5. grbl mega 소스 수정 (정말로 중요한 곳이다.)

   ~/Documents/Arduino/libraries/grbl 디렉토리로 이동한 다음,

   config.h 파일을 편집기로 연 다음, 다음 두 라인을 코멘트 처리하고,(맨 앞에 // 를 추가한다.)

   #define DEFAULTS_GENERIC

   #define CPU_MAP_2560_INITIAL

   

   다음 두 라인을 실제 코드 라인으로 바꿔준다. (맨 앞에 있는 // 를 제거한다.)

   // #define DEFAULTS_RAMPS_BOARD

   // #define CPU_MAP_2560_RAMPS_BOARD

   

6. grbl mega 소스 수정, 스핀들 모터의 PWM 속도 제어 가능

   기존 소스로는 PWM 속도 제어 불가능

   https://lotronblog.wordpress.com/2018/01/25/changing-spindle-pin-on-grbl-mega/ 에서

   제안한 방법으로 소스를 수정한다.

   ~/Documents/Arduino/libraries/grbl 디렉토리로 이동한 다음,

   cpu_map.h 파일을 편집기로 연 다음, 다음과 같이 수정한다.

   

  //Control Digital Pin 6 which is Servo 2 signal pin on Ramps 1.4 board

  #define SPINDLE_TCCRA_REGISTER    TCCR4A

  #define SPINDLE_TCCRB_REGISTER    TCCR4B

  //#define SPINDLE_OCR_REGISTER      OCR4C   <- 바뀐 부분

  //#define SPINDLE_COMB_BIT          COM4C1   <- 바뀐 부분, 그리고 아래 두 줄을 추가

  #define SPINDLE_OCR_REGISTER      OCR4A

  #define SPINDLE_COMB_BIT          COM4A1


  // 1/8 Prescaler, 16-bit Fast PWM mode

  //#define SPINDLE_TCCRA_INIT_MASK ((1<<WGM40) | (1<<WGM41))   <- 바뀐 부분

  //#define SPINDLE_TCCRB_INIT_MASK ((1<<WGM42) | (1<<WGM43) | (1<<CS41))    <- 바뀐 부분

  //#define SPINDLE_OCRA_REGISTER   OCR4A // 16-bit Fast PWM mode requires top reset value stored here.   <- 바뀐 부분, 그리고 아래 세 줄을 추가

  #define SPINDLE_TCCRA_INIT_MASK (1<<WGM41)

  #define SPINDLE_TCCRB_INIT_MASK ((1<<WGM42) | (1<<WGM43) | (1<<CS40)) 

  #define SPINDLE_OCRA_REGISTER   ICR4

  #define SPINDLE_OCRA_TOP_VALUE  0x0400 // PWM counter reset value. Should be the same as PWM_MAX_VALUE in hex.


  // Define spindle output pins.

  #define SPINDLE_PWM_DDR   DDRH

  #define SPINDLE_PWM_PORT  PORTH

  //#define SPINDLE_PWM_BIT   5 // MEGA2560 Digital Pin 8    <- 바뀐 부분, 그리고 아래 한 줄을 추가

  #define SPINDLE_PWM_BIT   3 // MEGA2560 Digital Pin 6 

   

  RAMPS 1.4 보드에서 스핀들모터와 스핀들모터 PWM 신호는 리셋스위치 오른쪽의 12개 핀아웃에서 나온다.

    PWM    ON/OFF

  O  ~  O  X  

  O  O  O  O

  O  O  O  O  <- All ground pin


7. grbl mega 컴파일 및 업로드

   최상위 메뉴에서 “파일” -> “예제” 에서 아래쪽 “사용자 지정 라이브러리의 예제”쪽에 있는 

   “grbl” -> “grblUpload” 를 선택하면, 파일이 열립니다.

   

   다시, 최상위 메뉴에서 “툴” -> “보드” -> “Arduino/Genuino Mega or Mega 2560” 

   “툴” -> “프로세서” -> “ATmega2560 (Mega 2560)”

   “툴” -> “포트” -> “/dev/cu.usbmodem14201”  ※포트명은 컴퓨터에 따라 달라질 수 있음!

   각각을 잘 선택하고, 업로드(오른쪽방향 화살표 동그란 아이콘 클릭)하면 됩니다.

   

   ※ 미리 컴파일이 잘 되는지만 확인해보고(체크 표시 동그란 아이콘 클릭), 업로드하는 것이 좋습니다.


P.S. 여기에 사용한 grbl은 순수하게 Mega 보드용이므로, 다른 보드를 위한 grbl을 사용하기 위해서는 미리 제거해야 한다.

     (grbl 이라는 폴더 이름이 충돌하기 때문에...)

   

   기존 설치된 라이브러리를 제거하려면,

   ~/Documents/Arduino/libraries 폴더로 이동한 다음에 해당 grbl 디렉토리를 삭제하고,

   Arduino IDE를 다시 시작하면, 해당 라이브러리가 없어진 것을 확인할 수 있다.

   (최상위 메뉴에서 “스케치” -> “라이브러리 포함하기” 에서 grbl 이름이 없는 것을 확인!)

   

------------------------------------------------------------------------------------------   

Grbl Controller 와 Universal G-Code Sender 를 다운받아서 설치한다.

Port name은 “/dev/cu.usbmodem14201”

Baud Rate는  115200 으로 설정


Open 버튼을 클릭했을때, 다음과 같은 메시지가 나와야 정상이다.


Grbl 1.1g['$'for help]

>$G

...

>$$

$0=10

...

...

...

$132=200.000


Posted by 훅크선장
, |
인터넷 검색을 통해서, 찾은 아두이노 연습 예제들

http://www.ladyada.net/learn/arduino/
http://www.adafruit.com/tutorials
http://www.freeduino.org/
http://www.arduinotutorials.com/
http://tronixstuff.wordpress.com/
http://todbot.com/blog/spookyarduino/
http://letsmakerobots.com/node/2164
http://tutorial.cytron.com.my/2011/08/11/arduino-tutorial/
http://sheepdogguides.com/arduino/FA1main.htm
http://makezine.com/arduino/
http://www.instructables.com/tag/?sort=none&q=arduino&limit%3Atype%3Aid=on
http://www.hacktronics.com/Table/Tutorials/

Posted by 훅크선장
, |
아두이노와 L293D 칩(또는 L293B 칩에 다이오드를 추가하여,)을 이용해서,

일반적인 모터의 On/Off 및 정회전/역회전을 조절할 수 있습니다.

아두이노 프로토타입 보드에 실장한 예는 다음과 같고,
http://basbrun.com/2011/04/22/arduino-motor-controller-using-an-l293d-chip/  

실제 회로도 및 아두이노 프로그램은 다음의 두 링크에서 소개되었습니다.
 http://lab.guilhermemartins.net/2009/01/29/l293d-custom-motor-driver/ 
http://luckylarry.co.uk/arduino-projects/control-a-dc-motor-with-arduino-and-l293d-chip/ 


자세한 회로도 및 예제 연습은 Arduino Cookbook의 Chapter 8에 잘 나와 있습니다.
http://shop.oreilly.com/product/9780596802486.do 


PDF 파일을 구해서, 보시면 됩니다.
 
Posted by 훅크선장
, |
http://forum.sparkfun.com/viewtopic.php?f=32&t=27960

http://www.sparkfun.com/tutorials/247 

Reinstalling your Arduino bootloader
 


**SOLUTION** Reinstall the Arduino Pro Mini Bootloader using my Arduino Uno as an ISP Programmer!

To resolve the errors I burned the bootloader to the Arduino Pro Minis using my functioning Arduino Uno as an ISP. For the most part I followed the instructions here: http://www.sparkfun.com/tutorials/247 adhering to Option 1 but using the Arduino IDE to burn the bootloader. Here is what I did step by step:
1. Connect the Arduino Uno via USB to the PC
2. Open the Arduino IDE
3. Select the correct COM port and board (Arduino Uno)
4. Open the ArduinoISP sketch (File>Examples>ArduinoISP)
5. Upload the sketch. once complete your Arduino Uno is now programmed to be an ISP programmer. This is great because I really didn't want to buy a seperate programmer.
6. Power the Uno off and wire the Uno to the Arduino Pro Mini in the following fashion:

Uno---------------Pro Mini
3.3v-----------------------VCC
GND------------------------GND
Digital Pin 11(MOSI)----pin 11 (MOSI)
Digital Pin 12(MISO)----pin 12 (MISO)
Digital Pin 13(SCK)-----pin 13 (SCK)
Digital Pin 10----------RST

7. Power on the Uno
8. Select the correct COM port
9. IMPORTANT: Select board Arduino Pro Mini 3.3v w/ATmega328 as the board we are uploading to
10.from the Tools menu, select Burn Bootloader > w/Aduino as ISP

This was a magical moment for me. All kinds of LEDS were blinking and flashing. After a few seconds the IDE said: Done burning bootloader, thank you. If this is also your result you have successfully reinstalled the bootloader on you Arduino Pro Mini. Next, connect the FTDI board to the Arduino Pro Mini and attempt to upload a sketch. I was so excited that this worked I let my wife sucker me into going to the arts and crafts store so she could buy some new sewing thread. Don't fall for this. Every sketch I have uploaded to my Arduino Pro Minis has been successful form this point on. The end.
 
Posted by 훅크선장
, |