Read bit stream from a Serial Interface

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
giacomoalbe
Posts: 6
Joined: Thu Dec 22, 2016 10:15 pm

Read bit stream from a Serial Interface

Postby giacomoalbe » Thu Apr 20, 2017 5:04 pm

Hi all!

I'm facing a problem with serial communication with the MicroPython board.

I have a digital sensor that outputs data to a Synchronous Serial Interface (SSI) according to a protocol that's shown in the figure below:

Screen Shot 2017-04-20 at 18.53.46.png
Screen Shot 2017-04-20 at 18.53.46.png (44.31 KiB) Viewed 107 times


As you can see from this datasheet https://ams.com/ger/content/download/438063/1340357/file/AS5045B_Datasheet_EN_v2.pdf the reading of the value is init by an high impulse on a sensor pin and after a period of time (which is written in the datasheet) the sensor starts to output values on the serial line.

Any subsequent reading of the value are init in the same way.

The problem is that this particular protocol is not coded in any MicroPython class, because it's not SPI nor UART nor I2C or any other protocol which is included with MicroPython distribution.

My question is: do I have to make a pyb module or can this task be achieved with only MicroPython?
Further more, I need to know how to give the sensor the CLK, is there any pin on the Micropython? Can I do this with Pythonor do I have to create a module?

If the C module is the only way, can you please point me some documentation on how to do this?

Thanks a lot for your precious help!

Giacomo

User avatar
deshipu
Posts: 975
Joined: Thu May 28, 2015 5:54 pm

Re: Read bit stream from a Serial Interface

Postby deshipu » Thu Apr 20, 2017 5:29 pm

This looks vaguely like I2C. You might check the details, it might be actual I2C (also called IIC or TWI), but they avoid calling it by name because there were trademark and patent issues with it.

Otherwise, you should be able to read that with the SPI peripheral.

User avatar
Roberthh
Posts: 582
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Read bit stream from a Serial Interface

Postby Roberthh » Thu Apr 20, 2017 8:22 pm

You can create the signals CSn, CLK in Python and read also the data back, since the device has no restriction on slow reading. The clock raze that can be achieved depends on the code generator used. Using viper code, about 1 MHz could be possible.

giacomoalbe
Posts: 6
Joined: Thu Dec 22, 2016 10:15 pm

Re: Read bit stream from a Serial Interface

Postby giacomoalbe » Fri Apr 21, 2017 10:15 am

Thank you all for your precious support!

Once I get the sensor to work properly, I'll try with Python!

Maybe a stupid question: what is Viper code? It is something related with programming or is it actual coding language or paradigm?

Thanks again for your precious help!

User avatar
Roberthh
Posts: 582
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Read bit stream from a Serial Interface

Postby Roberthh » Fri Apr 21, 2017 10:20 am

Viper is a function decorator, which causes the python compiler of the device to use a code emitter, which generates effective native machine code. It supports a language subset only, but for bitbanging tasks thsi is very useful. Look here:
http://docs.micropython.org/en/latest/p ... ight=viper


Return to “The MicroPython pyboard”

Who is online

Users browsing this forum: No registered users and 2 guests