Generation of a sine and graphic display
2nd example: https://github.com/elc-construction-electronique/Librairie-Python-ALR32XX/blob/main/Exemples/Exemple_2.py
Last updated
2nd example: https://github.com/elc-construction-electronique/Librairie-Python-ALR32XX/blob/main/Exemples/Exemple_2.py
Last updated
The purpose of this is to control the supply voltage of the ALR3203 to create a low frequency sine wave. Once the voltage is sine, a load will be connected and the power supply will measure the current generated and display it graphically.
As in the previous example, the development libraries are added and the power supply variable is created.
To complete the initialization of the procedure, we need to declare a variable for our feed:
Here, the variable X will be linked to the ALR3203 connected via USB or RS232 to the computer. X therefore inherits functions from the library, for example X.Meesure_tension() to measure the voltage on the power supply channel.
Creating the sine and storing the values in lists
The idea for this development is to send to the power supply the calculated values of a sine evolving between 0 and 32V. To do this, we use a for loop with i between 0 and 360 (i represents the degree) and we send to the power supply 16*sin(i)+16.
The power supply therefore receives a voltage value at each loop turn.
As the power supply has its values for drawing the sine, we record the values of i, time and current measured throughout the loop so that we can display a graph. Our three lists are previously declared. Everything happens in the previous for loop:
On the power supply side, we observe our sine curve on an oscilloscope:
The last step is to display the previously measured current values. The matplotlib library can be used to display a list of values in graphical form.
The figure you find is then similar to the one below.