transmit specific set of bits from Excel file in Mycropython

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
MariaKats
Posts: 2
Joined: Fri Aug 12, 2022 10:17 am

transmit specific set of bits from Excel file in Mycropython

Post by MariaKats » Fri Aug 12, 2022 10:21 am

Hello.
I am new to Micropython. I already have a code that runs and sends to my Raspberry pi pico a square wave to power an LED.
Now I would like it to send a set of 0 and 1 bits to run the LED. This set of bits are saved in an Excel file.
I am having trouble making my Thonny code firstly to read this Excel file (.xlsx) and then to make my ode read this set of bits..
This is what I am using now to send the square wave to my LED.

def square():
wrap_target()
set(pins, 1)
set(pins, 0)
wrap()


sm = rp2.StateMachine(0, square, freq=1000000, set_base=Pin(21))
sm.active(1)

Hope someone will help, thank you :)

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: transmit specific set of bits from Excel file in Mycropython

Post by scruss » Fri Aug 12, 2022 2:04 pm

I don't know any way of reading an xlsx file in MicroPython: they are zip files with the content encoded in XML in files stored inside. If you save it as CSV, it might not be impossible to parse.

If you're needing the 10 MHz frequency, though, reading from flash and parsing won't be fast enough. You'll probably have to pack the entire bit sequence into RAM and replay it from there.

MariaKats
Posts: 2
Joined: Fri Aug 12, 2022 10:17 am

Re: transmit specific set of bits from Excel file in Mycropython

Post by MariaKats » Fri Aug 12, 2022 2:09 pm

Oh I see..
Thank you for your reply. I will try to find another way to do what I want, instead of using the excel file then :)

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

Re: transmit specific set of bits from Excel file in Mycropython

Post by Roberthh » Fri Aug 12, 2022 2:13 pm

If you want to send pulse trains, this lib may be helpful: https://github.com/robert-hh/RP2040-Exa ... ter/pulses

Post Reply