7 segment display Pin outs?

Are you building a cockpit, planning to build one or just dreaming, this is your cockpit builder meeting point

Moderators: russ, Ralph

Post Reply
Message
Author
User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: 7 segment display Pin outs?

#61 Post by jph »

Keith Baxter wrote: Mon Dec 05, 2022 2:14 pm Guys,

If Kirk is simply going to substitute the two 4 digit LEDs for two 3 digit LEDs. and wiring pin for pin then you have to manipulate the string which is 8 characters long. Do not worry about the decimal point. We can fix that in formatting the code.

If however you want the number of decimals to be RIGHT addressed so that the decimals remain in the same position when a 5 character string is displayed 12.987 on a 5 digit display then you have to wire up and format as I have said.

Keith
Hi Keith
You can send exactly the number(s) you want to appear on the display(s), You don't have to do it all in one line of code.
It all depends on how you connect the digits. As said, if using 2 x 3 digit units, then the first digit can be wired with D7 to the left most digit, D6 next, and then D5. The seconds 3 digit block will simply use D4, D3, D2 for its digits from left to right. Simple.
The 2 x 3 blocks together will now work exactly the same as the first 6 digits from the left of an 8 digit standard board.
How can it be simpler than that ?
He can't 'plug them in' to the existing 7219 driver sockets as they are SMD, it would be pointless trying.
if 6 digits, you can then send ANY 6 digit number in the normal order with no formatting at all.
If you want to send 12.987 to a 5 digit display you wire it exactly as above - this time using D7 to D3 left to right digit order. (same as the 8 digit layout)
You then simply need to send
hw_chr_display_set_text(display_chr_id, "12.987")
It honestly cannot get much easier.

edit - oh, just saw your images - I still don't see any issue Keith. If you want to sent " 1000" then send
hw_chr_display_set_text(display_chr_id, " 1000")
As said you don't have to do everything on one line of code. AM is left justifying the number in the first place. If you are spreading the display across multiple digits placed on different pcbs then you simply run it through appropriate code first to get the correct numbers to send.
I think it is possibly of case of 'why are you doing that ?' - answer - because I have always done it that way. -- or 'someone else' does it that way. ;)

Joe
Joe. CISSP, MSc.

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

Re: 7 segment display Pin outs?

#62 Post by Keith Baxter »

Joe,

I am talking about the boards in post #30.

https://www.forums.siminnovations.com/v ... 719#p50719

I am lost as I do not see the SMD LED's ? Peeps simply un-solder and solder in connectors then they have the ability to swap between 4 digit and 3 digit LED's

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 

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: 7 segment display Pin outs?

#63 Post by Kaellis991 »

If you are talking about the .3" displays, they have the crennelations on the edge for pins.
They can also be Surface mounted

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

Re: 7 segment display Pin outs?

#64 Post by jph »

Its a bit of a trick one Keith :D
The devices he has are - I believe -
https://www.aliexpress.com/item/3271971 ... EYCNEb6mK7
They are more rightly classed as 'flat mount / castellated mount" but not really designed for pins. It is also quite usual for the pinout to be non standard as there is no standard. In this case it is similar. Once you get to 5 and 6 digits then it's anyones guess.
A bit confusing.
As for the other matter then I understand the reason for the formatting you are doing in when sending the string to the arduino.
I am simply saying that rather than have it on one line of code, then why not write a function to send the number (presuming it is incorrect in formatting - ie - more than 2 decimal places) to a small function to strip it to the required format THEN send just the number to the 7219 ?. A radio or similar frequency should already be exact in where the decimal point is placed.
Any function can be used over and over again.
It could even be made adjustable by passing parameters.
I am sure that is possible in LUA. I can do it easily with rounding but it gets more difficult to ignore rounding in reducing decimal places although I can't think of a time that would be needed off hand ? :)
Any way, whichever works is good enough as it gets the job done.

Messageport ... :lol: :lol:

Joe
Joe. CISSP, MSc.

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: 7 segment display Pin outs?

#65 Post by Kaellis991 »

@simpassion @Keith Baxter @jph

Hey Guys,

The two (3) digit displays are now connected with a wiring harness and some perfboards to the Max7219 display board.
Using an IDE sketch I am able to get the displays working as shown in the attached images....but now I need some help in getting this transposed over to AM.

