Page 1 of 1

transmit specific set of bits from Excel file in Mycropython

Posted: Fri Aug 12, 2022 10:21 am
by MariaKats
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 :)

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

Posted: Fri Aug 12, 2022 2:04 pm
by scruss
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.

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

Posted: Fri Aug 12, 2022 2:09 pm
by MariaKats
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 :)

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

Posted: Fri Aug 12, 2022 2:13 pm
by Roberthh
If you want to send pulse trains, this lib may be helpful: https://github.com/robert-hh/RP2040-Exa ... ter/pulses