Memprogram 24LC64 dengan Port Serial

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace _24LC64
{
    /// 
<summary>
    /// Pin 3 (TX)  --          -- CS
    /// pin 4 (DTR) -- SCL      -- SCK
    /// Pin 6 (DSR) -- SDA IN   -- 
    /// Pin 7 (RTS) -- SDA OUT  -- MOSI (DO)
    /// Pin 8 (CTS) --          -- MISO (DI)
    /// </summary>


    public partial class Form1 : Form
    {
        public const bool H = true, L = false;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            serialPort1.BaudRate = 9600;
            serialPort1.PortName = textBox1.Text;
            serialPort1.Open();

            //serialPort1.DtrEnable = true;
            //serialPort1.RtsEnable = true;

            //perintah Write
            StartBit();
            kirim(0xA0);
            bit(1); //ACK
            
            //Alamat memory (0x001)
            //0x00 
            kirim(0x00);
            bit(1); //ACK
            //0x01
            kirim(0x01);
            bit(1); //ACK

            //Data (0x33)
            //kirim(0x33);
            byte[] data = StringToByteArray(textBox2.Text);
            kirim(data[0]);
            bit(1); //ACK
            
            StopBit();


            serialPort1.Close();

        }
        void kirim(int byteData) {
            for (int i = 7; i >= 0; i--) 
            {
                int bitData = (byteData >> i & 0x01);
                bit(bitData);
            }
        }
        void StartBit()
        {
            SDA(H); SCL(H);
            Thread.Sleep(1);
            SDA(L); SCL(H);
            Thread.Sleep(1);
        }
        void StopBit()
        {
            SDA(L); SCL(H);
            Thread.Sleep(1);
            SDA(H); SCL(H);
            Thread.Sleep(1);
        }
        void bit(int val) 
        {
            SCL(L);
            if (val == 0) SDA(L);
            else SDA(H);
            SCL(H);
            Thread.Sleep(1);
            SCL(L);
            SDA(H);
            Thread.Sleep(1);
        }

        void SCL(bool status)
        {
            serialPort1.DtrEnable = status;
        }
        void SDA(bool status)
        {
            serialPort1.RtsEnable = status;
        }

        int bacaBit() {
            int bitData = 0;
            SCL(L);
            SCL(H);
            bool bit = serialPort1.DsrHolding;
            if (bit == true) bitData = 1;
            Thread.Sleep(1);
            SCL(L);
            SDA(H);
            Thread.Sleep(1);
            return bitData;
        }

        public static byte[] StringToByteArray(string hex)
        {
            return Enumerable.Range(0, hex.Length)
                             .Where(x => x % 2 == 0)
                             .Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
                             .ToArray();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            serialPort1.BaudRate = 9600;
            serialPort1.PortName = textBox1.Text;
            serialPort1.Open();


            //perintah Write
            StartBit();
            kirim(0xA0);
            bit(1); //ACK

            //Alamat memory (0x001)
            //0x00 
            kirim(0x00);
            bit(1); //ACK
            //0x01
            kirim(0x01);
            bit(1); //ACK

            //perintah Read
            kirim(0xA1);
            bit(1); //ACK


            int data = 0;
            for (int i = 7; i >= 0; i--)
            {
                data = data << 1;
                data = data | bacaBit();
            }
            bit(1); //ACK

            StopBit();


            serialPort1.Close();
            byte[] hasil = new byte[1]; hasil[0] = (byte)data;
            textBox2.Text = BitConverter.ToString(hasil);
        }
    }
}

Proteksi firmware ATmega dengan Nomor Seri

Menggunakan bantuan 1-Wire device, dengan jenis yang bermacam macam, misal: DS1820

#include <OneWire.h>
#include <EEPROM.h>

#define DEBUG 1

OneWire  ds(A1);  // This is where DQ of your DS18B20 will connect.
bool validity = false;
void setup(void) {

#ifdef DEBUG
  Serial.begin(9600);
#endif

  validity = getDeviceAddress();
}

