Dec 19, 2020

 still under development for arduino grbl

Drivers and how to connect to arduino in the next video. I will keep the driver in the cloud Software Robodk https://robodk.com/ Create a 6-axis Robot Arm: https://youtu.be/fNdqvi81djM RoboDK Arduino GRBL - Robot GRBL for Robodk: https://youtu.be/YV8CytL1IdE
SHOW LESS

Dec 6, 2020

CNC

 Grbl Mega 5Axis 



Dec 3, 2020

Support me for more videos: https://www.patreon.com/GreatScott Previous video: https://youtu.be/r9GMUYa_DvY Arduino Basics 101: https://youtu.be/BtLwoNJ6klE Facebook: https://www.facebook.com/greatscottlab Twitter: https://twitter.com/GreatScottLab You can get Arduino boards here (affiliate links): Aliexpress: Arduino Uno: https://s.click.aliexpress.com/e/_dT2... Arduino Nano: https://s.click.aliexpress.com/e/_dUL... Arduino Pro Mini: https://s.click.aliexpress.com/e/_d62... FTDI board: https://s.click.aliexpress.com/e/_dV4... Ebay: Arduino Uno: http://rover.ebay.com/rover/1/711-532... Arduino Nano: http://rover.ebay.com/rover/1/711-532... Arduino Pro Mini: http://rover.ebay.com/rover/1/711-532... FTDI board: http://rover.ebay.com/rover/1/711-532... Amazon.de: Arduino Uno: http://amzn.to/2ljDLFL Arduino Nano: http://amzn.to/2ljnq3J Arduino Pro Mini: http://amzn.to/2kMv0ly FTDI board: http://amzn.to/2ljvuRY In this second epsiode of the Arduino Basics video series I will talk about control structures like if, for, while and switch and how to use them in combination with variables to create more advanced code. At the end I will also talk about why interrupts are so important and how to use them as well. Music: In the Hall of the Mountain King, Kevin MacLeod Ecstatic Wave, Jens Kiilstofte https://machinimasound.com/music
SHOW LESS

This repository is for those who would like to learn how to use the Python module PySerial and Arduino.

There will be a corresponding Arduino (.ino) and Python (.py) file for each part. Each part builds upon the previous.


View the YouTube Play List for step by step instruction and detailed instructions:

https://www.youtube.com/playlist?list=PLb1SYTph-GZJb1CFM7ioVY9XJYlPVUBQy

All code

 Code

saves = open('data.txt', 'w')

saves.write(path)

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

def chooseDir(): 

global path

path = filedialog.askdirectory(title="Choose a download directory")

tk.Label(root, text=path, bg='gray').place(x=240,y=300)

saves()

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

saves = open('data.txt', 'w')

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

tk_buttom

Button(root,text="Download video", width=20, bg='black',fg="white", command=downloadVideo).place(x=240, y=130)

Button(root,text="Choose location", width=20, bg='black',fg="white", command=chooseDir).place(x=240, y=160)

Label_3=Label(root, text="Curent location: ", font=("bold"), bg='gray')

Label_3.place(x=250, y=245)





Dec 1, 2020

Serial python

The response always ends with the FF byte. So i want to read the bytes into a buffer untill i encounter FF. Than the buffer should be printed and the function should return.

import serial

s_port = 'COM1'
b_rate = 2400

#method for reading incoming bytes on serial
def read_serial(ser):
    buf = ''
    while True:
        inp = ser.read(size=1) #read a byte
        print inp.encode("hex") #gives me the correct bytes, each on a newline
        buf = buf + inp #accumalate the response
        if 0xff == inp.encode("hex"): #if the incoming byte is 0xff
            print inp.encode("hex") # never here
            break
    return buf   

#open serial
ser = serial.Serial(
    port=s_port,
    baudrate=b_rate,
    timeout=0.1
)

while True:

    command = '\x05\x06\x40\x00\x02\x05\xF6\x5C' #should come from user input
    print "TX: "
    ser.write(command)
    rx = read_serial(ser) 

print "RX: " + str(rx) 

===============================================================

python serial read

วันนี้ได้เขียนหลายเรื่องเลย งานเร่งด่วนมาก
ตอนนี้จะเกี่ยวกับการอ่านค่า ที่ได้รับจาก serial port

ตัวอย่าง code

#! /usr/bin/python

 
import time
import serial

port = serial.Serial("/dev/ttyUSB0", baudrate=19200, timeout=1.0)

i = 1

while 1:
  port.write(chr(i))
  rcv = port.read(1) ================== (1)
  if rcv != '':================== (2)
    ans = ord(rcv) ================== (3)
    if ans == 0x61:
      print "Status Ready"
    else:
      print rcv
  else: ================== (4)
    print "Loss communication"


(1) คืออ่านค่าจาก serial port ใส่ในตัวแปร rcv
(2) ตรวจสอบว่าค่า rcv ที่อ่านมา มีค่าอะไรอยู่หรือไม่ ถ้ามีก็ทำต่อไป ถ้าไม่มีก็กระโดดไปที่ (4)
(3) เปลี่ยนตัวแปร rcv ที่เป็น string ให้เป็น int เพื่อที่เราจะสามารถเปรียบเทียบค่ากับ hex ที่เราต้องการได้


ที่มา http://stackoverflow.com/questions/12929593/how-to-test-for-hexidecimal-output-on-serial-port-in-python

=========================================================================

Python re

https://l.facebook.com/l.php?u=https%3A%2F%2Fmedium.com%2F%40tanabodin.kamol%2Fpython-regular-expression-8e8b87ee44a6%3Ffbclid%3DIwAR0oobY_M85uZVB_nLNPpSuHaCRGHZyHERZpaudtYQGM3n-yM9ZrwbK9KGc&h=AT1HL99ZYq1IkaBRNYOxmGLtRXpyw6cB4GrZ5B0_lBdeisOynBqZ9iecRYZmz-aDlbkmGAbx4s51Kb0zZ0JhLxisLHIwAhP3jAumk9F-A0xzbKYMNTNDxHg15eSlNgbj_B30nQ


========================================================================