mjuhanne / fyrtur-motor-board

Custom firmware for the STM32 based IKEA Fyrtur roller blind motor board
MIT License
114 stars 12 forks source link

List/Map of Error codes available? #7

Closed rummens closed 3 years ago

rummens commented 3 years ago

Hi there,

First of all thank you very much for great this awesome project! I successfully connected a Raspberry Pi to the motor board using the original cables and firmware but I am failing to make sense of the UART response. No matter which command I send, I get a seemingly random response of one or two bites. I triple checked my UART config and tried many variations, since I saw you deactivated the HW flow control in your code. I assume they are some kind of error codes as they have nothing to do with the expected responses described in your docs but I fail to see the pattern. Also no activity from the motor but I can confirm that it still works as it does it's initial quarter rotation when connecting to Power. I take this a sign that I didn't fried the board (yet).

I hope my wiring is correct as well but I guess there is not a lot one can do wrong. VCC/Gnd --> 7.5V power/Gnd, R Motor --> T Pi, T Motor --> R Pi

A couple examples of the returns I get:

Serial<id=0x76646e30, open=True>(port='/dev/ttyAMA0', baudrate=2400, bytesize=8, parity='N', stopbits=1, timeout=2, xonxoff=False, rtscts=False, dsrdtr=False)
INFO:root:b'\x00\xff\x9a\n\xee\xe4'
INFO:root:b''
INFO:root:Write
INFO:root:b'\xf6'
INFO:root:Write
INFO:root:b''
INFO:root:Write
INFO:root:b'\xf0\xfc'
INFO:root:Write
INFO:root:b'\xe1'
INFO:root:Write
INFO:root:b'\xfa'
INFO:root:Write
INFO:root:b'\xe0\xf2'
INFO:root:Write
INFO:root:b'\xe4'
INFO:root:Write
Serial<id=0x7669de70, open=True>(port='/dev/ttyAMA0', baudrate=2400, bytesize=8, parity='N', stopbits=1, timeout=2, xonxoff=False, rtscts=False, dsrdtr=False)
INFO:root:b'\x00\xff\x9a\xcc\xcc\x00'
INFO:root:b''
INFO:root:Write
INFO:root:b'\xf8\xce'
INFO:root:Write
INFO:root:b'\xcc'
INFO:root:Write
INFO:root:b'\xfe'
INFO:root:Write
INFO:root:b'\xc0\xf0'
INFO:root:Write
INFO:root:b'\xfe'
INFO:root:Write
INFO:root:b'\xfa'
INFO:root:Write
INFO:root:b'\xe8\xe0'
INFO:root:Write

Python Debugging code I am using:

import serial
import logging
from time import sleep

logging.basicConfig
logging.basicConfig(level=logging.DEBUG)

ser = serial.Serial ("/dev/ttyAMA0", 2400, timeout=2, rtscts=False, dsrdtr=False, xonxoff=False)
print(ser)
down = b'\x00\xFF\x9a\x0A\xEE\xE4'
down17 = b'\x00\xFF\x9a\x0A\x0E\x04'

stop = b'\x00\xff\x9A\x0A\xCC\xC6'
status = b'\x00\xFF\x9A\xCC\xCC\x00'

data = status
logging.info(data)

while True:
    received_data = ser.read(8)             #read serial port
    sleep(0.5)
    data_left = ser.inWaiting()             #check for remaining byte
    received_data += ser.read(data_left)
    logging.info(received_data)
    logging.info("Write")
    ser.write(data)   
    sleep(1)    
rummens commented 3 years ago

Turns out there is still plenty things left one can do wrong with Wiring ^^

I forgot the Ground loop to the Pi, meaning the UART circuit was never closed properly. For future readers this is how to connect the Wiring:

VCC Motor --> 7.5V Ground Motor --> Ground Power Supply AND Ground Raspberry Pi (Ping 6) Read Motor --> Transmit Pi (Pin 8) Transmit Motor --> Read Pi (Pin 10)

Note: To understand which cables match which purpose check the ZigBee Board. Close to the plug in which the four motor cables connect, you can find little writing with the cable purpose and position. Otherwise open the motor housing (as explained in this repo) and check the writing there. Read is the red cable, followed in order by Transmit, Ground, VCC