Routing PCB dengan CNC (YOOCNC 3020ZD)

Buka File Layout

Buka file skema (.sch) dan juga board (.brd) dengan Eagle. Arahkan pada tampilan Board.
disarankan untuk mengubah latar belakang menjadi hitam dengan cara pilih menu

Option --> User Interface --> Pilih pada Layout--> Background --> Black.

Cek posisi dan kesalahan layout dengan DRC

Cek desain dengan DRC, pada menu tool –> DRC lalu isikan parameter jika diperlukan.

Penting: Untuk penggunaan VBit ukuran ujung 0.5 mm maka isikan di bagian clearance 20mil. untuk ujung 0.2 mm maka isikan di bagian clearance 10 mil. Jika sudah memunyai simpanan seting DRC, tinggal di-Load aja. Berikut contohnya: File DRC Yoo CNC

Klik tombol Check dan jika ada Error atau Warning akan muncul di bagian kanan bawah. Benahi  dahulu error! Jika yakin tidak ada masalah, maka dapat di klik tombol Clear All atau langsung ditutup.

Buat kode GCode dengan PCB GCode

Klik tombol dengan tulisan ULP (di bagian atas, di bawah menu library). Pilih file PCB-Gcode-Setup.ulp lalu buka setingan default pada menu tab GCode Style.

Penting: harus memilih software yang digunakan untuk CNC terlebih dahulu sebelum mengisi parameter. Jika memilihnya setelah mengisi parameter, maka isian parameter akan ter-reset!

Pada tab Generation Option: (pilih GCode yang akan dibuat, centang yang dipilih)
——————

  • Top Side: Layer atas
  • Outline: Guratan
  • Drill: Lubang
  • Bottom Side: Layer Bawah
  • Outline: Guratan
  • Drill: Lubang
  • Mirror: dibalik (gunakan fitur ini untuk YOOCNC, karena koordinat x+ dan x- mesin terbalik)
  • Show preview: tampilkan preview, isikan sesuai ukuran PCB
  • Generate milling: -1.27mm / sesuaikan dengan tebal PCB (pilihan ini untuk membuat GCOde milling/bentuk PCB sesuai layer 46. Tandai centang jika diperlukan)
  • Generate text: -0.127mm (pilihan untuk membuat GCOde guratan text yang ada pada layer 46. Tandai centang jika diperlukan)
  • Spot drill hole: -0.05mm (Tandai lubang pada PCB.  Gunakan jika akan dibor secara manual untuk memudahkan pengeboran. Jika dibor dengan CNC, tidak perlu ditandai, hilangkan tanda centang)
  • Isolation: centang single pass jika ingin sekali guratan saja. (Gunakan fasilitas singgle pass  ini untuk mengecek preview guratan)
  • Minimum: 0.005mm (isikan jarak guratan terdekat dengan jalur PCB)
  • Maximum: 0.5mm (Isikan dengan ukuran ujung bor/bits)
  • Stepsize: 0.127mm (isikan jarak antar guratan pertama dengan guratan selanjutnya)
  • Etching tool size: 0.20 (idealnya adalah ukuran ujung bor/bits, namun biarkan ke angka default)

Machine:
——–

  • Unit: Milimeter
  • Spin Up Time: 1 detik (Jeda waktu untuk spindle/bor berputar)
  • Feed rates:
    •     X Y: 500 mm/menit (kecepatan pindah spindle arah XY)
    •     Z: 180 mm/menit (kecepatan pindah spindle arah Z; mengebor)

Sesuaikan feed rates XY dengan kemampuan mesin. Lihat di Config -> Motor Tuning and Setup pada Mach3 dan cari bagian Velocity. Bagi nilai Velocity dengan 3 atau 4.Sesuaikan feed rates Z dengan ketajaman bor, semakin tumpul harus semakin kecil serta tidak melebihi kecepatan Motor Tuning)

  • Misc:
    • Epsilon: 0.00254 mm (jarak terdekat perpindahan spindle yang ditolelir. Sumbu X,Y maupun Z)
    • DDRF: biarkan kosong, kecuali jika CNC mampu mengganti bor otomatis
  • Z Axis:
    • Z High: 12 mm (Jarah terjauh/tertinggi bor ke PCB untuk istirahat)
    • Z Up: 2 mm (Jarak bor ke PCB saat pindah dari satu tempat ke tempat lain)
    • Z Down: -0.05 mm (kedalaman miling/guratan PCB, sesuaikan dengan ketebalan lapisan tembaga pada PCB)
    • Drill Depth: -2 mm (sesuaikan dengan tebal PCB + 0.5 mm untuk kalibrasi posisi mata bor saat  pengeboran)
    • Drill Dwell: 0.5 detik (Lamanya proses pengeboran)
  • Tool Change: (posisi spindle saat mengganti bor)
    • Position X: 0 mm
    • Position Y: 0 mm
    • Position Z: 21 mm (sesuaikan dengan panjang colet/dudukan mata bor)
  • GCOde Option, Plugins dan Other: Untuk sementara, biarkan default

Jika parameter sudah diisi semua, maka tekan tombol Accept and make my board. Jendela preview akan muncul.

Cek kondisi preview milling/guratan. Jika ada yang tidak tergurat. Ganti/geser letak jalur atau ganti jalu yang ukuranya lebih kecil. Ukuran jalur terkecil yang diperkenankan adalah 0.6mm (25 mil)

Modifikasi file GCode untuk proses autolevelling

Autoleveling adalah menentukan ketinggian/ketebalan PCB dengan bantuan probe pada mesin CNC pada port 15 menggunakan Software Autoleveling.

Buka software Autoleveler (software ini memerlukan java) lalu pilih mesin Mach3 (Sebelah tombol About). Klik tombol Browse for Gcode dan arahkan ke file hasil pengubahan ke GCode. File ditandai dengan akhiran .bot.etch.tap untuk layer bawah dan akhiran .top.etch.tap untuk layer atas.

Secara otomatis bagian Probe setting akan terisi. Jika ingin dimodifikasi:

  • Z Feed: 100 mm/menit (kecepatan probing, semakin kecil semakin presisi. Jangan melebihi Z feed Rate pada PCB-GCode)
  • Probe Depth: -0.1 mm (Jika PCB tidak berhasil di-probe, maka secara otomatis dianggab PCB berada di 0.1 mm dibawah mata bor)
  • Probe clearance: 2.5 mm (Mata bor akan berpindah antar titik probe dengan ketinggian 2 mm. Isikan sesuai rumus: Z UP pada PCB-GCode + Probe Depth pada autoleveler Misal: 3mm + (-0.5)mm = 2.5 mm )
  • Probe Spacing: 25 mm (Jarak antar probe. Karena ukuran PCB 100mm x 100mm maka diganti menjadi 20mm agar hasilnya: 100*100 / 25*25 = 16 kali probe saja)
  • Z Safe Heigh: 20 mm (Jarak probe terjauh ke atas untuk berhenti)

Setelah parameter diisikan, klik tombol  CreateLevelledGCode lalu disimpan. file siap dibuka di Mach3.

Modifikasi file GCode drill.tap agar ada waktu untuk mengganti mata bor

Buka file .bot.drill.tap dan ganti perintah: G01 Z0.0000  F254 menjadi M00 (ganti perintah pindah ke posisi Z=0 mm mjd perintah stop). Maksud penggantian kode yaitu agar saat pergantian bor (setelah perintah M06) maka mesin akan berhenti. Saat mesin berhenti, bor dapat diganti sesuai dengan ukuran yang ditunjukkan di GCode setelah tanda ; (titik koma) dalam satuan milimeter.

Nilai F254 mungkin berbeda, karena bergantung dari nilai Feed Rate yang diisikan di PCB Gcode

Pengoperasian Mesin:

Pasang PCB sesuai gambar berikut:


Pastikan PCB tidak menggelembung. Alasi PCB dengan papan yang rata, atau PCB yang sudah tidak terpakai.
Buka Mach3 lalu klik pada tombol SoftLimit hingga border hijau hilang. Ingat Mach3 harus dibuka dahulu sebelung mengaktifkan mesin CNC, agar CNC tidak bergerak sendiri / mengunci jika terjadi error pada port
komputer.

Aktifkan mesin CNC lalu tekan tombol Reset (biasanya berkedip jika belum ditekan) hingga border berwarna hijau.

Arahkan dahulu spindle/bor ke arah atas dengan tombol Page Up agar spindel tidak menabrak PCB. Geser CNC menggunakan tombol tanda panah kiri (<–) atau kanan (–>) untuk mengggerakkan
spindle, serta atur letak PCB agar tidak miring. Awas: YOOCNC memiliki arah X+  dan x- terbalik, maka
hati hati dalam menggerakkan spindle.

Taruh mata bor/bit tepat diatas koordinat titik nol yang dikehendaki sekitar 2 s.d 3 mm, jangan
terlalu dekat dengan PCB. Ada kalanya PCB tidak rata. Lalu gerakkan bor ke semua arah PCB. Jika terlalu mepet dengan PCB, gerakkan ke atas dengan tombol Page Up pada keyboard. Jika terlalu jauh dari PCB, gerakkan ke  arah bawah dengan tombol Page Down. Awas: Hati-hati saat menggerakkan  spindle ke bawah, jika bits/mata bor terkena PCB maka bisa patah, atau PCB berlubang!

Jika sudah siap, mata bor ditaruh di atas PCB dengan tepat pada titik nol yang diinginkan, maka tekan tombol REF ALL HOME pada Mach3. Putar spindle lalu lubangi sedikit untuk titik 0 dengan cara menekan tombol page down pada keyboard. Lubang nantinya dijadikan tanda untuk titik nol pada saat pengboran.

Cek setingan port pada menu tool, pastikan pada port 15 dan active low dicentang. Lihat kondisi probe pada Tab diagnostic. Pastikan saat probe dihubungkan kedua kutubnya, maka bagian Digitize akan berwarna Hijau.

Pasang kutub probe pada spindle, tapi jangan diaktifkan dahulu spindelnya. Pasang kutub yang lain pada PCB. Penting: Pastikan penjepit probe menjepit kuat agar tidak lepas. Kalau sampai lepas, maka bit akan patah, PCB berlubang dan bahkan dasar mesin CNC juga berlubang!

Load file GCode hasil Autoleveler. Lanjutkan dengan pindah spindle menyusuri PCB sesuai pada gambar toolPath, dan pastikan semua area toolpath terkover di PCB (Ukuran PCB tidak kurang) serta tidak menabrak penjepit PCB.

Kembalikan ke titik 0 dengan menekan tombol GOTO Z (Goto Zero). Klik Run dan biarkan CNC
bekerja sambil diamati! Wajib: Sambil diamati! Bila probe atau bits/mata bor menabarak
sesuatu, langsung ditekan tombol EMERGENCY STOP agar CNC tidak rusak lalu ulangi lagi langkah
dari awal.

