Skip to content

SPI communication between ESP32 and TLE5012B magnetic encoder #15164

Discussion options

You must be logged in to vote

I managed to solve it myself so here is a super simple but functional program in micropython that gets the angle. It took me long enough.

from machine import Pin, SoftSPI
import time

class TLE5012B() :
    def __init__(self,sck_pin=2,mosi_pin=13,miso_pin=15,cs_pin=4):
        self.spi = SoftSPI(baudrate=8000000, sck=Pin(sck_pin), mosi=Pin(mosi_pin), miso=Pin(miso_pin))          #defining the SPI object
        #self.spi.init()
        self.cs = Pin(cs_pin,mode=Pin.OUT, value=1) #defining chip select pin
        self.rotation_counter = 0
        self.previous_angle = 0
        self.start_angle = 0
        self.zero()
        
    def zero(self):
        self.start_angle = self.get_angle_d…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by michaelboatboy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Other
Labels
None yet
1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy