raplin / DPS-1200FB

Python code to read status from the DPS-1200FB power supply
MIT License
125 stars 33 forks source link

smbus issue with list #2

Closed KHouse75 closed 6 years ago

KHouse75 commented 6 years ago

I'm trying to get this working with smbus but I'm having trouble with the checksum list.

I changed this: return self.i2c.readVar(self.address,writeInts,count) to this: return self.i2c.read_i2c_block_data(self.address,writeInts,count) but read_i2c_block_data is looking for an integer and not a list.

The error returned is an "integer is required" which has to do with the writeInts list.

What's the trick to passing the checksum when using smbus?

I'm able to read the eeprom using i2dump and can see the product info just fine.

In addition to 0x57 and 0x5f, I also see 0x4f.

raplin commented 6 years ago

have look at https://github.com/kplindegaard/smbus2 Example 6: "Dual i2c_rdwr"; they write two bytes (you want to write reg and checksum) then read two.

KHouse75 commented 6 years ago

Thanks! I'm getting a little further now. I'm able to query values but I'm getting 0 for most everything. If I write an incorrect checksum, I get 55 so it seems to be working. The only value that fluctuates is 0x0e:["TEMP2_INTERNAL_FARENHEIT",32.0]. It'll vary from 75 to 79.

I was also able to change fan speed.

I don't think it should matter but I don't have anything hooked up to the power supply. I'd expect to be seeing values other than 0 for most everything.

I dumped the checksums and used i2cset and i2cget with the same results.

