Hello dear plcnext team, i’m currently at a stage where i’m trying to establish communication between my axc f 2152 and a pixy2 cam. i’ve got an axl f rs uni 1h module set up. i wanna use rs485 to communicate with the cam via uart. unfortunatly i can’t figure out where to start. i was reading old posts and datasheets but it didnt really help since i’ve got zero experience in this field. what i’ve done so far is:
* downloaded the Modbus_RTU_7 block library
* bridged 20 to 30 and 21 to 31 on the rs uni
* wired 10 to the A+ and 11 to B- of this converter <https://www.ebay.de/itm/252852473229>
* connected the Rx and Tx lines to an arduino for testing purposes
but other then that i’m a little lost on how to send and receive messages. a basic tutorial would be greatly appreciated.
Hello Chris, in the help of the Modbus library you should be able to find a short example how to setup the Modbus Master (client).
I guess your pixy cam will function as a Modbus Slave (Server)?
You will have to specify the unit ID at the Slave and connect to this ID with your Master.
You also have to make sure that the Baudrate Parity ect. match between the Modbus devices. For starters you can check the RX and TX led at the RS UNI to check if you are sending and recieving data at all..
Then you should be getting some Error codes depending on any missmatching configurations.
Hi Oliver, thanks for your help. Ive now worked through the examples and made a new program with the REC, Master, SND, FC1 and FC2 funktionblocks included. i set the arduino to send a “2” every 500milliseconds. the RxD led on the RS UNI flashes in the same rhythm so i guess its receiving something. if i look into the array whichs is connected to the input i can see that:
* position [0] is toggeling between 16#30 and 16#70
* position [1] is toggeling between 16#01 and 16#00
* [2] is set to 16#02
* [3] and [4] are set to 16#32
* the rest is set to 16#00
so it seems like something is received by the RS UNI but i cant interpretate the values. edit: if i chance the sent value to 4 [3] and [4] are set to 16#34 so i guess that represents my value but i dont understand why. maybe you would be so kind to elaborate a little further?
please attach some screenshots with activate debug mode + place the arrays into the watchwindow.
I dont know exactly which Input you are refering to.
I guess you are talking about the Proccessdata of the RS UNI?
You should be recieving Modbus registers directly at the FC Functionblock for easier processing…
The values get transfered as bytes so you might have to order and convert them accordingly.
What kind of value do you expect to recieve? Int, uint,Float ect ? kind regards,
Oliver.
Hello, i attatched 2 screenshots. arrInputData.png shows the array i was talking about and RecBlock.png shows where the array is connected to. what i want to do is receive a message like (“xCoordinate(uint) yCoordinate(uint) degree(int)”) with the coordinates ranging between 0 and ~300 and degree from -180 up to 180. so for example (“100 200 -175”) “You should be recieving Modbus registers directly at the FC Functionblock for easier processing…” by that you mean looking into the array of type “arrModbus2_X_1_2000” which is connected to the arrReadData port of FC2 ?
i just did try that and its an array of bools which are all “false”. Or did i get you wrong? big thanks for your time and help!!
you will have to take a look at the Datasheet of your Device.
This will properbly mention the Supported Modbus “Function Codes”.
As you have INT values. I guess you will need to have a look at the FC 4, FC 6 and FC 16.
What you see at the UNI_REC Array are the serialised communication data and raw responses of the RS UNI module. You do not have to handle this yourself. The Client functionblock and FCs entangle these data for easy processing…
Usually when you have the client setup.
You enter the registers you want to read at the functionblock. (The documentation of the Modbus Slave has to mention which registers are holding which values.)
For now just try reading with FC4 and read as many as you can.
Properbly the FC4 will then return an error 16#C100 → 0002 because you are only allowed to read some registers.
Or it tells you 16#C100 0003 that means FC 4 is not supported ect…
For further info on the error code have a look at the documentation of the MB RTU FCs. (righclick and press help on a Funktionblock)
Which registers you are allowed to read and in which register certain values are stored.
Should be documented by the Modbus RTU SLAVE.
If it is not you have to do try and error to find the correct parameters.
Hey, i finally found some time to try out what you suggested. Unfortunately i cant get it to work. I’ve set up the receive, master and send blocks and inserted the FC_4 afterwards. i set the parameters of the function block FC_4 as follows: activate is connected to xMaster_active so it is true. xSendRequest is toggeling between True and False every 1 sec. xEnablePoll is set to true. tPollInterval: 0.5 s uiSlaveAdress: 1 but no matter what i set uiStartAdress to, i’m unable to get any values in arrReaddata of FC4. the wDiagCode stays at 16#8300 for 8 calls of the function. then it changes to 16#110 for some cycles with wAddDiadCode displaying 16#0001. again at this point i’m a little lost. i’m sure that the whole thing is working to some degree but i cant figure out how to access the correct registers to get my values i want to reveice out of this block. i’m guessing my uiStartAdress is not correct.
Hello, Can you give us some information about the Modbus RTU features of the pixy cam you are using - perhaps a link to the relevant part of the User Manual for that device? ~ Martin.
Hi Martin, i’m currently a the stage that i’m using an arduino as a translator between the pixy and the RS Uni, so that i can define all the parameters to what is required. due to time contraints on my part i just wanna send something like (“100 200 -175”) (all uint/int) to the RS UNI. basically the arduino sends a message like that every second and i want to receive that on the PLC side. i thought that there would be a way to just send this via uart (arduino standart Serial.print()) to a ttl uart - RS485 converter ( https://www.ebay.de/itm/252852473229) and to the RS UNI and receive the data there somehow. do i have to set up my arduino as a modbus server? or is there a simple way to decode what the PLC is already receiving? i’m sorry. maybe my questions are dumb as i dont have any experience in this field.
from what i read now, usually the master sends a request to which the slave answers. so using modbus might not be the preferred solution to my problem.
Hi Chris, No worries about the questions, hopefully we can get you sorted. That RS485 board is useful, but you’re right - unless you install a Modbus server on the Arduino, the characters will simply be sent as raw bytes without any of the additional protocol information that a Modbus server would send, that would be recognised by a Modbus client. In this case, without a Modbus Server on the Arduino side, it is possible to set up the RS UNI in “Transparent” mode, and just receive the raw data being sent from the RS485 card. The simplest way to start might be to use the AXL_RSUNI_PD function block in the AXL_ComSerial library in the PLCnext Store. You still need to configure the RS UNI module in PLCnext Engineer with parameters that match your Aduino board, but after that you should see the incoming bytes in the arrReceiveData array connected to the AXL_RSUNI_PD function block. Hope this helps! ~ Martin.
Hi, i hope you guys had a merry christmas so i implemented the AXL_RSUNI_PD_2 function block, set xActivate and xAutoAck to true and xReceive to toggle with every call of the program. the DiagCode shows 16#8000 so i’m guessing the block is operating. the parameters at the axl f rs uni 1h are RS485, transparent, 9600, 8databits/no parity/1 stopbit (which is similar to what i configured the arduino to. but when i pull the array which is connected to arrRcvData into the debug view, every slot of said array contains 16#0000. did i miss anything while parametring the function block? or something else? thank you!
Hi Chris, Try connecting the xReceive input to the xRcvBufferNotEmpty output. This will request a read only when the input buffer is not empty, i.e. when the RS UNI receives bytes from the Arduino. Also, use the rising edge on xRcvNDR to increment a counter, for example. Since this is only set to TRUE for one scan cycle, the counter will allow you to see each time new data is received. If this output never goes high (i.e. the counter never increments), then you are not receiving data. ~ Martin.
Hey Martin, so i did everything you proposed, but the implemented counter stays at zero. i tried almost every configuration of databytes, parity and stopbits. so i’m guessing it doesnt receive anything. which is weird because the RxD led on the RS UNI flashes as its supposed to do. it seems like the fb is somehow not connected to the RS UNI module. but i’m left clueless on what to try now.
Hi..based on my experience with the issue i ll recommend to build up your program as an independent executable. For this situation, you should follow the model given in the Sample Runtime venture on Github. This activities tells the best way to call a RSC Service - for this situation, the “DataAccessService” (among others), yet for your situation it will be the “AcyclicCommunicationService”. This model undertaking additionally demonstrates the significant call to the ArpSystemModule_Load work, which is required for an exe to get to PLCnext administrations. pcb assembly china