2024-07-25 05:12 AM
Hi i am New for Arm mbed ,MY project is i want to Control 3 phase induction motor speed using VFD
Here my inovance VFD controlling by (RS 485 Communication Using Max 485 Module) STM 32 Nucleo F767ZI controller,
My slave ID -01,
Baud rate -9600.
modbus data format -8-N-2,
All my VFD Setting was done and Cross checked by USB to RS 485 Driver using modbuspoll Software.(Here i controlling Motor Speed and Direction)
my connection max 485 drive
Nucleo PD_6 (RX)->RO
RE and DE short connect Digital pin PC_8
Nucleo PD_5 (Tx)->DI
VCC connect 5V power supply
A connect VFD 485+
B connect VFD 485-
Gnd connect with GND
this photo is MY VFD Setting
Below i Attached my code
```
#include "mbed.h"
#include "BufferedSerial.h"
Serial pc(USBTX, USBRX,115200);
Serial RS485(PD_5,PD_6); // Tx, Rx
DigitalOut ho(PC_8);
//Serial RS485(PD_6,PD_5);
typedef uint8_t byte;
//byte data[9] = {0x01,0x04,0x00,0x48,0x00,0x02,0xf1,0xdd};//your data
byte enable[9] = {0x01,0x03,0x04,0x00,0x00,0x00,0X01,0x3B,0xF3};
//byte enable[9] = {0x01,0x06,0x20,0x0E,0x00,0x08,0xE2,0x0F};//your data
//byte run[9] = {0x01,0x06,0x20,0x89,0x00,0x0A,0xD3,0xE7};//your data
byte run[9] = {0x01,0x06,0x04,0x10,0x00,0x50,0x00,0X80,0xCA};//your data
//byte stop[9] = {0x01,0x06,0x20,0x0E,0x00,0x07,0xA2,0x0B};//your data
int main()
{
printf("Main\n");
RS485.baud(9600);
pc.baud(115200);
while(1) {
// RS485.baud(115200);
pc.printf("Starting\n");
ho = 1; // 3.3V output from digital out pin
for (int i=0; i<(sizeof(enable)-1);i++)
{
RS485.putc(enable[i]);
}
wait_ms(2000); // Silent interval
printf("\n Enable done");
for (int i=0; i<(sizeof(run)-1);i++)
{
RS485.putc(run[i]);
}
printf(" \n Run Done waiting for 5 min");
wait_ms(5000); // Silent interval
/* for (int i=0; i<(sizeof(stop)-1);i++)
{
RS485.putc(stop[i]);
}
wait_ms(50); // Silent interval*/
pc.printf("Getting data\n");
ho = 0;
pc.printf("The RS485 value %d\n",RS485.readable());
char buffer[50];
RS485.gets(buffer, 9);
for (int count = 0; count < 8; count++) {
pc.printf("%02hhX", buffer[count]);
}
pc.printf("\n");
pc.printf("Done\n");
wait_ms(1000);
}
}
```