Author Topic: Structured Text example  (Read 14729 times)

Offline Mike AA

  • PLUS+1 Guru
  • *****
  • Posts: 116
  • Karma: +0/-0
    • Dewind Dewatering
Structured Text example
« on: September 13, 2017, 09:20:53 PM »
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

Offline BRIan

  • PLUS+1 Expert
  • ****
  • Posts: 60
  • Karma: +3/-0
Re: Structured Text example
« Reply #1 on: September 14, 2017, 12:20:22 AM »
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.

Offline Mike AA

  • PLUS+1 Guru
  • *****
  • Posts: 116
  • Karma: +0/-0
    • Dewind Dewatering
Re: Structured Text example
« Reply #2 on: September 14, 2017, 01:52:55 PM »
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