Sign in to follow this  
Followers 0
David Larsson

Write program to PLC thru SerialPort using WP

4 posts in this topic

Hi! I´m having trouble figuring out how the WP command works and how I should use it. The PLC is a CPM1A V1 I have a application that will be used alot of times and always will look the same so I want to be able to send a CD with the installer for our software and then it scans for connected plc´s of the right model. Well I have all that workng and when it finds a plc it adds it to the database and adds an ID to the plc´s memory and starts to read the status of the plc. Its all working as a charm but as it is now a small program is needed in the plc and that means that I need to send all plc´s here, unpack them, program them, pack them again and then send them to the customer. The solution is that if its a new plc which the pc-software knows if it is it could program it and then use it. But I cant get the command to work and I´m not sure if I get the right program out the plc. I use MultiWay to figure out what commands to send in my software but the WP command isnt really explained much. I use the RP command and get alot of data from the plc which seems to be the program. But if I use the download program function in MultiWay I get another Hex-code. And if I try to send it all I get is a message back that basicly says that it didnt work. (Should return 00 if it works but it returns 84) The command I´m trying to send now looks like this: @00WP0080081B9E00010C140C1480091D9E0C1600010C16800A1D9E0C1800010C18800B1D9E0C1A00010C1A800C1D9E0C1C00010C1C800D1D9E0C1E00010C1EA0081D9E0C2800010C28A0091D9E0C2A00010C2AA00A1D9E0C2C00010C2CA00B1D9E0C2E00010C2EA00C1D9E0C3000010C30A00D1D9E0C3200010C321814DEADDEAD18011801 + checkSum+*+\r Its the command first @00WP00 (Should the last two 00 be there?) then its the program that was in the textfile downloaded from the plc and then the same ending I use for all other commands that works. Could really need some help figuring out how to send this cause it would save me alot of work later on. /David Edited by David Larsson

Share this post


Link to post
Share on other sites
David Here is the way that RP and WP work. To read the program, you issue an RP command such as @00RP42*<CR> The PLC will respond with multiple frames of data as follows first frame = @00RP00 + data for that frame, followed by <CR> (not by *<CR>). after the PC recieves this frame, it sends back a <CR> to acknowledge receipt of the frame, then the PLC send the next frame second frame = data for the frame + <CR> (again, not *<CR>). PC sends back a <CR> third frame from PLC to PC PC sends back a <CR> ..... last frame = data for the frame + <FCS>*<CR>. The *<CR> marks to the PC that this is the last frame. The <FCS> is for all the packets starting from the @00RP... WP is the same thing in reverse. First frame @00WP + first frame data + <CR> (not *<CR>). PLC sends back <CR> you send second frame data (do not start with @00WP, just send the second frame data) + <CR> PLC sends back <CR> you continue to send frames of data... on the last frame you send, send the frame data + <FCS> + *<CR>. The FCS that you send is for the entire Hostlink WP command, not just the last frame. I have attached a working example in VB6, if this helps. Sorry, it could be documented a little better. PMCR WPRPExample.zip

Share this post


Link to post
Share on other sites
Hi! Thanx for your help! I will look into it under the day and hopefully it will work... Omron should really write some more about this command in their manual. /David

Share this post


Link to post
Share on other sites
Omron manuals can take some 'getting used to'. They tend to not overload a section of the manual with too much information. Many times relative information cannot be found in the same section or even the same manual for that matter. In the case of the information that PMCR has provided, it is in the section labeled "Block Format" and "Block Format With More Than One Frame". You'll find that format is the same for all commands that require or return multiple frames. I hope that makes it easier to understand. Good Luck.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0