JBauer Posted November 29, 2013 Share Posted November 29, 2013 Does the PMAC continue to execute motion lines? How does you program open the buffer at the beginning of the "for" loop? No, The program stops exactly after executing 600 lines. But the lines are sent to the rotary buffer which is 1200 provided by PR command once after the motion is stopped. Also the GUI get back to the update thread since the PR value is more than 750. The first rotary open is as follows PMACCom("A"); PMACCom("&1"); PMACCom("Q CLOSE I9=0"); PMACCom("&1 DEL ROT"); PMACCom("CLS"); PMACCom("CLR"); sprintf( strCom, "&1 DEFINE ROT %d",BufferSize); PMACCom(strCom); PMACCom("DELETE TRACE"); PMACCom("DELETE GATHER"); PMACCom("&1 DEFINE LOOKAHEAD 1000,500"); PMACCom("&1B0"); PMACCom("&1 OPEN ROT CLR"); And the subsequent open is as in the code snippet provided. The code execution is fine, if I don't close the buffer until all the NC codes are sent to the buffer. Hope you could provide a solution for this problem since we are struggling with it for long time now. In your code: LineIndex++; if(LineIndex>=(total_line_count)) { PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; return; } } } else { PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; } } else { PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; return; } //****************************************************** I would comment out the PMACCom("CLOSE"); and see what happend. I´m almost sure it will make it. This code: if(LineIndex>=(total_line_count)) { PMACCom("CLOSE"); ->will stop execution before it is finish. Instead of sending "CLOSE" ,send a M30 and make a CMD"CLOSE" inside the M30, but first try the comment out of the PMACCom("CLOSE"); and test it. //********************************************** To find out pmac need more lines I use to read this address ry:$203f Read bit 17 : pmac need more lines if (readresult and 65536)=0 I only use the PR command for fun to display a progressbar. Link to comment Share on other sites More sharing options...
Raghav Posted November 29, 2013 Author Share Posted November 29, 2013 Does the PMAC continue to execute motion lines? How does you program open the buffer at the beginning of the "for" loop? No, The program stops exactly after executing 600 lines. But the lines are sent to the rotary buffer which is 1200 provided by PR command once after the motion is stopped. Also the GUI get back to the update thread since the PR value is more than 750. The first rotary open is as follows PMACCom("A"); PMACCom("&1"); PMACCom("Q CLOSE I9=0"); PMACCom("&1 DEL ROT"); PMACCom("CLS"); PMACCom("CLR"); sprintf( strCom, "&1 DEFINE ROT %d",BufferSize); PMACCom(strCom); PMACCom("DELETE TRACE"); PMACCom("DELETE GATHER"); PMACCom("&1 DEFINE LOOKAHEAD 1000,500"); PMACCom("&1B0"); PMACCom("&1 OPEN ROT CLR"); And the subsequent open is as in the code snippet provided. The code execution is fine, if I don't close the buffer until all the NC codes are sent to the buffer. Hope you could provide a solution for this problem since we are struggling with it for long time now. In your code: LineIndex++; if(LineIndex>=(total_line_count)) { PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; return; } } } else { PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; } } else { PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; return; } //****************************************************** I would comment out the PMACCom("CLOSE"); and see what happened. I´m almost sure it will make it. This code: if(LineIndex>=(total_line_count)) { PMACCom("CLOSE"); ->will stop execution before it is finish. Instead of sending "CLOSE" ,send a M30 and make a CMD"CLOSE" inside the M30, but first try the comment out of the PMACCom("CLOSE"); and test it. //********************************************** To find out pmac need more lines I use to read this address ry:$203f Read bit 17 : pmac need more lines if (readresult and 65536)=0 I only use the PR command for fun to display a progressbar. The CLOSE after if(LineIndex>=(total_line_count)) { PMACCom("CLOSE"); and the last close after the last else is to close the buffer once all the NC codes are sent to PMAC. So I had commented the 2nd "CLOSE" and just enabled the machine timer. I tried with commenting the "Close" command. But there is memory violation errors popping out. I hope since the buffer is open and i try to update the machine status, PMAC creates an error since the UI queries the M variables. Link to comment Share on other sites More sharing options...
JBauer Posted November 29, 2013 Share Posted November 29, 2013 Does the PMAC continue to execute motion lines? How does you program open the buffer at the beginning of the "for" loop? No, The program stops exactly after executing 600 lines. But the lines are sent to the rotary buffer which is 1200 provided by PR command once after the motion is stopped. Also the GUI get back to the update thread since the PR value is more than 750. The first rotary open is as follows PMACCom("A"); PMACCom("&1"); PMACCom("Q CLOSE I9=0"); PMACCom("&1 DEL ROT"); PMACCom("CLS"); PMACCom("CLR"); sprintf( strCom, "&1 DEFINE ROT %d",BufferSize); PMACCom(strCom); PMACCom("DELETE TRACE"); PMACCom("DELETE GATHER"); PMACCom("&1 DEFINE LOOKAHEAD 1000,500"); PMACCom("&1B0"); PMACCom("&1 OPEN ROT CLR"); And the subsequent open is as in the code snippet provided. The code execution is fine, if I don't close the buffer until all the NC codes are sent to the buffer. Hope you could provide a solution for this problem since we are struggling with it for long time now. In your code: LineIndex++; if(LineIndex>=(total_line_count)) { PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; return; } } } else { PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; } } else { PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; return; } //****************************************************** I would comment out the PMACCom("CLOSE"); and see what happened. I´m almost sure it will make it. This code: if(LineIndex>=(total_line_count)) { PMACCom("CLOSE"); ->will stop execution before it is finish. Instead of sending "CLOSE" ,send a M30 and make a CMD"CLOSE" inside the M30, but first try the comment out of the PMACCom("CLOSE"); and test it. //********************************************** To find out pmac need more lines I use to read this address ry:$203f Read bit 17 : pmac need more lines if (readresult and 65536)=0 I only use the PR command for fun to display a progressbar. The CLOSE after if(LineIndex>=(total_line_count)) { PMACCom("CLOSE"); and the last close after the last else is to close the buffer once all the NC codes are sent to PMAC. So I had commented the 2nd "CLOSE" and just enabled the machine timer. I tried with commenting the "Close" command. But there is memory violation errors popping out. I hope since the buffer is open and i try to update the machine status, PMAC creates an error since the UI queries the M variables. //****************************************** Instead of comment out the PMACCom("CLOSE"); //PMACCom("CLOSE"); you can change it to PMACCom("M30"); But not the first Close command in the top of your program or you can make a BIIG delay (10 sek or more) before all the the PMACCom("CLOSE"); and if it makes a different Link to comment Share on other sites More sharing options...
Unit101 Posted November 29, 2013 Share Posted November 29, 2013 Hello, I have written many HMI's that use DPRam and the BinRot to download millions of lines of NC code... actually running programs for weeks at a time on a single machine. I have a good example application showing basics of doing this both with ASCII and Binary type buffer. But it is written in Visual Studio and using PcommServer If this will help you I be glad to give you a full copy with source. -I have attached a pdf that describes this demo app... Are you connected to PMAC with USB or Ethernet ? Can you show me the line of code actually sending the line to execute to the buffer ? I'm confused reading all the posts above... and not sure what is or is not working ? Can you describe simply what IS and what IS NOT working ? I also have some examples of using PMAC Interrupts and data gathering techniques. Note that with my NC hmi I use multiple threads, one to send the data to the pmac buffer, and a different thread to update the HMI to watch motor positions, status, NC line number executing, and even draw on simple 2D graphics the motion as it is executing... Thanks, mikePComm2 Delta Tau Example HMI Program.pdf Link to comment Share on other sites More sharing options...
Raghav Posted November 29, 2013 Author Share Posted November 29, 2013 Hello, I have written many HMI's that use DPRam and the BinRot to download millions of lines of NC code... actually running programs for weeks at a time on a single machine. I have a good example application showing basics of doing this both with ASCII and Binary type buffer. But it is written in Visual Studio and using PcommServer If this will help you I be glad to give you a full copy with source. -I have attached a pdf that describes this demo app... Are you connected to PMAC with USB or Ethernet ? Can you show me the line of code actually sending the line to execute to the buffer ? I'm confused reading all the posts above... and not sure what is or is not working ? Can you describe simply what IS and what IS NOT working ? I also have some examples of using PMAC Interrupts and data gathering techniques. Note that with my NC hmi I use multiple threads, one to send the data to the pmac buffer, and a different thread to update the HMI to watch motor positions, status, NC line number executing, and even draw on simple 2D graphics the motion as it is executing... Thanks, mike Hi Mike, I had followed the same logic as you have in the example. I have a thread for updating the machine status and I have a subprogram which is called by the thread every 50ms. So once the user clicks on the send buttons, a set of lines are first sent immediately after open buffer command. Soon after that, R command is given and the PMAC executes the NC lines sent to the buffer. So after this first set of NC codes, the control moves to the update thread, in which the same logic of sending lines is performed. During sending the lines, the machine update thread is disabled. and after the lines are sent, the subprogram enables the thread back. Now the issue is, if I use the same logic but without using the CLOSE command in between anywhere, all the lines are executed perfectly. But no update of the machine status is possible since the buffer is open. But if I CLOSE the buffer after sending the required number of lines, the motion execution is achieved until the first CLOSE command with remaining few lines still in the buffer which is identified from the PR command. So my main issue is to CLOSE the buffer intermittently to update the machine status and also the executing lines info. I'm using USB communication. So following are the set of program which I had written to send the NC codes: if(PR<750) { for (int i =0; i<=(1500-PR); i++) { PMACCom(String[LineIndex].c_str()); // Sending the NC codes here LineIndex++; if(LineIndex>=(total_line_count)) { PMACCom("&1B0R"); firstRUN = false; PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; return; } } if(firstRUN ==true) { PMACCom("&1B0R"); //PMACCom("CLOSE"); // if I comment this and disable the machine timer, everything works fine firstRUN = false; sub_function(); // calling the sub-function here } Sub_function if(PR<750) { tmrUpdateMachineState->Enabled = false; //PMACCom("&1 OPEN ROT"); //Want to use the Open and close buffer in the sub-function so that i can // Update the machine status for (int i =0; i<=(1500-PR); i++) { PMACCom(String[LineIndex].c_str()); LineIndex++; if(LineIndex>=(total_line_count)) { PMACCom("CLOSE"); tmrUpdateMachineState->Enabled = true; return; } } } else { PMACCom("CLOSE"); // if I comment this and disable the machine timer, everything works fine tmrUpdateMachineState->Enabled = true; return; } Link to comment Share on other sites More sharing options...
Raghav Posted November 29, 2013 Author Share Posted November 29, 2013 Hello, I have written many HMI's that use DPRam and the BinRot to download millions of lines of NC code... actually running programs for weeks at a time on a single machine. I have a good example application showing basics of doing this both with ASCII and Binary type buffer. But it is written in Visual Studio and using PcommServer If this will help you I be glad to give you a full copy with source. -I have attached a pdf that describes this demo app... Are you connected to PMAC with USB or Ethernet ? Can you show me the line of code actually sending the line to execute to the buffer ? I'm confused reading all the posts above... and not sure what is or is not working ? Can you describe simply what IS and what IS NOT working ? I also have some examples of using PMAC Interrupts and data gathering techniques. Note that with my NC hmi I use multiple threads, one to send the data to the pmac buffer, and a different thread to update the HMI to watch motor positions, status, NC line number executing, and even draw on simple 2D graphics the motion as it is executing... Thanks, mike Also let me know if I need to put in lot of effort if I use BIN Rot or DPRAM option for sending the ASCII code. Can you share the PMAC interrupt and data gather option as well. I would request you to suggest me the easier option so that i can wind-up this project Link to comment Share on other sites More sharing options...
JBauer Posted November 29, 2013 Share Posted November 29, 2013 Also let me know if I need to put in lot of effort if I use BIN Rot or DPRAM option for sending the ASCII code. Can you share the PMAC interrupt and data gather option as well. I would request you to suggest me the easier option so that i can wind-up this project It is not easy for me to tell how to do in C++, because I write my software for IPAD in objective C, but my experience is : Do not send the "CLOSE" command before PR is 0. Jorgen Link to comment Share on other sites More sharing options...
Unit101 Posted December 2, 2013 Share Posted December 2, 2013 Go here to get full example HMI. https://www.dropbox.com/s/ktkqk05njfgbjjy/Pcomm2_120409.zip?n=12757969 I see you have a function PMACCom() but this does not show me what/how you are sending lines to pmac buffer ? I assume you have a line like this ? Pmac.DPRAsciiStrToRotEx(m_nDevice, command, 0, bufSendImmediate, out status); What is "bufSendImmediate" set to ? True, False ? I think this is you issue.... Since using USB you need to set this value to "FALSE" until you are ready to send the LAST set of lines to buffer, then you set this to TRUE. It is a bit tricky but look at example code: private void loadNcToBuffer() function closely... Look at the do-while loop that contains the Pmac.DPRAsciiStrToRotEx() function, you can see that the "bufSendImmediate" is changed while downloading.... Thanks, mike Link to comment Share on other sites More sharing options...
Raghav Posted December 4, 2013 Author Share Posted December 4, 2013 Go here to get full example HMI. https://www.dropbox.com/s/ktkqk05njfgbjjy/Pcomm2_120409.zip?n=12757969 I see you have a function PMACCom() but this does not show me what/how you are sending lines to pmac buffer ? I assume you have a line like this ? Pmac.DPRAsciiStrToRotEx(m_nDevice, command, 0, bufSendImmediate, out status); What is "bufSendImmediate" set to ? True, False ? I think this is you issue.... Since using USB you need to set this value to "FALSE" until you are ready to send the LAST set of lines to buffer, then you set this to TRUE. It is a bit tricky but look at example code: private void loadNcToBuffer() function closely... Look at the do-while loop that contains the Pmac.DPRAsciiStrToRotEx() function, you can see that the "bufSendImmediate" is changed while downloading.... Thanks, mike Dear Mike, Thank you for your reply. Currently I'm using the ASCII communication with "DeviceGetResponseEx" command. PMACCom calls this function. In this case how do I send the command to the buffer and also update the coordinates? In the Pcomm application you had sent me, the machine coordinates are update while using non-ascii communication alone and that too using the "GetNetActualPosition" which I'm unable to find in the PCOMM32.dll calls. Also in the ASCII communication in your code, I'm unable to see any "CLOSE" command for intermittent machine coordinate updates. So should I use only the DPRAM option to update in real-time? Kindly advise. Link to comment Share on other sites More sharing options...
Unit101 Posted December 4, 2013 Share Posted December 4, 2013 My recommendations: 1. Be sure to use the latest PcommServer, not the older pcomm. 2. Use DPram for ALL but most simple and basic communication with pmac. - you might use getresponse to send an "occasional" command to pmac but NOT when doing buffer and move downloads while running the machine !... here ONLY use DPram to work with pmac. -you simply set up registers of data in pmac dpram to hold all the data you want, then in pmac perhaps in a plc you update these registers as often as needed.... then on PC side you simply get a group of registers at a time and bring them over, then parse the data out... -so with a single command on PC you can get 100's of registers from pmac with data such as motor position and status... -below is another example application that shows exactly how to do this... look for the function GetDPRWords() -it takes a bit of work to set this up, but once you do all the data in PMAC is easily available to your application.... and with very low overhead on the system and communications -I have also attached a doc on the comms with PcommServer -since changes in company we don't use dropbox anymore, for example application please simply email me directl Thanks, mikeGuide-PMAC-Drivers-Setup-2013.pdfGuide-PMAC-Communication2012.pdf Link to comment Share on other sites More sharing options...
Raghav Posted December 4, 2013 Author Share Posted December 4, 2013 My recommendations: 1. Be sure to use the latest PcommServer, not the older pcomm. 2. Use DPram for ALL but most simple and basic communication with pmac. - you might use getresponse to send an "occasional" command to pmac but NOT when doing buffer and move downloads while running the machine !... here ONLY use DPram to work with pmac. -you simply set up registers of data in pmac dpram to hold all the data you want, then in pmac perhaps in a plc you update these registers as often as needed.... then on PC side you simply get a group of registers at a time and bring them over, then parse the data out... -so with a single command on PC you can get 100's of registers from pmac with data such as motor position and status... -below is another example application that shows exactly how to do this... look for the function GetDPRWords() -it takes a bit of work to set this up, but once you do all the data in PMAC is easily available to your application.... and with very low overhead on the system and communications -I have also attached a doc on the comms with PcommServer https://www.dropbox.com/s/bv8rroh7j7l8713/Pcomm3-120413.zip Thanks, mike Dear Mike, I had tried to use the "DeviceDPRAsciiStrToRotEx" command instead of the getresponse, but the NC codes are not executed at all. These are the calls I used to initialize the DPRam and for PR value I used "DeviceDPRProgRemaining". ENABLE/DISABLE ROTARY BUFFER EnabDisabDPRCom(int state) { if(state ==1) { DeviceDPRRotBufChange(noOfDevice, 0, BufferSize); DeviceDPRRotBuf(noOfDevice, 1); } else { DeviceDPRRotBuf(noOfDevice, 0); DeviceDPRRotBufRemove(noOfDevice, 0); DeviceDPRRotBufClear(noOfDevice, 0); } } OPENING THE ROTARY BUFFER PMACCom("M999->DP:$60F48"); PMACCom("UNDEFINE ALL"); PMACCom("A"); PMACCom("&1"); PMACCom("Q CLOSE I9=0"); PMACCom("CLS"); PMACCom("CLR"); sprintf( strCom, "&1 DEFINE BIN ROT %d",(BufferSize/2)); PMACCom(strCom); PMACCom("DELETE TRACE"); PMACCom("DELETE GATHER"); PMACCom("&1 DEFINE LOOKAHEAD 1000,500"); PMACCom("&1B0"); PMACCom("&1 OPEN BIN ROT CLR"); SENDING ASCII COMMAND EnabDisabDPRCom(1); OpenRotBuffer(); RotaryBuffer=1; LineIndex=0; firstRUN=true; long PR = ProgRemaining(); if(PR { for (int i =0; i<=(BufferHighLimit-PR); i++) { bool bufstate = false; command = "M999==" + AnsiString(LineIndex+1); PMACRotCom(bufstate, command.c_str()); if(i == (BufferHighLimit-PR)) bufstate = true; PMACRotCom(bufstate,reditMain->Lines->Strings[LineIndex].c_str()); command = ""; LineIndex++; if(LineIndex>=(total_line_count)) { PMACcontrolObj->EnabDisabDPRCom(0); if(firstRUN ==true) { PMACRotCom("&1R"); firstRUN = false; } tmrUpdateMachineState->Enabled = true; return; } } if(firstRUN ==true) { PMACRotCom("&1R"); firstRUN = false; tmrUpdateMachineState->Enabled = true; } } } TIMER EVENT Above code is repeated in this. I'm not closing the buffer anywhere in the code. I disable the DPRAM option at the end of the NC code execution. So I'm not sure whether I can use the "getresponse" command to update my UI or do I need to set-up the M variables as you had mentioned above. Since the all the programming is completed using Pcomm32.dll and only this rotary buffer issue is pending, I would like to continue with Pcomm32.dll as of now and use the DPRam functions. I tried to execute the NC program, but no motion is achieved. Also it shows that all the NC codes are sent to the PMAC. I'm not sure where and what is the mistake I'm making as i'm pretty new to DPRAM option. I would like to get your help in setting up the DPRAM program. The code sample which you had sent is created in newer version of visual studio and I'm unable to open it. I currently have VS2008. Looking forward for your suggestions in this regard. Link to comment Share on other sites More sharing options...
Unit101 Posted December 10, 2013 Share Posted December 10, 2013 I resent you link to example that demonstrates in a simple way the method recommended to work with Binary Rotary and Ascii buffer and DPRam for VS2005. I includes pmac code as well so with this example you should be able to create a simple version of what you need to do. I strongly suggest you work to get the example running then I'm sure you will best understand how to implement similar logic in your more extensive machine code. If you have trouble with example let me know I can help you with this since I have same code. Helping you with your larger program is very difficult since we only see code snippets and not the whole thing. The secret is to first get the logic working in as simple a system as possible... then build from there. Best Regards, mike Link to comment Share on other sites More sharing options...
fly away Posted June 3, 2016 Share Posted June 3, 2016 Hello, I have written many HMI's that use DPRam and the BinRot to download millions of lines of NC code... actually running programs for weeks at a time on a single machine. I have a good example application showing basics of doing this both with ASCII and Binary type buffer. But it is written in Visual Studio and using PcommServer If this will help you I be glad to give you a full copy with source. -I have attached a pdf that describes this demo app... Are you connected to PMAC with USB or Ethernet ? Can you show me the line of code actually sending the line to execute to the buffer ? I'm confused reading all the posts above... and not sure what is or is not working ? Can you describe simply what IS and what IS NOT working ? I also have some examples of using PMAC Interrupts and data gathering techniques. Note that with my NC hmi I use multiple threads, one to send the data to the pmac buffer, and a different thread to update the HMI to watch motor positions, status, NC line number executing, and even draw on simple 2D graphics the motion as it is executing... Thanks, mike Hello, I using the DPRAM binary ROT recently,but I don't complete the function of this.There is a problem that bothers me.When I down load the file to the DPRAM ROT,then the PMAC will get the file text from the DPRAM ROT to the internal ROT .The file awalys down load to the DPRAM ROT completely .But there are awalys some file don't down load into ROT in the PMAC.Maybe I don't understand the mechanism of the DPRAM Binary ROT and ROT.and I can't down load the PDF file for your privided. Can you give me the documents about this . Thanks Link to comment Share on other sites More sharing options...
Recommended Posts