Arduino Sending ASCII commands to programmable power supply

Hello guys,
I am working in a project where I would need to control a Programmable power supply with my Arduino DUE.
The programmable power supply is connected with an RS232 interface so I bought the UART to rs232 module for my arduino.

I made sure all the connections are properly connected and the voltages are at the right level.

When I try to send commands to the power supply nothing happens,
my code is:

bool once = false;

void setup()
{
pinMode(22,OUTPUT);
Serial.begin(9600);
// Open serial communications and wait for port to open:
Serial1.begin(2400);
}

void loop() // run over and over
{
digitalWrite(22, LOW);
if (once == false) {
onceloop();
}

}

void onceloop(){
if (Serial1.available()){
Serial1.write("SV 5");
Serial.print("connected");
once = true;}
return ;
}

When doing Serial1.write I have tried to send a string and it doesn't work. I don't know how to send Ascii commands.

I also tried doing
Serial1.write(0x56)
Serial1.write(0x74) etc...
which are the hexadecimal commands but nothing happens.

Anyone has any idea?

The link of the commands for the power supply is:
https://www.gwinstek.com/en-GB/products/downloadSeriesDownNew/7332/1431

I used it with my raspberry pi and I managed to do the commands in python but I cannot figure out how to do them in Arduino.

Thanks

Hi @gsaraullo
please, to post sketch use tags (</>).

RV mineirin

for test use this sketch:

bool once = false;

void setup()
{
  pinMode(22, OUTPUT);
  Serial.begin(9600);
  // Open serial communications and wait for port to open:
  Serial1.begin(2400);
}

void loop() // run over and over
{
  digitalWrite(22, LOW);
  if (once == false) {
    onceloop();
  }

}

void onceloop() {
//  if (Serial1.available()) {
    Serial1.write("SV 5");
    Serial.print("connected");
    once = true;
//  }
  return ;
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.