Click here to Skip to main content
Click here to Skip to main content

Control HUA YI Electronic Power Supply

, 5 Apr 2010 CDDL
Rate this:
Please Sign up or sign in to vote.
This program shows you how to control, give set-point and get feedback from Hua YI made Power Supplies

Introduction

Thanks to our Chinese brothers! Now, some of the digital controlling devices which previously were hard to find or were expensive, have been produced in mass scale and are cheaper than the European one. One of the most important parts of the controlling system is being able to precisely control a wide range voltage.

In some projects, we used to implement Micro-Controller based power supply RS232 controlling which sometimes caused error due to environment inducing motors and something similar. Fortunately, we found out some Chinese power supplies which were cheaper than what we'd made available.

Code Description

HYPS.jpg

One of the most popular controllable power supplies which was offered with only an installable controlling program and no extra information about in use communication protocols or even its controlling program’s source code is HYElect Hua YI Electronics, Type HY3020M! We requested the main company to send us the protocol, but it seems they've sealed themselves, so nothing can be released! Despite their great help!! Using RS232 sniffing method, fortunately the base protocol extracted!

The program consists of two parts. By choosing Virtual Power, it’s assumed to treat as a virtual power which you can remotely set its voltage and upper current limit and by choosing Real Power, it'll change to how you can contact with a real power supply unit.
The communication properties which shall be set are: 9600bps as Baud-Rate, 8 bit as default data length, with no parity bit and one stop bit and the wiring has to be done as what is shown below (pin 2 of computer connector must be connected to pin 3 of power supply connector, pin 3 of computer connector must be connected to pin 2 of power supply connector, pin 5 of computer connector must be connected to pin 5 of power supply connector and in each side, pin 7 and 8 have to be connected to each other)

Wiring.jpg

The protocol which has been used there is terribly easy. The requesting sting which has to be sent is “8”.

MSCom.Write("8")

The reply will be in this form: “VVVAAA”. “VVV” indicates the power supply voltage which has to be divided by ten and “AAA” indicates the power supply current which has to be divided by 10 as the same.

RP_Vol_In = Mid(STR_InSerial, 1, 3) 
RP_Cur_In = Mid(STR_InSerial, 4, 3) 
NumUpDown_RP_Get_Voltage.Value = Val(RP_Vol_In) / 10.0 
NumUpDown_RP_Get_Current.Value = Val(RP_Cur_In) / 10.0
Prg_Real.jpg

The program also makes it possible to change the voltage sett-point and current upper limit. For setting the voltage, the below piece of code is being used:

Dim Volt_Temp As Integer = NumUpDown_RP_Set_Voltage.Value * 10 
Dim Volt_Check As Integer = 2 
While Volt_Temp > 0 
     Volt_Check = Volt_Check + (Volt_Temp Mod 10) 
     Volt_Temp = Volt_Temp \ 10 
End While 
Volt_Check = Volt_Check Mod 10 
RP_Vol_Out = "2" & (NumUpDown_RP_Set_Voltage.Value * 10).ToString("0000") & _
	Volt_Check.ToString("0")

As is obvious in the last line, the string length is 6 characters. The indicator character for voltage setting string is “2” which must be set at the first of string. The next four characters are made by NumUpDown_RP_Set_Voltage.Value * 10).ToString("0000") declaring the desired value. The last character is Volt_Check which is the remainder of summation of all digits of Volt_temp divided by ten.

The process of current setting is alike, by this difference that the indicator character is “1”. The piece of code brought below describes the process of creating a string going to be sent to change the current upper limit.

Dim Curr_Temp As Integer = NumUpDown_RP_Set_Current.Value * 10 
Dim Curr_Check As Integer = 1 
While Curr_Temp > 0 
Curr_Check = Curr_Check + (Curr_Temp Mod 10) 
Curr_Temp = Curr_Temp \ 10 
End While 
Curr_Check = Curr_Check Mod 10 
RP_Cur_Out = "1" & (NumUpDown_RP_Set_Current.Value * 10).ToString("0000") _
		& Curr_Check.ToString("0")
Prg_Vir_02.jpg

HYPrg_01.JPG

Interesting Point

The most interesting thing that can be learnt is that “Never lean on the information companies have sent to you”! I barely can say that I’d spent more than one week surfing the Internet finding whether any useful piece of information might have been left helping persons as me to advance the projects, but fortunately found nothing that forced me to stay on my feet. As a famous Chinese proverb goes, “Disappointment is the first step of failure”!

Special Thanks

Special thanks to Prof. Kamalaldin Farzaneh who has trusted in me and let me experience, fail and start again.

History

  • 5th April, 2010: Initial post

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

Share

About the Author

Mahdi Mansouri
Engineer
Malaysia Malaysia
PhD Candidate in Biomedical Eng., Control
M.Eng Electronics, Control
B.Eng Computer, Hardware
That's all ;D !

Comments and Discussions

 
SuggestionLove the article PinmemberMazen el Senih28-Mar-12 10:36 
AnswerRe: Love the article PinmemberMahdi Mansouri28-Mar-12 15:32 
SuggestionRe: Love the article PinmemberMazen el Senih29-Mar-12 4:10 
GeneralCool project PinmemberShane Story12-May-10 9:13 
GeneralRe: Cool project PinmemberMahdi Mansouri13-May-10 19:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 5 Apr 2010
Article Copyright 2010 by Mahdi Mansouri
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid