Go Down

Topic: need a program writen (Read 274 times) previous topic - next topic

paulelder

hello I need help new at this and need a small program written to control a frequency board to change 4 times and the duty to change each time to then repeat over and over then I can mod it from there and learn please help 


Communication standard: 9600 bps data bits: 8
Stop bit :1
Check digit :none
Flow control : none

1, set the frequency of the PWM

"F101": Set the frequency to 101 HZ (001~999)

"F1.05": Set the frequency to 1.05 KHZ (1.00~9.99)

"F10.5": Set the frequency to 10.5KHZ (10.0~99.9)

"F1.0.5": Set the frequency to 105KHZ (1.0.0~1.5.0)

2, set the duty cycle of the PWM

"Dx:yyy": set the duty cycle of PWM x: (1~3) PWM serial number, yyy: (000~100) duty cycle %;

For example, D1:050, set the first PWM duty cycle to 50%.

3, read the setting parameters

Send a "read" string and read the set parameters.

The read data format is as follows: F156, D1: 052, D2: 059, D3: 058,

Set the success to return: DOWN;

Setting failed to return: FALL.

GaryP

Wait for Paul's...

Cheers,
Kari
The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

6v6gt

Can you start with this, hacking it if necessary to get it just to do something:

Code: [Select]

// connect pin 10 to the TX pin of your device
// connect pin 11 to the RX pin of your device

#include <SoftwareSerial.h>
SoftwareSerial pwmBoard(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
  }

  Serial.println("Starting. . .");

  // set the data rate for the SoftwareSerial port
  pwmBoard.begin(9600);
  delay(1000) ;
  Serial.println( "Sending F156" ) ;
  pwmBoard.println("F156");

  delay(1000) ;
  Serial.println( "Sending D1:050" ) ;
  pwmBoard.println("D1:050");

  delay(1000) ;
  Serial.println( "Sending D1:052" ) ;
  pwmBoard.println("D1:052");

  delay(1000) ;
  Serial.println( "Sending D2:059" ) ;
  pwmBoard.println("D2:059");

  delay(1000) ;
  Serial.println( "Sending D1:052" ) ;
  pwmBoard.println("D3:058");

  delay(1000) ;
  Serial.println( "Sending read" ) ;
  pwmBoard.println("read");

  while ( pwmBoard.available() ) {
    Serial.print( pwmBoard.read() ) ;
  }
  Serial.println() ;
  Serial.print("end") ;
}

void loop() {}

Go Up