XY-LPWM board always returning FAIL

Hello,

I tried to control XY-LPWM board for PWM generation with arduino using serial control provided by TX RX and GND pins on the PWM board.

I have connected Arduino 5V and GND pins to VIN+ and VIN-, respectively. Pin 11 as TX and pin 10 as RX, connected to RX and TX on PWM board, respectively.

Code is the example i've found on github:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.print("Hello");
}

char buf[40];
int count=0;

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    char ch = Serial.read();
    if(ch=='\r'){
      buf[count]=0;
      mySerial.print(buf);
      count = 0;   
    }else if(ch=='\n'){
      ;   
    }else{
      buf[count++] = ch;
    }
  }

}

On setup, i get FAIL from serial monitor.

Also, whatever i type into serial monitor i get FAIL as return.

Any ideas on how to solve this problem?

Thanks!

If You post a link to the datasheet of that board You might get useful replies.

Thanks, datasheet link is:
https://images-na.ssl-images-amazon.com/images/I/A1R7QdmPRhL.pdf

Since your sketch is not generating a "FAIL" message, it must be coming from the serial device. That is a good sign. The first "FAIL" probably comes as a response to the "Hello" message. Is the serial device supposed to respond? I suspect the problem is that you are not signaling the end of the command in any way. I would try:
mySerial.print("Hello\n");
mySerial.print("Hello\r");
mySerial.print("Hello\n\r");
and
mySerial.print("Hello\r\n");
Pick the shortest line ending that the serial device accepts as valid.

1 Like

Have You connected Tx/Rx correct? From the picture, from top to bottom: GND, the PC-Tx and lowest, the Pc-Rx.

1 Like

Problem solved, two things were wrong:

  1. Serial monitor must be set to Carriage return instead of Newline
  2. Anything other than the specified commands (such as "F101" ,"D050", etc.) will cause the device to return FAIL and not respond to new serial data

Thanks for useful comments and guidance, cheers

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