There is a hardware function in AM for the 7 segment display using a Max7219. (See attached). @ralph mentioned that there should be such a function in AM.
I created a clone with the hopes of modifying it to work with my display.

Is this the right place to start? There are a number of lines for FSX as well as lines for the standby freq. which I do not need.
Also, this code is for both the COM and NAV. How does that work when I have a separate board for the COM and the NAV displays?
I dont readily see in the hardware code how that is accomplished.
For the two displays, do I daisy chain the second display (NAV) and use just one MAX2719 board?

I can add the code to this discussion if necessary, but I dont remember how to do that.

So where do I begin on modifying this hardware function?
I also need to connect my rotary encoder but not sure how that connects.

Edit: I used the wiki example (see below) connected the A and B side of the encoder to my arduino pins 2 and 3 and connected COM to GND.
Without starting Xplane, how can I tell if this is working? Also in the example it talks about the type of encoder...what type do I have? Is type 2 correct?

display 1R.jpg
image.png
display 3R.jpg
image.png

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

Re: 7 segment display Pin outs?

#66 Post by SimPassion »

Hi Kirk @Kaellis991

at first, I really like this one :)


Image


The script posting is made by using this icon which add tags and we insert the script in the middle of both tags between "][" chars
image.png
image.png (1003 Bytes) Viewed 1018 times

In the mentioned script, we can extract the string format which, I guess, have to be edited accordingly to your own wiring and 2 x 3 Digits displays and X-Plane ?

So this would be specifically this part :

Code: Select all

string.format("%07.03f", com1_act / 1000)
string.format("%07.03f", com1_stby / 1000)
string.format("%07.03f", com2_act / 1000)
string.format("%07.03f", com2_stby / 1000)
string.format("%06.02f", nav1_act / 100)
string.format("%06.02f", nav1_stby / 100)
string.format("%06.02f", nav2_act / 100)
string.format("%06.02f", nav2_stby / 100)
From the section starting line #76 :

Code: Select all

function new_frequencies_xpl(com1_act, com1_stby, com2_act, com2_stby, nav1_act, nav1_stby, nav2_act, nav2_stby, bus_volts, avionics)

    if bus_volts[1] >= 5 and avionics == 1 and sw_power then
        frequency_value["COM1 ACT"]  = spaces_com .. string.format("%07.03f", com1_act / 1000)
        frequency_value["COM1 STBY"] = spaces_com .. string.format("%07.03f", com1_stby / 1000)
        frequency_value["COM2 ACT"]  = spaces_com .. string.format("%07.03f", com2_act / 1000)
        frequency_value["COM2 STBY"] = spaces_com .. string.format("%07.03f", com2_stby / 1000)
        frequency_value["NAV1 ACT"]  = spaces_nav .. string.format("%06.02f", nav1_act / 100)
        frequency_value["NAV1 STBY"] = spaces_nav .. string.format("%06.02f", nav1_stby / 100)
        frequency_value["NAV2 ACT"]  = spaces_nav .. string.format("%06.02f", nav2_act / 100)
        frequency_value["NAV2 STBY"] = spaces_nav .. string.format("%06.02f", nav2_stby / 100)
    else
        frequency_value["COM1 ACT"]  = "        "
        frequency_value["COM1 STBY"] = "        "
        frequency_value["COM2 ACT"]  = "        "
        frequency_value["COM2 STBY"] = "        "
        frequency_value["NAV1 ACT"]  = "        "
        frequency_value["NAV1 STBY"] = "        "
        frequency_value["NAV2 ACT"]  = "        "
        frequency_value["NAV2 STBY"] = "        "
    end

    for i = 1, 2 do
        hw_chr_display_set_text(max_display, i - 1, 0, frequency_value[user_prop_get(displays[i])])
    end

end

