LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus Help!

Solved!
Go to solution

Hi,

 

Firstly i keep getting a timeout error  6101 when i run my code, i have read the threads and i still keep getting this error. Perhaps it is the data i am inputting i am not sure. My device is an ADAM 4024. I perhaps need help with my configuration.

 

I am trying to control a power supply through my device.

 

Channel 0 controls the voltage and channel 1 the current.

 

I want to initially have 0 volts/ amp when i start up then apply 2 volts/ 1amp in the next step? But i am unsure how to do this with modbus.

 

The manual provides the following information:

 

40001 address is channel 0 read/write and outputs the current value

40002 address is channel 1 read/write and outputs the current value

 

I believe my starting address is 40000 so i input 0 as labview starts at 0? Is this corrrect?

And that i should use function3 read holding registers.

 

I dont know what data to put into my registers if i use write mutiple or data quantity if i use read holding register?

 

I have attached a vi, but i dont know if i require two master query.vis one to write multiple and the other to read holding register. Please help

 

Thank you.

 

0 Kudos
Message 1 of 30
(3,970 Views)
40001 address is channel 0 read/write and outputs the current value
40002 address is channel 1 read/write and outputs the current value

 Typo? info shows both registers as current value.

 

Modbus clients and servers tend to mix zero based and 1 based addressing and is a hit or miss affair. IMO YMMV

To write data to these holding registers you can use function code 16 and write both with a single master query.

 

As a check, you can download modbus poll from modbustools.com and use it to check the addressing scheme, I am guessing that if you enter 40000 and have the base addressing wrong (it is settable in modbus poll) the slave would respond with invalid address as 39999 is outside holding register area.

 

To confirm the Adam got the info, you can read the same registers with function code 3.

The Ethernet master query read/write function blocks include an output terminal for exception code. (I assume the serial do as well) If you tie this to an indicator, is the slave saying anything with an exception code.

 

I can't open your vi as I am still running 2011.

 

0 Kudos
Message 2 of 30
(3,950 Views)

Hi thanks for taking an interest in my problem. No it is not a typo 40001 corresponds to the voltage channel and 40002 to the current channel. I changed the address of the module to 5 and i dont get the timeout error i also get 0 for my exception code.

 

My understanding is not great so what would i need to do to send information to my power supply noting that the module is hardwired to the power supply? I am looking to send a value 1 for voltage and value 1 for current? Would i need the write to multiple registers function and then have a vi for read holding register or input register function?thanks

0 Kudos
Message 3 of 30
(3,943 Views)

What I have done ModbusTCP....

 

Case statement within a timed loop.

Dial - Open connection to slave: No errors - goto to talk, Error goto Hangup

Talk - Read / Write Querys: No errors - goto back to talk, Error goto Hangup

Hangup - Close connection: goto Dial

 

Addresses data size other static items are defined outside the loop, within the loop I set the poll rate by changing the loop inteval within ieach case.

In the talk case,

My data to the slave(s) is packed into an array form shared variables

My data from the slaves in unpacked from the returned array into shared variables

 

 

You might only need to add from panel controls for the Voltage and Current demands.

In the talk case, you would write two registers to the modbus addresses you listed. If you choose, you can verfy they made it by reading them back using function code 3. (if the write query produces no error or exception code it's a good bet they were accepted by the slave without isssue.)

 

 

 

0 Kudos
Message 4 of 30
(3,932 Views)

@S1ack wrote:
40001 address is channel 0 read/write and outputs the current value
40002 address is channel 1 read/write and outputs the current value

 Typo? info shows both registers as current value.

 


No.  40001 is channel 0's current value, the voltage.

No. 40002 is channel 1's current value, the current.

 

 

EDIT:  Sorry, I see it was already answered.  I had typed a reply, got sidetracked and finally got around to posting it.

0 Kudos
Message 5 of 30
(3,926 Views)

Hey,

 

When i use the read holding registers my code works fine but it shows the value 0 in my holding register. I want to write a value to the register, what do i put in for the registers? Do i put my address 40001 and 40002 in the registers or what data do i put in here?

 

Do i put in the voltage and current values in the registers or how does that work? When i use the write to single register/multiple register function i get an error 6001 saying illegal function.

 

Thank you

0 Kudos
Message 6 of 30
(3,924 Views)

Hey RavensFan,

 

I have noticed you are also familiar with modbus could you help me with my problem? I would really appreciate it.

0 Kudos
Message 7 of 30
(3,920 Views)
Do i put in the voltage and current values in the registers or how does that work? When i use the write to single register/multiple register function i get an error 6001 saying illegal function.

Multiple write = FC 16

Single write = FC 6

What your slave supports should be in it's manual.

 

If they are both throwing the error then there must be another address space for inbound commanded outputs.

The data is likely +/-32767 = +/- 10 Volts or 4-20ma - again the scaling will be in the slave's manual.

 

 

0 Kudos
Message 8 of 30
(3,910 Views)

The addresses  40201 and 40202 are the addresses i need for the write operation? The link is http://support.advantech.com.tw/support/DownloadSRDetail_New.aspx?SR_ID=1%2bGE%2b715&Doc_Source=Down... Thank you i have attached a picture of what i have done i still receive the error.

 

Damien

0 Kudos
Message 9 of 30
(3,883 Views)

The fact i want to write a command through my ADAM to the power supply i am using the ADAM 4024 as a master device correct? Can i then use the holding  registers function to write to the power supply?

0 Kudos
Message 10 of 30
(3,877 Views)