[solved] Strange potentiometer behaviour after AM 4.0 upgrade

Support for Arduino in combination with Air Manager and Air Player

Moderators: Ralph, russ

Message
Author
User avatar
Sling
Posts: 4441
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Strange potentiometer behaviour after AM 4.0 upgrade

#11 Post by Sling » Thu Apr 29, 2021 1:10 pm

On the compass code. You need to move the endless rotation command outside of the calibration function to the head of your code just after the motor add. You have been very lucky if this was what you used for a long time and it worked.

altack
Posts: 33
Joined: Mon Nov 21, 2016 1:13 pm

Re: Strange potentiometer behaviour after AM 4.0 upgrade

#12 Post by altack » Thu Apr 29, 2021 1:22 pm

Sling wrote:
Thu Apr 29, 2021 1:10 pm
You need to move the endless rotation command outside of the calibration function to the head of your code just after the motor add.
Roger Wilco !
But what about the Arduino Uno not responding to my LED set command in my previous test ?

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

Re: Strange potentiometer behaviour after AM 4.0 upgrade

#13 Post by Ralph » Thu Apr 29, 2021 2:49 pm

Hard to say, it's not posted as pure Lua script.

altack
Posts: 33
Joined: Mon Nov 21, 2016 1:13 pm

Re: Strange potentiometer behaviour after AM 4.0 upgrade

#14 Post by altack » Thu Apr 29, 2021 3:36 pm

Ok, here is my simple test script:

Code: Select all


-- Wet Compass LED internal ligthing
wc_led = hw_led_add("ARDUINO_UNO_C_D8", 0.0)

    


--BCN LIGHTS
function button_Test_Uno_pressed()
  -- The following print function is not necessary but can help you to verify that the button has been pressed
  print("Button Test_Uno pressed")

  -- Toggle the Beacon FSX and Prepar3D
  fsx_event("TOGGLE_BEACON_LIGHTS")
  hw_led_set(wc_led, 1.0)
end

function button_Test_Uno_released()
  -- The following print function is not necessary but can help you to verify that the button has been pressed
  print("Button Test_Uno released")

  -- Toggle the Beacon FSX and Prepar3D
  fsx_event("TOGGLE_BEACON_LIGHTS")
  hw_led_set(wc_led, 0.0)
end

--Button Hardware section
--++++++++++++++++++++++++++++--

hw_button_add("Button_Test_Uno", button_Test_Uno_pressed, button_Test_Uno_released)
If you can provide a pure LUA script to test a LED light on D8 position, please do so.
Thank you in advance

altack
Posts: 33
Joined: Mon Nov 21, 2016 1:13 pm

Re: Strange potentiometer behaviour after AM 4.0 upgrade

#15 Post by altack » Thu Apr 29, 2021 6:21 pm

I tinkered a little bit my UNO card and reflashed it with another channel just to be sure (use P instead of C) and other pin position for the LED (D12 instead of D8) and retested it, without success.

Since I have an extra MEGA card for an other project, I temporarely used it and flashed it as "P" MEGA and, bingo, I found something interesting:
with the UNO card mentionned in the logic.lua code there is no mention of the LED in the hardware properties window whereas with the MEGA mentionned the LED popup in the hardware properties window and, at last, my small test code runs as advertised (i.e the LED is lighted when pressing my D13 push-button).

Here are screenshots for both situation:

Image

Image

As a matter of fact the LED showing in the hardwarte properties window is not related to the actual connection of the UNO or MEGA card to the PC but only to the code written in the logic.lua window: Is it normal ?
Why the LED isn't showing when the UNO is used ?

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

Re: Strange potentiometer behaviour after AM 4.0 upgrade

#16 Post by Keith Baxter » Thu Apr 29, 2021 10:15 pm

Hi,

In your testing. After you make hardware/code changes do you shut down and restart both sim and AM?


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 

altack
Posts: 33
Joined: Mon Nov 21, 2016 1:13 pm

Re: Strange potentiometer behaviour after AM 4.0 upgrade

#17 Post by altack » Fri Apr 30, 2021 7:18 am

Hi Keith,
AM is restarted after any change (code or hardware). P3Dv4.5 is restarded after major change (harwdware or major code rework) since it is a rather long process.

User avatar
Corjan
Posts: 2371
Joined: Thu Nov 19, 2015 9:04 am

Re: Strange potentiometer behaviour after AM 4.0 upgrade

#18 Post by Corjan » Fri Apr 30, 2021 8:46 am

Hi,


Restarting is not going to help, at least it shouldn't.

The Hardware ID should be ARDUINO_MEGA2560_P_D12 instead of ARDUINO_MEGA_P_D12. That is why it pops up as a hardware property since it is not a valid hardware ID.

I'll test your script today on an Arduino Uno, the scripts seems okay.


Corjan

User avatar
Corjan
Posts: 2371
Joined: Thu Nov 19, 2015 9:04 am

Re: Strange potentiometer behaviour after AM 4.0 upgrade

#19 Post by Corjan » Fri Apr 30, 2021 12:09 pm

Hi,


Seems like the little Arduino ran out of memory...

Would you mind installing this AM BETA version and flash the Arduino within AM:
https://www.siminnovations.com/api4/dow ... n=HOME_USE


Corjan

altack
Posts: 33
Joined: Mon Nov 21, 2016 1:13 pm

Re: Strange potentiometer behaviour after AM 4.0 upgrade

#20 Post by altack » Fri Apr 30, 2021 1:42 pm

Thank you Corjan,
will do so and report ASAP

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests