Author Topic: Asynchronous Serial on attiny85?  (Read 1232 times)

0 Members and 1 Guest are viewing this topic.

Offline RefrigeratorTopic starter

  • Super Contributor
  • ***
  • Posts: 1652
  • Country: lt
Asynchronous Serial on attiny85?
« on: April 01, 2020, 06:15:04 pm »
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.
« Last Edit: April 01, 2020, 06:22:16 pm by Refrigerator »
I have a blog at http://brimmingideas.blogspot.com/ . Now less empty than ever before !
An expert of making MOSFETs explode.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13419
Re: Asynchronous Serial on attiny85?
« Reply #1 on: April 01, 2020, 06:48:28 pm »
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
« Last Edit: April 01, 2020, 06:50:56 pm by Ian.M »
 
The following users thanked this post: Refrigerator

Offline RefrigeratorTopic starter

  • Super Contributor
  • ***
  • Posts: 1652
  • Country: lt
Re: Asynchronous Serial on attiny85?
« Reply #2 on: April 01, 2020, 07:44:50 pm »
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

Thanks 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.
I have a blog at http://brimmingideas.blogspot.com/ . Now less empty than ever before !
An expert of making MOSFETs explode.
 

Offline RefrigeratorTopic starter

  • Super Contributor
  • ***
  • Posts: 1652
  • Country: lt
Re: Asynchronous Serial on attiny85?
« Reply #3 on: April 01, 2020, 08:01:50 pm »
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.  :D
I have a blog at http://brimmingideas.blogspot.com/ . Now less empty than ever before !
An expert of making MOSFETs explode.
 

Offline WattsThat

  • Frequent Contributor
  • **
  • Posts: 818
  • Country: us
Re: Asynchronous Serial on attiny85?
« Reply #4 on: April 01, 2020, 08:48:27 pm »
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
 

Offline RefrigeratorTopic starter

  • Super Contributor
  • ***
  • Posts: 1652
  • Country: lt
Re: Asynchronous Serial on attiny85?
« Reply #5 on: April 01, 2020, 09:45:51 pm »
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
I 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.
I have a blog at http://brimmingideas.blogspot.com/ . Now less empty than ever before !
An expert of making MOSFETs explode.
 

Offline WattsThat

  • Frequent Contributor
  • **
  • Posts: 818
  • Country: us
Re: Asynchronous Serial on attiny85
« Reply #6 on: April 01, 2020, 11:13:31 pm »
Quote
Also i don't think the arduino library would work on the digispark

Then I would expect you wouldn’t know that Arduino is the manufacturers supported development environment for the DigiSpark :palm:
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf