RC3563 IR tester

Announcement - Help us fight the BOTS! Please report all spam including stuff in your inbox!

Wolf

Active member
Joined
Sep 25, 2018
Messages
1,608
Looking now to figure out how to directly implement it into Excel.
I went at it a little differently. Rather than have excel pull the data from the serial port have python write to excel.
Well I got a bit further with @enki's python code.Thank you @enki for that.
Did a bit of research and found an include in python called xlwings.
Bumbling along I found out how to write to an open excel file. Most includes that I found would either create a new excel file or write the data to a closed excel file. This include works on the presently open workbook/excel file. It can also be programed to write to a specific excel book and sheet.
So @Bubba I got as far as writing the data to excel and it works great. The problem is when you pull the cell out the data does not remain.
The update to the 2 fields is dynamic Sure we can copy and paste the data while the cell is in the holder but that defeats the purpose.
Also I am trying to figure out how to write the 2 parameters (mΩ and V) to selected fields or even better to the next empty fields in the designated columbs for IR and V. Once the cell is removed the data is saved to the 2 excel fields and excel progresses to the next empty fields in the columb.
Now mind you it was midnight when this worked and I needed my beauty sleep so there is still a ways to go but I figured I would share what I have done so far. Maybe someone way smarter in programing than me can continue. I will bumble along till it works though.
Wolf
python.PNGpython1.PNG
#!/usr/bin/env python3 import xlwings as xw # Original Code............................. ..................................... # xw.Range('B1722').value = (f"{voltage}") xw.Range('A1722').value = (f"{resistance}")
 
Last edited:

Wolf

Active member
Joined
Sep 25, 2018
Messages
1,608
All right another midnight coding spree and I have solved it at least for my purposes. @enki wrote the python code that allowed us to read the RC3563 data in a serial stream. It is a continuous stream repeating the loop. Perfect. I added some code for Excel so now just start the python script with your Excel sheet open and your data is imported. I'm sure there are ways to open the Excel book when starting the python script but I haven't gotten there yet.
python.PNG
By installing xlwings and using this include to sent the data (Resistance and voltage) to a set of specific cells, in my case in the open sheet,
to cells A1722 and B1722. That data can then be copied and pasted into the next empty row with a VB script. Assigning a keyboard shortcut such as Ctrl+s runs the script and inserts the reading below the last entry and so on. So all I do is insert my numbered cell into the RC3563 cell holder hit Ctrl+s and the data that is written to the cells in a descending order.
In my case A1722 and B1722 is copied and inserted into column "7" or G with the VB code looking for the 1st empty cell.
As cells A1722 and B1722 are dynamic you can just insert cells one after the other running the VB script with Ctrl+s and the data will populate the cells
This is the code.
1619609635304.png
And these are the results .
1619609761863.png
Im sure I will do some tweaking but all in all the proof of concept works and it works very well.

Wolf
 
Last edited:

harvester

New member
Joined
Nov 8, 2021
Messages
4
Thank you all for your great work! That's a awesome idea (y):D
Can you tell me how you could connect to the RC3563? Did you use the pyserial module for this?
I use Windows 10 and Open Office Calc and have already been able to edit a calc table with the integrated Python 2.7. But because of the simplicity and my lack of knowledge of basic, I would prefer to use Microsoft Excel because otherwise I would have to rewrite all your macros.

Thanks in advance

harvester
 

Wolf

Active member
Joined
Sep 25, 2018
Messages
1,608
Can you tell me how you could connect to the RC3563? Did you use the pyserial module for this?
Yes then I created my version of the rc3563.py with the xlwings module (for excel export)

Found out which com port the RC3563 used after enabling it.
Wrote a small batch file.

@echo OFF
cd\
cd rc3563
ECHO ============================
ECHO Press enter to start RC3563 to Excel
ECHO ============================
PAUSE
python3 rc3563.py COM3

Make sure you have an excel file open and active and this is the result.
Cant get any easier than that. From there you can work with the VBscript in excel to copy and paste as I showed above.
1636947992271.png

Original code is found here.

Wolf
 
Last edited:

harvester

New member
Joined
Nov 8, 2021
Messages
4
Hello Wolf Thank you for your efforts! I should have written earlier a few days ago I got it to work. First I had to clean up the variable at the path to Python because I had too much there. Then I installed pyserial and xlwings. Then entered the COM port to the rc3563x.py file and after trying in vain for a while it worked after I had the idea to unplug and plug in the usb and to close the program. 🙈 Now I get the values from the RC3563 :cool:
I wanted to test a little further before I answer because everything doesn't seem to work for me. If I have your Excel sheet open and the Python script is running I have a very long delay of the measured values of up to 90 seconds.
With the removed values on the side IR & V & Capacity Test I have no delay.
With the Ctrl + s / z / w shortcuts the field jumps to the last cell but only with the values 0L & 0. What's that all about? Do I still have to adapt the VB script? or how do I have to proceed?

