emsg Posted June 21, 2016 Share Posted June 21, 2016 we are using ACC 36 E card to read analog input on TurboPMAC2 We have done coding in csharp and tried to access base address of ACC36E In csharp code, we have initialsed M5000 to point at base address. then assigned M5000 to P2001 output shows M5000 as 2730 and P2001 as 0 continuously even after varying analog input from 0 to 5 V We are new to TurboPmac and its development in csharp so require help and guidance. Csharp code is as follows 1.command = "M5000->Y:$078C00,0,12,U"; //Register for 12 bit first ADC of pair 2.Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 3.command = "M5002->Y:$078C00,12,12,U"; //Register for 12 bit second ADC of pair 4.Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 5.command = "M5004->Y:$078C00,0,24,U"; //register for channel select (value: 0-7) 6.Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 7.command = "M5005->Y:$078F30,5,1"; //Register for first ADC ready Flag 8.Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 9.command = "M5005"; //Register for first ADC ready Flag 10.Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 11.response = response.Trim(); 12.LowADCReady = Convert.ToDouble(response); 13.command = "M5006->Y:$078F31,5,1"; //Register for second ADC ready Flag 14.Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 15.command = "M5006"; //Register for first ADC ready Flag 16.Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 17. response = response.Trim(); 18.HighADCReady = Convert.ToDouble(response); 19.command = "M5004=0"; //Select ADC channel 20.Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 21. while (LowADCReady != 1 && HighADCReady != 1) 22. { 23. command = "M5005"; //Register for first ADC ready Flag 24. Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 25. response = response.Trim(); 26. LowADCReady = Convert.ToDouble(response); 27. command = "M5006"; //Register for first ADC ready Flag 28. Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 29. response = response.Trim(); 30. HighADCReady = Convert.ToDouble(response); 31. } 32. command = "M5000"; //Register for 12 bit first ADC of pair 33. Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 34. Console.WriteLine("M5000 o/p = " + response ); // o/p = 2730 35. command = "P2001 = M5000"; 36. Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 37. command = "P2001"; //Register for 12 bit first ADC of pair 38. Pmac.GetResponseEx(m_nDevice, command, false, out response, out status); 39. response = response.Trim(); 40. Console.WriteLine("P2001 o/p = " + response); // o/p = 0 Link to comment Share on other sites More sharing options...
Jay Lee Posted June 21, 2016 Share Posted June 21, 2016 not really sure if this is a csharp coding problem or not. If you can read M5000 with some value, there is no reason you are not seeing it in P2001. Make sure there is no other program or PLC writing to P2001 at the same time. and make sure the assignment from M5000 to P2001 is continuous, otherwise you are just assigning a value once in the beginning. Link to comment Share on other sites More sharing options...
Omron Forums Support Posted June 21, 2016 Share Posted June 21, 2016 What is the code used for what you said: initialized M5000 to point at base address. then assigned M5000 to P2001? Link to comment Share on other sites More sharing options...
emsg Posted June 22, 2016 Author Share Posted June 22, 2016 I have updated this thread as ACC 36E was used and csharp code also given Link to comment Share on other sites More sharing options...
emsg Posted June 28, 2016 Author Share Posted June 28, 2016 please provide sample csharp programs on how to use turbo pmac2 with its acc like acc24e2,acc35,acc65,acc53 for getting started easily Link to comment Share on other sites More sharing options...
Recommended Posts