bool getDeviceAddress(void) {
  byte i;
  byte addr[8];
  bool valid = false;

  unsigned long upper = 0;
  unsigned long lower = 0;

#ifdef DEBUG
  Serial.println("Getting serial number...\n\r");
#endif
  while (ds.search(addr)) {
    if ( OneWire::crc8( addr, 7) != addr[7]) {
#ifdef DEBUG
      Serial.print("CRC is not valid!\n");
#endif
      return;
    }

    for (byte i = 0; i < 4; i++) {
      upper = upper << 8;
      upper = upper | addr[i];
    }
    for (byte i = 4; i < 8; i++) {
      lower = lower << 8;
      lower = lower | addr[i];
    }

    unsigned long result = upper & lower;
    Serial.println(result);

    bool initsn = false;
    if (EEPROM.read(0) == 0xFF) initsn = true;

    //initsn=true;
#ifdef DEBUG
    if (!initsn) Serial.println("Checking serial number...\n\r");
    else Serial.println("Writing serial number...\n\r");
#endif

    valid = true;
    for (byte i = 0; i < 4; i++) {
      byte e = EEPROM.read(i + 1);
      byte r = result & 0xff;
      if (initsn)
        EEPROM.write(i + 1, r);
      if (e != r) valid = false;
      result = result >> 8;
    }
    if (initsn) EEPROM.write(0, addr[7]);

#ifdef DEBUG
    if (valid) Serial.println("Good serial number...\n\r");
    else Serial.println("Bad serial number...\n\r");
#endif

  }
  ds.reset_search();
  return valid;
}


void loop(void) {
  // do nothing
}

Mengubah USB ISP menjadi USBASP

USBISP berbeda dengan USBASP. USBISP tidak dapat dioperasikan dengan AVRDude, namun harus menggunakan PROG ISP. USB ISP menggunakan uC ATmega88, dengan skema mirim USBASP namun bedanya adalah pin D- pada USB dihubungkan ke PD3, jadi PD3 harus diubah menjadi pin INPUT.

Agar dapat berfungsi jadi USBASP, maka download firmware dari https://www.fischl.de/usbasp/usbasp.2011-05-28.tar.gz dan ekstrak.

Buka file bin/usbasp.atmega88.2011-05-28.hex menggunakan notepad++ atau wordpad.

Lihat pada baris 100B8000,

:100B8000D9F77A9589F708951BB815B88BEF8AB90C

ubah menjadi :

:100B8000D9F77A9589F708951BB815B880EF8AB917

ubah ldi pada DDRD 8BEF menjadi  80EF

dan ubah checksum dari  0C  menjadi  17

Buka kemasan USBISP dan hubungkan via (lubang) yang ditandai <– UP –> menggunakan kabel kecil.

Upload dengan USBASP atau Arduino yang telah dijadikan Arduino as ISP.

Note:

# TARGET=atmega8 HFUSE=0xc9 LFUSE=0xef
# TARGET=atmega48 HFUSE=0xdd LFUSE=0xff
# TARGET=atmega88 HFUSE=0xdd LFUSE=0xff

gunakan HEX berikut, jika uC yang digunakan adalah ATmega8:

:100000003BC09FC554C053C052C051C050C04FC028
:100010004EC04DC04CC04BC04AC049C048C047C08C
:1000200046C045C044C0040309041C0377007700A0
:1000300077002E00660069007300630068006C00A2
:100040002E00640065000E0355005300420061005D
:100050007300700012011001FF000008C016DC05DB
:1000600003010102000109021200010100801909C7
:10007000040000000000000011241FBECFE5D4E002
:10008000DEBFCDBF10E0A0E6B0E0E0EAFDE002C0D8
:1000900005900D92A236B107D9F710E0A2E6B0E0C4
:1000A00001C01D92A73AB107E1F702D077C6A8CFE9
:1000B00012BA18BA11BA8FEF87BB17BA93E094BB84
:1000C0008EEF85BB93BF08D478940DD4FECFFF92FA
:1000D0000F931F93CF93DF939C01F62E80916200C4
:1000E000813021F4E90110E000E078C08430D1F3E0
:1000F0001FEF77C080916200813079F580917300A5
:100100009091740020916F003091700040917100C7
:1001100050917200892B31F4CA01B901488121E064
:1001200088D321C0CA01B901488120E082D38091DF
:1001300076008150809376008823A9F460916F0047
:10014000709170008091710090917200488126D367
:10015000809173008093760006C080916F0090912B
:1001600070006881F7D280916300909164000197DC
:100170009093640080936300892BD9F410926200FD
:100180008091750081FF14C08091760090E02091ED
:100190007300309174008217930751F060916F00E3
:1001A0007091700080917100909172004881F6D238
:1001B00011E080916F0090917000A0917100B0915A
:1001C00072000196A11DB11D80936F009093700085
:1001D000A0937100B09372000F5F21960F1508F481
:1001E00089CF812FDF91CF911F910F91FF900895BB
:1001F0000F931F93CF93DF939C01062F8091620092
:100200008250823010F00FEF32C0E90110E029C0B7
:1002100080916200823051F460916F0070917000A3
:10022000809171009091720043D205C080916F005F
:100230009091700071D2888380916F0090917000CE
:10024000A0917100B09172000196A11DB11D809323
:100250006F0090937000A0937100B09372001F5FC5
:1002600021961017A8F2083010F410926200802F27
:10027000DF91CF911F910F910895CF93DF93EC0100
:100280008981813061F49A9902C085E002C0809131
:1002900065001FD110926600A99879D104C0823000
:1002A00021F496D1A99A20E0F7C0833011F5E091AE
:1002B0007800F09179008A81099580936700E09138
:1002C0007800F09179008B81099580936800E09126
:1002D0007800F09179008C81099580936900E09114
:1002E0007800F09179008D81099580936A0024E06F
:1002F000D3C0843011F580916600882391F49B81EE
:1003000080E02A8130E0822B932BAA2797FDA095CD
:10031000BA2F80936F0090937000A0937100B093F8
:1003200072009F8180E02E8130E0822B932B90938E
:1003300064008093630082E090C0873011F5809163
:100340006600882391F49B8180E02A8130E0822B33
:10035000932BAA2797FDA095BA2F80936F009093B7
:100360007000A0937100B09372009F8180E02E8195
:1003700030E0822B932B909364008093630083E0A2
:100380006CC0853021F451D18093670084C08630E1
:10039000D9F580916600882391F49B8180E02A81C1
:1003A00030E0822B932BAA2797FDA095BA2F80933C
:1003B0006F0090937000A0937100B09372008C81D5
:1003C0009D81292F2F7020937500492F50E0407F89
:1003D000507094E0440F551F9A95E1F7480F511D56
:1003E000509374004093730020FF02C04093760046
:1003F0009F8180E02E8130E0822B932B90936400CC
:100400008093630081E029C0883059F580916600AF
:10041000882391F49B8180E02A8130E0822B932B0A
:10042000AA2797FDA095BA2F80936F009093700034
:10043000A0937100B0937200109274001092730038
:10044000109275009F8180E02E8130E0822B932BEB
:10045000909364008093630084E0809362002FEFA8
:100460001BC0893081F481E0809366008A819B8182
:10047000AC81BD8180936F0090937000A093710058
:10048000B093720010CF8A3009F00DCF8A8180932B
:1004900065001092670021E087E690E090938C0061
:1004A00080938B00822FDF91CF910895382F90E0B9
:1004B00006C022B782B7821B8C33E0F39F5F93178D
:1004C000C0F3089580917B008DB980917A008EB938
:1004D0000895282F882311F42AE002C0883028F1DB
:1004E00080E193E0909379008093780010927A00F5
:1004F0002930A9F02A3018F4283051F412C02B30DA
:1005000029F02C3029F481E080937A0081E50AC03B
:1005100082E580937B0081E080937A00089582E5F4
:1005200001C083E580937B00089580EF92E0909373
:100530007900809378002430B1F0253038F42230EF
:10054000B1F0233090F42130C9F415C0263031F0D9
:10055000263038F0273091F483E00AC020937C00E5
:1005600008958CE005C088E103C080E301C080E607
:1005700080937C00089580EC80937C00089522B7DE
:1005800090917C0082B7821B8917E0F3089587B3AE
:100590008C6287BBC298C59892B720917C0082B7C5
:1005A000891B8217E0F3C29A92B782B7891B821720
:1005B000E0F3C29880917800909179008051934047
:1005C00031F480917B008DB980917A008EB90895C5
:1005D00087B3837D87BB88B3837D88BB1DB80895AF
:1005E000482F50917C0020E030E047FF02C0C39AC2
:1005F00001C0C398220FB4992F5FC59A92B782B7F2
:10060000891B8517E0F3C59892B782B7891B8517B8
:10061000E0F33F5F383011F0440FE7CF822F0895A9
:100620008FB9779BFECF8FB108950F931F9300E290
:1006300039C0E0917800F09179008CEA0995E09159
:100640007800F091790083E50995E0917800F091C8
:10065000790080E00995182FE0917800F0917900F9
:1006600080E00995133511F480E01FC01DB8C59ACC
:1006700092B720917C0082B7891B8217E0F3C5985E
:1006800092B782B7891B8217E0F38091780090912E
:1006900079008051934031F480917B008DB9809135
:1006A0007A008EB9015028F681E01F910F910895CC
:1006B000EF92FF920F931F937B018C01862F817025
:1006C000880F880F880FE0917800F09179008062A0
:1006D0000995D801C70129E0B695A7959795879503
:1006E0002A95D1F7E0917800F09179000995169557
:1006F0000795F794E794E0917800F09179008E2DBA
:100700000995E0917800F091790080E009951F91BA
:100710000F91FF90EF9008950F931F938C01E0913C
:100720007800F091790080EA0995E0917800F091E5
:100730007900812F0995E0917800F0917900802F60
:100740000995E0917800F091790080E009951F917A
:100750000F910895FF920F931F938C01F62EE09155
:100760007800F091790080EC0995E0917800F091A3
:100770007900812F0995E0917800F0917900802F20
:100780000995E0917800F09179008F2D09958EE11F
:100790008DDE80E01F910F91FF900895CF92DF9240
:1007A000EF92FF920F931F936B017C01142FE09146
:1007B0007800F09179008CE40995D701C60149E0F1
:1007C000B695A795979587954A95D1F7E0917800CA
:1007D000F09179000995D701C601B695A79597952F
:1007E0008795E0917800F09179000995E091780083
:1007F000F091790080E009951F3F19F48FE056DEF3
:1008000007C002B71EE1C701B60152DF8F3F11F0EA
:1008100080E008C082B7801B8D33A8F302B7115067
:1008200091F781E01F910F91FF90EF90DF90CF90B3
:100830000895CF92DF92EF92FF920F931F936B0177
:100840007C01042F122F862F8170880F880F880F4C
:10085000E0917800F091790080640995D701C60194
:1008600069E0B695A795979587956A95D1F7E09138
:100870007800F09179000995D701C601B695A79542
:1008800097958795E0917800F09179000995E0912E
:100890007800F0917900802F09951123A9F00F3786
:1008A00019F48FE003DE10C002B71EE1C701B601E4
:1008B000FFDE8F3749F482B7801B8D33B8F302B760
:1008C0001150A1F781E001C080E01F910F91FF90CE
:1008D000EF90DF90CF90089585B7836085BF8BB789
:1008E00080648BBF08951F93CF93DF9360918D0039
:1008F000635067FDA3C080918A00CCE0D0E0C81BA4
:10090000D109CF56DF4F809189008D3209F084C024
:10091000683009F091C083EC80937D008AE5809374
:100920006000109277008881807639F0CE01A5DCD6
:10093000282F8F3F09F45FC065C09A81109286000E
:100940008981882321F41092870022E04DC08530F0
:1009500019F490938E0047C08630B1F58B818130B9
:1009600019F484E590E004C0823041F486E690E01A
:1009700090938C0080938B0022E122C08330F9F4A5
:100980008A81882341F486E290E090938C008093E2
:100990008B0024E015C0813041F48AE290E090930E
:1009A0008C0080938B002CE10BC0823041F486E4F4
:1009B00090E090938C0080938B002EE001C020E0AB
:1009C00080E4809377001EC0883021F421E080E924
:1009D00090E00CC0893019F49093900004C08A30E4
:1009E00011F421E001C020E086E890E090938C00B3
:1009F00080938B0007C0888187FD2E8180E88093DB
:100A0000770006C08F81882319F48E81821708F041
:100A1000822F8093610010C08091770087FF0CC007
:100A2000CE0155DB8F3F21F48EE18093600004C03E
:100A3000882311F01092610010928D008091600067
:100A400084FF58C0809161008F3F09F453C0182F74
:100A5000893008F018E0811B8093610080917D004F
:100A600098E8892780937D00112391F18091770088
:100A700087FF08C08EE790E0612FBADB182F89301E
:100A800098F526C020918B0030918C0086FF0DC018
:100A9000AEE7B0E080E090E0F901E80FF91FE491E3
:100AA000ED9301961817C1F708C0912FD901EEE711
:100AB000F0E08D9181939150E1F71150812F90E0FA
:100AC0001F5F0196820F931F90938C0080938B0081
:100AD0008EE790E0612F31D0612F6C5F6C3041F078
:100AE0008FEF8093610004C08FEF809361006EE10F
:100AF0006093600094E186B3837031F49150D9F72C
:100B000010928E0010928800DF91CF911F9108956E
:100B1000A82FB92F80E090E041E050EA60956F5F28
:100B200058F42D9138EF82279795879510F08427F8
:100B300095273F5FC8F3F3CF0895EADF8D939D9328
:100B40000895CF93CFB7CF93C395B09BE9F7B09BF0
:100B500009C0B09B07C0B09B05C0B09B03C0B09B51
:100B600001C0A1C0DF93C0918A00DD27CF56DF4FBF
:100B7000B09B02C0DF91EBCF2F930F931F9306B36F
:100B80002FEF00FB20F94F933F9316B34FEF012750
:100B900000FB21F93BE031C04E7F012F16B32160ED
:100BA00028C0102F4D7F2260000006B329C04B7F64
:100BB0002460012F000016B32BC016B3477F2860B6
:100BC0002AC04F7E06B320612CC04F7D16B3206231
:100BD0002FC04F7B06B3206432C0422706B349932F
:100BE0004FEF0000102710FB20F916B31370C9F166
:100BF000297F91F2012700FB21F906B3237F89F2B7
:100C0000315058F1102710FB22F916B3277E79F2E4
:100C1000012700FB23F92F7C81F206B3102710FB7C
:100C200024F92F7971F200C016B3012700FB25F9D2
:100C30002F7359F200C006B3102710FB26F922309B
:100C400040F200C016B3012700FB27F9243028F634
:100C50004F77206816B30000F9CF10E41ABF0027C1
:100C600017C03B503195C31BD04010E41ABF088118
:100C7000033CE9F00B34D9F0209188001981110F61
:100C80001213EDCF093641F10D3211F0013E39F763
:100C900000938F003F914F911F910F912F91DF9102
:100CA000CAB7C6FD51CFCF91CFBFCF911895209134
:100CB0008F00222379F310918D00112311F5343028
:100CC00012F130938D002093890010918A003BE04F
:100CD000311B30938A0017C000918D0001308CF4D5
:100CE0000AE53091600034FD10C000936000CDE74C
:100CF000D0E00FC02795A8F45150A9F4220F0000AE
:100D0000F9CF4AE503C042ED01C0432FC4E1D0E072
:100D100032E017B31360C09A17BB08B320E413E0A6
:100D20005F93012756E008BB279520F4515021F42A
:100D3000220FF9CF012756E000003B5A08BBD0F242
:100D4000279528F4515029F4220F0000F9CF0127EC
:100D500056E0279508BB20F4515021F4220FF9CF1B
:100D6000012756E02991332308BB21F60C7F10910F
:100D70008E00110FC651D04008BB11F010938800AF
:100D800010E41ABF016017B31C7F402F4C7F5F91A6
:100D900000C000C008BB17BB48BB7CCFF894FFCF96
:020DA0005AFFF8
:00000001FF