xpl_dataref_subscribe("sim/cockpit2/radios/actuators/com1_frequency_hz_833", "INT",
                      "sim/cockpit2/radios/actuators/com1_standby_frequency_hz_833", "INT",
                      
                      "sim/cockpit2/radios/actuators/com2_frequency_hz_833", "INT",
                      "sim/cockpit2/radios/actuators/com2_standby_frequency_hz_833", "INT",
                      
                      "sim/cockpit2/radios/actuators/nav1_frequency_hz", "INT",
                      "sim/cockpit/radios/nav1_stdby_freq_hz", "INT",
                      
                      "sim/cockpit2/radios/actuators/nav2_frequency_hz", "INT",
                      "sim/cockpit/radios/nav2_stdby_freq_hz", "INT", 
                      
                      "sim/cockpit2/electrical/bus_volts", "FLOAT[6]",
                      "sim/cockpit2/switches/avionics_power_on", "INT", new_frequencies_xpl)
From the whole script :

Code: Select all

local displays = { }

displays[1] = user_prop_add_enum("Display 1", "COM1 ACT,COM1 STBY,COM2 ACT,COM2 STBY,NAV1 ACT,NAV1 STBY,NAV2 ACT,NAV2 STBY,NONE", "COM1 ACT", "What should display 1 show")
displays[2] = user_prop_add_enum("Display 2", "COM1 ACT,COM1 STBY,COM2 ACT,COM2 STBY,NAV1 ACT,NAV1 STBY,NAV2 ACT,NAV2 STBY,NONE", "COM1 STBY", "What should display 2 show")
outline     = user_prop_add_enum("Outline", "Left,Center,Right", "Center", "How should the frequencies outline")

use_powersw = user_prop_add_boolean("Power switch", true, "Also use hardware switch for power")
swap1_buttn = user_prop_add_enum("Swap 1", "COM1,COM2,NAV1,NAV2", "COM1", "Which frequencies to swap")
swap2_buttn = user_prop_add_enum("Swap 2", "COM1,COM2,NAV1,NAV2", "NAV1", "Which frequencies to swap")

local frequency_value = { }

frequency_value["COM1 ACT"]  = "        "
frequency_value["COM1 STBY"] = "        "
frequency_value["COM2 ACT"]  = "        "
frequency_value["COM2 STBY"] = "        "
frequency_value["NAV1 ACT"]  = "        "
frequency_value["NAV1 STBY"] = "        "
frequency_value["NAV2 ACT"]  = "        "
frequency_value["NAV2 STBY"] = "        "
frequency_value["NONE"]      = "        "

local spaces_com = ""
local spaces_nav = ""

if user_prop_get(outline) == "Center" then
    spaces_com = " "
    spaces_nav = " "
elseif user_prop_get(outline) == "Right" then
    spaces_com = "  "
    spaces_nav = "   "
end

max_display = hw_chr_display_add("Frequencies", "MAX7219", 2)
local sw_power = true
switch_pwr  = hw_switch_add("Power switch", function(position)
    if user_prop_get(use_powersw) then
        sw_power = position == 1
    end
    
    if fsx_connected() or p3d_connected() or fs2020_connected() then
        request_callback(new_frequencies_fs)
    elseif xpl_connected() then
        request_callback(new_frequencies_xpl)
    end
end)

function swap(channel)
    if user_prop_get(channel) == "COM1" then
        xpl_command("sim/radios/com1_standy_flip")
        fsx_event("COM_STBY_RADIO_SWAP")
        fs2020_event("COM_STBY_RADIO_SWAP")
    elseif user_prop_get(channel) == "COM2" then
        xpl_command("sim/radios/com2_standy_flip")
        fsx_event("COM2_STBY_RADIO_SWAP")
        fs2020_event("COM2_STBY_RADIO_SWAP")
    elseif user_prop_get(channel) == "NAV1" then
        xpl_command("sim/radios/nav1_standy_flip")
        fsx_event("NAV1_RADIO_SWAP")
        fs2020_event("NAV1_RADIO_SWAP")
    elseif user_prop_get(channel) == "NAV2" then
        xpl_command("sim/radios/nav2_standy_flip")
        fsx_event("NAV2_RADIO_SWAP")
        fs2020_event("NAV2_RADIO_SWAP")
    end
end

hw_button_add("Swap 1", function()
    swap(swap1_buttn)
end)

hw_button_add("Swap 2", function()
    swap(swap2_buttn)
end)

