LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus testing CVI code

Roberto, 

 

Your CVI 7.1 project ZIP seems to be missing the file "ModbusFramework.c".  Can you re-upload?

 

 

 EDIT

 

I see that the file does exist in the modbus.zip file also attached.  Assuming there's no difference between the two versions, I just copied it myself.

 

Thanks!

 

 

0 Kudos
Message 21 of 30
(1,986 Views)

You're right, it is missing in 7.1 project. Taking it from the other project is ok.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 22 of 30
(1,977 Views)

I am facing the same issue with my device where i can query , but i cannot write anything to the device. I am getting error 99 time out. 

0 Kudos
Message 23 of 30
(1,927 Views)

Please, do not duplicate your posts...

0 Kudos
Message 24 of 30
(1,918 Views)

Hi Robert Bozolo,

I am also having the EXACT same issues described here using the Modbus testing CVI code you provided: 1) When I "query" the device, I would get -58 or CRC error about 60 percent of the time. When I tried to "write" to the device I always (100%) got crc errors. I have never been able to write to the device.

My question is: has this issue been resolve by anyone? Any help would be appreciated. 

Thank you.

 

Bob

0 Kudos
Message 25 of 30
(1,249 Views)

Hi Bob,

 

Could you elaborate on the troubleshooting steps you have taken so far? This post has included several troubleshooting steps to attempt so we would not want to reiterate any of those steps.

Brian.D
NI Product Owner
VeriStand
0 Kudos
Message 26 of 30
(1,230 Views)

Hi Robert Bozolo,

Sorry for the very long delay. I was busy doing other work. I have attached four screenshots which show the errors I am getting.

1) Modbus product I am testing is Ruideng Power Supply DPS5015. Power supply is 0-12V adjustable DC Power Supply set to 4.99V.
2) I am using CVI2012. My test system is Win7 SP1, 64-bit OS, Intel Core 2 CPU 2.4GHz, 4 GIG RAM

Screenshot 1
------------
I am attempting to read voltage output of power supply. Pressing "Querry Slave" (the very first time) produced Error.

Screenshot 2
------------
Pressing "Querry Slave" (the second time) produced the correct query result of 4.99V. "Answer from Slave" window gives:
msg[3]  =  Ist data = Hi Byte = 0x01
msg[4]  =  2nd data = Lo Byte = 0xf3
The two bytes together becomes 0x01f3
Converting 0x01f3 (Hex) to decimal = 499
Dividing this by 100 gives the result = 4.99V

Screenshot 3
------------
I am attempting to set output voltage of power supply to 9.54V. Pressing "Write to Slave" button produced the displayed error.
I tried about 15 times. I got same error result.

Screenshot 4
------------
I am attempting to set output voltage of power supply to 9.54V. I re-run modbus program. Pressed "Write to Slave" button.
Got error on 1st run. On 2nd run and onward I never got any errors but it did not set the power supply voltage - nothing happened:
Data in msg[7] (Ist data = Hi Byte) and msg[8] (2nd data = Lo Byte) did not add up to the expected 9.54V.
Is there something I am doing wrong. Any help would be appreciated.

 

0 Kudos
Message 27 of 30
(1,195 Views)

The very first thing I noticed is that you leaved time-to-wait=0 msec! That is, the program does not give time to the slave to elaborate the command and answer to it.

That time-to-wait parameter is used by my example both for read and write commands, so it affects all tests you are performing. By running my code step-by-step you will find that both QueryMem () and WriteMem () functions receive a 'wait' parameter in milliseconds.

 

What is probably happening is that the first command times out (your error 1 screen states that), the second one finds and answer which is really the answer to your first query sitting in the input queue! This could also explain the CRC error: the program may be trying to decode what it thinks is the answer to a message but is really the answer to the (possibly different) previous one.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 28 of 30
(1,191 Views)

I remember putting wait(3) but it also did not work. I would verify again this weekend and post my result this coming Monday 10/8/18.

Thanks for the reply.

 

Bob

0 Kudos
Message 29 of 30
(1,178 Views)

Well, 3 msec is quite short a delay! I always had to use larger delays (say 50~200 msec) with the devices I interfaced till now. I would experiment with different delays for testing, turning off and on the device to be sure it is answering the last query or better flushing the input queue before sending a message. 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 30 of 30
(1,174 Views)