Wet / Magnetic Compass Questions

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

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

Re: Wet / Magnetic Compass Questions

#11 Post by SimPassion »

bmooneyhan wrote: Sat Mar 18, 2023 8:08 pm Okay, so I found that, thank you. I'm getting the impression that the screenshot is for a new version of AM than I'm running (3.6), as I don't see the same screen. Are you saying that the hardware functionality exists to do this properly in AM 4.x?

Thank you again.

Buddy
image.png
image.png

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

Re: Wet / Magnetic Compass Questions

#12 Post by Ralph »

That's indeed in version 4.

bmooneyhan
Posts: 32
Joined: Tue Jan 08, 2019 8:28 pm

Re: Wet / Magnetic Compass Questions

#13 Post by bmooneyhan »

Hi Ralph,

Yes, I downloaded and installed version 4 as soon as I read it. Looks like there's a lot of other interesting and cool stuff in 4. One question. My code to display on 7-segment displays seems to be acting differently now. As an example, where I used to get "110.500", now I just get ".500", which is displayed on the 4 left-most display digits. Was there a change in how the MAX7219 handles the data, and now I need to pad the string to 8 digits?
Mine are 6-digit PCBs, and I use code that looks like this to output:

Code: Select all

display_chr_id = hw_chr_display_add("MAX7219", 4, "ARDUINO_MEGA2560_B_D26", "ARDUINO_MEGA2560_B_D27", "ARDUINO_MEGA2560_B_D28")

hw_chr_display_set_brightness(display_chr_id,0,0.35)

function com1sb_code(data_code1)
   data_str1 = (data_code1 / 100)
   com1sb_str = tostring(data_str1)
   hw_chr_display_set_text(display_chr_id, 1, 0, string.format("%.3f", com1sb_str))
 end

xpl_dataref_subscribe("sim/cockpit/radios/com1_freq_hz", "int", mycom1_code)
xpl_dataref_subscribe("sim/cockpit/radios/com1_stdby_freq_hz", "int", com1sb_code)
Thanks!

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

Re: Wet / Magnetic Compass Questions

#14 Post by SimPassion »

bmooneyhan wrote: Sun Mar 19, 2023 1:03 pm Hi Ralph,

Yes, I downloaded and installed version 4 as soon as I read it. Looks like there's a lot of other interesting and cool stuff in 4. One question. My code to display on 7-segment displays seems to be acting differently now. As an example, where I used to get "110.500", now I just get ".500", which is displayed on the 4 left-most display digits. Was there a change in how the MAX7219 handles the data, and now I need to pad the string to 8 digits?
Mine are 6-digit PCBs, and I use code that looks like this to output:

Code: Select all

display_chr_id = hw_chr_display_add("MAX7219", 4, "ARDUINO_MEGA2560_B_D26", "ARDUINO_MEGA2560_B_D27", "ARDUINO_MEGA2560_B_D28")

hw_chr_display_set_brightness(display_chr_id,0,0.35)

function com1sb_code(data_code1)
   data_str1 = (data_code1 / 100)
   com1sb_str = tostring(data_str1)
   hw_chr_display_set_text(display_chr_id, 1, 0, string.format("%.3f", com1sb_str))
 end

xpl_dataref_subscribe("sim/cockpit/radios/com1_freq_hz", "int", mycom1_code)
xpl_dataref_subscribe("sim/cockpit/radios/com1_stdby_freq_hz", "int", com1sb_code)
Thanks!
Should have been an internal bug in AM prior to AM 3.7, which was allowing this to work ...

This is not correct :

Code: Select all

hw_chr_display_set_text(display_chr_id, 1, 0, string.format("%.3f", com1sb_str))
Should be something like this :

Code: Select all

hw_chr_display_set_text(display_chr_id, 1, 0, string.format("%03.3f", com1sb_str))
or at least :

Code: Select all

hw_chr_display_set_text(display_chr_id, 1, 0, string.format("%3.3f", com1sb_str))

bmooneyhan
Posts: 32
Joined: Tue Jan 08, 2019 8:28 pm

Re: Wet / Magnetic Compass Questions

#15 Post by bmooneyhan »

Thank you, all working now. Appreciate the help as always.

bmooneyhan
Posts: 32
Joined: Tue Jan 08, 2019 8:28 pm

Re: Wet / Magnetic Compass Questions

#16 Post by bmooneyhan »

Regarding the compass, I have a couple of additional questions.

In the Create/Edit tab, I added the Hardware Function for the wet compass with manual calibration. I configured the pins for the stepper and calibrate button. I configured type, steps, speed. When I run the hardware from here, it functions perfectly, calibration works, rotate to new heading works fine, if I move the plane in xplane, the hardware follows.

When I go back to the panel and Show it, nothing happens at all. At this point there is no compass on the panel. SO, I added the same wet compass with manual calibration to the panel configure all the params and pins the same, still nothing happens. I feel like I'm missing something very simple and obvious, but what?

1. Is the instrument on the panel not tied to the hardware function?
2. Is the hardware function used instead of the instrument?

Thanks,
Buddy

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

Re: Wet / Magnetic Compass Questions

#17 Post by SimPassion »

bmooneyhan wrote: Sun Mar 19, 2023 3:35 pm Regarding the compass, I have a couple of additional questions.

In the Create/Edit tab, I added the Hardware Function for the wet compass with manual calibration. I configured the pins for the stepper and calibrate button. I configured type, steps, speed. When I run the hardware from here, it functions perfectly, calibration works, rotate to new heading works fine, if I move the plane in xplane, the hardware follows.

When I go back to the panel and Show it, nothing happens at all. At this point there is no compass on the panel. SO, I added the same wet compass with manual calibration to the panel configure all the params and pins the same, still nothing happens. I feel like I'm missing something very simple and obvious, but what?

1. Is the instrument on the panel not tied to the hardware function?
2. Is the hardware function used instead of the instrument?

Thanks,
Buddy
Indeed, a hardware instrument is never meant to be displaying something in any case
For this expected purpose, we have to add a standard instrument without the hardware handling to avoid duplicate hardware handling

So :

1 x Instrument with display capability
1 x Instrument with hardware handling

or 1 x Instrument with both display and hardware capabilities

bmooneyhan
Posts: 32
Joined: Tue Jan 08, 2019 8:28 pm

Re: Wet / Magnetic Compass Questions

#18 Post by bmooneyhan »

Hi SP, thanks for that info, still a bit confused.

The hardware instrument runs the motor fine to make the compass move when I run it in the Create/Edit tab. I don't need a compass instrument in my panel for my own use, are you saying that I need a standard compass instrument on the panel to "call" or tie to the hardware instrument?

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

Re: Wet / Magnetic Compass Questions

#19 Post by SimPassion »

bmooneyhan wrote: Sun Mar 19, 2023 3:57 pm Hi SP, thanks for that info, still a bit confused.

The hardware instrument runs the motor fine to make the compass move when I run it in the Create/Edit tab. I don't need a compass instrument in my panel for my own use, are you saying that I need a standard compass instrument on the panel to "call" or tie to the hardware instrument?
Absolutely not, just answered to your request to show something on display

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

Re: Wet / Magnetic Compass Questions

#20 Post by SimPassion »

Just understood : binding in the [Create/Edit] tab is not the same thing than binding the instrument in the Panel through the [Home] tab
So we have to select the hardware instrument in the panel and bind to Arduino inputs for it to work

Post Reply