Is HLF brand legit? - Page 1
Forum section: electronics / general

author: kgavionics
author_rank: Regular Contributor
timestamp: July 05, 2022, 03:48:45 pm
content: HelloI created this custom stereo digital volume control that I hooked to my stm32 black pill, but I'm struggling to make it work! I wrote my bare metal I2C driver, which works with other I2c peripherals, but not with this one. As a matter of fact, I get no I2C activity on my oscilloscope (Both SDA and SCL line stay high). I think that the HLF PT2258 is fake, because I soon I plug an audio source, I get a sound output, but no attenuation!Do you think that this brand is legit ? Do you have any previous experience with this brand?Thanks in advance

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 05, 2022, 06:16:58 pm
content: The reference is legit, but the vendor doesn't seem to be. The original part:http://www.princeton.com.tw/en-us/products/multimediaaudioic/electronicvolumecontroller.aspx(PTC)You probably got this part from Aliexpress or the like. Who knows what this part really is then.I suppose you have the above datasheet and followed it?

author: wraper
author_rank: Unknown
timestamp: July 05, 2022, 06:26:13 pm
content: It's made by Shenzhen honglifa Electronics, have no idea how good of a clone it is. However if it was an outright fake, you would get no audio output at all.

author: wraper
author_rank: Unknown
timestamp: July 05, 2022, 06:38:36 pm
content: Also code2 and code2 pins must be properly connected according to how you address the chip. And your soldering and PCB are dodgy enough that you cannot be sure that pins make a proper electrical contact. I would not suspect the chip as the main possible culprit considering how dodgy your implementation is. None of decoupling capacitors are used either.

author: 8goran8
author_rank: Contributor
timestamp: July 05, 2022, 06:53:03 pm
content: What is your PT2258 power supply voltage? Which pins are you using for i2c?

author: kgavionics
author_rank: Regular Contributor
timestamp: July 05, 2022, 07:01:51 pm
content: All the connections where tested and are good, so maybe the pcb doesn't look good, but should work!Regarding the decoupling cap it's there .On top of that a decoupling cap is not gonna prevent the circuit from working.Furthermore, the circuit was build on bread board and it's not working either.The circuit is 5v powered.I forgot to mention that I followed the schematic on the datasheet and the IC address is 88H.I'm using Pin 6 and 7 ( SDA and SCL).

author: wraper
author_rank: Unknown
timestamp: July 05, 2022, 07:05:20 pm
content: Quote from: kgavionics on July 05, 2022, 07:01:51 pmUnless it's on the bottom side, there is none. Saying that a quite fast digital circuit should work without a decoupling cap is quite optimistic. It could, but far from guaranteed.

author: kgavionics
author_rank: Regular Contributor
timestamp: July 05, 2022, 07:13:45 pm
content: You think 100khz is fast?

author: 8goran8
author_rank: Contributor
timestamp: July 05, 2022, 07:33:02 pm
content: Have you complied with the i2c bus initialization time of at least 200-300ms?"After Power is turned ON, PT2258 needs to wait for a short time in order to insure stability. The waitingtime period for PT2258 to send I 2 C Bus Signal is at least 200ms. If the waiting time period is less than200ms, I 2 C Control may fail."

author: wraper
author_rank: Unknown
timestamp: July 05, 2022, 07:33:29 pm
content: Quote from: kgavionics on July 05, 2022, 07:13:45 pmSquare wave has rise/fall times way faster than 100kHz frequency of I2C, which is not slow either.

author: kgavionics
author_rank: Regular Contributor
timestamp: July 05, 2022, 08:06:40 pm
content: Quote from: 8goran8 on July 05, 2022, 07:33:02 pmyes, I did !By the way, this is my code:Code:#include<stm32f401xc.h>#define SLAVE_ADDR 0x88#define PT2258_CMD_RESET 0xc0#define PT2258_CMD_UNMUTE 0xf8#define PT2258_CMD_MUTE 0xf9void delay_ms(uint16_t t);void I2C1_init(void);int pt2258_send_att(char saddr, char byte1, char byte2);int pt2258_command(char saddr, char command);int main(void){I2C1_init();delay_ms(300); // delay after power on to allow pt2258 to initialize properlypt2258_command(SLAVE_ADDR,PT2258_CMD_RESET ); // 0XC0 IS A COMMAND TO CLEAR THE INTERNAL PT2258 REGISTERpt2258_send_att(SLAVE_ADDR,0x84,0x80); // Send -40 dB attenuation to channel 1pt2258_send_att(SLAVE_ADDR,0x44,0x80); // Send -40 dB attenuation to channel 2while(1){}}This is the pt2258 board schematic:

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 05, 2022, 08:09:43 pm
content: Now that reminds me of another post? Do I remember right?Was this chip not requiring that you send the attenuation in 2 successive commands, one for a 10dB-step value and one for a 1dB-step value? Was it this chip?If so, I do remember this point. You apparently are not sending both values for each channel, so the chip doesn't take the change into account.

author: kgavionics
author_rank: Regular Contributor
timestamp: July 05, 2022, 08:21:06 pm
content: Quote from: SiliconWizard on July 05, 2022, 08:09:43 pmpt2258_send_att(SLAVE_ADDR,0x84,0x80); // Send -40 dB attenuation to channel 1You're right man! But I'm sending -40 dB in the first byte which is 0x84 then I'm sending a 0 dB (0x80) in the second byte then I'm sending a stop bit. See attached imageAccording to datasheet, there's no command to send an attenuation value to more than one channel in the same time (except mute command), so you have to send the attenuation separately to each channel.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 05, 2022, 08:32:04 pm
content: OK, so that was "hidden" in your pt2258_send_att() function.Can you try the "MUTE" command - which should mute all channels - to see if the chip reacts at all to the commands you send?Ideally, if you have a scope, you should take a look at the I2C signals and see what happens on the bus. In particular, whether the chip does acknowledge anything you send.

