How can i add the adc function in ANSI C? (by Carlos )
I'm interested in adding the function of adc reading and have a variable from this feature I've seen in the section of this function ansic.cpp that there is only one message. and I can modify the code and do not throw me error.Greetings
(no subject) (by Jonathan Westhues)
You can modify your PLC runtime code to write the A/D result to a special variable every frame before it calls PlcCycle(). For example, to make the ADC result available as the ladder logic variable AdcResult, you'd write to U_i_AdcResult.
Take a look at the comment around EXTERN_EVERYTHING in the generated code, and let me know if you have any questions. A similar technique can be used to implement analog outputs, like a DAC or PWM duty cycle.