Menambahkan Bootloader ATMega8 di Arduino versi 1.5.x ke atas

buka file platforms.txt

cari bagian: tools.avrdude

copy paste barisnya dan ubah menjadi tools.avrdudeM8 dengan menghapus -Uefuse:w:{bootloader.extended_fuses}:m

# AVR Uploader/Programmers tools M8
# ------------------------------

tools.avrdudeM8.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude
tools.avrdudeM8.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf

tools.avrdudeM8.upload.params.verbose=-v -v -v -v
tools.avrdudeM8.upload.params.quiet=-q -q
tools.avrdudeM8.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

tools.avrdudeM8.program.params.verbose=-v -v -v -v
tools.avrdudeM8.program.params.quiet=-q -q
tools.avrdudeM8.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"

tools.avrdudeM8.erase.params.verbose=-v -v -v -v
tools.avrdudeM8.erase.params.quiet=-q -q
tools.avrdudeM8.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m

tools.avrdudeM8.bootloader.params.verbose=-v -v -v -v
tools.avrdudeM8.bootloader.params.quiet=-q -q
tools.avrdudeM8.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m

Buka Board.txt, cari atmegang.menu.cpu.atmega8=ATmega8 dan tambahkan diatasnya:

 

atmegang.menu.cpu.atmega8.bootloader.tool=avrdudeM8

Selanjutnya pilih Board: ArduinoNG, Processor: ATmega8, Programmer: (sesuaikan)

Siap untuk klik, Burn Bootloader

Set agar mata bor CNC berada pada titik Nol dengan ketinggian tepat diatas PCB

Brikut cara menset agar mata bor CNC berada pada titik Nol. Jika menggunakan software Mach3 maka cukup aktifkan CNC lalu pindah mata bor ke tempat yang diinginkan sebagai titik nol. Memindahkannya cukup menggunakan tombol panah kiri/kanan/atas/bawah pada keyboard. Tidak perlu mengiraukan ketinggiannya. Cukup sumbu X dan Y nya saja.

Ketinggian diatur dengan tombol PageUp dan PageDown. Pengturan harus hati hati agar tidak terlalu turun sehingga bor patah. Cukup di-tap (tekan sedikit demisedikit saja) jangan ditekan terus menerus. Jika sudah hampir menabrak media yang akan di-bor, maka hentikan pada kurang lebih ketinggian 10mm.

Pemasangan probe cukup mudah, namun butuh pengecekan dan mungkin pengaturan. Selanjutnya pasang probe yang biasanya dalan bentuk konektor jepit buaya. Jika tidak tersedia, bisa dibuat sendiri dengan munghubungkan panel probe-nya. Untuk meyakinkan bahwa probe berfungsi, maka buka bagian Diagnostics (Alt+F7) lalu tempelkan probe pada PCB. Jika pada pilihan Digitize berubah warna, maka probe telah berfungsi dengan baik. Namun jika belum berubah warna, coba cek bagian Config dan centang Probe dan Active Low.

