friendlyfire
Member
Hi gang,
What a great forum, I've learned a great deal from all the posts and thoughtful responses.
I'm developing a controller using the ST language. I haven't settled on a hardware platform and am for the moment using the TwinCat software from Beckhoff to get a head start on the design. I'm impressed with the power of the language and capabilties of the software tool. I have a couple of questions about coding in ST.
a) is there a really good book that goes beyond providing an overview of IEC 61131 languages and into details of how best to implement real control solutions? I checked Amazon and saw a couple of options but it would be nice to have some recommendations.
b) I've written some code to run a counter at a variable frequency. This may become the engine generating the pulse sequence to a stepper motor. I'm used to VHDL (for gate arrays) and it is normal in that environment to pull whatever bits you need from a counter, but in ST it doesn't seem to be easy to grab just one bit. To be specific, in this case I just want to pull out the least significant bit of the counter and feed this to an ouput (so it will be a square wave at the frequency of the signal driving the counter). Optionally I will use other bits which present square waves at various divisions of the driving signal...
The counter is a WORD variable. I can write some kind of hack something like
IF INT(counter/2)*2 = counter then
pulse:=1;
ELSE
pulse:=0;
END_IF
but this seems very clumsy
Am I missing a quick way to connect one bit of a word variable to a boolean? In VHDL it would look something like pulse:=counter[0] if my memory serves correctly.
thanks
What a great forum, I've learned a great deal from all the posts and thoughtful responses.
I'm developing a controller using the ST language. I haven't settled on a hardware platform and am for the moment using the TwinCat software from Beckhoff to get a head start on the design. I'm impressed with the power of the language and capabilties of the software tool. I have a couple of questions about coding in ST.
a) is there a really good book that goes beyond providing an overview of IEC 61131 languages and into details of how best to implement real control solutions? I checked Amazon and saw a couple of options but it would be nice to have some recommendations.
b) I've written some code to run a counter at a variable frequency. This may become the engine generating the pulse sequence to a stepper motor. I'm used to VHDL (for gate arrays) and it is normal in that environment to pull whatever bits you need from a counter, but in ST it doesn't seem to be easy to grab just one bit. To be specific, in this case I just want to pull out the least significant bit of the counter and feed this to an ouput (so it will be a square wave at the frequency of the signal driving the counter). Optionally I will use other bits which present square waves at various divisions of the driving signal...
The counter is a WORD variable. I can write some kind of hack something like
IF INT(counter/2)*2 = counter then
pulse:=1;
ELSE
pulse:=0;
END_IF
but this seems very clumsy
Am I missing a quick way to connect one bit of a word variable to a boolean? In VHDL it would look something like pulse:=counter[0] if my memory serves correctly.
thanks