author: kgavionics
author_rank: Regular Contributor
timestamp: July 05, 2022, 08:39:48 pm
content: Quote from: SiliconWizard on July 05, 2022, 08:32:04 pmI already tried that, but It didn't work!what surprises me, that the board it's outputting sound even if I disconnect the SCL and SDA lines! It's like there is no I2C communication at all between the MCU and the PT2258. I even checked single connection on the board and I didn't find any fault! On top of that, the I2C driver code it's working with the other I2C peripherals (with a little modification of course) , like the PCF8574 IC.I'm going to hook my scope again and see what's going on!

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 05, 2022, 08:44:39 pm
content: Double-check the I2C address. It's sometimes confusing depending on what you're using for driving I2C (a vendor library, your own access to registers, ...) It's a 7-bit address but that needs to be left-shifted, and then add the R/W bit in position 0. Might be obvious to you, but that's a common issue.

author: 8goran8
author_rank: Contributor
timestamp: July 05, 2022, 08:52:09 pm
content: Quote from: kgavionics on July 05, 2022, 08:39:48 pmPlease, check bus activity on your scope regarding PT2258 power on. Maybe your delay_ms routine is not good.

author: kgavionics
author_rank: Regular Contributor
timestamp: July 05, 2022, 11:07:49 pm
content: This is the signal I got! It looks weird to me. I sent 0x88 address, but it looks like is 0x10 according to the screenshot( shot right after startup or reset state) !Honestly, I have no clue, why I'm getting this!!The delay routine is not the culprit, because I increased the delay up to 2s and I have still the same issue!

author: ebclr
author_rank: Super Contributor
timestamp: July 06, 2022, 03:26:47 am
content: Apparently the no legit thing is the piece behind the solder

author: kgavionics
author_rank: Regular Contributor
timestamp: July 06, 2022, 10:52:35 am
content: If you are trying to be funny,you're not!As I said before, the PCB doesn't look good because, it was made for fast prototyping purpose,but the finl product will be different!Furthermore, every single connection was tested and it's good! Do you understand that?

author: 8goran8
author_rank: Contributor
timestamp: July 06, 2022, 12:18:30 pm
content: Can you post the code for I2C1_init()?I think the pt2258 address is not written correctly in the OAR1 register.

author: newbrain
author_rank: Super Contributor
timestamp: July 06, 2022, 12:34:16 pm
content: Quote from: kgavionics on July 05, 2022, 11:07:49 pmThen try sending 0x44 as address - 0x10 looks very much like 0x88 << 1, doesn't it?Heed the advice that SiliconWizard provided!Quote from: SiliconWizard on July 05, 2022, 08:44:39 pm

author: kgavionics
author_rank: Regular Contributor
timestamp: July 06, 2022, 07:34:20 pm
content: Quote from: newbrain on July 06, 2022, 12:34:16 pmAs it may sound weird, sending the address to 0x44, got the circuit working (the IC address is still 0x88). I have no idea why it's happening yet, though!Thank you very much newbrain for the trick! but I have to figure out why this is happening, because it's only happening for the address, not the data!

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 06, 2022, 07:43:41 pm
content: You need to show us the code that handles the I2C peripheral. It probably shifts the I2C address by 1, as I hinted earlier, since I2C addresses are 7-bit but the actual transmitted *byte* is the address (MSb first) and the R/W bit.And glad you got it to work.

author: gamalot
author_rank: Super Contributor
timestamp: July 06, 2022, 07:53:04 pm
content: Read this:https://www.i2c-bus.org/addressing/

author: kgavionics
author_rank: Regular Contributor
timestamp: July 06, 2022, 10:57:57 pm
content: Quote from: SiliconWizard on July 06, 2022, 07:43:41 pmThank you SiliconWizard for your help.The mistake, I made is that have forgotten that the I2C addresses are only 7 bits.Now I know why my code worked on the pcf8574 and not pt2258,because the latter has a address of 0x27, but the pt2258 has 0x88 ( which exceeds 7 bits).Anyways, Now I know what was the culprit!Anyways, thanks again guys for your help.

author: newbrain
author_rank: Super Contributor
timestamp: July 07, 2022, 07:21:32 am
content: Quote from: gamalot on July 06, 2022, 07:53:04 pmTo the OP support it must said that that data sheets are not consistent in the way the address is defined, the PT2258 gives the 8 bit left aligned format, while, e.g. the PCF8574 bus expander gives the 7 bit right aligned format.Same goes for vendor libraries, though the most part I have encountered require the right aligned format.There only one way to make sure: check the DS for a picture of the address bits "on the wire" with the R/W bit, and check the library to understand what is required.(or just try and see if you get the ACK bit...)Quote from: kgavionics on July 06, 2022, 07:34:20 pmThat's because with I2C the address is sent together with the Read/Write bit as the first byte of a transaction.The R/W bit is in position 0, bits 1 to 7 contain the seven bit address, hence the doubt about giving the address left or right aligned in docs and code.For data, all 8 bits in the octet are used for a single byte - no ambiguity here.