ElectroLund Posted April 8 Share Posted April 8 I'm unable to call a specific function from inside a sequence page from a control button. I would prefer to organize my functions that are related in a single sequence page. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted April 9 Share Posted April 9 There are two errors: 1) the primary error is that you are mixing C/C++ syntax with DAQFactory. DAQFactory only uses {} for denoting a static array. It is not used for blocks like it is in C. So, you want something like: function LampToggle(Light) // code endfunction function LampCurrentMonitor() // more code endfunction 2) while you can put multiple functions in a single sequence, the first function MUST have the same name as sequence. Actually it doesn't, but the name you provide for the sequence is the one the first function gets. So if the code you posted (with the changes mentioned above for endfunction) was in a sequence called myFunctions, you would be able to call LampCurrentMonitor() fine, but LampToggle() would not work. It would be named myFunctions() as far as DAQFactory is concerned because that is what you named the sequence. Quote Link to comment Share on other sites More sharing options...
ElectroLund Posted April 9 Author Share Posted April 9 Thanks, I resolved by splitting those functions into separate sequences. So now I have a helper sequence: function LampCheck() while (1) //-------------------- // check the lamp current pin LampCurrent() // check the lamp power pin LampPower() //-------------------- // now process the results // GPIO 1 GPIO 2 if (lampCurrent[0] == 0 && lampPower[0]) == 0) ? "Power not available/disconnected" v.lampStates.AddValue(-1) elseif (lampCurrent[0] == 0 && lampPower[0]) > 435) ? "Power available, lamp not connected" v.lampStates.AddValue(-2) elseif (lampCurrent[0] > 205 && lampCurrent[0] < 270 && lampPower[0]) > 435) ? "Power available, lamp off" v.lampStates.AddValue(0) elseif (lampCurrent[0] > 270 && lampPower[0]) > 435) ? "Power available, lamp on (flashing)" v.lampStates.AddValue(1) else ? "Other combinations wouldn’t be valid" v.lampStates.AddValue(-3) endif ? v.lampStates[0] //-------------------- // critical delay! delay(0.3) // execute 3 times a second endwhile This needs to run a couple times a second once started, parallel to the calling sequence. I understand this is a call for (pun) the BeginSeq() command. So here's a sample caller sequence: beginseq(LampCheck) ? "started sequence" Delay(.8) ? "delayed 0.8 seconds" Delay(1.4) ? "delayed 1.4 more seconds" endseq(LampCheck) Yet when I start this caller sequence, it is getting stuck in the LampCheck. The two sequences aren't running concurrently. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted April 9 Share Posted April 9 I'm assuming you called your sequence "LampCheck" too. I'm not sure and would need more detail on your application and what exactly makes you think it is failing. I made a simple equivalent sample (release 19.1) that I've attached here that shows it working as expected, both in 19.1 and 20.2. sequenceCaller.ctl Quote Link to comment Share on other sites More sharing options...
ElectroLund Posted April 9 Author Share Posted April 9 your ctl file is for a newer version. Mine is... older. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted April 9 Share Posted April 9 Your release is ancient (by software standards). Like over 13 years old. As such I can't really address any issues with it. You really should upgrade, at least to 19.1, probably to 20.2, especially if you are creating a new document. There is no charge for the upgrade to the newer release. Quote Link to comment Share on other sites More sharing options...
ElectroLund Posted April 9 Author Share Posted April 9 Wait, I think I got it fixed. If I simply remove the function name (LampCheck) at the top of the LampCheck sequence, and then call the sequence from the button, then I see the two sequences running concurrently. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted April 9 Share Posted April 9 OK. I still recommend upgrading... You are missing out on a lot. Just backup your document before doing so. Then you could revert back to 5.87c if you really wanted to. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.