Saat selesai probing, maka CNC akan berhenti. Ambil probe, jaga jangan sampai terhubung antar
probe dan aktifkan spindle dengan kecepatan maksimum. Saat sudah sampai ke kecepatan maksimum,
tekan Run di Mach3 lagi. (Sekali lagi, wajib: Sambil diamati! Bila probe atau bits/mata bor menabarak sesuatu, langsung tekan tombol EMERGENCY STOP agar CNC tidak rusak lalu ulangi lagi langkah dari awal)

Setelah selesai, biasakan untuk mengembalikan posisi spindle ke home, atau titik nol. Gunakan
fasilitas tombol Goto Z pada Mach3.

Proses pengeboran

Pindah spindle ke atas dengan tombol keyboard Page Up secukupnya, lalu ganti bor dengan ukuran terkecil. Setelah diganti, turunkan mata bor sedikit demi sedikit hingga kurang lebih 1mm jangan terlalu dekat dengan PCB. Lalu tekan REF ALL Home. Lalu gerakkan bor ke semua arah PCB.

Jika terlalu mepet dengan PCB, gerakkan ke atas dengan tombol Page UP. Catat perubahan Z lalu
kembali he home dengan tombol Goto Z lalu naikkan dengan tombol Page Up hingga nilai Z sesuai
pada catatan dan klik REF ALL Home.

Awas: Hati-hati saat menggerakkan spindle ke bawah, jika bits/mata bor terkena PCB maka bisa patah, atau PCB berlubang!

Usahakan jarak terjauh antar PCB dengan mata bor di seluruh permukaan PCM maksimal adalah 0.5 mm
(Sesuai dengan perhitungan Drill Depth pada PCB-GCode). Ulangi langkah pemindahan mata bor ke
seluruh PCB hingga tidah ada PCB yang terlalu mepet pada mata bor.

Jika semua OK maka kembali ke home dengan tekan GOTO Z.

jika home tidak pas pada lubang titik 0 yang tadi ditandai saat miling, maka paskan dengan
menekan tombol panah, namun jangan mengubah ketinggian mata bor. Jika sudah pas, maka tekan
REF ALL Home. Catatan: Jika ternyata spindle berubah ketinggian, atau terpencel tombol page up atau
page down, maka kembalikan ke titik 0 dengan Goto Z.

Tutupi PCB dengan kertas transparan (mika) agar debu pengeboran tidak tercecer! Buka file GCode drill.bot.tap dan kemudian Run (Klik cycle Start) dan biarkan CNC bekerja. (Wajib: Saat CNC bekerja, haris diamati! Bila bits/mata bor menabarak sesuatu, langsung tekan tombol EMERGENCY STOP agar CNC tidak rusak lalu ulangi lagi langkah dari awal)

Proses Penggantian mata bor

Saat GCode sampai pada kode M00, maka proses pengeboran berhenti. Matikan dahulu spindle lalu ganti mata bor sesuai ukuran yang ditunjukkan pada GCode. Jangan sampai posisi berubah dan CNC jangan dimatikan, cukup matikan putaran spindle saja.

AWAS: Mata bor mudah patah, jatuh dari atas meja saja sudah patah!

Memprogram AT89S52 dengan Arduino

Programmer AT89S51 biasanya membutuhkan koneksi serial, namun laptop tidak memiliki port serial. Karena Arduino menggunakan port serial, maka bisa dimanfaatkan menjadi programmer AT89S52.

 

Siapkan arduino dengan kode berikut:

lalu upload ke arduino.

 

Siapkan rangkaian sesuai skema berikut:

 

Lalu gunakan applikasi file uploader untuk upload file

What do you have to know about MAX232

Max232 is designed by Maxim Integrated Products. This IC is widely used in RS232 Communication systems in which the conversion of voltage level is required to make TTL devices to be compatible with PC serial port and vice versa. This chip contains charge pumps which pumps the voltage to the Desired Level. It can be powered by a single +5 volt power supply and its output can reach +_7.5 volts.MAX232 comes in 16 Pin Dip and many other packages and it contains Dual Drivers. It can be used as a hardware layer convertor for 2 systems to communicate simultaneously.Max232 is one of the versatile IC to use in most of the signal voltage level conversion problems.

Construction of MAX232:

Mostly MAX232 used in 16-pin DIP package. it consist of 3 major blocks .It can only be powered by 5 volts to make it power supply compatible with most of the embedded systems. First block is the voltage doubler in this ic switched capacitor techniques is used to make the voltage double .Once the voltage is doubled second block will converts that voltage to +10 and -10. The third block consists of 2 transmitters and 2 receivers which actually convert the voltage levels.

External components:

Max232 requires minimum 4 external capacitor. Their Value can range from 1uf to 10uf and16 volts or more rating. There are many different versions of this versatile ic available each of them Require different capacitor value for proper working.

Application and uses of MAX232:

Premierly MAX232 is used in Serial communication. Problem arises when we have to communicate between TTL logic and CMOS logic based systems. RS232 is internationally defined standard named as EIA/TIA-232-E and in this standard logic 0 is the voltage between +3 to +15 and logic 1 is defined as the voltage between -3 to -15.In TTL logic 0 is defined is by 0 volt and 1 is defined by 5 volt so in this scenario this is a very handy IC to be incorporated.

