Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K1 AIOC Hardware Rev 1.2 #93

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

K1 AIOC Hardware Rev 1.2 #93

wants to merge 14 commits into from

Conversation

skuep
Copy link
Owner

@skuep skuep commented Oct 27, 2024

As you might know I am still in the works for an updated K1 AIOC Hardware. This is still untested!

There have been requests that allow the input/output gain/attenuation be set by software e.g. to control radios that have line level inputs/outputs.

I have started to make changes and named them rev. 1.2. See this schematic
Screenshot 2024-10-27 at 09-28-22 k1-aioc-schematic-rev1 2 pdf

The idea is to use the internal OPAMP to add gain to the 1:2 divider on the input. However the biasing needs to be adjusted to be always at mid-level of the full-scale, so I am planning to use the second OPAMP and the internal calibration feature to do just that.

For the output, I changed to having line-level output if the DAC_ATTEN signal is open drain, and if it is pulled to ground, it should output mic levels.

Let me know if you are interested in this feature and would be able to test the line-level portion, but maybe also the "old" functionality with regular K1 HTs.

@skuep
Copy link
Owner Author

skuep commented Oct 27, 2024

Added an RC-lowpass on the bias net to reduce noise

Screenshot 2024-10-27 at 13-40-35 k1-aioc-schematic-rev1 2-1 pdf

@skuep
Copy link
Owner Author

skuep commented Nov 3, 2024

I did the switch to a different USB Type-C socket, that will hopefully be easier to (second-) source in China.
Thanks to @lexszero from PR #68 and @rhgndf from issue #95

@Patronics
Copy link

Any rough estimates of a timeline for finalizing this variant? I'd definitely be interested in giving it a try, happy to tinker or help with the design a bit if needed!

@skuep
Copy link
Owner Author

skuep commented Nov 20, 2024

I am planning to do testing and required firmware work around Christmas.

@samoyedfranek
Copy link

samoyedfranek commented Nov 28, 2024

I am planning to do testing and required firmware work around Christmas.

so i shouldn't buy 1.2 from jlcpcb at this moment?

@skuep
Copy link
Owner Author

skuep commented Nov 28, 2024

You can, but it will only work after I get those changes in and there is even a slight chance I did a boo-boo. 😁

So in short: you shouldn't, yet

@skuep skuep mentioned this pull request Dec 3, 2024
@Radio-X24
Copy link

You can, but it will only work after I get those changes in and there is even a slight chance I did a boo-boo. 😁

So in short: you shouldn't, yet

I've tested most of the current features, working well obviously you're the professional and will improve the firmware and possibly find bugs however for me I've not hit any brick walls yet.

1.3.0 RC2

@skuep
Copy link
Owner Author

skuep commented Dec 3, 2024

If you are okay with the audio output being line level and not mic level and the audio input probably being distorted due to the missing DC bias with the old firmware, sure go ahead 😅

@skuep
Copy link
Owner Author

skuep commented Jan 4, 2025

Alrighty, Hardware V1.2 looks very promising. I have had some time to play around and implement the RX gain and TX boost features in firmware. Sorry for not getting to that earlier, looks like I got myself the cold on the Christmas holidays.

This allows the K1 AIOC now to have configurable RX gain (1x,2x,4x,8x,16x) and a TX signal booster (switch to line level instead of default mic level output).

See this updated script from the release page (removed all the GPIO and PTT stuff)

import sys
import hid
from struct import Struct
from enum import IntEnum, IntFlag

class Register(IntEnum):
    MAGIC = 0x00
    USBID = 0x08
    AIOC_IOMUX0 = 0x24
    AIOC_IOMUX1 = 0x25
    CM108_IOMUX0 = 0x44
    CM108_IOMUX1 = 0x45
    CM108_IOMUX2 = 0x46
    CM108_IOMUX3 = 0x47
    SERIAL_CTRL = 0x60
    SERIAL_IOMUX0 = 0x64
    SERIAL_IOMUX1 = 0x65
    SERIAL_IOMUX2 = 0x66
    SERIAL_IOMUX3 = 0x67
    AUDIO_RX = 0x72
    AUDIO_TX = 0x78
    VPTT_LVLCTRL = 0x82
    VPTT_TIMCTRL = 0x84
    VCOS_LVLCTRL = 0x92
    VCOS_TIMCTRL = 0x94

