Hello, I'm trying to comunicate my arduino Uno with power inverter which control an engine. I have UART <-> Rs485 converter (this power inverter reads only Rs485 protocol) , so i wrote code in serial protocol (see below). After uploading code on arduino and disconecting arduino from my computer it doesn't send anything (TX led isn't lighted). Maybe some of you know why?
Thank you for any help
SoftwareSerial mySerial(0, 1);
TxPacket.DestinationAddress = 0x01;
TxPacket.function = 0x06;
TxPacket.functioncode = 0x01;
TxPacket.functioncode1 = 0x0E;
TxPacket.data = 0x00;
TxPacket.data1 = 0x64;
TxPacket.CRClow = lowByte(MakeCRC(&TxPacket));
TxPacket.CRChigh = highByte(MakeCRC(&TxPacket));
uint16_t MakeCRC(struct DataPacket *InPacket)
uint16_t TempCRC = 0xFFFF;
TempCRC = _crc16_update(TempCRC, InPacket->DestinationAddress);
TempCRC = _crc16_update(TempCRC, InPacket->function);
TempCRC = _crc16_update(TempCRC, InPacket->functioncode);
TempCRC = _crc16_update(TempCRC, InPacket->functioncode1);
TempCRC = _crc16_update(TempCRC, InPacket->data);
TempCRC = _crc16_update(TempCRC, InPacket->data1);
It is not usually a good idea to use the hardware Serial pins for SoftwareSerial. What happens if you use 2 other pins ?
I changed pins on 3 and 4. Now it doesn't send data at all (neither through USB nor pins). I don't necessary need to use softwareserial, i just want to send data from arduino to the converter, so if there is any simpler way to do this i can try it.
I tried also hardware serial comunicaton (via TX, RX pins), but then problem is the same as i wrote on the beginning.
The Uno has only got a single hardware UART which is used to upload code and is also used by the Serial monitor. Trying to use it for something else is usually not a good idea, hence it is common to use SoftwareSerial to provide a second serial connection on 2 digital pins other than 0 and 1
When you tried pins 3 and 4 how exactly did you connect them to the RS485 converter ? Which pin on the Uno to which pin on the converter ?
3 to RO (receiver output) and 4 to DI (driver input)
The order of pins when the SoftwareSerial object is created is Rx, Tx. Did you have them in the order 3, 4 ?
Do you like to change the above data types into uint8_t; because, you are assigning 8-bit values to the above avriables as seen in the following codes:
Please, post your receiver codes.
I'm not programming my receiver, it is programmed to receive some specific data frames and respond by other frames (accordling to sended data frame). This protocol is described in instruction to power inverter (model E2000 Eura drives), unfortunately i couldn't find it in english version.
In the same instruction is written that CRC number have to have16 bits and be added to data frame as 8-bit symbols
Edit: Now i understand that I should change this data type to uint8_t, thank you for help. However it still doesn't solve my promblem
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.