Other Applications & Uses

  • Battery Powered RS 232 Systems
  • Interface Translation
  • Low Power Modems
  • RS 232 Networks (Multidrop)
  • Portable Computing

PC Serial PORT communication by using MAX232 IC:

Desktop and some old Laptops have Serial port which comes in DB9 package. In Most of the Circuits designer is concerned about the Tx and Rx pins only so the function of the rest of the pins are not used here mostly.

In the above circuit only one Driver is used and second driver can be used for other purpose. TTL data is available on pin 12 and pin 11 and these pins can be attached to Microcontroller or any system which accept TTL logic.

 

GSM Modem Communication:

 

There are many GSM modems available in the market and most of them are on TTL logic but some of them use RS232 standards and again it becomes a problem to communicate wilt GSM modem by using Micro controller, aurdino or any other TTL platform.MAX232 is used to solve this problem.

Types of MAX232:

1)“MAX232N” where “N” Represent PDIP package Style this package is easy to sold and most widely used.

2) MAX232D where “D” indicates the SOIC package which is difficult to sold and required a trained professional to be used correctly.

Common mistakes:

  • Capacitor voltage rating is less than 16.
  • Interchange Tx and Rx pins on one side of MAX232 at one time.
  • Distorted power supply. Use decoupling capacitor to remove distortion.
  • Check all the connections again.
  • Check the capacitor with capacitance meter.
  • Use Tantalum Capacitor for better performance.

Kalibrasi MPU6050

MPU6050 adalah sensor sudut dan percepatan atau biasa disebut gyrometer. Sama seperti kebanyakan sensor lain, MPU6050 perlu dikalibrasi sebelum digunakan. Kinerja gyrometer ini sangat terpengaruh terhadap suhu, jadi pastikan suhu stabil terlebih dahulu sebelum melakukan proses kalibrasi. Beri jarak waktu antara 3 sampai dengan 5 menit setelah power on agar suhu stabil. Hasil proses kalibrasi pun akan berbeda saat dilakukan di suhu ruangan dibandingkan dengan kalibrasi di luar ruangan. Pastikan dikalibrasi pada suhu ruangan yang sama, atau setidaknya hampir sama, dengan dengan suhu dimana alat akan digunakan.

Berikut kode kalibrasi dari Luis Ródenas denga sedikit modifikasi:

Pastikan sudah melakuan instalasi librari I2Cdev dan MPU6050 dan hubungkan MPU6050 dengan skema berikut

 

Taru MPU6050 pada bidang datar, semisal meja dan jangan digerakkan sampai proses kalibrasi selesai.  Selanjutnya, untuk proses kalibrasi, buka dengan serial monitor dengan baud rate 115200 dan kirimkan satu huruf (bebas) lalu tekan send atau klik tombol enter. Tunggi hingga daftar offset muncul dengan ditandai tulisan ‘Your offsets:’

How to make USBasp work with Arduino in Linux

Make sure USBasb plugged into USB Port and check whenever its conected or not by typing lsusb in terminal.

stufi1983@latif-laptop:~$ lsusb
Bus 001 Device 003: ID 0db0:6877 Micro Star International RT2573
Bus 001 Device 004: ID 058f:6387 Alcor Micro Corp. Flash Drive
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 16c0:05dc Van Ooijen Technische Informatica shared ID for use with libusb
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

USBasp should detected with VendorID 16c0 and ProductID 05dc. Look at bus address. It says Bus 002 Device 003. See permission on Bus 002 Device 001 by typing ls -l /dev/bus/usb/002/003 in terminal.

stufi1983@latif-laptop:~$ ls -l /dev/bus/usb/002/003
crw-rw-r-- 1 root root 189, 130 Sep  6 10:05 /dev/bus/usb/002/003

Current permission is crw-rw-r– mean user dont have permission to write at the bus. So, change permission to 777 with chmod command.

stufi1983@latif-laptop:~$ sudo chmod 777 /dev/bus/usb/002/003
[sudo] password for stufi1983:

OK, Done. USBasp now already to use with Arduino. Select in Arduino  menu Tool>Progammer>USBasp. Make new file New>Examples>Basic>Blink. Then upload by using menu: File>Upload using Programer

Be wise in using Microcontroller’s memory

Memory is a finite resource on these tiny processors and some applications are just plain too big for an microcontroler(uC). But most code has some room for optimization. So if program is just a little overweight, with a little diet and exercise, probably shed enough bytes to make it fit into uC. As we know, there are 3 types of memory in uC:

  • Flash or Program Memory
  • SRAM
  • EEPROM

Flash Memory

Flash memory is used to store your program image and any initialized data. You can execute program code from flash, but you can’t modify data in flash memory from your executing code. To modify the data, it must first be copied into SRAM

Flash memory is the same technology used for thumb-drives and SD cards. It is non-volatile, so your program will still be there when the system is powered off.

Flash memory has a finite lifetime of about 100,000 write cycles. So if you upload 10 programs a day, every day for the next 27 years, you might wear it out.

SRAM

SRAM or Static Random Access Memory, can be read and written from your executing program. SRAM memory is used for several purposes by a running program:

  • Static Data – This is a block of reserved space in SRAM for all the global and static variables from your program. For variables with initial values, the runtime system copies the initial value from Flash when the program starts.
  • Heap – The heap is for dynamically allocated data items. The heap grows from the top of the static data area up as data items are allocated.
  • Stack – The stack is for local variables and for maintaining a record of interrupts and function calls. The stack grows from the top of memory down towards the heap. Every interrupt, function call and/or local variable allocation causes the stack to grow. Returning from an interrupt or function call will reclaim all stack space used by that interrupt or function.