Thanks in advance

harvester
 

Attachments

  • SharedScreenshot2.jpg
    SharedScreenshot2.jpg
    500 KB · Views: 11
  • SharedScreenshot3.jpg
    SharedScreenshot3.jpg
    411.1 KB · Views: 11
Last edited:

Wolf

Active member
Joined
Sep 25, 2018
Messages
1,608
@harvester

Good OK you got most of it to work.
Not sure about the delay but here is my modified rc3563.py code. and I don't have any delay

Python:
#!/usr/bin/env python3

import serial
import struct
import sys
import xlwings as xw


with serial.Serial(sys.argv[1], 115200) as ser:
    while True:
        pkt = ser.read(10)
        #print("PKT: ", pkt)
        status_disp, r_range_code, r_disp, sign_code, v_range_code, v_disp = struct.unpack('BB3s BB3s', pkt)
          
        #print(f"status_disp='{status_disp:#x}'")

        r_disp = struct.unpack('I', r_disp + b'\x00')[0]
        resistance = float(r_disp) / 1e4

        r_disp_code = (status_disp & 0xF0) >> 4

        if r_disp_code == 0x05:
            r_unit_disp = 'mΩ'
        elif r_disp_code == 0x06:
            r_unit_disp = 'mΩ'
            resistance = 'OL'
        elif r_disp_code == 0x09:
            r_unit_disp = 'Ω'
        elif r_disp_code == 0x0a:
            r_unit_disp = 'Ω'
            resistance = 'OL'
        else:
            print(f"Unknown display code '{r_status_disp_code:#x}'")

        #print(f"r_disp_code='{r_disp_code:#x}' r_unit_disp='{r_unit_disp}'")

        r_unit = r_unit_disp

        if r_range_code == 1:
            r_range = '0-20 mΩ'
            r_range_unit = 'mΩ'
        elif r_range_code == 2:
            r_range = '0-200 mΩ'
            r_range_unit = 'mΩ'
        elif r_range_code == 3:
            r_range = '0-2 Ω'
            r_range_unit = 'Ω'
        elif r_range_code == 4:
            r_range = '0-20 Ω'
            r_range_unit = 'Ω'
        elif r_range_code == 5:
            r_range = '0-200 Ω'
            r_range_unit = 'Ω'
        elif r_range_code == 6:
            r_range = 'AUTO'
            r_range_unit = None
        else:
            r_range = None
            r_range_unit = None
            print(f"Unknown resistance range code '{r_range_code:#x}'")

        if r_range_unit and r_unit_disp != r_range_unit:
            print(f"Display unit '{r_unit_disp}' override by range unit '{r_range_unit}' for selected range '{r_range}'")

            # Range unit has preference
            r_unit = r_range_unit
  
        print(f"RESISTANCE range='{r_range}' {resistance} {r_unit}")

        sign_multiplier = None
        if sign_code == 1:
            sign_multiplier = 1.0
        elif sign_code == 0:
            sign_multiplier = -1.0
        else:
            print(f"Unknown sign code '{sign_code:#x}'")

        v_disp = struct.unpack('I', v_disp + b'\x00')[0]
        voltage = sign_multiplier * float(v_disp) / 1e4

        v_disp_code = ( status_disp & 0x0F )
        if v_disp_code == 0x04:
            pass # Nop, everything is OK
        elif v_disp_code == 0x08:
            voltage = 'OL'

        if v_range_code == 1:
            v_range = '0-20 V'
        elif v_range_code == 2:
            v_range = '0-100 V'
        elif v_range_code == 3:
            v_range = 'AUTO'
        else:
            v_range = 'Unknown'
            print(f"Unknown voltage range code '{v_range_code:#x}'")

        #print(f"v_range_code='{v_range_code:#x}' v_range='{v_range}'")
  
        print(f"VOLTAGE range='{v_range}', {voltage} V")

        xw.Range('A1722').value = (f"{resistance}")

        xw.Range('B1722').value = (f"{voltage}")

I removed a bunch of stuff I didn't need.
Notice at the bottom (Xw.Range) I send the voltage and resistance to excel column A and B row 1722. You can make this any place you want. I just put it low enough in my sheet so it would not interfere with the rest of the sheet.

