0

I am creating a Solar Array Simulator with python to simulate the voltage and current being created with different angles and intensities of sunlight as a satellite orbits around the earth. I have a very simple program that outputs the voltage and current just with the angle (no orbiting parameters yet). However, I need it to communicate the outputs generated with a E4350B model solar array simulator through a serial port, and I don't know where to start. I have installed pip and used that to install PySerial but do not know what to do from there. How do I communicate the voltage and amp outputs to the simulator through COM ports? Here is what I have for my program that runs the simulator.

from math import sin,radians,pi
import time

'''Needed information:
   Voc (per one cell) = 2,680mV
   Vmp (per one cell = 2,325mV
   Isc (per one cell) = 453mA
   Imp (per one cell) = 434mA
   angular velocity = .05d/s'''

#Timer eclipse set for total eclipse tim ein seconds
timeEclipse = 1800
#total eclipse time = 30 mins
#Timer sun set for how many seconds it takes to change one degree
timeSun = 20
#Total sun exposer time = 60 mins
#Find the Vmp, Voc, Imp, and Isc from Beta angles 0 - 180
def Exposure():
    tSun = timeSun
    for x in range(0,181):
       angle = sin(radians(x))
       Voc = 2680 * angle
       Vmp = 2325 * angle
       #Amps are going to be a function of voltage
       Isc = 453 * angle
       Imp = 434 * angle
       #
       print('At angle ',x,' Vmp = ',Vmp,
         'mV, Voc = ',Voc,'mV, Isc = ',Isc,'mA, and Imp = ',Imp,'mA')
   time.sleep(tSun)

#Simulate time during eclipse
#Outputs nothing
def Eclipse():
    tEclipse = timeEclipse
    time.sleep(tEclipse)

#Run loop through Exposure and eclipse
def Run():
    run = True
    while(run):
        Exposure()
        Eclipse()

P.S. For anybody who dabbles in a little bit of physics, I need a way to find the current as a function of the voltage at every angle.

wfulton
  • 21
  • 3
  • Have you read any of the pyserial documentation and tried any of the examples? – Wayne Werner Jul 18 '16 at 17:31
  • Yes I have, but I don't really know what any of it means. – wfulton Jul 18 '16 at 18:18
  • So perhaps you should [edit] your question and add the parts you find confusing, e.g. "It says that I should connect the widget to the frobnosticator, but where do I find the widget and the frobnosticator?" We want *specific, answerable* questions. – Wayne Werner Jul 18 '16 at 18:29
  • Alright, sorry for the vague question. I'm just trying to find a good place to start. But, for starters, how do you get a list of all COM ports connected to your computer? – wfulton Jul 18 '16 at 18:59
  • That would be a good question, if it's not already asked. I would do something like search google for _How do you list all com ports connected to your computer site:stackoverflow.com_ - failing that, I would search the internet at large, but I'd probably post the question on Stack Overflow if it wasn't found, because that *is* a useful question, and it's specific, and answerable :) – Wayne Werner Jul 18 '16 at 20:41
  • @wfulton: See, for example, http://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python and http://stackoverflow.com/questions/1205383/listing-serial-com-ports-on-windows – Warren Weckesser Jul 18 '16 at 21:06

0 Answers0