Lamboom
Lifetime Supporting Member
Here’s a nice problem I haven't been able to solve using basic C programming. Ya have to use basic C when programming Red Lion G3 HMI's (which are awesome HMI's) .. but I'm not a good programmer .. sniff!
I have an actuator that will be commanded to make sine wave motion. The program that does that, in the actuator’s driver-controller, requires the actuator to first be in a zero position. Homing has already been done, so the drive knows where the actuator is. You cannot modify the sine wave program; but, you can command a Move Absolute program in the Motion Controller, which manages the drive, to take the actuator to zero, if it isn’t already there. When the actuator is at zero, it is “In position” and a digital tag will go True. If the Tag is False, the actuator is not at zero, it’s at some other position, and only the Move Absolute program can return the actuator to zero.
So, when launching this Command program, using only Basic C programming, how would you write a control program that would test the status of the actuator’s position, and finding it at zero (the “InPos” tag is therefore true) will start the Sine Wave program. If the “InPos” Tag is false, will then start the Move Absolute program, which will return the actuator to zero; and then, when the actuator is "In Position", will start the Sine Wave program.
Here’s the tricky part. It will take only a few milliseconds to start the Move Absolute program (if required) .. but how do you get the “C” control program you are writing, to wait until the actuator actually reaches zero, and the “inPos” tag goes true … which could take several seconds?
I don’t believe there is a WaitFor function in “C” , and you cannot send either the Move Absolute, or the Sine Wave program more than once .. so, if a loop is used, it can loop only one time .. presumably with conditional delays. You cannot use Sleep().. that would be cheating.. the full program must run in the least amount of time, and you do not know how far the actuator is from zero.
You could use if (! InPos) or if (InPos) to qualify what programs to run .. but, where does the "wait for In position” fit into C Programming?
Perhaps "Continue" is usable.. but where does the "wait" come from.. ? Thanks Much
I have an actuator that will be commanded to make sine wave motion. The program that does that, in the actuator’s driver-controller, requires the actuator to first be in a zero position. Homing has already been done, so the drive knows where the actuator is. You cannot modify the sine wave program; but, you can command a Move Absolute program in the Motion Controller, which manages the drive, to take the actuator to zero, if it isn’t already there. When the actuator is at zero, it is “In position” and a digital tag will go True. If the Tag is False, the actuator is not at zero, it’s at some other position, and only the Move Absolute program can return the actuator to zero.
So, when launching this Command program, using only Basic C programming, how would you write a control program that would test the status of the actuator’s position, and finding it at zero (the “InPos” tag is therefore true) will start the Sine Wave program. If the “InPos” Tag is false, will then start the Move Absolute program, which will return the actuator to zero; and then, when the actuator is "In Position", will start the Sine Wave program.
Here’s the tricky part. It will take only a few milliseconds to start the Move Absolute program (if required) .. but how do you get the “C” control program you are writing, to wait until the actuator actually reaches zero, and the “inPos” tag goes true … which could take several seconds?
I don’t believe there is a WaitFor function in “C” , and you cannot send either the Move Absolute, or the Sine Wave program more than once .. so, if a loop is used, it can loop only one time .. presumably with conditional delays. You cannot use Sleep().. that would be cheating.. the full program must run in the least amount of time, and you do not know how far the actuator is from zero.
You could use if (! InPos) or if (InPos) to qualify what programs to run .. but, where does the "wait for In position” fit into C Programming?
Perhaps "Continue" is usable.. but where does the "wait" come from.. ? Thanks Much