Once you get the data showing up in excel at the appropriate column and row then you need to modify the VBScript to where you want this data to be copied from and pasted to.
Here is the VBScript with some explanations.

Sub Copy_Paste_Below_Last_Cell()
'Find the last used row in a sheet and copy and paste data below it.

Dim lRow As Long

ThisWorkbook.Activate ' The active workbook that you have open

'1. Find last used row in destination sheet. In my case the worksheet name is IR & V & Capacity Test.
' The Rows.Count, 7 where the 7 correlates with the 7th column (G) you want to paste the data to. The 8th column (H) is understood as it ' copies and pastes 2 cells adjacent to each other.


lRow = Worksheets("IR & V & Capacity Test").Cells(Worksheets("IR & V & Capacity Test").Rows.Count, 7).End(xlUp).Row

'Offset 1 row below last used row
lRow = lRow + 1

'2. Copy data
Worksheets("IR & V & Capacity Test").Range("A1722:B1722").Copy
' Range("A1722:B1722") is where the rc3563.py script should be sending the data to and that is what you want to copy.
'3. Paste data
Worksheets("IR & V & Capacity Test").Range("G" & lRow).PasteSpecial
' Range("G" & lRow) is where we are pasting to given the instructions above to "Offset 1 row below last used row"


'Clear copy mode (marching ants around copied range)
Application.CutCopyMode = False

Everything in green is just my explanation and should be removed from the code.
The Macro shortcut you just add to run the VBscript.
In my case as I do 3 separate IR and V measurements,( Pre charge, post charge, post 25 day) hence I have 3 separate scripts that paste the IR and V into 3 different columns. therefore the Ctrl+s , z and so on. Hope this explains how it works. Let me know if you need more help.
1636986419543.png
Oh also check to see in my sheet that you are getting the data on row 1722 where you see OL and 0 after you insert a cell.
1636993085916.png
It should show you the V and IR as in this example. Try it with a plain empty workbook and see if you get the right data.
Wolf
1636993153212.png
 
Last edited:

harvester

New member
Joined
Nov 8, 2021
Messages
4
I do not know what was wrong but now it works like clockwork! Thank you very much for your help! (y):)

I am in the process of building a 24 port cell holder in order to be able to test the cells quickly. I want to give something back to the community and will open an extra post to show my project in case someone intends to recreate something like that. At the moment i'm still waiting for an order for springs for the brass contacts. I overlooked that it is being shipped from china dammed 🙈. But i think i'll get it done this year. The cell holder is good for measuring many cells one after the other (IR & V), to test a battery pack before connecting the cells firmly and to test fuses between the cells. I will see that I have little transition resistance and document this. I have a SKYRC UltimateDuo Balance Charger / Discharger with which I would like to test various smaller battery packs.

To automate Wolf's script even more, I'll use an Autohotkey script for the cell holder to trigger ctrl + s (^ s) every 3 seconds. It remains to be seen whether it will work then but you can increase the time in milliseconds.

install -> right click -> new -> AutoHotkey Script -> insert (below) -> start if excel is open to measure

#Persistent
SetTimer, PressKey, 3000
Return

PressKey:
Send,^s
Return

To stop it you can click on exit in the system tray

With Autohotkey you can certainly do even more to stop the script after 24 or x times measurements or to start and end it with the push of a button.
 

Wolf

Active member
Joined
Sep 25, 2018
Messages
1,608
With Autohotkey you can certainly do even more
Interesting.....
The only issue I have found is that sometimes it takes the RC3563 a bit to settle on an IR reading. Most of the time it is quite quick and a 3 second delay is probably OK.

Question..... does it trigger the ^+s every 3 seconds whether the cell is inserted in the holder or not?
If it does, for me anyway, since I am a fumbling old fart it may cause more missposts than good ones.

Wolf
 

harvester

New member
Joined
Nov 8, 2021
Messages
4
Yes it only makes the key combination time-dependent whether a cell is inserted or not. Not the best way but might work for most. Maybe you know a better way. That was the easiest and feasible with my knowledge. I'm more of a practitioner i need a long time to write a code. Maybe this works in excel with basic so that you can trigger the next ctrl + s depending on a value in the cell so that a null value is not mistakenly copied. You're right, it takes a while for the value to settle down. For you it would be best to increase the value to 10-15 seconds if you only have one cell holder and have to insert it every time and see that it has a good contact. What i have planned is that i will insert all 24 cells and that they will have a good connection. Then, with the help of a slide and copper sliding contacts, i can always drive a little further to the next cell. 3 - 5 seconds would probably be enough for me. I hope I have the apparatus ready soon then you can see it as I mean it.
 
Top