Control servo with few line of asm costycnc


i used arduino nano cnc shield v4.0 https://it.aliexpress.com/w/wholesale-cnc-shield-v4.html for compile asm and upload to arduino nano (cnc-shield-v4) use https://costycnc.it/avr1 .equ RXCIE0 = 7 .equ RXEN0 = 4 .equ UCSR0B = 0xc1 .equ UCSR0C = 0xc2 .equ TXEN0 = 3 .equ UDR0 = 0xc6 .equ bps = 16000000/(16*9600) - 1 .equ UBRR0L = 0xc4 .equ UBRR0H = 0xc5 .equ UCSZ00 = 1 .equ UCSZ01 = 2 .org 0x0 jmp RESET ; Reset Handler .org 0x24 ;USART, RX Complete Handler jmp receive .org 0x60 RESET: ldi r16,103 ldi r17,0 sts UBRR0L,r16 sts UBRR0H,r17 ldi r16 ,(1 << UCSZ00) | (1 << UCSZ01) sts UCSR0C,r16 ldi r16,(1 << RXCIE0) | (1 << RXEN0)| (1 << TXEN0) sts UCSR0B,r16 sei sbi 4,4 loop: cbi 5,4 rcall pause mov r18,r16;here change value to change angle sbi 5,4 rcall pause rjmp loop pause: L2: dec r19 brne L2 dec r18 brne L2 ret receive: lds r16,UDR0 next: reti html code(open notepad and paste the code bellow -save file as text.html and open it): <html lang="it"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>TEST SERIAL</title> </head> <body> <button onclick="connectSerial();">Connect</button> <input type="range" value="11" min="11" max="54" onmousemove="range(this.value);"/> <script> async function connectSerial() { try { // Prompt user to select any serial port. port = await navigator.serial.requestPort(); await port.open({ baudRate: 9600}); textEncoder = new TextEncoderStream(); writableStreamClosed = textEncoder.readable.pipeTo(port.writable); writer = textEncoder.writable.getWriter(); } catch { alert("Serial Connection Failed"); } } async function range(value) { console.log(value); await writer.write(String.fromCharCode(value)); } async function stanga(value) { console.log(value); await writer.write(String.fromCharCode(value)); } async function dreapta(value) { console.log(value); await writer.write(String.fromCharCode(value)); } </script> </body> </html>

Comments

Popular posts from this blog

Compile mks dlc32 using Visual Studio Code and Platform.io

MAKERBASE MKS DLC32 $ESP Configurations AP STA Costycnc