HMI:Rotary Module - Tethered .NET and Python - Values not changing

I have found some time to start exploring the recently arrived DUELink Essentials Kit. Thank you to the GHI Team.

All the modules have been updated to the latest firmware (v00.71) and drivers. The HMI:Rotary module works as expected using the demo script in Standalone configuration and the module is the first and only module in the Daisylink, from the USB Hook.

When using the .NET and Python demo programs in Tethered configuration, the button presses are detected and reported, but the “distance” value remains unchanged and not displayed (other than initially if it changes from the initialized value (0)).

I have checked the Sensors:Distance module in both Standalone and Tethered (.NET) configuration using the demo script and program and both configurations worked as expected.

I also noted that the USB Com Port doesn’t always exit cleanly after breaking the while (true) loop. Often had to use the Console to connect and then disconnect from the module for

var duelink = new DUELinkController(availablePort);

to be successful.

P.S. The Ghizzy and Holiday Tree modules were a big hit with the grandchildren over the holidays :slight_smile: . Thank you.

2 Likes

Glad you had fun with the tree and ghizzy :grin:

In summary, rotary works fine standalone using a script but the fails with tethered to a PC using Python. We will verify on our end.

What I love about this post is that you have a full grasp on the entire setup, without asking as for any help. Please let us know if you have any pointers for improving the docs.

By the way, have you tried MicroBlocks? It is a lot of fun for younger ones.

I just copied and pasted the current code. It works in both C# and Python. Did you change the sample code?

Since the kit setup is that the distance sensor is the first module and the N18 is the second one, please disconnect all other modules and keep only the distance sensor and the N18.

Print something to the console and show something to the N18.

Remove all code related to other modules (SetServo, PlaySound, R16, Rotary, etc.). When the code tries to communicate with a non-existent module, a timeout occurs, it will drive you to different issue; the default timeout is 3 seconds.

Edit:

  • Make sure that when updated the firmware, also update the driver as well. Because when erased firmware, driver is erased to (by using Erase All or Memory Clear), so the sample calls driver that is gone then return 0 value.

*** RESOLVED ***
I didn’t fully appreciate the comment at the beginning of the rotary tethered code example.

// Note:
// The rotary driver uses interrupts, so DUEScript user code must remain in a while-loop indefinitely.
// Append the while-loop below to ensure the user code stays in a while-loop indefinitely if the device does not already have one.
// /////// User code //////
// Asio(1) # Allow communication between host and device
// while (1) # while loop indefinitely
// Wait(1000)
// wend

When I loaded (via Console) the following into Region 1 - User on the rotary module:

Asio(1) # Allow communication between host and device
while (1) # while loop indefinitely
Wait(1000)
wend

The rotary value became available.

Dat, Thank you.

Gus, I think between the current documentation, the forum discussions, and experience (nothing beats using the examples and experimenting) everything is there. I think a step-by-step tutorial would help put all the pieces in place and help understand the interplay between the host and modules.
On your other question, I have only used MicroBlocks in a very limited way. A 2026 task is to learn more so I can start to teach the grandchildren.

1 Like

Yes,

Because the rotary encoder needs interrupts, and interrupts in DUELink require an indefinite while loop.

When the board stays in the while loop, it is blocked, so we need Asio(1), which allows commands to be injected from the host.

Just an explanation, if you’re wondering why.

1 Like

Also, as discussed in an earlier forum thread, a loop is also necessary for the scheduler to work.

1 Like