Jump to content
OMRON Forums

how to access adc input from ACC 36E in csharp


emsg

Recommended Posts

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

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

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

Guest
This topic is now closed to further replies.

×
×
  • Create New...