• There's also an X!

    Floris15 hours ago 0 comments

    In the lirc file I use, there is  a large section with some hex-codes, but also a smaller section with so called 'raw codes', see here a snippet with the raw codes for "POWER_ON".

    begin remote
    
          begin raw_codes
    
              name POWER_ON
                  896     853    1792    1749    1792     874
                  874     874     874     874     874    4437
                  874     874     874    1749     896     832
                 1792     874     874     874     874     874
                  874     874     874     874     874     874
                  874    1770     896
    
          end raw_codes
    
    end remote

    My Raspberry Pi, that also has an IR receiver, never understood these. And as they only contained codes I didn't use on the Pi anyway (as I use some other codes to control the Pi) I didn't bother.

    Now it is the other way around, I use a uC to control the amp, so now they became more important.

    When looking at the lirc documentation, the raw codes were just raw pulses and pauses, starting with a pulse. So the code above beneath POWER_ON would send out a 896us pulse, then 853us of pause, 1792us pulse, 1749 pause, and so on. Given that a 1 is encoded as approximately a 889us pause, followed by a 889us pulse and a 0 the other way around, It is not that hard to decode. Which I started on some time ago already.

    (Note, that 889us is based on a 36kHz carrier signal (64/frequency/2; 64 carrier pulses at 36kHz per bit, half of the bit is pulse, half pause). I mentioned in a previous log that the receiver in the Marantz is a 38kHz version. I don't exactly know what is right, the captured raw codes above would indicate a 36kHz signal. Either way, both setting the output to 38kHz and 36kHz work when I put it in my programming. There's quite some tolerance on the input..)

    Knowing the START bit is always a 1, it should start with that. Obviously the first pause is not included, so only half of the START bit is actually in the raw code, then it follows that the start of the code would be 0b1101 0000. And then there's a 4437us pause. Which didn't make sense to me in the RC-5 protocol, as that would be 2.5 bits worth of pause (4437/889 is about 5 half bits). And that's not part of the standard.

    RC-5x

    But that's where the x comes in.

    According to the internet, there is a not very well documented RC-5x protocol standard. There is a reference on kernel.org and a more interesting mailing list discussion, that also contains the image below.

    RC-5x protocol timing
    RC-5x protocol timing

    It is called the "Marantz Extended Data Word" in the discussion, but according to Mona, it is "actually the RC5x protocol". But as said, searching for RC-5x doesn't give a lot of results, definitely a lot less than RC-5.

    And it shouldn't be confused with extended RC-5! Extended RC-5 uses the 2nd start bit (or field bit) as an extra command bit. But extended RC-5 has the same length (14 bits) as normal RC-5.

    RC-5x however has a length of 22 bits. Including 2 bits of spaces, in which the signal doesn't go high at all. And that matched perfectly to my binary code with the mysterious 2.5bit pause above!

    Now the command could easily be finished to 0b1101 0000 ss 0011 0000 0001 (with ss the 2 spaces) or hexidecimal 0xD0301 (with the spaces after bit 8 cut out).

    Sending that to the amp also worked flawlessly (after correcting a few errors I made in the decoding that is), so now POWER_ON also works!

    For completeness, here all 4 decoded raw codes that were listed in the lirc config. Just don't forget to add a 2 bit space after bit 8 when sending.

    • POWER_ON - 0xD0301
    • POWER_OFF - 0xD0302
    • AUX1 - 0xD0006
    • AUX2 - 0xD0007

  • Small victory - Remote control works!

    Floris4 days ago 0 comments

    Yes! So after writing the last project log (and therefore kind of rubber ducking it) I made the changes I proposed over there:

    I made sure I used the correct timings and was connected to the remote input. As the timings are pretty slow for a uC (at least 800us or about 1200 Hz) between setting outputs), I just did it in C++ instead of the PIO-program on the Pico. That way, I better knew what I was doing and was not dependent on my still developing ASM skill. I still want to program it in the PIO later on though.

    Next I tried it out, commented out some things I forgot about and tried again and it just worked!

    A satisfying muting/unmuting of the amp was heard! Muting was my initial test case, since I would be able to hear a relay in the amp clicking from where my desk is.

    But also other commands as setting input source worked flawlessly. 

    On volume control

    Volume needs some fine tuning though. Sending the volume up/down command works perfectly, but there's some mechanics in play: this amplifier has a physical, motorised volume knob connected to a double 50k-potmeter. So, when you turn the volume up and down by hand, you rotate the potmeter, when you do it by remote, the amp enables a small motor to rotate the volume knob. Which you can also see if you use the remote and which is extremely satisfying, but there is some mechanical inertia.

    Quickly a step back in the RC-5 protocol:

    The 3rd bit of the protocol is a Control bit. This one should change on each button press. So for example for the volume up key, the binary string would be:

    • b11 0100 0001 0000 on the 1st press
    • b11 1100 0001 0000  on the 2nd press
    • b11 0100 0001 0000 <pause> b11 0100 0001 0000 <pause> b11 0100 0001 0000 on a 3rd press, combined with holding it down. It'll just repeat until you let go.

    This way, the receiver can differentiate between different presses or a single press that might have been interrupted by something blocking the signal.

    For volume up, that means that with the mechanical inertia, sending 10x a single command of "volume up" (so, with intervals and switching control bits) is not the same as sending a single command of volume up, but repeated 10 times (like a button being held down). The end position of the volume knob will not be the same (given an identical start position).

    For now, I've set it to sending out the message 2 times, which gives me sufficiently small control. All other messages are sent only once as these are 'boolean' messages like (un)mute and setting a source.

    Remote control circuit

    In the last log, I mentioned assuming that the signals that should be sent over the remote connections should follow the RC-5 protocol. This wasn't a random assumption, but was actually based on the schematic of the amp.

    Marantz remote IO schematic with highlighted nets
    Marantz remote IO schematic with highlighted nets

    In the schematic above, I've highlighted some nets for clarity.

    Let's start at the end. The incoming RC-5 signal (purple) connects to the RXRC input of the the control chip (refdes 7401). This active high signal can be pulled to GND (black) by BC547 (7414) on the bottom right.
    This transistor 7414 is activated by either the RC-5 input signal (green) through 47k resistor 3462. That is the connection straight from the remote input connector 1401.
    Or, transistor 7414 is activated by enabling the BC557B 7412. This one is held high from +4.9V (red) through 10k resistor 3459, but can be switched by the IR receiver 7403 through 10k resistor 3461.

    GP1U28XP (refdes 7403) block diagram
    GP1U28XP (refdes 7403) block diagram

    As also shown in the last log, the IR receiver 7403 has an internal pull up to Vcc (+4.9V), when a signal is received it will pull its output to GND.

    Lastly, there is a ENTX signal (yellow) that switches both transistors 7409 and 7410, which would enable transistor 7413 and disable transistor 7412 and 7414. This keeps the RXRC signal high and would probably allow the TXRC (light purple) to become active and switch transistor 7411. I don't know when that one becomes active...

    Read more »

  • Remote functionality

    Floris6 days ago 0 comments

    The RC-5 protocol

    The Marantz amplifier has a remote included (one that has fallen apart like an old Nokia phone I don't know how many times, but still going strong!), an RC8000PM.

    Marantz RC8000PM remote
    Marantz RC8000PM remote

    I hooked that one up to LIRC on my Raspberry Pi a long time ago and according to the configuration file out of the LIRC database (thanks Hans de Jonge!), it uses the RC-5 protocol, built up as a 14 bit command like in the table below. See Wikipedia for the protocol details.

    STARTFIELDCONTROLSYSTEM ADDRESSCOMMAND
    Bits11156

    As I already got the used values from LIRC config: shouldn't be too hard!

    I tried to figure out the schematic and at least found out the remote in and out are connected to the same pins. So, if I measure the output when I trigger it with a remote and mirror the output back to it, that should be all! Unfortunately, I didn't have a scope to check the signal, nor did I want to drag the 14kg amp to a local hackerspace to connect it over there.

    So, I just assumed, that the remote input/output connectors would use the same RC-5 protocol. So I programmed that on a PIO of a Raspberry Pi Pico W, based on the Raspberry Pi Manchester encoding pio example, connected it to either of the remote connectors on the back (they were wired similar anyway!) and tried it out by sending a mute command to the amplifier and... nothing happened.

    Assuming I just made an error I checked the code until it ended up like below, still, nothing though.

     start:
        OUT null, 32           [1]  ; empty OSR before new pull, add delay to finish last bit
        PULL block      side 0      ; set to 0 and (externally) wait for next word
        OUT Y, 5                    ; the amount of data bits, store from OSR in Y
    
    .wrap_target
        get_bit:
            JMP Y-- start
            OUT X, 1                ; Always shift out one bit from OSR to X, so we can branch on it
            JMP !X do_0            
        do_1:
            nop         side 0 [3]  ; Low for 4 cycles (3 delay, +1 for nop)
            JMP get_bit side 1      ; High for 1 cycle. 'get_bit' takes another 3 cycles
    
        do_0:
            nop         side 1 [3]  ; Output high for 4 cycles
            nop         side 0      ; Output low for 1 cycle
    .wrap

    At this point I gave up for a bit and tried finding more information on the RC5 protocol and got to a page on San Bergmans his SB-Projects site. It confirmed the 14 bit command from Wikipedia, but added a bit of information regarding the carrier signal. So, instead of sending a constant on-pulse, it sends a burst of 32 short pulses according to the image below, depending on whether it is a 1 or a 0.

    Initially I falsely assumed, each bit was sent in one cycle (38kHz for the Marantz given that is uses a GP1U28XP (refdes 7403 in the service manual)), but instead, 1 carrier pulse was sent each cycle.  On top of that, the pulse/pause ratio was supposed to be 1/3-1/4 to save power. But that wasn't part of my PIO-program!

    RC-5 carrier signal
    RC-5 carrier signal

    Thinking (in hindsight also incorrectly) that was the problem, I got to programming again and came up with the following, which, spoiler alert, also did nothing. I do want to check if it works like intended when I get my hands on a scope though. So far, it is still untested.

    ; Transmit one bit every 8 cycles. a '0' is encoded as a high-low sequence
    ; (each part lasting half a bit period, or 4 cycles) and a '1' is encoded as a
    ; low-high sequence.
    ;
    ; Side-set bit 0 must be mapped to the GPIO used for TX.
    ; The program starts at the public label 'start'.
    
    .define public RPU 1                    ; ratio pulse
    .define public RPA 3                    ; ratio pause
    .define public PL (RPU+RPA)             ; pulse length, RPU+RPA
    .define public CC 32                    ; cycles
    
    start:
        OUT null, 32        side 0          ; empty OSR before new pull, add delay to finish last bit
        PULL block          side 0          ; set to 0 and (externally) wait for next word
        OUT Y, 5            side 0          ; the amount of data bits, store from OSR in Y
    
    .wrap_target
        get_bit:
            JMP Y-- new_bit side 0 [PL-4]   ; if not 0, get next bit
            JMP start       side 0
        new_bit:
            OUT X, 1        side 0          ; Always shift out one bit from OSR to X, so we can branch on it
            JMP !X do_0     side 0          ;
    
        ; logic 1 starts with 32 silence, then 32 pulses
    ...
    Read more »

  • New power switch and repurposing the button

    Floris11/22/2024 at 14:47 0 comments

    As mentioned in the previous blog, I messed up power switch 1201 when removing the power link 216 from it. See the picture below how it is installed (with the new switch already). It physically connect the button on the front panel, around the large capacitors to the power switch.

    Marantz PM7200 mains PCB with power switch and connected power link (black bar)
    Marantz PM7200 mains PCB with power switch and connected power link (black bar)

    When I removed the power link 216 the first time, I pulled it off when the power switch 1201 was in the depressed state, which broke something internally.

    Luckily, I could order a working spare part for this power switch 1201 through eBay as it was clearly labeled "ALPS SDL1P-D". For a couple of euros and some weeks later this was delivered and ready for installation.

    ALPS SDL1P-D, new one on the left, original one on the right
    ALPS SDL1P-D, new one on the left, original one on the right

    Installation was easy and the weeks that I was without switch I had time to measure the parts, model them and come up with a solution to press the button that I could detect externally.

    What I came up with, was 2 3D-printed parts that would snap over the power switch 1201 and the power link 216. It contains 2 micro switches (2, so the forces are equal on both sides). I've added some edges to the switch-holding side to make sure they wouldn't come out, but that was completely unnecessary and due to the forces one of the corners broke off, so I removed them later again.

    Switch mechanism with 2 micro switches
    Switch mechanism with 2 micro switches

    When installed, it looks pretty snug. A bit too snug actually, as the right side came in contact with the transformer that is placed over there. I had to cut a corner away to make it fit, but it works perfectly. When I press the power button on the front panel, the buttons in the mechanism are triggered and it is easily removable when needed.

    Switch mechanism installed (no wires soldered yet though)
    Switch mechanism installed (no wires soldered yet though)

    I've updated the mechanism with an added chamfer, but won't print them again, as it works as intended. The FreeCAD-files and .stl's can be found on Thingiverse.

    Next step: understanding the remote protocol and finding an undocumented component on the Marantz PCB.

  • Mains switching

    Floris11/21/2024 at 22:03 0 comments

    So, first things first, trying to switch mains to the amplifier.

    As said, I didn't want to modify the amp itself (too much) and wanted the power button to still function. At first I checked the service manual (which contains the complete schematic + PCB layout!) to see if I could rewire the power switch and connect mains downstream of the switch.

    In the excerpts from the manual below, the power button is marked red, refdes 1201.

    It directly switches L, but there is a bridge (refdes 9204, blue arrow) in the schematic that is not present in my version. When placed, this bridge 9204 bypasses the switch 1201 when placed. I guess that's meant for an always on version of the amplifier that can only be put in standby. (Note: When in standby, relay 5202 just downstream of the power switch stays disabled, cutting power to the amplifier stage.)

    These bridges are just a kind of (through hole) jumper wires that can be used to bypass part of the circuit in other version. Perfect for putting my own wire in.

    For the neutral, it wasn't clear to me where I could solder to. There were several points, but I didn´t really know what they looked like. So I opened it up and it seemed that refdes 1223 (blue arrow) was a header post, to which a wire could easily be soldered. So my bypass function shouldn't be a problem!

    While I was disassembling the amp though, I removed the power link (refdes 216, not in pictures below) from the power switch 1201. As the switch itself is almost at the back of the unit, there's a long plastic link, that physically connects the power button on the front with the switch. While removing it though, I broke the power switch 1201, meaning it wouldn't latch on anymore.

    That sucked, because it rendered my amp useless, unless somebody was keeping the switch pressed. So, as a temporary work around, I soldered my bypass wires to a generic JST B2P3-VH, which is also used for mains input connector 1221. That meant I could wire the mains input cord either to connector 1221 on the PCB or to my bypass connector. Now, plugging the other side of the mains cord in an Shelly Plug S, I could switch my amp on and off!

    Marantz PM7200 mains PCB with bypass wires installed
    Marantz PM7200 mains PCB with bypass wires installed

    Problem one fixed! Ish.

    A more permanent fix has yet to follow. Also more on how the power link 216 connects to the power switch 1201 and what I did to bring back power button functionality..

    Part of the Marantz PM7x00/8x00 schematic
    Part of the Marantz PM7x00/8x00 schematic
    Part of the Marantz PM7x00/8x00 mains PCB layout
    Part of the Marantz PM7x00/8x00 mains PCB layout

  • Introduction

    Floris11/21/2024 at 10:55 0 comments

    Years ago, I bought a nice stereo amplifier: a Marantz PM7200. For around €200 on a dutch second hand site, checked by an electrician and in great state.
    What I love about this amplifier, apart from the sound, is its simplicity: it amplifies stereo audio. That's it. No bells and whistles like HDMI inputs, wifi or bluetooth control, not even a tuner. I like this, because those always get outdated. It was introduced around 2004, 20 years ago as I'm writing this, which means that the included extras could be largely obsolete anyway. Hell, even something as an FM-tuner would be near obsolete these days!

    What it does do:

    • 5 line stereo inputs (RCA)
    • 1 phone stereo input (RCA + GND) for a turntable
    • Pre-processor in-/output (bridged together normally)
    • 2 stereo speaker outputs

    If you ask me, technology that is still relevant in 20 years to come.

    A year or so ago, I got sucked in the world of home automation. I personally don't really see the need of automations that detect when I get home and turn on the lights, I mostly use it for making small things in life easier like being able to turn on all my lights at once.

    One requirement I always had though: it should always be controllable without internet. So a lamp should always have a physical switch to control it, additional to wireless control.

    This is also what I want for my amplifier. When I want to turn on my (internet)radio, I can do that using the remote that came with the Marantz. I've built a clock some years back, also featuring a IR receiver and a Raspberry Pi with LIRC to process those commands. The amplifier though, I have to turn on myself, with a physical, clunky switch at the start of the mains circuit of the amplifier. It does feature a standby mode, but I'm not a great fan of it in this amp. I've had it fail on me a couple of times.

    Furthermore, the remote has been showing it's age, especially the volume buttons. I've fixed it with some pencil once which improved it for a while, but it has worn out again, so a goal was born:

    • Be able to switch the amplifier on/off remotely
      • Not by using the standby, but by actually switching mains to the amplifier
      • But as mentioned: also be able to turn it on/off with a physical button!
    • Add volume control
      • So I can also control it while working at home without turning the physical knob
    • Modify the amplifier itself as little as possible
      • Maybe I want to sell it at one point and I want to be able to easily put it back in its original state
      • Apart from that: I definitely do not want to mess with the audio circuit

    A project is born.

    Marantz PM7200 front view
    Marantz PM7200 front view
    Marantz PM7200 back view
    Marantz PM7200 back view