Semua Tentang Belajar Teknologi Digital Dalam Kehidupan Sehari - Hari

  • IC Timer 555 yang Multifungsi

    IC timer 555 adalah sirkuit terpadu (chip) yang digunakan dalam berbagai pembangkit timer, pulsa dan aplikasi osilator. Komponen ini digunakan secara luas, berkat kemudahan dalam penggunaan, harga rendah dan stabilitas yang baik

  • Ayo Migrasi TV Digital

    Kami bantu anda untuk memahami lebih jelas mengenai migrasi tv digital, apa sebabnya dan bagaimana efek terhadap kehidupan. Jasa teknisi juga tersedia dan siap membantu instalasi - setting perangkat - pengaturan antena dan distribusi televisi digital ke kamar kos / hotel

  • Bermain DOT Matrix - LOVEHURT

    Project Sederhana dengan Dot Matrix dan Attiny2313. Bisa menjadi hadiah buat teman atau pacarmu yang ulang tahun dengan tulisan dan animasi yang dapat dibuat sendiri.

  • JAM DIGITAL 6 DIGIT TANPA MICRO FULL CMOS

    Jika anda pencinta IC TTL datau CMOS maka project jam digital ini akan menunjukkan bahwa tidak ada salahnya balik kembali ke dasar elektronika digital , sebab semuanya BISA dibuat dengan teknologi jadul

  • Node Red - Kontrol Industri 4.0

    Teknologi kontrol sudah melampaui ekspektasi semua orang dan dengan kemajuan dunia elektronika, kini semakin leluasa berkreasi melalui Node Red

Tampilkan postingan dengan label vumeter. Tampilkan semua postingan
Tampilkan postingan dengan label vumeter. Tampilkan semua postingan

Kamis, 02 Juli 2020

The Coolest Way To Visualize VU Meter From Arduino to Microsoft Excel



On this tutorial i will try to show you how cool is python if combined with arduino, as i've already wrote on previous blogs Here dan Here . Sorry since i was writing only in Bahasa so please use google translate for your convenience and now i would like to write in english and i hope you'll understand.

First prepare some components from this schematic for amplifier part, the purpose is to create audio signal gain (from condenser mic) which is too weak for arduino's ADC to read from. 

Since we only want to read the signal's voltage so we can skip loud speaker part, but if you want to hear some poor noisy sound then it is up to you. Pin no 5 of LM386 can directly feed into any arduino ADC pin and the power supply can directly connected to 5 volt on arduino. The Script is quite simple as i only copy and paste from arduino's ADC example scripts collection.


int analogPin = A0; // Any ADC Pin on ardiuno
                    
int val = 0;  // variable to store the value read

void setup() {
  Serial.begin(9600);           //  setup serial
}

void loop() {
  val = analogRead(analogPin);  // read the input pin
  Serial.println(val);          // send value to serial
  delay(100);   // 100 ms delay is the best, try other number
}
That is one simple scripts, i only use hardware serial directly connecting to USB COM port then the python will do the rest. Xlwings library is a simple tools to write and read directly to any excel 'cell' so then the graph chart on excel can becoming "alive" in real time if the data is changed rapidly. 


import serial #serial library
import xlwings as xw #excel library

wb = xw.Book('Audio.xlsx') #file name, change accordingly
sht = wb.sheets['data'] #sheets name, change it depend on your excel
row = 1

serialPort = serial.Serial(port = "COM4", baudrate=9600,   #baudrate
                           bytesize=8, timeout=2, 
                           stopbits=serial.STOPBITS_ONE)

serialString = ""   

while(1):
    if(serialPort.in_waiting > 0): #read if any serial data is coming
        serialString = serialPort.readline()
        data=serialString.decode('utf-8')     
        print(data) 
        if row == 51: #reset the row
          row=2 
        else: 
          row=row+1
        audio='A'+str(row) #new cell
        sht.range(audio).value= float(data) #write cell

The scripts read the integer value from ADC readout which is sent by arduino, then write it rapidly on cell A2 until A51 in excel file. The graph will be "dancing" according to the sound wave traveling through the condenser microphone.



As microsoft excel is easy to use or to customize then you can create any chart or graph you like and can be use as simple visualization as long as the data speed is not very fast, eg: Heart Beat or ECG.





 I hope you understand and happy Visualizing your favorite music on Excel


Naya Marie Rivera , naya rivera, glee, @nayarivera, missing
Share:

Selasa, 06 Agustus 2013

Kreasi Pembaca: VU Meter Untuk Sound Level dengan ATMega8535 (Versi Digital)



Kreasi pembaca lanjutan dari tulisan sebelumnya merupakan penggabungan dari beberapa pembahasan mengenai penulisan ke lcd dan topik yang membahas tentang ADC (Analog To Digital Converter). Sinyal yang diterima oleh mic condenser kemudian dikuatkan dua kali oleh op-amp LM358 kemudian output yang berupa tegangan ini akan memberikan inputan menuju ADC port pada minimum system 8535. Sebelumnya alangkah baiknya kita ketahui dulu bagaimana response tegangan dengan suara yang tidaklah linear akan tetapi logaritmik.