class Command(IntFlag):
    NONE = 0x00
    WRITESTROBE = 0x01
    DEFAULTS = 0x10
    RECALL = 0x40
    STORE = 0x80

class PTTSource(IntFlag):
    NONE = 0x00000000
    CM108GPIO1 = 0x00000001
    CM108GPIO2 = 0x00000002
    CM108GPIO3 = 0x00000004
    CM108GPIO4 = 0x00000008
    SERIALDTR = 0x00000100
    SERIALRTS = 0x00000200
    SERIALDTRNRTS = 0x00000400
    SERIALNDTRRTS = 0x00000800
    VPTT = 0x00001000

class CM108ButtonSource(IntFlag):
    NONE = 0x00000000
    IN1 =  0x00010000
    IN2 =  0x00020000
    VCOS = 0x01000000

class RXGain(IntEnum):
    RXGAIN1X = 0x00000000
    RXGAIN2X = 0x00010000
    RXGAIN4X = 0x00020000
    RXGAIN8X = 0x00030000
    RXGAIN16X = 0x00040000

class TXBoost(IntEnum):
   TXBOOSTOFF = 0x00000000
   TXBOOSTON = 0x00000100

def read(device, address):
    # Set address and read
    request = Struct('<BBBL').pack(0, Command.NONE, address, 0x00000000)
    device.send_feature_report(request)
    data = device.get_feature_report(0, 7)
    _, _, _, value = Struct('<BBBL').unpack(data)
    return value

def write(device, address, value):
    data = Struct('<BBBL').pack(0, Command.WRITESTROBE, address, value)
    device.send_feature_report(data)

def cmd(device, cmd):
    data = Struct('<BBBL').pack(0, cmd, 0x00, 0x00000000)
    device.send_feature_report(data)

def dump(device):
    for r in Register:
        print(f'Reg. {r.value:02x}: {read(device, r.value):08x}')

aioc = hid.Device(vid=0x1209, pid=0x7388)

magic = Struct("<L").pack(read(aioc, Register.MAGIC))

if (magic != b'AIOC'):
    print(f'Unexpected magic: {magic}')
    sys.exit(-1)

print(f'Manufacturer: {aioc.manufacturer}')
print(f'Product: {aioc.product}')
print(f'Serial No: {aioc.serial}')
print(f'Magic: {magic}')

if False:
    # Load the hardware defaults
    print(f'Loading Defaults...')
    cmd(aioc, Command.DEFAULTS)

if False:
    # Dump all known registers
    dump(aioc)

if False:
    # Set RX settings
    rxgain = RXGain.RXGAIN4X
    print(f'Setting Audio RX gain to {str(rxgain)}')
    write(aioc, Register.AUDIO_RX, rxgain)

if False:
    # Set TX settings
    txboost = TXBoost.TXBOOSTON
    print(f'Setting Audio TX boost to {str(txboost)}')
    write(aioc, Register.AUDIO_TX, txboost)

if False:
    # Store settings into flash
    print(f'Storing...')
    cmd(aioc, Command.STORE)

Attached is the required firmware: aioc-fw-1.3.0-hw1.2.zip

After changing the RXGAIN/TXBOOST value in the register map, you need to re-start your audio application since this setting is applied on the AIOC upon opening the audio stream.

I also welcome you to try out this firmware on older hardware version. Obviously you don't have those new features, but the default settings are designed such that they work on older hardware versions as well. This means that the new features will be integrated into the standard firmware and will be available publicly upon next official release.

@skuep
Copy link
Owner Author

skuep commented Jan 19, 2025

k1-aioc-pinout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants