A question for Ralph or Corjan to answer is can the Arduino and Rpi encoder implementations handle the different quadrature detents per pulse combinations. This will depend on the way the encoder inputs are being read in software. It seems a lot of the encoder examples on the net assume 1 detent per pulse, but 2 per pulse is also common and I've got a grayhill one with 4 detents per pulse. Can we expect all of these variations to work on both the Arduino's and Rpi.
It's possible this is the reason why we have seen some struggles with encoders for some folk.
Alps rotary encoder
Re: Alps rotary encoder
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: Alps rotary encoder
Hi Sling,
I tried the code you posted.
Here is what I got in the console window
-----------------------------------------------
1st detent CW = INFO - The dial turned clockwise
1st detent CCW = INFO - The dial turned counterclockwise
2nd detent CW = INFO - The dial turned counterclockwise
2nd detent CCW = INFO - The dial turned clockwise
etc,
------------------------------------------------
The direction reversed with each detent (CW-CCW-CW-CCW, etc...) after the first detent.
I then tried some new Uno's I purchased today and it worked like a charm. You were right about the pull-up resistors. Not all boards are created equal. I went back to my original board and put in two 10K pull-up resistors. The encoder is now working fine with that board too.
There is still the issue of the Arduino installer not working with the Mega's but Uno's will do fine for this project. I posted about it in the Arduino forum.
Thank you for your help. You saved my RTU project.
Pierre
I tried the code you posted.
Here is what I got in the console window
-----------------------------------------------
1st detent CW = INFO - The dial turned clockwise
1st detent CCW = INFO - The dial turned counterclockwise
2nd detent CW = INFO - The dial turned counterclockwise
2nd detent CCW = INFO - The dial turned clockwise
etc,
------------------------------------------------
The direction reversed with each detent (CW-CCW-CW-CCW, etc...) after the first detent.
I then tried some new Uno's I purchased today and it worked like a charm. You were right about the pull-up resistors. Not all boards are created equal. I went back to my original board and put in two 10K pull-up resistors. The encoder is now working fine with that board too.
There is still the issue of the Arduino installer not working with the Mega's but Uno's will do fine for this project. I posted about it in the Arduino forum.
Thank you for your help. You saved my RTU project.
Pierre
Re: Alps rotary encoder
Your most welcome. I'm glad it's now working.
Can you post the code you finally used. I'm interested to know if you needed frumpys method or if the wiki code worked. I plan to source encoders with the different detent/pulse combinations to experiment with this myself. I'll post something when I finally get round to doing this.
Can you post the code you finally used. I'm interested to know if you needed frumpys method or if the wiki code worked. I plan to source encoders with the different detent/pulse combinations to experiment with this myself. I'll post something when I finally get round to doing this.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: Alps rotary encoder
Very much a work in progress but this is roughly what it will look like. I am still not sure if I will use soft keys or hardware switches for the different functions. I am using a 5.3 inch screen so there is no room for anything on the sides if it's going to fit into the radio bay. Switches and encoders will have to go below the screen. I will use 2 dual encoders for tuning
Here is the encoder related code I have so far. Only COM1 and NAV1 are implemented at the moment. Next will be XPON, ADF, TCAS functions and the second set of radios.
--------------------------------------START
-- RADIO SELECT SWITCHES
radio=0 --encoder is disabled at startup
-- 1 = COM1
-- 2 = NAV1
-- 3 = XPON
-- 4 = ADF
function new_selectcom()
switch_set_state(switch_1, 1)
switch_set_state(switch_2, 0)
--switch_set_state(switch_3, 0)
--switch_set_state(switch_4, 0)
radio=1
end
function new_selectnav()
switch_set_state(switch_1, 0)
switch_set_state(switch_2, 1)
--switch_set_state(switch_3, 0)
--switch_set_state(switch_4, 0)
radio=2
end
-- WHOLE ENCODER
function dial_change(direction)
if direction == 1 and (radio==1)
then
fsx_event("COM_RADIO_WHOLE_INC")
elseif direction == 1 and (radio==2)
then
fsx_event("NAV1_RADIO_WHOLE_INC")
end
if direction == -1 and (radio==1)
then
fsx_event("COM_RADIO_WHOLE_DEC")
elseif direction == -1 and (radio==2)
then
fsx_event("NAV1_RADIO_WHOLE_DEC")
end
end
-- Bind to Arduino pin 11 (encoder A) and pin 10 (encoder B)
hw_dial_add("ARDUINO_UNO_B_D11", "ARDUINO_UNO_B_D10", dial_change)
-- FRACT ENCODER
function dial_change(direction)
if direction == 1 and (radio==1)
then
fsx_event("COM_RADIO_FRACT_INC")
elseif direction == 1 and (radio==2)
then
fsx_event("NAV1_RADIO_FRACT_INC")
end
if direction == -1 and (radio==1)
then
fsx_event("COM_RADIO_FRACT_DEC")
elseif direction == -1 and (radio==2)
then
fsx_event("NAV1_RADIO_FRACT_DEC")
end
end
-- Bind to Arduino pin 13 (encoder A) and pin 12 (encoder B)
hw_dial_add("ARDUINO_UNO_B_D13", "ARDUINO_UNO_B_D12", dial_change)
------------------------------END
Here is the encoder related code I have so far. Only COM1 and NAV1 are implemented at the moment. Next will be XPON, ADF, TCAS functions and the second set of radios.
--------------------------------------START
-- RADIO SELECT SWITCHES
radio=0 --encoder is disabled at startup
-- 1 = COM1
-- 2 = NAV1
-- 3 = XPON
-- 4 = ADF
function new_selectcom()
switch_set_state(switch_1, 1)
switch_set_state(switch_2, 0)
--switch_set_state(switch_3, 0)
--switch_set_state(switch_4, 0)
radio=1
end
function new_selectnav()
switch_set_state(switch_1, 0)
switch_set_state(switch_2, 1)
--switch_set_state(switch_3, 0)
--switch_set_state(switch_4, 0)
radio=2
end
-- WHOLE ENCODER
function dial_change(direction)
if direction == 1 and (radio==1)
then
fsx_event("COM_RADIO_WHOLE_INC")
elseif direction == 1 and (radio==2)
then
fsx_event("NAV1_RADIO_WHOLE_INC")
end
if direction == -1 and (radio==1)
then
fsx_event("COM_RADIO_WHOLE_DEC")
elseif direction == -1 and (radio==2)
then
fsx_event("NAV1_RADIO_WHOLE_DEC")
end
end
-- Bind to Arduino pin 11 (encoder A) and pin 10 (encoder B)
hw_dial_add("ARDUINO_UNO_B_D11", "ARDUINO_UNO_B_D10", dial_change)
-- FRACT ENCODER
function dial_change(direction)
if direction == 1 and (radio==1)
then
fsx_event("COM_RADIO_FRACT_INC")
elseif direction == 1 and (radio==2)
then
fsx_event("NAV1_RADIO_FRACT_INC")
end
if direction == -1 and (radio==1)
then
fsx_event("COM_RADIO_FRACT_DEC")
elseif direction == -1 and (radio==2)
then
fsx_event("NAV1_RADIO_FRACT_DEC")
end
end
-- Bind to Arduino pin 13 (encoder A) and pin 12 (encoder B)
hw_dial_add("ARDUINO_UNO_B_D13", "ARDUINO_UNO_B_D12", dial_change)
------------------------------END
Re: Alps rotary encoder
Are you using original Arduino's or Chinese Arduino clones?
Re: Alps rotary encoder
Chinese Uno`s. They work fine with AM. Had no luck getting Chinese Mega's to work.
Re: Alps rotary encoder
We've only tested with genuine Arduino's. There's so many clones out there that it's impossible to test those. Should all work well with genuine Arduino's.
Re: Alps rotary encoder
Thanks Pierre,
So you are using the standard wiki method and all is good, albeit with additional pull-ups. That's good to know. Do you have the encoder part number handy?
A tip for next time. Try posting any code inside </> code tags as it makes it easier to read.
Thanks
Tony
So you are using the standard wiki method and all is good, albeit with additional pull-ups. That's good to know. Do you have the encoder part number handy?
A tip for next time. Try posting any code inside </> code tags as it makes it easier to read.
Thanks
Tony
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: Alps rotary encoder
Tony,
Noted. Here is the link for the Alps encoders: http://www.alps.com/prod/info/E/HTML/En ... _list.html.
I am using the dual-shaft 30 detent/15 pulse version.
Ralph,
Import duties and taxes on genuine Arduino's are very high here in Thailand. The Chinese ones are so cheap I consider them a disposable product. Agree that it can be a hit and miss thing. Worst case some of them need pull-up resistors.
Regards,
Pierre
Noted. Here is the link for the Alps encoders: http://www.alps.com/prod/info/E/HTML/En ... _list.html.
I am using the dual-shaft 30 detent/15 pulse version.
Ralph,
Import duties and taxes on genuine Arduino's are very high here in Thailand. The Chinese ones are so cheap I consider them a disposable product. Agree that it can be a hit and miss thing. Worst case some of them need pull-up resistors.
Regards,
Pierre
Re: Alps rotary encoder
This code also works with the CTS-288 encoders I use on my MCP (1 increment for every 2 detents). That was the only component I had to run on OC/SIOC. Now I can run my whole cockpit on Arduinos.