Asynchronous Serial on attiny85? - Page 1
Forum section: electronics / general

author: Refrigerator
author_rank: Super Contributor
timestamp: April 01, 2020, 06:15:04 pm
content: Can the hardware USI (UART + SPI) interface on the attiny85 work with asynchronous serial signal as in the pic attached below?I'll be honest, i'm not very good with micros but i do like playing around with them very much.The width of one bit is about 555µs so that should be about 1800 baud unless i'm terribly wrong.The signal is what the IR receiver on a RGB LED strip controller receives from the remote, the controller died and i want to turn my Digispark into one.I can do it in software but before i try that i want to find out whether the hardware on the attiny85 can be used to do the same (if not better).Any suggestions?Ps: .txt of the waveform also included, and no, my scope does not do serial decoding, unfortunately.

author: Ian.M
author_rank: Super Contributor
timestamp: April 01, 2020, 06:48:28 pm
content: Almost certainly not. That looks like a variable bit rate protocol with either a '1' represented by a short interval between low-going pulses and a '0' by a long interval or visa-versa.A UART can handle fixed bit rate protocols with a start bit for each word and one or more stop bits between words. Each bit is the same width (with the possible exception of 1.5 bit wide stop bits) and is either high or low. A SPI interface handles clocked serial data, and a slave SPI interface accepts an external clock to set the bit timing. The data is latched on a clock edge. As you don't have separate data and clock signals, a SPI slave interface wont help.First you've got to figure out which of the many IR remote control protocols you've got there, then you need to figure out how to decode it. Maybe start from this Sparkfun Arduino tutorial:https://learn.sparkfun.com/tutorials/ir-communication/all

author: Refrigerator
author_rank: Super Contributor
timestamp: April 01, 2020, 07:44:50 pm
content: Quote from: Ian.M on April 01, 2020, 06:48:28 pmThanks that helped alot.So it looks like it will be easier to do in SW then?Also it seems to match with the bog standard NEC protocol (560µs short and 1690µs long pulses), so as long as i can make my micro read what the remote sends i should be allright i think.

author: Refrigerator
author_rank: Super Contributor
timestamp: April 01, 2020, 08:01:50 pm
content: Also explains why every low pulse is the same length.I wrote this quick and dirty matlab script to help me understand the protocol a little better.

author: WattsThat
author_rank: Frequent Contributor
timestamp: April 01, 2020, 08:48:27 pm
content: There is a decent Arduino library originally written by Ken Shirriff that supports most IR protocols. You’ll find all the bit timing definitions in each protocols .cpp file which might help you avoid re-inventing the wheel.It can be found on github:https://github.com/z3t0/Arduino-IRremote

author: Refrigerator
author_rank: Super Contributor
timestamp: April 01, 2020, 09:45:51 pm
content: Quote from: WattsThat on April 01, 2020, 08:48:27 pmI kinda sorta already did reinvent the wheel, since i've made my matlab script take the raw .txt from my scope and spit out hex.Also i don't think the arduino library would work on the digispark, from what i've seen it can even give problems to the nano due to the timers it uses.I think i might just write my own code, which would be pretty much the same as my matlab script imo, i just need to find out how to utilize the timers in the attiny85 correctly.

author: WattsThat
author_rank: Frequent Contributor
timestamp: April 01, 2020, 11:13:31 pm
content: QuoteThen I would expect you wouldn’t know that Arduino is the manufacturers supported development environment for the DigiSpark