Rotary Encoders stopped working after update to 4.1

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

Message
Author
LittleWing918
Posts: 7
Joined: Sat Nov 12, 2022 4:58 pm

Rotary Encoders stopped working after update to 4.1

#1 Post by LittleWing918 »

Hi all -

I have four rotary encoders connected to an Arduino Mega that have always functioned fine with 3.7. Yesterday I completely uninstalled 3.7 and updated to 4.1.
I flashed and added the Arduino just fine.
Under Create / Edit, I created a new script and pasted the one I had been using in 3.7 to control the rotary encoders.

The system sees my Arduino but when I 'Play' the script and attempt to turn the encoders, they don't show any actions in the Console window at all.

I know it's not my Arduino and encoder setup because I've since uninstalled 4.1 and gone back to the 3.7 version and all works like a charm as before.

Did something change between the two versions that I'm unaware of? I can't find anything online to help me.

SimPassion
Posts: 5339
Joined: Thu Jul 27, 2017 12:22 am

Re: Rotary Encoders stopped working after update to 4.1

#2 Post by SimPassion »

LittleWing918 wrote: Sat Nov 12, 2022 5:05 pm Hi all -

I have four rotary encoders connected to an Arduino Mega that have always functioned fine with 3.7. Yesterday I completely uninstalled 3.7 and updated to 4.1.
I flashed and added the Arduino just fine.
Under Create / Edit, I created a new script and pasted the one I had been using in 3.7 to control the rotary encoders.

The system sees my Arduino but when I 'Play' the script and attempt to turn the encoders, they don't show any actions in the Console window at all.

I know it's not my Arduino and encoder setup because I've since uninstalled 4.1 and gone back to the 3.7 version and all works like a charm as before.

Did something change between the two versions that I'm unaware of? I can't find anything online to help me.
Could you please post your logic.lua, so we could confirm on our side ?

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Rotary Encoders stopped working after update to 4.1

#3 Post by Keith Baxter »

Hi,

Did you update the plugin? And did you reflash the Arduino?

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

LittleWing918
Posts: 7
Joined: Sat Nov 12, 2022 4:58 pm

Re: Rotary Encoders stopped working after update to 4.1

#4 Post by LittleWing918 »

I did re-flash the Arduino and it shows up that it's connected. I also have the latest plugin installed on both XP-11 and XP-12.

Here's the script. It works great on 3.7 but doesn't do anything on 4.1.
When I turn the encoders, they show up in the Console window going 'clockwise' or 'counterclockwise' in 3.7.
In 4.1 the console window doesn't show anything.


function dial_vor1_callback(direction)
if direction == 1 then
xpl_command("sim/radios/obs1_down")
print("clockwise")
elseif direction == -1 then
xpl_command("sim/radios/obs1_up")
print("counterclockwise")
end
end

hw_dial_add("ARDUINO_MEGA2560_A_D28", "ARDUINO_MEGA2560_A_D29", dial_vor1_callback)

function dial_vor2_callback(direction)
if direction == 1 then
xpl_command("sim/radios/obs2_down")
print("clockwise")
elseif direction == -1 then
xpl_command("sim/radios/obs2_up")
print("counterclockwise")
end
end

hw_dial_add("ARDUINO_MEGA2560_A_D27", "ARDUINO_MEGA2560_A_D26", dial_vor2_callback)

function dial_heading_indicator_callback(direction)
if direction == 1 then
xpl_command("sim/instruments/DG_sync_up")
print("clockwise")
elseif direction == -1 then
xpl_command("sim/instruments/DG_sync_down")
print("counterclockwise")
end
end

hw_dial_add("ARDUINO_MEGA2560_A_D23", "ARDUINO_MEGA2560_A_D22", dial_heading_indicator_callback)

function dial_headingbug_callback(direction)
if direction == 1 then
xpl_command("sim/autopilot/heading_up")
print("clockwise")
elseif direction == -1 then
xpl_command("sim/autopilot/heading_down")
print("counterclockwise")
end
end

hw_dial_add("ARDUINO_MEGA2560_A_D24", "ARDUINO_MEGA2560_A_D25", dial_headingbug_callback)

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Rotary Encoders stopped working after update to 4.1

#5 Post by Keith Baxter »

Hi,

If you operate the dials/encoders via the console does it work. If it does then you have a arduino issue.

Try and re-flash and make sure they are connected.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Ralph
Posts: 7921
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Rotary Encoders stopped working after update to 4.1

#6 Post by Ralph »

Your first step is to confirm if your script works by adding prints. Also as Keith mentioned, see if it works with a software dial.

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Rotary Encoders stopped working after update to 4.1

#7 Post by Keith Baxter »

Ralph wrote: Sat Nov 12, 2022 6:34 pm Your first step is to confirm if your script works by adding prints. Also as Keith mentioned, see if it works with a software dial.
Ralph the code is fine. I tested in create/edit and his print statements work 100%

It is a arduino connection issue.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

LittleWing918
Posts: 7
Joined: Sat Nov 12, 2022 4:58 pm

Re: Rotary Encoders stopped working after update to 4.1

#8 Post by LittleWing918 »

The Arduino shows that it's connected. I've re-flashed it several times to make sure.

Also – I've reverted back to 3.7 three different times now and everything works fine, but when I update to 4.1 each time (reflash the arduino and update plugin) I'm seeing nothing in the console window.

How do I operate it via the Console? (I'm completely stumped)

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Rotary Encoders stopped working after update to 4.1

#9 Post by Keith Baxter »

Hi,

Are you sure the Arduino channel is correct?

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2856
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Rotary Encoders stopped working after update to 4.1

#10 Post by jph »

It is definitely being flashed as mega 2560 "A" ?

edit - ha, thinking on the same lines.
Joe. CISSP, MSc.

Post Reply