Author Topic: analogue input control analogue output  (Read 5900 times)

can

  • Full Member
  • Posts: 160
  • I'm a llama!
    • View Profile
analogue input control analogue output
« on: May 02, 2011, 10:45:28 AM »
Hi. If I need to control a motor based on adc(1), how can I get a responsive control? eg, if adc(1) > 15, setdac 1,500. However, when adc(1) < 15, setdac 1,0. It has to do this while looking out for changes from adc(1) until an interupt is activated. Do I use a while loop? thank you.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:analogue input control analogue output
« Reply #1 on: May 02, 2011, 11:05:17 AM »
You can use the {CusFn} form (non-differentiated) of the custom function so that this custom function that monitors the ADC can be executed every scan of the ladder program. This way your program will still be running other parts and not get locked up into only the while loop that monitors the ADC.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

can

  • Full Member
  • Posts: 160
  • I'm a llama!
    • View Profile
Re:analogue input control analogue output
« Reply #2 on: May 02, 2011, 11:10:27 AM »
Hi. If I put an interlock for this process, will the response time be better? When this process is run, all other steps are ignored until this process is completed. Thanks.


support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:analogue input control analogue output
« Reply #3 on: May 02, 2011, 03:05:37 PM »
If your system can tolerate the program being stuck inside a while loop to monitor the ADC then you can use a while loop to continuously monitor the ADC as you have intended. You should have a way to break it out using interrupt (e.g. ISR can change a variable so that the while loop will break if the variable is changed to a certain value.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS