Live demo showing you how to use the PST (Preset Table) instruction to accurately monitor and control high speed processes independent of scan time.
Our FREE Practical Guide to Programmable Logic Controllers eBook: https://www.automationdirect.com/ebooks/plc-handbook
In this video we’re going to use the Preset Table command to control these 8 LEDs on this rotating strip. This is a great way to help visualize exactly how the PST command works because you can actually see when the outputs changes the output. This works the same way on any Productivity Series controller, we happen to be using the Productivity 2000 with an HSO module and two HIS modules installed. An encoder is wired in parallel to channel 1 on both HSI modules and we’re driving the LEDS on this strip with the HSI outputs through a slip ring so the LEDs can rotate. The HSO Module is driving a stepper and this I/O is being used to enable the drive. Here’s the actual hardware were using. This is the 1024 count encoder on one end of the motor and the slip ring on the other to transfer the signals to the rotating LEDs. Were using ziplink cables, ziplink breakout modules and this stepper power supply. Here’s a summary of all the parts we used …click on the link to go right to the catalog page for that part. Let’s do a quick example. The HSO is configured to output pulses with no scaling and provide status in these tags. There’s a whole video on configuring the HSO so check that out if you need more on this. HSI number 1 is also setup for pulses – no custom units – the channel status is stored in these tags, and we are using a 4X factor on the input, which means instead of getting 1024 counts out of that encoder, we will be getting 4096. An here is a key point – we configured the HSI module to reset the encoder to ZERO every time the encoder’s Z pulse goes active. Which is why we wired him in earlier. HSI number 2 is setup the exactly like HIS #1. Given that setup, all we have to do is enable the drive, tell the motor to start spinning and then use the PST Instruction to control the LEDs. Let’s do it. Let’s create a contact to turn on the motor enable and then use a Write HS Output Instruction on the HSO to turn on that motor enable output. Because this is edge triggered, we have to create a second instruction to turn the output off so on the falling edge of this contact, and we do that by writing a zero to the output. And let’s change this to a rising edge contact just to be consistent. We’ll use a VMOV instruction to spin up the motor to a given velocity. We want this channel on the HSO to control the stepper motor. We’ll create a structure so we can play with all of these values in a dataview. And we’ll use the positive direction only. We don’t need jerk and we’ll do an immediate stop instead of decelerating to a stop. There is a whole video on using the VMOV instruction so check that you if you need help here. And let’s create a contact to enable the VMOV instruction. Let’s create an LED enable contact .. and then bring up the PST instruction to control the LEDs. We want this High Speed Input channel on the first High Speed Input module. We’ll use a structure so we don’t have to type in all of these values. You can create up to 16 steps, so let’s use all of them. Let’s so something every 100 encoder counts. Don’t forget – we configured this to generate 4 pulses for each encoder count so we have 4096 encoder pulses around the circle. So at step 16 where we are at 1600 counts, we will be just under half way around the circle. We want to enable the LED during the entire step. We could invert that, reset the table, reset the position counter or reset both the table and the position counter. Let’s toggle output 1 every step, output 2 every two steps, output 3 every 4 steps and output 3 every 8 steps. And on the last step, we want to reset the table so this repeats indefinitely. Hit OK, accept the new tags. So, we can enable the motor drive, start the motor spinning and we can drive LEDs as a function of encoder count. Let’s try it. Transfer to the processor and when done, Make sure we are in RUN mode, and bring up a dataview. Add our control bits, and Velocity parameters. Our Motor Drive is set to 1000 pulses per revolution, so let’s set the velocity to 10,000 pulses per second so we get 10 revolutions per second. And we’ll give it a modest ramp rate of 5000 so it will take 2 seconds to get there. Enable the motor drive, start the motor spinning and enable the LEDs. And sure enough you can see the pattern of the four LEDs we were driving from the first HSI module. LED1 is toggling every step – which is every 100 encoder steps. LED2 every other step, etc. This is so cool because you can visually see what 100 encoder counts is. And you can see that of the 4096 encoder counts in one revolution, the pattern is stopping at around 1600 – exactly what we expect. And the pattern always starts in the same place because we are using that Z pulse to reset the encoder count which is right here. Could we drive the 4 LEDs on HSI number two? Sure. It’s wired identically so let’s copy that instruction, change it over to channel 1 of the HSI Module in slot 4 where the other 4 LEDs are wired and change the structure name. We just add that to the same enable and are ready to go. Transfer to the Processor … Make sure we are in run mode and our dataview values are still intact …enable the drive … fire up the motor … and enable the LEDS. Now we see all 8 LEDs generating the pattern. Perfect. Let’s take a look at the Pulse option. Instead of turning the second HSI module’s output number four on here and off here, let’s pulse it on, get rid of the off and create a tag to specify the pulse duration. This little blue double arrow reminds us that we can change the pulse duration while the instruction is running. We’ll do that in the demo … but it’s important to understand that the pulse duration will only be updated each time the instruction is enabled or on each table reset – which for us is here. So it will complete the current cycle and THEN change the pulse duration, it won’t change mid-cycle. Well, let’s try that. We do want to create that new tag, and we’ll transfer the program to the processor. Make sure the processor is in run mode. Let’s add the pulse duration to the dataview. We’ll be rotating at 10 revolutions per second - or 100ms per revolution – so let’s make the pulse duration 25 msec. So now output 4 should turn on at the start and should stay on for a quarter of the rotation. Fire up the drive, enable the motor and enable the LEDs. Sure enough, output 4 is 25ms which is 25% of the 100ms rotation time. We said you can change the pulse duration while the instruction is running, right? let’s try it. How about 50 milliseconds? Maybe 90 milliseconds. How about 99 milliseconds. Sure enough, only 1 of the 100 millisecond rotation time isn’t lit. Cool. It’s important to understand the outputs have a maximum off-to-on time of 25usec and an on-to-off time of another 25usecs so the worst case output rate is every 50usec or 20,000hz. So if your input frequency is 100,000 Hz … but the output can only toggle 20,000Hz, then the smallest step size the output can respond to is 5 – right? So don’t make tis step size smaller what than the output can handle otherwise you won’t get the results you expect. Especially since this module can handle up to a one MHz input on each channel Can you reset the HSI count while the PST command is running? Sure. You can use this tag in the HSI configuration to reset the count to this value. Just set this tag to 1 in code and the current count will be changed to this. And while we didn’t do it in this video, you should always check and make sure the High Speed Module is ready before sending it commands. Remember, it runs independently of the main CPU, so this is the only way you know if it’s ready to receive those commands. Just go to the hardware configuration, HSI module, and setup the Module Ready tag here. So if you need to monitor signals from devices like encoders at rates up to 1Mhz and use that input to control outputs at rates of up to 20 Thousand Hertz, and you need to do it with precision and accuracy that is completely independent of scan time or current processor load, then this High Speed Input module from AutomationDirect is the way to go. And while we associate this with high speed inputs, don’t forget that it works great for low speed applications that still need precision and accuracy independent of processor load! If you need any help with the productivity series controllers, please contact AutomationDirect’s free award winning support team. They will be happy to help. And don’t forget the forums. There are lots of experienced automation professionals there that love to share their years of experience. Just don’t post any questions directed at AutomationDirect’s support team there, they don’t monitor the forums on a regular basis.
Voted #1 mid-sized employer in Atlanta
Check out our job openings