Skip to main content

Delta Elektronika SM15K Power Supply

image image image

This is a created package for functional operation of SM15K.

Available operations and functions

  1. Functions from datasheet Delta Electronika
  2. Data logging thread for three type of frames (Basic, Ah and Wh)
  3. Watchdog thread for safe operation
  4. Charging thread for 3 step charging algorithm
  5. Discharging thread for discharging algorithm
  6. Cycling thread for battery cycling algorithm

Used build-in modules

  1. Socket Module / import socket
  2. Threading Module / import threading
  3. Time Module / import time
  4. Csv Module / import csv
  5. Datetime Module / import datetime
  6. Sys Module / import sys
  7. Logging Module / import logging

Note: Datalogger logs as txt and comma separated base.

Installation

pip install SM15K

How to use it?

Code and Syntax Examples

from deltaelektronika import SM15K
import time
# IP Address of the power supply, can be obtain the device itself.
IPV4 = '0.0.0.0' 

# To activate debugging option. Creates system-log file and logs there
SM15K.activateDebugLogger = True 

# To use colorful printing at console.
ColorPrint = SM15K.ColorPrinter()
ColorPrint.printFeedback(message="Your message to print to console as feedback!")
ColorPrint.printComment(message="Your message to print to console as comment!")
ColorPrint.printError(message="Your message to print to console as error!")
ColorPrint.printNormal(message="Your message to print to console as normal!")
ColorPrint.printColorful(message="Your message to print to console as colorful!", colour="purple")
# Available colors for printColorful method are "purple", "blue", "cyan", "green", "red", "yellow", "normal"

# To use all comments for SM15K
MyDelta = SM15K.SM15K(IPV4=IPV4)

# Source related comments
MyDelta.source."SourceRelatedComments"()
MyDelta.source.ReadPowerSet()
MyDelta.source.SetCurrent(current=20)

# Measure related comments
MyDelta.measure."MeasureRelatedComments"()
MyDelta.measure.MeasurePower()
MyDelta.measure.SetAhMeasurementState(setting="ON")

# Output related comments
MyDelta.output."OutputRelatedComments"()
MyDelta.output.ReadOutputSet()
MyDelta.output.SetOutput(setting="ON")

# System related comments
MyDelta.system."SystemRelatedComments"()
MyDelta.system.ReadWatchdogSet()
MyDelta.system.SetPowerLimit(powerlimit=2000, setting="ON")

# Shutdown related comments
MyDelta.shutdown."ShutdownRelatedComments"()
MyDelta.shutdown.limitShutdownValues()
MyDelta.shutdown.setShutdownOutput()

Note: All comments group according to datasheet of SM15K.

Note: Datasheet for Delta Electronika

# There are additional independent features has been added!
# Watchdog operation for safety.
Safety = SM15K.WatchdogOperation(timer=5, sleeptime=4)

Note: Be sure that sleeptime is lower than timer. This means withing 5 seconds of lack of communication, SM15K will shut its output down. If sleeptime is lower, watchdog will reset itself for every cycle of sleeptime period.

# Datalogger operation for logging related data.
# Default color is green, available colors are;
# purple, blue, cyan, green, yellow, red and normal                            
BasicDatalogger = SM15K.BasicDataloggerOperation(IPV4, loggingTime=10,
                printColor= 'purple')    

Note: Basic data frame is; dataFrameBasic = 'Timestamp','Voltage', 'Current', 'Power'

# Datalogger operation for logging related data.
# Default color is green, available colors are;
# purple, blue, cyan, green, yellow, red and normal 
AhDatalogger = SM15K.AhDataloggerOperation(IPV4, loggingTime=10, 
                printColor= 'red')

Note: Ah data frame is; dataFrameAh = 'Timestamp','Voltage', 'Current', 'Power', 'PositiveAh', 'NegativeAh', 'AhSeconds', 'AhHours'

