9/5/2017 1:36 AM | |
Joined: 3/16/2015 Last visit: 10/10/2021 Posts: 1250 Rating: (173) |
In the project tree, double click device configuration. Click on the properties tab on the bottom Under the general tab scroll down to High speed counters and HSC1 (or whichever HSC you configured) and click on the arrow to expand the menu click on event configuration In the main properties window, check the box "generate interrupt for counter value equals reference value event" Click Add new In the dialog box, click OK. A new organization block will be created and will show up in the project tree on the left Double click on the the new bock just created and add the code as per your requirement. Attachmentinterrupt.zip (292 Downloads) |
This contribution was helpful to1 thankful Users |
9/13/2017 5:15 AM | |
Joined: 3/16/2015 Last visit: 10/10/2021 Posts: 1250 Rating: (173) |
Very good defende, excellent effort. Let's break it down a little bit to make sure we're building on solid ground. 1-Let's make sure the hardware configuration and HSC are correct. Easiest way is to use a move instruction and put it in OB1 ( you can delete it later) then run your motor and look at the input i the move instruction, does the number change up or down as you expect them to? If yes move on to the next steps: 2-Take your CTRL_HSC and also place in and OB1 and connect it directly to the rail. then remove all the variables and just put a number in NEW_RV (for example you wanted 1000 though that may come very fast so pick a larger number if you want) 3-Find OB40 that you created when setting hardware configuration and open it. 4-Insert a set instruction for Q0.0 You can do these steps or in the same program you started just make sure Q0.0 is not being set or reset anywhere else in the program and that you have only one CTRL_HSC for the same counter. Compile and run the program and now your output should be set when the encoder reaches the number you enter as a reference value in CTRL_HSC. After you have that running everything should fall in place and you will know how to modify your code to make it work. AttachmentHSC2.zip (322 Downloads) |