Set semua menjadi titik Nol, biasanya cukup menekan tombol REFF ALL HOME, namun kadangkala ada sumbu X, Y, Z yang tidah mau berubah jadi 0. Maka tekan saja tombol tersebut. Selanjutnya buka file findzero.nc ini untuk memindah dan set ketinggian tepat diatas PCB.

G0 Z0  (Pindah ke posisi 0,0,0)
G31 Z-10 F100 (Cari probe dengan arah Z negatif atau turun 10mm dengan kecepatan 100mm/det)
G92 Z0 (Jika probe telah ditemukan, maka set Z=0)
G0 Z2 (Pindah ke posisi Z=2 atau naik 2mm)
G31 Z-1 F50 (Cari probe lagi dengan kecepatan 50 mm/det)
G92 Z0 (Set ulang ketinggian menjadi 0)
G0 Z1 (Pindah ke posisi naik 1mm)
M1 (Pause atau berhenti sejenak)

Selanjutnya tinggal lepas Probe dan CNC siap untuk digunakan.

Pemanfaatan Timer pada ESP8266

Interrupt Software Timer

#include <ESP8266WiFi.h>
#include <Ticker.h>  
Ticker blinker;
#define LED 2  //On board LED
void changeState()
{
  digitalWrite(LED, !(digitalRead(LED)));  
}

void setup()
{
    pinMode(LED,OUTPUT);
    blinker.attach(0.5, changeState); //atau attach_ms dalam milisecond
}

void loop()
{
}

Interrupt Hardware Timer (Timer1), Timer0 tidak bisa digunakan karena untuk koneksi WiFi

#include <ESP8266WiFi.h>
#include <Ticker.h>
Ticker blinker;
#define LED 2  //On board LED
void ICACHE_RAM_ATTR onTimerISR(){
    digitalWrite(LED,!(digitalRead(LED)));  //Toggle LED Pin
    timer1_write(600000);//12us

}


void setup()

{

    pinMode(LED,OUTPUT);

 


    timer1_attachInterrupt(onTimerISR);

    timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE);

    timer1_write(600000); //120000 us

}


void loop()

{

}


Sumber:

https://circuits4you.com/category/esp8266/

https://www.switchdoc.com/category/esp8266/

Driver PL2303HX untuk Windows 10 64bit

Pernah beli alat USB to Serial Converter murah, dengan IC PL2303. Saat dipasang di komputer, ternyata butuh driver. Alhasil menemukan driver di situs produsen IC namun ada catatan :

Windows 8/8.1/10 are NOT supported in PL-2303HXA and PL-2303X EOL chip versions.

Untungnya ada situs yang baik hati (lupa dimana) memberikan file hasil modifikasi driver Windows 7 agar bisa dipasang di Windows 10.

Link: http://latiful.hayat.web.id/file/PL2303HX-edit.zip

Semoga bisa bermanfaat

Cara membuka acakan siaran parabola jenis BISS

Langkah pertama: Mencari PID

Setelah siaran yang diacak direkam dalam bentuk TS (Transport Stream), lalu buka file melalui TSReader. Cari PID tayangan yang diacak. PID ditampilkan dalam format Hexadesimal. Untuk mengetahui dalam bentuk desimal, gunakan kalkulator dengan mode scientific. (Misal: 0x0031Hex = 49 Dec)

Langkah kedua: Brute dengan CW Finder

  • Buka file dan masukkan PID dalam bentuk desimal (Misal: 49)
  • Pilih menu Pilihan lanjut pilih Gunakan file daftar serangan
  • Buka file daftar kunci, klik Baca File, OK pada jendela Info, centang pada Gunakan daftar serangan, dilanjutkan dengan klik Gunakan pada jendela Daftar serangan CW
  • Semua jendela akan menutup otomatis
  • Klim menu Mulai, tunggu sebentar hingga muncul kode CW
Search Thread started...
CW found: 
A3 B2 C1 [16] D6 E5 F4 [AF]
Search Thread stoped...
  • Tinggal isikan kode (misal yang ditemukan di atas adalah: A3B2C116D6E5F4AF pada receiver

Jika langkah kedua gagal, gunakan langkah ketiga

  1. Cari kode Crypt8 dengan CSA Rainbow Table
  • Siapkan dahulu file rbt, CSA_B8hx00h_10000h.rbt (untuk jenis MP2) atau CSA_B8hxFFh_10000h.rbt (untuk jenis MP4)
  • Buka CSA Rainbow Table
  • Pada bagian TS file:, arahkan ke file TS
  • Pada bagian PID, isikan PIDnya (Misal: 49)
  • Klik tombol Start

csa

  • Pada contoh di atas, ditemukan 2 kode Crypt8, yaitu FD ED 27 37 23 ED 5E 5B dgn jumlah 231668 dan 08 E5 A3 EF F5 FB D5 78 dengan jumlah 34. Pilih yang jumlahnya paling banyak, yaitu: FD ED 27 37 23 ED 5E 5B
  • Copy yang telah dipilih lalu paste ke bagian Crypt8: FD ED 27 37 23 ED 5E 5B
  • Arahkan RBT Dir: ke tempat dimana file rbt atau CSA_B8hx00h_10000h.rbt berada
  • Klik tombol Start, maka hasil CW akan ditampilkan di bagian CW:
  • Tinggal isikan kode (misal yang ditemukan di atas adalah: A3B2C116D6E5F4AF pada receiver

 

Referensi: satelitindonesia.com

Contoh kode interupsi I2S pada WAU8822 pada Nuvoton NUC-LB140

Contoh loopback dari dan ke WAU serta pembentukan sinyal sinusoida

#include "NUC100Series.h"
#include "gpio.h"
#include "portinit.h" //lcd
#include "lcd.h"
#include "wau8822n.h"

# define PLLCON_SETTING      CLK_PLLCON_50MHz_HIRC
# define PLL_CLOCK           50000000
# define HCLK_DIV            1

#define MUTE_OFF(x)         PE->DOUT &= ~(1 << 14)
#define MUTE_ON(x)          PE->DOUT |=  (1 << 14)

//#define POOLING
#define LOOPBACK 1
#define MONOTOSTEREO 1
#define GAIN 1//50

#define SIN_SAMPLES     32
int32_t i32SinIdx = 0;
int16_t i16Sin[SIN_SAMPLES] = {
    0,3203,6284,9124,11612,13655,15172,16106,16423,16107,15172,13655,
    11613,9124,6284,3204,1,-3205,-6284,-9124,-11613,-13654,-15173,-16107,
    -16422,-16106,-15172,-13655,-11613,-9123,-6285,-3203
};

uint32_t g_u32TxValue;
uint32_t connect=TRUE;
void displayLCD(){

    //PC15=0;
    print_Line(0,   " Teknik Elektro ");
    printS(2*8+4,1*16,"Universitas"); //printS(x, y, char)
    printS(2*8,2*16,"Muhammadiyah");
    printS(3*8,3*16, "Purwokert0");
    connect=FALSE;

}

uint32_t spectrum[128];
volatile uint8_t ii=0;
extern void wau(void){
    uint8_t i;
    for(i=0;i<128;i++){
        spectrum[i]=0;
    }


    SYS_UnlockReg(); // Unlock protected registers
    CLK_EnableXtalRC(CLK_PWRCON_XTL12M_EN_Msk | CLK_PWRCON_OSC10K_EN_Msk ); // Enable HXT external 12MHz cyrstal
    CLK_SetCoreClock(50000000);    //  Set HCLK frequency 50MHz
    SYS_LockReg(); // Lock protected registers

    Port_Init(SPI3PORT);
    init_LCD();
    clear_LCD();

    //I2C - I2S WAU8822 codec
    WAU8822_Config();

    GPIO_SetMode(PE, BIT14, GPIO_PMD_OUTPUT);
    PE14=0;  //PHone OUT Enable (NUC-LB-140)

#ifdef POOLING
    //uint32_t u32Tmp;

    //open I2S function
    //st.u32SampleRate     = 16000;
    //st.u8WordWidth       = I2S_DATABIT_16;
    //st.u8AudioFormat     = I2S_STEREO;
    //st.u8DataFormat      = I2S_FORMAT_I2S;
    //st.u8Mode            = I2S_MODE_SLAVE;
    //st.u8TxFIFOThreshold = I2S_FIFO_TX_LEVEL_WORD_0;
    //st.u8RxFIFOThreshold = I2S_FIFO_RX_LEVEL_WORD_8;//SMP_ONE
    I2S_Open(I2S,I2S_MODE_MASTER,32000,I2S_DATABIT_16,I2S_STEREO,I2S_FORMAT_I2S);

    // Set MCLK and enable MCLK
    I2S_EnableMCLK(I2S,6000000);

    while(1)
    {

            if((I2S->STATUS & I2S_STATUS_TXFULL_Msk) == 0)
            {
                u32Tmp = i16Sini[i32SinIdxi];
                u32Tmp &= 0xFFFFUL;
                //u32Tmp |= u32Tmp << 16;  //duplicate it to stereo to Tx FIFO
                I2S->TXFIFO = u32Tmp;
                i32SinIdxi++;
                if(i32SinIdxi >= SIN_SAMPLESi)
                    i32SinIdxi = 0;

            }

    }
#else

    //interrupt
    I2S_Open(I2S,I2S_MODE_SLAVE,32000,I2S_DATABIT_16,I2S_STEREO,I2S_FORMAT_I2S);
    I2S_EnableMCLK(I2S,12000000);

    I2S_EnableInt(I2S,I2S_IE_RXTHIE_Msk );
    NVIC_EnableIRQ(I2S_IRQn);

    GPIO_SetMode(PC,BIT12,GPIO_PMD_OPEN_DRAIN);PA12=1;
    GPIO_SetMode(PC,BIT14,GPIO_PMD_OPEN_DRAIN);

    if(PE15==1) displayLCD();

    while(1)
    {
        CLK_SysTickDelay(1000000);
        if(PE15==0)
        {
            if(connect==FALSE) {
                clear_LCD();
                print_Line(0,   "Line-In Sound OK");
            }
            PC12 ^= 1;  //in LIN connected
            connect=TRUE;


        }else{
            if(connect){displayLCD();}

        }


    }
#endif
}

void I2S_IRQHandler(void)
{
    uint32_t u32Tmp=0;
    //unit32_t s =

    /* Fill sin samples to I2S until Tx FIFO full */
    while((I2S->STATUS & I2S_STATUS_TXFULL_Msk) == 0)
    {

#if LOOPBACK // Just loop Rx FIFO to Tx FIFO
        u32Tmp = I2S->RXFIFO;
        I2S->TXFIFO = (u32Tmp*GAIN);
#elif MONOTOSTEREO // Mono data in Rx FIFO and duplicate it to stereo to Tx FIFO
        u32Tmp = I2S->RXFIFO*GAIN & 0xFFFF0000UL;
        u32Tmp |= u32Tmp >> 16;
        I2S->TXFIFO = u32Tmp;

#else // Output Sin Wave
        u32Tmp = i16Sin[i32SinIdx];
        u32Tmp &= 0xFFFFUL;
        u32Tmp |= u32Tmp << 16;
        I2S->TXFIFO = u32Tmp;
        i32SinIdx++;
        if(i32SinIdx >= SIN_SAMPLES)
            i32SinIdx = 0;
#endif
    }
    ii = u32Tmp;
    PC->DOUT ^= (1 << 14);
}