EEPROM

EEPROM is another form of non-volatile memory that can be read or written from your executing program. It can only be read byte-by-byte, so it can be a little awkward to use. It is also slower than SRAM and has a finite lifetime of about 100,000 write cycles (you can read it as many times as you want).

Several Memory Problems

Most memory problems occur when the stack and the heap collide. When this happens, one or both of these memory areas will be corrupted with unpredictable results. In some cases it will cause an immediate crash. In others, the effects of the corruption may not be noticed until much later. One way to diagnose memory problems is to measure how much memory is in use.

Optimize Flash memory

Flash memory usage is depend on code and compiler. If it have reached or exceeded the space available, some of these optimizations may help get you back under the limit.

Remove Dead Code

If project is a mash-up of code from several sources, chances are there are parts that are not getting used and can be eliminated to save space.

  • Unused Libraries – Are all the #include libraries actually used?
  • Unused Functions – Are all the functions acutally being called?
  • Unused Variables – Are all the variables actually being used?
  • Unreachable Code – Are there conditional expressions which will never be true?
 Hint: If  not sure about an #include, a function or a variable. Comment it out. If the program still compiles, that code is not being used. Just remove it!

Consolidate Repeated Code

If any sequence of code statements in two or more places, consider making a function out of them.

Eliminate the Bootloader

If space is really-really tight, you might consider eliminating the bootloader. This can save as much as 2K or 4K of Flash – depending on which bootloader you are currently using.

The downside of this is that you will need to load your code using an ISP programmer instead of via a standard USB cable.

 

Optimize SRAM

SRAM is the most precious memory commodity. SRAM shortages are probably the most common memory problems. They are also the hardest to diagnose. If program is failing in an otherwise inexplicable fashion, a crashed may happen in the stack due to a SRAM shortage. There are a number of things that can do to reduce SRAM usage.

Remove Unused Variables

If not sure whether a variable is being used or not, comment it out. If the sketch still compiles, get rid of it!

Use F() Macro

Literal strings are repeat memory offenders. First they take up space in the program image in Flash, then they are copied to SRAM at startup as static variables. This is a horrible waste of SRAM since we will never be writing to them.

Paul Stoffregen of PJRC and Teensyduino fame developed the F() macro as a super-simple solution to this problem. The F() macro tells the compiler to keep your strings in PROGMEM. All you have to do is to enclose the literal string in the F() macro.

For example, replacing this:

  Serial.println("This string will be stored in memory. Horible waste of SRAM!");

with this:

  Serial.println(F(" This string will be stored in memory. Horible waste of SRAM!"));

Will save bytes of wonderful SRAM!

Reserve() your strings

The string library allows to reserve buffer space for a string with the reserve() function. The idea is prevent String from fragmenting the heap by using reserve(num) to pre-allocate memory for a String that grows.

With the memory already allocated, String doesn’t need to call realloc() if the string grows in length. In most usages, lots of other little String objects are used temporarily as you perform these operations, forcing the new string allocation to a new area of the heap and leaving a big hole where the previous one was (memory fragmentation). Usually all you need to do is use reserve() on any long-lived String objects that you know will be increasing in length as you process text.

Move constant data to PROGMEM.

Data items declared as PROGMEM do not get copied to SRAM at startup. They are a little less convenient to work with, but they can save significant amounts of SRAM. The basic Arduino reference for PROGMEM is here. And there is a more detailed tutorial on the subject here.

#define FS(x) (__FlashStringHelper*)(x)
const char MyText[]  PROGMEM  = { “My flash based text” };

void setup() {
Serial.begin(57600):
Serial.println(FS(MyText));
}

Reduce Buffer Sizes

Buffer and Array Allocations: If you allocate a buffer, make sure it is no bigger than it needs to be.

Buffers in Libraries: Also be aware that some libraries allocate buffers behind the scenes that may be candidates for trimming as well.

System Buffers: Another buffer hidden deeply in the system is the 64 byte serial receive buffer. If your sketch is not receiving a lot of high-speed serial data, you can probably cut this buffer size in half – or maybe even less.

For an Example, if using Arduino library, Serial buffer can be reduced. The Serial buffer size is defined in HardwareSerial.cpp. This file can be found in your Arduino install directory: \Arduino-1.x.x\hardware\arduino\cores\arduino\HardwareSerial.cpp. Look for the line: #define SERIAL_BUFFER_SIZE 64 And change it to 32 or less.

Reduce Oversized Variables: Don’t use a float when an int will do. Don’t use an int when a byte will do. Try to use the smallest data type capable of holding the information. Use char instead of int if only need 255 bits data.

 

Think Globally. Allocate Locally.

Let’s have another look at how SRAM is used (and abused):

Global & Static Variables

Global and Static variables are the first things loaded into SRAM. They push the start of the heap upward toward the stack and they will occupy this space for all eternity.

Dynamic Allocations

Dynamicaly allocated objects and data cause the heap to grow toward the stack. Unlike Global and Static variables, these variables can be de-allocated to free up space. But this does not necessarily cause the heap to shrink! If there is other dynamic data above it in the heap, the top of the heap will not move. When the heap is full of holes like swiss cheese we call it a “fragmented heap”.

Local Variables

Every function call creates a stack frame that makes the stack grow toward the heap. Each stack frame will contain:

  • All parameters passed to the function
  • All local variables declared in the function.

This data is usable within the function, but the space is 100% reclaimed when the function exits!

The Takeaway

Avoid dynamic heap allocations – These can quickly fragment the limited heap-space.

Prefer local to global allocation – Stack variables only exist while they are being used. If you have variables that only are used in a small section of your code, consider making that code into a function and declaring the variables local to the function.

 

Optimize EEPROM

EEPROM is a handy, non-volatile storage space that works well for storing data such as calibration or tuning constants that are not practical to hard-code into Flash.

It is unusual to run out of EEPROM. And it is not often practical to use EEPROM to offload SRAM data. But we’ll mention it here for completeness. Using EEPROM requires that you include the EEPROM library.

#include <EEPROM.h>

The EEPROM library gives us 2 functions:

uint8_t read(int) //Read a byte from the specified EEPROM address

void write(int, uint8_t) //Write a byte to the specified EEPROM address

  • Note that while reads are unlimited, there are a finite number of write cycles limited (typically about 100,000).
  • Always check that EEPROM is ready before reading/writing to it (eeprom_is_ready function)
  • Always prefer the update functions rather than the write ones, as update checks first if the stored data is different than the data, so it erases / writes the new data only if it has changed. Check first if the value has changed before writing, or even use the EEPROMex alternative EEPROM Arduino library.
  • Read / write operations on EEPROM should never be interrupted : you should always disable/clear interrupts (cli()) before any operation and re-enable/set interrupts after (sei()).

Here is the example:

while (!eeprom_is_ready());

cli();

if(eeprom_read_word((uint16_t*)addr) != sensorValue) {

eeprom_write_word((uint16_t*)addr, sensorValue);

}

sei();

Arduino: ATMega8535 & Arduino IDE

Arduino Uno, merupakan salah satu varian yang saat ini banyak digunakan untuk praktisi dan hobbi elektronika. Arduino adalah pengendali mikro dengan prosesor Atmel AVR dan softwarenya memiliki bahasa pemrograman sendiri. Memiliki library yang cukup komplit serta didukung forum yang ramai, sehingga memudahkan untuk membangun proyek sistem kendali. Library arduino memiliki hampir semua interface dan sesor.

Arduino Uno use widely by electronic practical and hobbyist. Arduino consist of microcontroller which have its own Integrated Development Environtment based on Processing. It has plenty of library supported by many discussion forum, so it will be make easier to build control system projects.

Mikrokontroler arduino bermacam macam, untuk lebih jelasnya dapat dilihat di wikipedia. Kebanyakan menggunakan mikrokontroler Atmel AVR, namun untuk Arduino Yun, Arduino Due dan Arduino Zero menggunakan arsitektur ARM.

Arduino has vary variant depending on its microcontroler, it can be seen through wikipedia. Most of it use AVR, and Atmel Microcontroler. There is also 3 variants using ARM mikrocontroller such as Arduino Yun, Arduino Due and Arduino Zero.

Arduino UNO memiliki pin I/O yang cukup memadai, sekitar 14. Jilka memerlukan pin yang lbih banyak, dapat menggunakan Arduino dengan mikrokontroler jenis ATMega2560 atau jenis ARM yang memiliki I/O 54 pin. Namun sayang sekali memerlukan biaya yang cukup mengusras kantong 😀

Arduino UNO has 14 pin can be used as I/O. If more pin needed, Arduino which employ ATMega2560 or ARM architechture are more elegible to use. Those variant have 54 I/O pin, of cource more expensive than Arduino UNO.

Pada komponen rack yang saya miliki hanya tersedia IC AVR jenis ATMega8, 328, 8535 dan ATTiny2313. Padahal project kali ini membutuhkan I/O sejumlah 20 pin. Mau tidak mau harus mengoprek ATMega8535 yang memiliki 40 pin (32 pin I/O) agar dapat diprogram menggunakan library Arduino. Oke, sekedar sharing ilmu, berikut langkah dan hasilnya :

In my component rack, there are only ATMega8, ATMega328, ATMega8535 and ATTiny2313. I’d tried to use ATMega8535 because I need 20 I/O pin. ATMega8535 has 32 I/O pin. To make ATMega8535 can be used with Arduino library, it can be done by add several line on arduino/hardware/arduino/board.txt as follow:

Tambahkan pada file arduino/hardware/arduino/board.txt dengan baris berikut:

##############################################################

arduino_atmega8535.name=Stumpino-Atmega8535-8Mhz arduino_atmega8535.upload.protocol=stk500v2 arduino_atmega8535.upload.maximum_size=7168 arduino_atmega8535.upload.speed=38400 arduino_atmega8535.bootloader.low_fuses=0xE4 arduino_atmega8535.bootloader.high_fuses=0x98 arduino_atmega8535.bootloader.extended_fuses=0xFD arduino_atmega8535.bootloader.path=atmega arduino_atmega8535.bootloader.file=stk500boot_v2_notdefined.hex #arduino_atmega8535.bootloader.unlock_bits=0x3F #arduino_atmega8535.bootloader.lock_bits=0x0F arduino_atmega8535.build.mcu=atmega8535 arduino_atmega8535.build.f_cpu=8000000L arduino_atmega8535.build.core=arduino arduino_atmega8535.build.variant=stumpinomega40 ##############################################################

arduino_atmega8535-16.name=Stumpino-Atmega8535-External 16Mhz arduino_atmega8535-16.upload.protocol=stk500v2 arduino_atmega8535-16.upload.maximum_size=7168 arduino_atmega8535-16.upload.speed=38400 arduino_atmega8535-16.bootloader.low_fuses=0xEF arduino_atmega8535-16.bootloader.high_fuses=0x98 arduino_atmega8535-16.bootloader.extended_fuses=0xFD arduino_atmega8535-16.bootloader.path=atmega arduino_atmega8535-16.bootloader.file=stk500boot_v2_notdefined.hex #arduino_atmega8535-16.bootloader.unlock_bits=0x3F #arduino_atmega8535-16.bootloader.lock_bits=0x0F arduino_atmega8535-16.build.mcu=atmega8535 arduino_atmega8535-16.build.f_cpu=16000000L arduino_atmega8535-16.build.core=arduino arduino_atmega8535-16.build.variant=stumpinomega40

Kemudian dengan bantuan header yang telah dibut oleh Eric Conner lalu taruh di folder arduino/hardware/arduino/variants/stumpinomega40

Using header that Eric Conner have made, place it in arduino/hardware/arduino/variants/stumpinomega40 folder

Ok, siap pakai. Buka Arduino lalu pilih menu Tool>Board>Stumpino ATMega8535-Eksternal16Mhz dan buka File>Example>01 Basic>Blink. Saya menggunakan downloader USBAsp, jadi saya pilih di bagian menu Tool>Programmer>USBAsp

OK, its ready to use. Open Arduino IDE than choose  Tool>Board>Stumpino ATMega8535-Eksternal16Mhz than open File>Example>01 Basic>Blink. I use USBAsp dwonloader, so I click on Tool>Programmer>USBAsp

Saatnya merangkai ATMega8535 dan ISP-pin di project board dan mencoba. Perlu diketahui, D13 pada ATMega8535 adalah di pin IC kaki 19, jadi tempatkan led di IC pin 19. Silahkan mencoba….

Its time to connect  ATMega8535 and ISP-pin in project board. Arduino D13 pin in ATMega8535 is pin 19. Happy trying…

Mikrokontroler Nuvoton NUC140 (ARM)

Mikrokontroler Nuvoton NUC140 (ARM) ARM adalah prosesor dengan arsitektur set instruksi 32­bit RISC (Reduced Instruction Set Computer) yang dikembangkan oleh ARM Holdings. ARM merupakan singkatan dari Advanced RISC Machine (sebelumnya lebih dikenal dengan kepanjangan Acorn RISC Machine). Dalam proses perkembangannya, akhirnya kekayaan intelektual tentang ARM dibeli oleh ARM Ltd namun ARM Ltd kemudian memutuskan untuk tidak memproduksi ARM prosesor, tetapi melisensikan desain prosesor tersebut untuk digabungkan dengan ASIC (Application Specific IC) yang membutuhkan kontroler embedded (contoh: kontroler printer, kontroler mesin cuci, kontroler video dekoder, kontroler ethernet hub/router, dan sebagainya). ARM klasik (Classic ARM Processors) adalah keluarga ARM prosesor yang pertama kali dirilis oleh ARM Ltd (sekarang ARM Holdings). Prosesor ARM klasik ideal untuk pengguna yang ingin menggunakan teknologi telah teruji di pasar. Prosesor­prosesor ini telah digunakan untuk berbagai macam produk elektronik selama bertahun­-tahun. Desainer produk elektronik yang memilih prosesor­prosesor ini dijamin mempunyai dukungan ekosistem dan sumber daya yang luas, tingkat kesulitan integrasi yang minimum, dan menurunkan waktu desain.ARM Cortex Embedded (ARM Cortex Embedded Processors)Prosesor­prosesor di keluarga seri Cortex­M telah dikembangkan khusus untuk domain mikrokontroler, dimana permintaan untuk kecepatan, determinasi waktu proses, dan manajemen interrupt bersama dengan jumlah gate silikon minimum (luas silikon yang minimum menentukan harga akhir prosesor) dan konsumsi daya yang minimum sangat diminati. Contoh aplikasi prosesor Cortex­M adalah mikrokontroller dan sensor cerdas.Prosesor­-prosesor di keluarga seri Cortex­R, sebaliknya, dikembangkan khusus untuk keperluan real­time yang mendalam, dimana kebutuhan konsumsi daya minimum dan sifat interrupt yang terprediksi diimbangi dengan performa yang luar biasa dan kompatibilitas yang kuat dengan platform yang telah ada. Contoh aplikasi prosesor Cortex­R adalah ABS (Automotive Braking Systems), kontroler elektronik roda gigi, hidrolik, dan mesin otomotif.ARM Cortex Prosesor (ARM Cortex Application Processors)Prosesor­prosesor di keluarga prosesor aplikasi dikembangkan untuk aplikasi yang membutuhkan daya komputasi yang tinggi (frekuensi prosesing rata­rata 2GHz), seperti netbook, mobile internet devices, smartphone, dan lain-­lain. Mikrokontroler Nuvoton NUC140NUC140 series adalah ARM Cortex mikrokontroler dengan M0. Cortex M0 adalah prosesor ARM terbaru dengan kinerja 32 bit dengan biaya setara dengan mikrokontroler 8 bit. ARM Cortex­M0 mempunyai peripheral­peripheral yang terintegrasi dengan prosesor. Peripheral­peripheral tersebut merupakan bagian dari desain ARM Cortex­M0. Karena itu, peripheral­peripheral tersebut terdapat di semua mikroprosesor yang berbasis ARM Cortex­M0, walaupun dibuat oleh manufaktur yang berbeda. Selain itu, peripheral­peripheral yang terdapat di ARM Cortex­M0, juga terdapat di prosesor ARM Cortex­M yang lain (ARM Cortex­M1, ARM Cortex­M3, ARM Cortex­M4), sehingga semua prosesor di keluarga ARM Cortex­M kompatibel satu sama lainnya.Kompatibilitas Set Instruksi Nuvoton NUC140 ARM Cortex­M0Set instruksi yang digunakan oleh ARM Cortex­M0 dinamakan set instruksi Thumb. Set instruksi ARM Cortex­M0 adalah subset dari set instruksi ARM Cortex­M yang lain, sehingga program yang dikompile untuk ARM Cortex­M0 kompatibel dengan prosesor ARM Cortex­M yang lain.Selain itu, ARM Cortex­M0 juga kompatibel dengan set instruksi prosesor ARM dari seri klasik dan Cortex­A (ARM Cortex Application Processor).NuMicro seri NUC1xx memiliki inti ARM Cortex M0 yang tertanam dengan kecepatan hingga 50 MHz, dilengkapi dengan memori flash untuk program 32KB/64KB/128KB, SRAM sebesar 4KB/8KB/16KB dan memori flash loader untuk ISP (In System Programming) sebesar 4KB. Selain itu juga dilengkapi dengan berbagai macam periperal, seperti GPIO, Timer, Watchdog Timer, RTC, PDMA, UART, SPI/MICROWIRE, I2C, I2S, PWM, LIN, CAN, PS2, USB 2.0 FS Device, ADC 12 bit, komparator analog, Low Voltage Reset, dan Brown Out Detector. Sumber Wacana:http://www.kelas-mikrokontrol.com/e-learning/mikrokontroler/mengenal-arm-cortexm0.htmlhttp://gygasjunipratama.com/category/nuvoton/Daftar Catatan: Mikrokontroler Nuvoton NUC140 Arduino: ATMega8535 dengan Arduino IDE Be wise in using Microcontroller’s memory Driver USBasp 64bit How to make USBAsp work with Arduino in Linux Intel Edison a Computer smaller than Raspberry Pi Kalibrasi MPU6050 Koneksi PHP – Serial MAX232 Memprogram AT89S52 dengan Arduino Routing PCB dengan CNC (YOOCNC 3020ZD) Skema star delta untuk motor 3 fasa dengan timer Timer Interrupt on ATMega8535 using Arduino IDE Ways to detecting heart rate

Sumber: Mikrokontroler Nuvoton NUC140 (ARM) – | Latiful Hayat

Lensa Kontak Pintar Samsung dan Sony

Latiful Hayat - Lensa Kontak CanggihPara insinyur Samsung sedang membangun sesuatu yang futuristik: lensa kontak pintar dilengkapi dengan tampilan serta sebuah kamera.

Meski masih dalam tahap awal pengembangan, eye-wear dimaksudkan untuk pemanfaatan augmented reality (AR) berpengalaman, dibandingkan dengan Google Glass dan teknologi lain yang dipakai. Alat yang telah dipatenkan di Korea Selatan ini memiliki layar khusus yang mengirimkan gambar langsung ke mata si pemakai.

Menurut keterangan yang diberikan oleh pengembang, lensa kontak dikendalikan oleh kedipan mata. Pengolahan data diproyeksikan ke layar pada perangkat eksternal, seperti smartphone.

Sementara itu, Sony tidak mau ketinggalan. Pera pengembang membuat lensa kontak yang memiliki memori yang dibenamkan pasa lensa kontak, sehingga penyimpanan data dapat langsung disimpan dalam lensa kontak tanpa membutuhkan piranti eksternal.

Lensa kontak besutan Sony dilengkapi dengan sensor piezoelektrik mini yang mampu mengenali perubahan tekanan, temperatur, akselerasi dan daya. Sensor pada kemudian mengkonversi perubahan ini menjadi muatan listrik, yang kemudian akan digunakan untuk mengaktifkan rekaman melelui gerakan mata pemakainya.

Sumber:

Perlindungan kesalahan pemasangan baterai dengan FET

Latiful hayat - Perlindungan dengan FET Perangkat elektronik banyak digunakan pada saat ini, bahakan setiap satu orang bisa memiliki tiga sampai lima perangkat elektronik. Perangkat elektronik portabel memerlukan catudaya berupa baterai untuk dapat tetap bekerja. Namun bagaimana jika pengguna alat elektronik salah memasang baterai secara terbalik? Hal tersebut dapat merusak IC atau perangkat sensitif lainnya. Dalam beberapa perangkat telah dipasangkan perlindungan kesalahan pemasangan baterai.
Cara termudah untuk proteksi baterai adalah dengan memasangkan dioda secara seri dengan baterai. Dioda mampu menapis arus dari arah berlawanan (reverse current), namun memiliki kekurangan pada turunnya tengangan pada arus maju (forward bias) kurang lebih 0,6 Volt.
FET (Field Effect Transistor) kini memiliki hambatan aktif (on-resistance) yang sangat kecil, sehingga dapat diaplikasikan sebagai proteksi perlindungan pemasangan baterai.
Sumber: http://www.ti.com/lit/an/slva139/slva139.pdf