Added a custom instrument now PI panel never full loads and disconnects from air manager

Support for Air Player desktop on ARM devices, like the Raspberry Pi.

Moderators: russ, Ralph

Message
Author
pscarratt
Posts: 32
Joined: Mon May 11, 2020 4:06 pm

Added a custom instrument now PI panel never full loads and disconnects from air manager

#1 Post by pscarratt »

I can only assume my custom instrument is the problem (although it works fine on the main PC where I tested it). Is there anyway to go back without reflashing everything?

Many thanks,

Paul

pscarratt
Posts: 32
Joined: Mon May 11, 2020 4:06 pm

Re: Added a custom instrument now PI panel never full loads and disconnects from air manager

#2 Post by pscarratt »

Little update, any instruments that do load communicate with xplane just fine but the pi won't talk to Air Manager.

Very weird

pscarratt
Posts: 32
Joined: Mon May 11, 2020 4:06 pm

Re: Added a custom instrument now PI panel never full loads and disconnects from air manager

#3 Post by pscarratt »

Further updates: -

I have definately narrowed it down to this instrument (controlling a HW compass) that stops the panel loading on the PI - it works fine on the desktop. PI is connected to an Arduino Mega for the controls.

If anyone has any ideas it would be much appreciated!!

The compass uses a rotary encoder/switch to set initial calibration, the switch after calibration then turns the compass LED on/off

Code: Select all

local Calibration_ok = false
local calib_pos = 0
local my_stepper = hw_stepper_motor_add("compass", "VID66-06", 2048, 30)
local compass_on = 1
local compass_light = hw_led_add("compass light", compass_on)

function compass_adj(direction)
if not Calibration_ok then
calib_pos = calib_pos + (direction/360)
if calib_pos < 0 then calib_pos = 1 end
if calib_pos > 1 then calib_pos = 0 end
local rotate_direction
if direction == 1 then rotate_direction = "CLOCKWISE" else rotate_direction = "COUNTERCLOCKWISE" end
print(rotate_direction)
hw_stepper_motor_position(my_stepper, calib_pos)
end
end

function compass_set()
if not Calibration_ok then
hw_stepper_motor_calibrate(my_stepper, 0)
Calibration_ok = true
end
if Calibration_ok then
if compass_on == 0 then compass_on = 1 else compass_on = 0 end
hw_led_set(compass_light, compass_on)
end
end

function new_heading (heading)
local pos = 1 - (heading/360)
if (Calibration_ok) then
hw_stepper_motor_position(my_stepper, pos, "FASTEST")
end
end


hw_dial_add("compass dial", .5, compass_adj)
hw_button_add("set button", compass_set)

xpl_dataref_subscribe("sim/cockpit2/gauges/indicators/compass_heading_deg_mag", "FLOAT", new_heading)

User avatar
Sling
Posts: 5239
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Added a custom instrument now PI panel never full loads and disconnects from air manager

#4 Post by Sling »

Any reason why you are using an Arduino plugged into the Rpi rather that the Rpi I/O directly?
Last edited by Sling on Tue May 12, 2020 7:19 am, edited 1 time in total.

pscarratt
Posts: 32
Joined: Mon May 11, 2020 4:06 pm

Re: Added a custom instrument now PI panel never full loads and disconnects from air manager

#5 Post by pscarratt »

Hi Sling,

Couple of reasons!

1) I couldn't get clear in my mind the pinout on the GPIO - every diagram I could find seemed to have it different and the numbers available in AM seemed different again :lol:

2) As well as the compass I have a further 6 rotary encoders connected to control the steam gauges

I do have a psu for the arduino arriving today but i don't think it will make any difference

Thanks,

P.S. Weirdly I just had it load all instruments and be fine, went into xplane all good!

Then back into airmanager to tweak a setting and boom PI is lost again. Now when I reboot a random amount of instruments don't finish loading

pscarratt
Posts: 32
Joined: Mon May 11, 2020 4:06 pm

Re: Added a custom instrument now PI panel never full loads and disconnects from air manager

#6 Post by pscarratt »

Managed to SSH to the pi (defaults are pi/raspberry not pi/password as I found elsewhere on the forum), CPU is fine.

Code: Select all


pi@raspberrypi:~ $ top

top - 07:37:00 up 1 min, 1 user, load average: 0.63, 0.25, 0.09
Tasks: 102 total, 1 running, 54 sleeping, 0 stopped, 0 zombie
%Cpu(s): 4.3 us, 9.5 sy, 0.0 ni, 86.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 766748 total, 581540 free, 94336 used, 90872 buff/cache
KiB Swap: 102396 total, 102396 free, 0 used. 618320 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
521 root 20 0 585412 62708 15752 S 51.5 8.2 0:56.15 AirPlayer
682 pi 20 0 8108 3180 2720 R 1.0 0.4 0:00.86 top
643 pi 20 0 11524 3828 3112 S 0.7 0.5 0:00.19 sshd
8 root 20 0 0 0 0 I 0.3 0.0 0:00.18 rcu_sched
60 root 1 -19 0 0 0 S 0.3 0.0 0:00.16 vchiq-slot+
1 root 20 0 28024 5956 4852 S 0.0 0.8 0:01.93 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:+
5 root 20 0 0 0 0 I 0.0 0.0 0:00.04 kworker/u8+
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_+
7 root 20 0 0 0 0 S 0.0 0.0 0:00.12 ksoftirqd/0
9 root 20 0 0 0 0 I 0.0 0.0 0:00.00 rcu_bh
10 root rt 0 0 0 0 S 0.0 0.0 0:00.01 migration/0
11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/1
13 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/1
pi@raspberrypi:~ $ vcgencmd get_throttled
throttled=0x0
pi@raspberrypi:~ $

User avatar
Sling
Posts: 5239
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Added a custom instrument now PI panel never full loads and disconnects from air manager

#7 Post by Sling »

pscarratt wrote: Tue May 12, 2020 7:19 am Hi Sling,

Couple of reasons!

1) I couldn't get clear in my mind the pinout on the GPIO - every diagram I could find seemed to have it different and the numbers available in AM seemed different again :lol:

2) As well as the compass I have a further 6 rotary encoders connected to control the steam gauges

I do have a psu for the arduino arriving today but i don't think it will make any difference

Thanks,

P.S. Weirdly I just had it load all instruments and be fine, went into xplane all good!

Then back into airmanager to tweak a setting and boom PI is lost again. Now when I reboot a random amount of instruments don't finish loading
1/ It will depend on your version of Rpi. The AM hardware id’s are the PIN numbers not the I/O references.

2/ If you have a later RPi you have 24 pins to play with.

pscarratt
Posts: 32
Joined: Mon May 11, 2020 4:06 pm

Re: Added a custom instrument now PI panel never full loads and disconnects from air manager

#8 Post by pscarratt »

"The AM hardware id’s are the PIN numbers not the I/O references." - Ok this is the lightbulb moment! Thanks! :D

I might try it direct on the pi then, its a 3B, I'll report back if it makes any difference.

Thanks again Sling

Paul

pscarratt
Posts: 32
Joined: Mon May 11, 2020 4:06 pm

Re: Added a custom instrument now PI panel never full loads and disconnects from air manager

#9 Post by pscarratt »

Saying that - I can't run a stepper from the PI directly can I? Or is that only if you are not using an interface card like the A4988?

Thanks,

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

Re: Added a custom instrument now PI panel never full loads and disconnects from air manager

#10 Post by SimPassion »

Just for reference and in any case :
viewtopic.php?f=36&t=1079

Image

Gilles

Post Reply