My task is to set the machine's clock to UTC using a PC connected by modbus. Hundreds of these will be deployed across the country and beyond. Requiring manual intervention by the end user is not an option. So, not at all knowing what I'm doing, I've been slogging around the swamp for a while, and I think I stumbled on the answer. I ended up here: https://learn.microsoft.com/en-us/windows/win32/wmisdk/swbemdatetime Based on that, I came up with this, which appears to work: Set dateTime = CreateObject("WbemScripting.SWbemDateTime")...
Don, It seems to me you should be able to just look up this key's value in the machine manually: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\Bias. Then just take this value (300 for Eastern Time) and plug it into the script as shown below. dim d d = DateAdd("n", 300, Now()) SetRegisterValue 3, 1, DatePart("s", d) SetRegisterValue 3, 2, DatePart("n", d) SetRegisterValue 3, 3, DatePart("h", d) SetRegisterValue 3, 4, DatePart("w", d) SetRegisterValue 3, 5, DatePart("d", d)...
Or maybe not. When I try to run this it doesn't update. If I comment out the for loop it updates, but it doesn't have the UTC offset. I'm also not sure I see how to get the bias for the local time zone. dim d dim offset offset = 0 Dim wmi : Set wmi = GetObject("winmgmts:root\cimv2") Set timeZones = wmi.ExecQuery("SELECT Bias, Caption FROM Win32_TimeZone") For Each tz In timeZones tz.Bias = -300 tz.Caption = (UTC-05:00) Eastern Time (US & Canada) Next d = DateAdd("n", offset, Now()) 'd = Now() SetRegisterValue...
Oops! I should have read your post more carefully. The stack overflow link shows how to do it. Thanks!
Hi Doug, My customer is saying they want the time in UTC. I've seen some posts showing how to read the registry time offset, but I can't get them to work. Here's what one says to do: Dim var_offset Dim WshShell set WshShell = WScript.CreateObject("WScript.Shell") var_offset = WshShell.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias") d = DateAdd("n", var_offset, Now()) But as soon as I add the 'set' line it stops working. I guess you aren't running wscript interpreter?...
Hi Doug, Thanks for the fast response. I was going to post a message this morning that I had figured it out, but you beat me to it. I found the help page, and that told me I needed a VB script and some of the syntax I needed. Then googling 'vb script date' gave me the functions I needed. I ended up with this: dim d d = Now() SetRegisterValue 3, 1, DatePart("s", d) SetRegisterValue 3, 2, DatePart("n", d) SetRegisterValue 3, 3, DatePart("h", d) SetRegisterValue 3, 4, DatePart("w", d) SetRegisterValue...
Don, Please see if you don't have "clock.vbs" in your sources download folder. It shows how you can use the "timer" variable that is part of Visual Basic Script to get the time. Since it is small I will include it here: dim x dim n dim hr dim min dim sec n = int(timer/100) x = timer - n*100 h = timer SetRegisterValue 3, 0, n SetRegisterValue 3, 1, x if ((int(x/10)*10 - x) >= -1) then SetRegisterValue 3, 2, x ' Or your code here end if hr = int(timer/60/60) min = int((timer - hr * 3600)/60) sec =...
Don, Please see if you don't have "clock.vbs" in your sources download folder. It shows how you can use the "timer" variable that is part of Visual Basic Script to get the time. Since it is small I will include it here: dim x dim n dim hr dim min dim sec n = int(timer/100) x = timer - n*100 h = timer SetRegisterValue 3, 0, n SetRegisterValue 3, 1, x if ((int(x/10)*10 - x) >= -1) then SetRegisterValue 3, 2, x ' Or your code here end if hr = int(timer/60/60) min = int((timer - hr * 3600)/60) sec =...
Balaji, Are you using "seperate set of registers for each station"? Please review https://sourceforge.net/p/modrssim2/tickets/22/ If this does not help, please provide the version that you using, a screen shot of the main screen, and a debug log for me to review. With this information, I will be better able to help you. Thanks. Doug Lyons
How do you write scripts? I have a customer with a Modbus client with no user I/O and they want to set the real-time clock. They suggested Open ModSim, and I learned enough javascript to write a script that reads the PC clock and writes time into holding registers. But I can't get it to respond to my requests. I downloaded ModRSsim2 and it replies to the request, but I need to get the time values from the PC's RTC into the registers. Thanks in advance.
Coil writes are not working well for some ranges
Home
where is the device address setting?
Closing now.
Patrick, Address 0 is not deactivated, but receives and processes requests. It just is prohibited from sending a response because of its slave status that address 0 is a broadcast address for all listening slaves. If more than one responded, this would be very confusing in general. Thanks. Doug Lyons
Malformed Modbus message for Function Code = x17
Closing this now.
Jonas, I have just uploaded a new version 8.21.2.8 what should have this functionality completely implemented for both Serial (your case) and Ethernet. Enjoy and Thanks for your interest and comments on this project. Doug Lyons
Socket Timeout
Closing this now.
Version 8.21.2.8 was just released and it changed the range for timeouts from 10-1000 to 1-1000. Thanks for your interest in this project. Sorry it took so long to get to this request. Doug Lyons
Hi Doug, While I haven't been using this program for a while now, I will make sure to give it a twirl once an update lands ;-)
Jonas, As I mentioned above, Function Code 23 was not implemented on the Serial side. I plan to post an updated versions of this program within the next month that will implement it in version 8.21.2.8, so maybe you can watch for it. I have just recently found time to address this issue. Pavel, Your fix just removed the error message, but did not account for the needed response. Thanks for forking and working on this. Doug Lyons
Physical connection. Not a bug.
Moving to 'closed' now. Thanks.
Sarge, Thank you very much for your follow-up comment. I find it very informative and hopefully it will help out any others who might come here for this or a similar problem.
Yes. If you select the format (Fmt:) as "float 32" this will show the numbers as floating point values and you can enter them directly here. Because we cannot know whether the two consecutive words start on an even or odd address, all addresses are displayed as if they were the beginning value, so you will have to know to use and look at only the odd or even displayed values. This does not allow for any word or byte swaps, but only uses the standard IEEE-32 bit floating point format as used in the...
Several PLC use address 0 to receive their request. It is not correct to deactivate address 0 by programming. Especially since it is already possible with the bottom bar.
Socket Timeout
I've fixed this here https://github.com/Cavaler/ModRSsim2/releases/tag/v8.22.0.1
There are some manufacturers of PLC's that say they support the Modbus protocol that use the swapped word arrangement for floats internally. There is no defined standard within the Modbus documents about how a 32-bit IEEE-754 floating point number is stored in a Modbus PLC. So there is no consistency among manufacturers, other than that most that deviate from what Modbus does, do word swaps. This is what the "Clone" represents. The "Clone" selection means that this handles the 32-bit floats like...
Why is it named 'Clone'?...
Forked this on Github
I suggest that you try using the F1 key and looking at the HTML help file. To answer your question, on the "Registers" display near the top right there is a "Clone" checkbox that reverses the byte order for floats and doubles. Thanks.
This program responds to any Device ID from 1 through 255. Device ID zero (0) is a broadcast address and any requests to this address create no responses. This is the reason that there is no input needed for this parameter. The bottom of the display shows which device is asking for data and you can go to the "Comms" display to see the Device ID. I normally consider this a feature, rather than a bug. Thanks.
Sorry for the delay. I have had health problems lately and am moving slowly these days. From looking at what you attached, it looks like you may be testing using the "serial" protocol. If so, then I have not addressed this at all. I have been testing and using only the TCP/IP protocol. FC23 was the last Function Code that I added and did not address the "serial" side. I retired about 2 years ago and no longer use this much, so there is not much chance I will fix this. Thanks for reporting and if...
Endian formats
How are two register 32bit floats simulated? Do I have to manually figure out the bytes and put in two consecutive registers or is there a way to enter the single value and the simulator can populate both registers?
FYI- I think no one is listening...
I figured it out, thanks for the reply
where is the device address setting?
Ha Doug, believe it or not ... or read the official Doc from modbus.org: https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf ;-) The Schneider picture posted by Chris is "3.5.2 Connectors pin-out for optional 4W-MODBUS", Page 30. This is quite uncommon, but the Pins4/5+8 is also used for the very common "3.5.1 Connectors pin-out for 2W-MODBUS" Page 29. Edit: Okay, I now see your sentence "I do not believe that there is any standard for an RJ45 Modbus connection" could also be read like "Surely...
Ha Doug, believe it or not ... or read the official Doc from modbus.org: https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf ;-) The Schneider picture posted by Chris is "3.5.2 Connectors pin-out for optional 4W-MODBUS", Page 30. This is quite uncommon, but the Pins4/5+8 is also used for the very common "3.5.1 Connectors pin-out for 2W-MODBUS" Page 29. HTH, Sarge
Malformed Modbus message for Function Code = x17
Multiple ID,
Closing now. This is actually a feature request and not a bug. Thanks.
Chris, I do not believe that there is any standard for an RJ45 Modbus connection. I have used many RJ45 connectors in the past and I have always had to refer to the equipment vendor's documentation and mostly use conversion from their standard to RS-232 standard 9-pin D-shell connectors. I have used RS-485 signal levels in the past as well, but only with full documentation from the vendor of the converters or devices. Good Luck! Doug Lyons
Physical connection. Not a bug.
Hi Doug, I realized to 5th station "illegal data address" was due to 13000 I set... Thanks for confirm. I get a workaround by voiding to use ID 5,11,16.... If in the future you'll get a fix, please inform me Do you have a newsletter or similar I can register into? Fabrizio On Thu, Dec 2, 2021 at 6:18 PM Doug Lyons douglyons@users.sourceforge.net wrote: OK. I believe that I see what is happening here. We only have a maximum of 65536 registers that we can use. If you are assigning 13000 registers per...
OK. I believe that I see what is happening here. We only have a maximum of 65536 registers that we can use. If you are assigning 13000 registers per station then we can calculate the maximum stations that you can use as the integer of 65536 / 13000 which is 5. So you can only have 5 stations and so you get the error on station #6. There is a wrap-around effect probably that allows you to use numbers higher than this, that probably should be trapped and reported as an error. On the next revision of...
You should use the 'F1' key when ModRSsim2 is the active window to see the help file and search for "Log" to answer your questions. I have attached a picture here that shows what it says. The file will be named "DEBUG.TXT" and will be in the same directory where ModRSsim2 resides. Thanks.
I enabled logging but..where can I get log files? On Thu, Dec 2, 2021 at 4:13 AM Doug Lyons douglyons@users.sourceforge.net wrote: Also, please turn on logging and capture some example communications for me and attached it here. Thanks. [tickets:#22] https://sourceforge.net/p/modrssim2/tickets/22/ Multiple ID, * Status: open Milestone: 1.0 Created: Wed Dec 01, 2021 04:23 PM UTC by fleaplc Last Updated: Thu Dec 02, 2021 03:09 AM UTC Owner: nobody Attachments: ModRSsim2.mp4 https://sourceforge.net/p/modrssim2/tickets/22/attachment/ModRSsim2.mp4...
you're right, I'm using "use a separate setof registers for each station" : I need it to emulate multiple node ID on same IP address Slave [image: tvnviewer_lXSWqmJGZt.png] On Thu, Dec 2, 2021 at 4:09 AM Doug Lyons douglyons@users.sourceforge.net wrote: Please send me a screen capture of your "Advanced Emulation Settings" page. It can be viewed by clicking on the next-to-the-last button at the top right of the ModRSsim2 screen. I suspect that you may be using the "Use a separate set of registers...
Also, please turn on logging and capture some example communications for me and attached it here. Thanks.
Please send me a screen capture of your "Advanced Emulation Settings" page. It can be viewed by clicking on the next-to-the-last button at the top right of the ModRSsim2 screen. I suspect that you may be using the "Use a separate set of registers for each station. Thanks.
Multiple ID,
One of the options is "Units are all off at startup", so if you check this option, you will have to manually say what you DO want. Maybe that is a help.
Oh, excellent. Will peruse - TVM As usual I have plenty of time to do the job badly, none available to do it properly.
Yup, but my bomb-aiming skills are a bit rusty, so I need all the help I can get.
I just feel that if the s/w being tested is meant to read from slave 2 - but by mistake is reading from 4 - you don' make the world better by replying on 4 :-) So I'd force the user to say where they DO want it to reply, rather than reply to all slave addresses. I see you have a broadcast setting, which would allow that if desired.
Thank you - I had missed the 'at startup' button - that fixes my nervousness, though yes a .bak or a manual archive would be a good thing too. Just to be a devil's advocate - why would you NOT want to restore the last settings at start-up? I believe that people who write stuff have great difficulty un-knowing what they know, and there's nothing like a newbie to ask the obvious, or show you what the man in the street doesn't have at their fingertips. Also on my own stuff I greatly appreciate having...
over-write register config seems to be very easy?
The registers are saved in the file MODDATA.DAT in the same directory as the program. So it may be a good idea to back up this file if it contains lots of changes. You can use a CSV import to set the registers and save this which gives you lots of options for revisions. I will consider adding a confirmation message box to the first two button options in my next program revision. There is a "Load register values on startup" option box when you use the fourth button as shown on the attached screen...
save 'station enabling'
Personally, I never change the stations enabled. But I appreciate your suggestion and I will consider including saving the stations enabled on my next revision.
Suggestion.
I will consider your suggestion for an improvement in my next revision. But for now, once you do double-click, it is very easy to tell where you are as you can see on the attached screen shot. Then you can "Cancel" if you have the wrong address.
Please review the "Help" text available by using the F1 key. Attached is an example of setting the stations to all off at startup for both serial and Ethernet options. Also, it shows how to set the registers to automatically load on startup.
'stations' handling could be better.
Regarding a seperate set of registers per station, this shows how to use the Advanced setting to select this and there is a good explanation in the Help available from the F1 key.
Please review the "Help" text available by using the F1 key. Attached is an example of setting the stations to all off at startup for both serial and Ethernet options.
Any change of an easy-to-install option?
I am glad that you found it. I have provided a compiled EXE that only needs the Visual Studio 2010 redistributable to be installed. Hopefully, you have figured this out now.
over-write register config seems to be very easy?
save 'station enabling'
Suggestion.
'stations' handling could be better.
Sorry - have now located it elsewhere.
Any change of an easy-to-install option?
No serial config window
Closed, since the user answered the question.
It is short for "protocol" which indicates whether you want to use serial, ethernet, A-B, or Joy.
Never mind I didn't know what prot: was for
No serial config window