Pin.value change is slow

Hello there,
I am currently tring to mimic Dali commands. My poc looks like that.
I loop throw on an array and set a the dout accordingly. My issue is that the code is really slow.
Attached a picture of the output. Is there a way to make it run faster?

command2 = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]

for a in command2:

also I did tried basic dout changes without anything. that wasn’t fast either.


Also tried sdout based on this github issue but I found a lot of unwanted traffic, I can’t adjust a the speed using that protocol, and the output didn’t really made much sense to me.
This was my code:


and this was my output in a broader view first and last spike is unwanted traffic:

and a closer view of the first message:

Thanks in advance,

What baud rate do you have the module set to? I am referring to the BD command?

it is set to 115200 [7]

I would recommend looking at your time.sleep functions.

When I did the simple pin low-high-low test without sleep, it also took 1.6 ms. (second pic)

So if I understand, what you are trying to do is what would be bit banging. Is that correct?

1 Like

Yes, exatly. My goal is to mimic dali commands. which has a baudrate of 2400.

As far as I am aware, the modules are not able to perform that kind of function. At least not as of right now. Instead you would want to use the secondary COM port on the modules that support it.

Can you elaborate a little bit? What is the secondary COM port? Is there a sample code for it? Thank you!
Keep in mind I am using an Xbee3

The XBee 3 Cellular modules offer two com ports. The Primary and a secondary COM port. The Primary is for the Python interface and the direct access COM port. The secondary COM port is for interfacing with the Python interface from or for an external device.

Well we use XB3-24Z8RM-J non cellular, because it will be a node in a mesh network. Puting cellular in every node will increase a the maintanence cost drasticly.
Are you sure that is no way to send out dali command from our board?
Thank you,

You would need to use the Primary UART and a Print function.

Okay, but as I wrote above the primary uart has a lot of unvanted traffic, and also I am not sure how can I send bit array-s on to the primary uart. Maybe my syntax is wrong?


If I do this, beside the unwanted traffic, the output doesn’t have the desired outcome.

I would suggest looking at the Examples.