PLUS+1 Software > Code sharing

Structured Text example

(1/1)

Mike AA:
I haven't done much for coding in C and when we covered structured text in the advanced class I pretty much got lost and couldn't find my way home. I remembered how to make the file and everything but I need help with making some logic work with structured text. I have some speed sensors that  are hooked to a motor and the ratio motor to auger isn't a nice integer. Will I be able to use structured text to work with the decimal part of the ratio? I guess the following is the math I want to do and the ratio I want to implement into Guide.

((Auger Sprocket Teeth)/(Motor Sprocket Teeth))x(Pulses Per Motor Revolution)
((25)/(16))X(30) = 46.875 pulses per auger rotation

I need to have each of the teeth numbers and the pulses per motor revolution as variables I can change in service tool.

Obviously if I punch in this in Guide the computer will lop off the .875 and just make it 46 pulses per revolution making the ratio almost 2% off and losing lots of revolution.

I guess I need help just understanding what I should do for structured text.

Mike

BRIan:
If you tell me the expected speed range and required rpm decimal points, I can do up a simple GUIDE solution. There is no need to use ST for this.

Mike AA:
Brian,

I think I actually after doing some reading in the Guide manual and online learning for structured text I think I figured out the structured text code.

I made a setup in Guide that would work with my number but I was afraid that I would hit the U32 limit in the counter I have to use.

I ended up multiplying both my pulses (count) and my pulses per revolution by 1000 to eliminate the decimal then further down the math divided by 1000.

I found out I will be able to get around 91625 revolutions and will likely only end up doing around 40,000 between resets.

Mike

Navigation

[0] Message Index

Go to full version