Microcontroller 8 bit akan mengalami kesulitan jika dipaksakan berhitung di skala logarithmic (entah micronya yg bakal error atau kepala yg bikin script akan pusing hebat). Nah untuk itu kita akan mengambil sampling data sound level dari sebuah bunyi (tone generator) , kemudian kita ukur pada dbMeter yang difungsikan sebagai kalibrator. Pada saat yang bersamaan kita catat pula level pembacaan ADC yang keluar pada layar LCD minimum system. 

Karena sudah memakai minimum system maka rangkaian yg kita tampilkan hanya berupa penguat dari mic condenser.



Klik gambar untuk memperjelas gambar
*) VCC 5v tidak sebagai input, melainkan input dari supply 9-12v


Jika pembaca sudah terbiasa dengan pembahasan ADC ungkin akan sangat mudah tetapi tetap saja saya tempel scriptnya demi kemudahan bagi pembaca setia.


//Insisialisasi awal

#define F_CPU 4000000UL //frek minsys 8535 versi innovative
#include <string.h>
#include <avr/io.h>
#include <util/delay.h>
#include "lcd.h"

// silahkan baca pembahasan menulis di lcd
//fungsi untuk menulis angka ke ASCII LCD
void reverse(char s[]) 
{ 
   int c, i, j; 
    
   for (i = 0, j = strlen(s)-1; i < j; i++, j--){ 
      c = s[i]; 
      s[i] = s[j]; 
      s[j] = c; 
   } 
} 
void itoa(int n, char s[]) 
{ 
   int i, sign; 
    
   if ((sign = n) < 0) // record sign 
      n = -n;         // make n positive 
   i = 0; 
   do {   // generate digits in reverse order 
      s[i++] = n % 10 + '0'; // get next digit 
   } while ((n /= 10) > 0); // delete it 
   if (sign < 0) 
      s[i++] = '-'; 
   s[i] = '\0'; // add null terminator for string 
   reverse(s); 
}  


//insisialisasi ADC

void initADC()
{
ADMUX=(1<<REFS0);// Aref=AVcc;
ADCSRA=(1<<ADEN)|(1<<ADIE)|(7<<ADPS0);
MCUCR |= _BV(SE);  // Sleep Enable, jadi abis ini processor diturunkan loadnya
MCUCR |=_BV(SM0);  // mode ADC NOISE REDUTION
}


//Baca ADC, pilih pin portA yg diinginkan

uint16_t ReadADC(uint8_t ch)
{

   //Select ADC Channel ch must be 0-7
   ch=ch&0b00000111;
   ADMUX|=ch;

   //Start Single conversion

   ADCSRA|=(1<<ADSC);

   //Wait for conversion to complete
   while(!(ADCSRA & (1<<ADIF)));

   //Clear ADIF by writing one to it
   ADCSRA|=(1<<ADIF);

   return(ADC);

}


int main(void)
{


uint16_t baca,decimal,pecahan;
uint8_t a;

//inisialisasi port I/O 

//PORTC menuju LCD & BUzzer
//PC0=buzzer, dapat tidak digunakan
DDRC  |= (1<<PC0)|(1<<PC1)|(1<<PC2)|(1<<PC3)|(1<<PC4)|(1<<PC5)|(1<<PC6)|(1<<PC7);
//PC1=Rs PC2=R/W PC3= E PC4-PC7 = data lcd 4 bit
//inisialisasi LCD
lcd_init(LCD_DISP_ON);
lcd_clrscr();


initADC();
char dum; //dum = variabel sementara penyimpan angka


   while(1)
   {

      baca=ReadADC(1); //baca tegangan output op-amp
      lcd_clrscr();
      lcd_gotoxy(0,0);

    // baca merupakan binner 10 bit, range 0-5V
    // jadi binnernya 0-1023  
    
  // berikut ini untuk buat animasi level VU
 for(a=0; a< (baca/64); a++) 
    {

     if(a<16) lcd_putc(0xFF); //tulis kotak ke LCD sesuai level

 }

// yang ini penentuan level buzzer, gunakan sesuai keinginan 
    if(a>13) PORTC|=(1<< PC0);
 else PORTC &= ~(1<< PC0);

//buzzer dapat tidak digunakan

      
   decimal= (baca * 5)/1000 ;

   pecahan= ( ((baca * 5) - (decimal * 1000) ) /10);

// tampilan tegangan ke LCD
      lcd_gotoxy(0,1);
      lcd_puts("teg =");

      itoa(decimal,&dum);
   lcd_puts(&dum);
   lcd_putc(',');
      
       if(pecahan <10) lcd_putc('0');

      itoa(pecahan,&dum);
   lcd_puts(&dum);

   lcd_puts(" V    ");
  

      _delay_ms(100);  //delay pembacaan, ubah2 sesuai keinginan, makin cepet susah dibaca tapi makin realtime

   }


return 0;

}




Selanjutnya jika menginginkan perhitungan dB (desibel) dari level suara, maka kita buat tabel seperti contoh berikut :


dB P1 P2 P3 AVG BINER
45 2.09 2.22 2.12 2.14 429
50 2.12 2.25 2.19 2.19 437
47 2.15 2.27 2.21 2.21 442
48 2.18 2.31 2.22 2.24 447
49 2.25 2.32 2.23 2.27 453
51 2.28 2.34 2.24 2.29 457
52 2.32 2.35 2.26 2.31 462
53 2.36 2.37 2.27 2.33 467
55 2.41 2.39 2.29 2.36 473
56 2.47 2.42 2.31 2.40 480
58 2.53 2.44 2.33 2.43 487
59 2.56 2.46 2.34 2.45 491
61 2.57 2.48 2.35 2.47 493
62 2.59 2.49 2.37 2.48 497
65 2.60 2.53 2.41 2.51 503
67 2.62 2.54 2.43 2.53 506
68 2.63 2.56 2.44 2.54 509
70 2.66 2.58 2.47 2.57 514 



Dengan perolehan data seperti diatas maka dapat dilakukan pengambilan sample level db vs voltage(rata-rata) kemudian secara mudah dapat dilakukan menggunakan lookup array ataupun paling primitif menggunakan "IF ELSE" saja seperti contoh berikut:




  if( baca <= 429) lcd_puts("<45 dB");
  else if( baca > 429 && baca <= 437 ) lcd_puts(" 45 dB");
  else if( baca > 437 && baca <= 442 ) lcd_puts(" 50 dB");
  else if( baca > 442 && baca <= 447 ) lcd_puts(" 47 dB");
  else if( baca > 447 && baca <= 453 ) lcd_puts(" 48 dB");
  else if( baca > 453 && baca <= 457 ) lcd_puts(" 49 dB");
  else if( baca > 457 && baca <= 462 ) lcd_puts(" 51 dB");
  else if( baca > 462 && baca <= 467 ) lcd_puts(" 52 dB");
  else if( baca > 467 && baca <= 473 ) lcd_puts(" 53 dB");
  else if( baca > 473 && baca <= 480 ) lcd_puts(" 55 dB");
  else if( baca > 480 && baca <= 487 ) lcd_puts(" 56 dB");
  else if( baca > 487 && baca <= 491 ) lcd_puts(" 58 dB");
  else if( baca > 491 && baca <= 493 ) lcd_puts(" 59 dB");
  else if( baca > 493 && baca <= 497 ) lcd_puts(" 61 dB");
  else if( baca > 497 && baca <= 503 ) lcd_puts(" 62 dB");
  else if( baca > 503 && baca <= 506 ) lcd_puts(" 65 dB");
  else if( baca > 506 && baca <= 509 ) lcd_puts(" 67 dB");
  else if( baca > 509 && baca <= 514 ) lcd_puts(" 68 dB");
  else if( baca > 514 ) lcd_puts(">70 dB");



Hasilnya pada video berikut ...jangan terkejut alau kualitas video jelek dan ada suara latar yang sangat "menggetarkan hati..."





Dan seperti biasa kabar gembira muncul dari hasil bimbinganku ini, tugas akhir yang dibuat mahasiswi dari aceh ini mendapatkan nilai "A"  . Duh ...senangnya.....


SELAMAT MENCOBA
Share:

Kontak Penulis



12179018.png (60×60)
+628155737755

Mail : ahocool@gmail.com

Site View

Categories

555 (8) 7 segmen (3) adc (4) amplifier (2) analog (19) android (12) antares (8) arduino (25) artikel (11) attiny (3) attiny2313 (19) audio (5) baterai (5) blog (1) bluetooth (1) chatgpt (2) cmos (2) crypto (2) dasar (46) digital (11) dimmer (5) display (3) esp8266 (25) euro2020 (13) gcc (1) iklan (1) infrared (2) Input Output (3) iot (58) jam (7) jualan (12) kereta api (1) keyboard (1) keypad (3) kios pulsa (2) kit (6) komponen (17) komputer (3) komunikasi (1) kontrol (8) lain-lain (8) lcd (2) led (14) led matrix (6) line tracer (1) lm35 (1) lora (5) MATV (1) memory (1) metal detector (4) microcontroller (70) micropython (6) mikrokontroler (1) mikrokontroller (14) mikrotik (5) modbus (9) mqtt (3) ninmedia (5) ntp (1) paket belajar (19) palang pintu otomatis (1) parabola (88) pcb (2) power (1) praktek (2) project (33) proyek (1) python (7) radio (15) raspberry pi (4) remote (1) revisi (1) rfid (1) robot (1) rpm (2) rs232 (1) script break down (3) sdcard (3) sensor (2) sharing (3) signage (1) sinyal (1) sms (6) software (18) solar (1) solusi (1) tachometer (2) technology (1) teknologi (2) telegram (2) telepon (9) televisi (167) television (28) transistor (2) troubleshoot (3) tulisan (92) tutorial (108) tv digital (6) tvri (2) vu meter (2) vumeter (2) wav player (3) wayang (1) wifi (3)

Arsip Blog

Diskusi


kaskus
Forum Hobby Elektronika