I'm using a DPS-1200FB-1. The only difference being it's 80 Plus Platinum certified.

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 01 00 00 01 05 0e 00 eb 01 04 19 63 b9 79 c0 c0    ?..???.????c?y??
10: c0 ca 35 37 39 32 32 39 2d 30 30 31 c8 30 35 2f    ??579229-001?05/
20: 31 39 2f 30 39 c1 00 24 01 09 19 c5 44 45 4c 54    19/09?.$????DELT
30: 41 da 48 50 20 50 4f 57 45 52 20 53 55 50 50 4c    A?HP POWER SUPPL
40: 59 20 20 20 20 20 20 20 20 20 20 20 ca 35 37 38    Y           ?578
50: 33 32 32 2d 42 32 31 c2 30 31 ce 35 41 56 44 43    322-B21?01?5AVDC
60: 30 41 34 44 30 45 30 36 33 00 00 c1 00 00 00 4f    0A4D0E063..?...O
70: 00 02 18 12 d4 b0 04 a0 05 1e 05 28 23 90 33 50    .??????????(#?3P
80: 46 20 67 2f 3f 0a 1a a0 15 00 00 00 00 01 02 0d    F g/?????....???
90: b2 3e 01 ce 04 74 04 ec 04 78 00 64 00 10 27 01    ?>???t???x.d.?'?
a0: 02 0d ef 01 82 b0 04 38 04 28 05 78 00 00 00 fa    ???????8?(?x...?
b0: 00 d0 82 12 5f 3d 0b 00 00 03 20 03 c0 13 80 85    .???_=?..? ?????
c0: 00 00 00 00 00 00 50 48 01 02 31 b0 1c 00 00 00    ......PH??1??...
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50    ...............P
raplin commented 6 years ago

is the power supply actually running? i.e. if you don't do the jumpering on the back connector to make it fully turn on it's just in standby mode and won't be outputting 12v and will return 0 for most things, IIRC.

KHouse75 commented 6 years ago

The adapter I'm using shows 12V. It's always on and has no power switch. I hooked it up to my rig and I'm currently running about 800 Watts through it. A couple more of the values are no longer showing 0 such as amps out. I tested the adapter with a 460W hp server power supply and I get the same results.

I do have a different style power adapter that had a on off switch. I'll give that one a try to see what happens.

DeviousPenguin commented 6 years ago

KHouse75 did you get it working in the end? With the 1200W platinum unit? I'm using the same unit and cannot get it to communicate with my Raspberry Pi.

By the sounds of it you're using a breakout board, can I ask which one you're using if you are? I've got pins 30,31 and 32 from the PSU connected to my Raspberry Pi, but i2cdetect -y 1 isn't finding any devices. I've tried connecting the same RPi so another I2C device (servo driver) and it sppears on the I2c bus correctly, so I can only assume it's the PSU that's not responding to the I2C signals.

The breakout board I'm using is listed on ebay as the first result for "DPS-1200FB/QB A Power Supply Breakout Board Adapter 12 ports", and the SDA and SCL pins are unused by the circuit, they don't appear to be connected to anything. Pin 30 is connected to some semiconductors, but I've checked pin 30 with a multimeter and it's 0v.

I have more than 1 of these PSU's so I'm going to test one without the breakout board shortly and see if I can get it to show up on the I2C bus, but it would be nice to know if you got the 1200w platinum PSU work or not.

Thanks

KHouse75 commented 6 years ago

I'm using one similar but with 8 ports. I bought it on ebay but it's no longer listed. This is it here: https://www.parallelminer.com/product/x6-breakout-board-adapter-compatible-with-hp-750w-1200w1500watt-hp-power-supply/

The only pins connected to anything are the ones going to the + and - strips. The others have no traces. I just soldered wires on to 30, 31 and 32 and plugged them up to the Pi.

Did you enable I2C on the Pi?

KHouse75 commented 6 years ago

I never did get it to work. I decided to just use an esp8266 and PZEM-004T to monitor and report energy consumption.

DeviousPenguin commented 6 years ago

Yep I've got I2C is enabled in raspi-config and I've also tried connecting up an I2C device (adafruit PWM servo driver) to it shows up using address 0x40 and 0x70. Double and triple checked the wiring. I've just 2 minutes ago connected it without the breakout board, just directly to the PSU and still no I2C devices.

I was pretty much ready to give up at this point, so I thought I'd swap around the SDA and SCL pins so that pin 32 (end pin) on the PSU is connected to SCL and pin 31 is connected to SDA. I expected the worst, stood back, turned everything on, no burning smell or magic smoke, and I now have 3 I2C addresses being used, before it was totally blank:

$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 4f
50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- 5f
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

So it looks like HP/Delta may have swapped the SDA and SCL on the 1200w platinum units, I'll try this script now and also see what's in the 0x4F address. Thanks :)

KHouse75 commented 6 years ago

I totally forgot that I also had to swap SDA and SCL to get things working.

DeviousPenguin commented 6 years ago

No problem, I tried pretty much everything else. At least I know I'm not going crazy now questioning if I had the wires the wrong way around the entire time.

FWIW I did find someone has forked this repo and has updated it with the smbus import here: https://github.com/rpcjacobs/DPS-1200FB/blob/smbus/DPS-1200FB-smbus.py I tried it but it didn't work for me, I get a

(<type 'exceptions.TypeError'>, 'DPS-1200FB-smbus.py', 109)
(<type 'exceptions.TypeError'>, 'DPS-1200FB-smbus.py', 226)
r 2c er 'NoneType' object is not iterable

error, it's probably something simple, if I get it working I'll post an update.

Heppie commented 6 years ago

@DeviousPenguin Let me know how you get on, having the same problem with RPi and python is a new language to me.

I am trying this code against a DPS750EB which has the same i2c addresses for the PIC and EEPROM. Hopefully when it is up and running it will turn out that it uses the same registers.

KHouse75 commented 6 years ago

I found that fork but I don't think it's functional unless they also modified smbus. I had to modify the code to get around that error to get to the actual error.

I ended up using https://github.com/kplindegaard/smbus2 but was getting mostly 0 returned for everything. I'm sure it was being queried properly because the wrong checksum would produce 55 for all queries. I was also able to change fan speed with no issues.

smbus2 may just be returning data that I'm parsing improperly but I haven't tried troubleshooting further.

Heppie commented 6 years ago

@KHouse75 Could you possibly upload the code you modified?

raplin commented 6 years ago

uploaded a modified version that uses the regular "smbus2" python library.