function new_frequencies_xpl(com1_act, com1_stby, com2_act, com2_stby, nav1_act, nav1_stby, nav2_act, nav2_stby, bus_volts, avionics)

    if bus_volts[1] >= 5 and avionics == 1 and sw_power then
        frequency_value["COM1 ACT"]  = spaces_com .. string.format("%07.03f", com1_act / 1000)
        frequency_value["COM1 STBY"] = spaces_com .. string.format("%07.03f", com1_stby / 1000)
        frequency_value["COM2 ACT"]  = spaces_com .. string.format("%07.03f", com2_act / 1000)
        frequency_value["COM2 STBY"] = spaces_com .. string.format("%07.03f", com2_stby / 1000)
        frequency_value["NAV1 ACT"]  = spaces_nav .. string.format("%06.02f", nav1_act / 100)
        frequency_value["NAV1 STBY"] = spaces_nav .. string.format("%06.02f", nav1_stby / 100)
        frequency_value["NAV2 ACT"]  = spaces_nav .. string.format("%06.02f", nav2_act / 100)
        frequency_value["NAV2 STBY"] = spaces_nav .. string.format("%06.02f", nav2_stby / 100)
    else
        frequency_value["COM1 ACT"]  = "        "
        frequency_value["COM1 STBY"] = "        "
        frequency_value["COM2 ACT"]  = "        "
        frequency_value["COM2 STBY"] = "        "
        frequency_value["NAV1 ACT"]  = "        "
        frequency_value["NAV1 STBY"] = "        "
        frequency_value["NAV2 ACT"]  = "        "
        frequency_value["NAV2 STBY"] = "        "
    end

    for i = 1, 2 do
        hw_chr_display_set_text(max_display, i - 1, 0, frequency_value[user_prop_get(displays[i])])
    end

end

xpl_dataref_subscribe("sim/cockpit2/radios/actuators/com1_frequency_hz_833", "INT",
                      "sim/cockpit2/radios/actuators/com1_standby_frequency_hz_833", "INT",
                      
                      "sim/cockpit2/radios/actuators/com2_frequency_hz_833", "INT",
                      "sim/cockpit2/radios/actuators/com2_standby_frequency_hz_833", "INT",
                      
                      "sim/cockpit2/radios/actuators/nav1_frequency_hz", "INT",
                      "sim/cockpit/radios/nav1_stdby_freq_hz", "INT",
                      
                      "sim/cockpit2/radios/actuators/nav2_frequency_hz", "INT",
                      "sim/cockpit/radios/nav2_stdby_freq_hz", "INT", 
                      
                      "sim/cockpit2/electrical/bus_volts", "FLOAT[6]",
                      "sim/cockpit2/switches/avionics_power_on", "INT", new_frequencies_xpl)
                      
function new_frequencies_fs(com1_act, com1_stby, com2_act, com2_stby, nav1_act, nav1_stby, nav2_act, nav2_stby, bus_volts, avionics)

    if bus_volts >= 5 and avionics and sw_power then
        frequency_value["COM1 ACT"]  = spaces_com .. string.format("%07.03f", com1_act)
        frequency_value["COM1 STBY"] = spaces_com .. string.format("%07.03f", com1_stby)
        frequency_value["COM2 ACT"]  = spaces_com .. string.format("%07.03f", com2_act)
        frequency_value["COM2 STBY"] = spaces_com .. string.format("%07.03f", com2_stby)
        frequency_value["NAV1 ACT"]  = spaces_nav .. string.format("%06.02f", nav1_act)
        frequency_value["NAV1 STBY"] = spaces_nav .. string.format("%06.02f", nav1_stby)
        frequency_value["NAV2 ACT"]  = spaces_nav .. string.format("%06.02f", nav2_act)
        frequency_value["NAV2 STBY"] = spaces_nav .. string.format("%06.02f", nav2_stby)
    else
        frequency_value["COM1 ACT"]  = "        "
        frequency_value["COM1 STBY"] = "        "
        frequency_value["COM2 ACT"]  = "        "
        frequency_value["COM2 STBY"] = "        "
        frequency_value["NAV1 ACT"]  = "        "
        frequency_value["NAV1 STBY"] = "        "
        frequency_value["NAV2 ACT"]  = "        "
        frequency_value["NAV2 STBY"] = "        "
    end

    for i = 1, 2 do
        hw_chr_display_set_text(max_display, i - 1, 0, frequency_value[user_prop_get(displays[i])])
    end

end

fsx_variable_subscribe("COM ACTIVE FREQUENCY:1", "MHz",
                       "COM STANDBY FREQUENCY:1", "MHz",
                      
                       "COM ACTIVE FREQUENCY:2", "MHz",
                       "COM STANDBY FREQUENCY:2", "MHz",
                      
                       "NAV ACTIVE FREQUENCY:1", "MHz",
                       "NAV STANDBY FREQUENCY:1", "MHz",
                      
                       "NAV ACTIVE FREQUENCY:2", "MHz",
                       "NAV STANDBY FREQUENCY:2", "MHz",
                      
                       "ELECTRICAL MAIN BUS VOLTAGE", "Volts",
                       "AVIONICS MASTER SWITCH", "Bool", new_frequencies_fs)
                       
fs2020_variable_subscribe("COM ACTIVE FREQUENCY:1", "MHz",
                          "COM STANDBY FREQUENCY:1", "MHz",
                      
                          "COM ACTIVE FREQUENCY:2", "MHz",
                          "COM STANDBY FREQUENCY:2", "MHz",
                      
                          "NAV ACTIVE FREQUENCY:1", "MHz",
                          "NAV STANDBY FREQUENCY:1", "MHz",
                      
                          "NAV ACTIVE FREQUENCY:2", "MHz",
                          "NAV STANDBY FREQUENCY:2", "MHz",
                      
                          "ELECTRICAL MAIN BUS VOLTAGE", "Volts",
                          "AVIONICS MASTER SWITCH", "Bool", new_frequencies_fs)

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

Re: 7 segment display Pin outs?

#67 Post by SimPassion »

@Kaellis991, could you post a picture of the plate you've plugged on the MAX7219 driver ?

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

Re: 7 segment display Pin outs?

#68 Post by Keith Baxter »

Hi,

I am getting a bit reluctant to continuing giving advise because peeps keep on second guessing my integrity. Not talking to you Kirk because you do not know and are asking for help.
I already gave you information on using the MAX7219.
If you do not want to listen and use some other method I cannot help.
The hardware Boeing 737-800 radios for the Zibo are in the store are based on a MAX7219 that is right addressed.
It is done this way because all radios are right addressed and it makes no difference if there are 1 digits or 8 digits. You have to wire the D0 pin from the MAX to the right most digit on the display.

A simple string format as such {string.format("% 9.03f",xxx)} in all code using the AM MAX7219 will always right address three decimal places to the right to any number of digits using the current Right indexed library AM uses.

I am over discussing this issue as I have flogged it to death without peeps grasping what I am saying.
@SimPassion fully understands because he put me up to the string formatting.

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 

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: 7 segment display Pin outs?

#69 Post by Kaellis991 »

SimPassion wrote: Sat Dec 10, 2022 5:22 pm @Kaellis991, could you post a picture of the plate you've plugged on the MAX7219 driver ?
First thing I will post an image of what I did to connect everything then start looking at the code.
I just connected machine pin headers to a properly cut-to-size perfboard then added standard dupont pin headers offset 2 rows and connected to the machine pins by the perfboard.

EDIT, the surface mount displays have the crennelations / castlellations and the dupont header pins are connected to the display that way.

display CON1.jpg
display CON2.jpg
display CON3.jpg

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

Re: 7 segment display Pin outs?

#70 Post by Keith Baxter »

Gilles @SimPassion

This is not a proper format for a 8 digit MAX7219 Chinese board that AM currently supports. AM only supports the generic boards which are indexed D7,D6,D5,D4,D3,D2,D1,D0and not the IC which are indexed D0,D1,D2,D3,D4,D5,D6,D7
D0 should always be the starting point on the IC index

Code: Select all

        frequency_value["COM1 ACT"]  = spaces_com .. string.format("%07.03f", com1_act / 1000)
I already gave example previous and the 6 digit display should be wired. D5,D4,D3,D2,D1,D0 and a 4 digit display should be wired D3,D2,D1,D0
Using this convention a standard is set for any number of digits wired to the MAX7219.

Code: Select all

        frequency_value["COM1 ACT"]  = string.format("%09.03f", com1_act / 1000)
When you think about you will understand my reasoning.


Keith
Last edited by Keith Baxter on Sat Dec 10, 2022 5:57 pm, edited 1 time in total.
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 

Post Reply