LoginSignup
0
1

More than 3 years have passed since last update.

昇圧時電流シミュレーション

Posted at

dutyは逐次計算で


# coding: utf-8

# In[278]:


get_ipython().magic('matplotlib inline')
import matplotlib.pyplot as plt


# In[279]:


import numpy as np
import math


# In[280]:


points = 360
ac_freq = 50 #Hz
ac_t = 1/ac_freq / 2 #半波: →/2
ac_volt_real = 220 #V
ac_volt_max = ac_volt_real * math.pow(2,0.5)
reactor_H = 40 #mH
dc_volt = 320
target_dc_volt = 320
career = 40 * math.pow(10,-6)
t_delt = ac_t / points
ep_dead_time_count = 3
dead_time = career * ep_dead_time_count


# In[281]:


def calc_time(i_point):
    return ac_t / points * i_point 

def calc_acv_sin(i_time):
    rad = (i_time / ac_t) * math.pi * 1 # 半波:*2→*1
    acv_sin = ac_volt_max * math.sin(rad)
    return acv_sin

def calc_duty(t, target_dc_volt, dc_volt, acv, aca_sum):
    duty = 0.4
    return duty


# In[282]:


#10ms, 40us, duty:100%, 0.01%刻み
print("分解能:",10*1000 / 40 * (100/0.1))


# In[283]:


#250000点で
#ACVの正弦波つくる
#40usごとの、40%ON60%OFF, 30%ON70%OFF, ...., を、pointsで、なんとか
#というか逐次電流からduty計算だからmapでは無理か……


# In[284]:


points_list = list(range(0,points))
time_list = list(map(calc_time, points_list))
acv_sin_list = list(map(calc_acv_sin, time_list))


# In[285]:


plt.plot(time_list, acv_sin_list)


# In[286]:


career_count = 0
aca_sum = 0.0
duty = 0
duty_on_count = 0
duty_off_count = 0
duty_on_time = 0
duty_off_time = 0
for t in time_list:
    ac_volt = calc_acv_sin(t)
    if t < dead_time: #dutyは0だけどACVとかACAは計算いりそうだから、ifのネストとか変更必要
        duty = 0
    if t >= 0.001 and ac_volt < 30: #1ms, dutyは0だけどACVとかACAは計算いりそうだから、ifのネストとか変更必要
        duty = 0

    if t >= (career * career_count): #40usごとにcareer_countとduty更新する感じ。初回にduty計算するためこれを上に持ってきた
        career_count += 1
        duty = calc_duty(t, target_dc_volt, dc_volt, ac_volt, aca_sum)
        duty_on_count = 0
        duty_off_count = 0
    else:
        if t < ((career * (career_count-1)) + (duty * career)): #duty出力中なら
            duty_off_time = t_delt * duty_off_count
            duty_on_count += 1
        else:
            duty_on_time = t_delt * duty_on_count
            duty_off_count += 1




# In[ ]:





0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1