# Datalogger operation for logging related data.
# Default color is green, available colors are;
# purple, blue, cyan, green, yellow, red and normal            
WhDatalogger = SM15K.WhDataloggerOperation(IPV4, loggingTime=5, 
                printColor='blue')  

Note: Wh data frame is; dataFrameAh = 'Timestamp','Voltage', 'Current', 'Power', 'PositiveWh', 'NegativeWh', 'WhSeconds', 'WhHours'

# Charging operation for battery charging.
Charging = SM15K.ChargingOperation(IPV4, sleeptime=5, bulkCurrent=100, 
                bulkVoltage= 14.5, floatVoltage=13.8, floatTime=300)

# Discharging operation for battery discharging.
Discharging = SM15K.DischargingOperation(IPV4, sleeptime=5, 
                dischargeCurrent=100, dischargeVoltage=10.5, 
                cutoffCurrent=2)
# Cycling operation for battery cycling.                
Cycling = SM15K.CyclingOperation(IPV4, sleeptime=5, cycletime=10, 
                bulkCurrent=100, bulkVoltage=14.5, floatVoltage=13.8, 
                floatTime=300, dischargeCurrent=100, dischargeVoltage=10.5, 
                cutoffCurrent=2,afterChargingRestTime=30.0, 
                afterDischargingRestTime=30.0, startCharging=True)

Note: Rest times can be set after each step (after charging and/or after discharging) Note: To be able to start from desired operation (charging or discharging as first step) set python startCharging=True or False

Each functionality has been created with related parameters at above.
To be able to use them python threadObject.start() must be used to start the thread operation

Safety.start()          # To start watchdog thread class
BasicDatalogger.start() # To start BasicDatalogger thread class
AhDatalogger.start()    # To start AhDatalogger thread class
WhDatalogger.start()    # To start WhDatalogger thread class
Charging.start()        # To start Charging thread class
Discharging.start()     # To start Discharging thread class
Cycling.start()         # To start Cycling thread class

After calling thread start, if main loop ends, thread is going to end as well because of being deamon thread true. That is why infinity loop or long term loop needed to run. Or it can be used as thread.join() after it has been started to be sure that main does not end before the thread is done.

Note: Do not operate charging and discharging threads at the same operation.

Note: Do not operate Ah and Wh datalogger threads at the same operation. Delta can log one of them at a time.

Note: Watchdog is being set to delta itself, that is why be sure timer is bigger than sleep time to have healthy operation.

while True:
    # Main Code Runs Here in infinity loop.
    time.sleep(30)
    print(f'Main loop runs in here!')

You can run anything you want here as well to have multifunctional operation while system runs with multiple threads.

Note: All threads are created as deamon thread which means, if main finishes its operation threads are going to stop operation. That is why you should keep them in infinite loop. If you like to have the thread keeps operation even if your main code has been finished, set the deamonState = False

License

© 2021 Yusuf Keklik

This repository is licensed under the MIT license. See LICENSE for details.

Release files for SM15K 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for SM15K 0.0.7
File Size Uploaded
SM15K-0.0.7.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for SM15K 0.0.7
File Interpreter ABI Platform
SM15K-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 42.3 kB

Release files / SM15K-0.0.7.tar.gz

Download URL SM15K-0.0.7.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4ec13772fa0f92eb1ac3daf5f26089c8b5a4cfe6e6473af55a6b531fac732f03
BLAKE2b-256 checksum
How to use checksums
acdaa4a7196f5b1cfb48c8934e1e3e131522fba728c27559a5c3f76f2ef0473c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

Release files / SM15K-0.0.7-py3-none-any.whl

Download URL SM15K-0.0.7-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83fda601761cb8db75b6335325f731fdbade4a20672a362890b2b6ce533b8c4d
BLAKE2b-256 checksum
How to use checksums
a90de39510e76c1971d6c8192a4453c0e7ba825d53ed9cb91ed88718b7a6e6de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page