scls19fr Posted April 11, 2008 Report Share Posted April 11, 2008 Hello, I would like to send a string using a serial com when I click on a button (4 buttons are possible) I'm using polling on buttons and testing if string is empty. (see main.vi and buttons_pressed.vi) When there is so many button polling is not a good thing so I'd like to change my code to use events structure. So first I made a minimal vi called ecu_keys.vi I think that I shouldn't set timeout value to 0 because I have a very high CPU usage ! Moreover I don't see the string changing when I click on one of the buttons. I also wonder how I should modify my VI to fit with "VISA Write" Best regards VI are available here http://svn.berlios.de/viewcvs/openphysic/l...bo-wrenturbines or svn checkout svn://svn.berlios.de/openphysic/labview/turbo-wrenturbines see trunk directory I also join the files in this post Download File:post-11213-1207857774.vi Download File:post-11213-1207857765.vi Download File:post-11213-1207857753.vi Download File:post-11213-1207857738.vi Download File:post-11213-1207857711.vi Download File:post-11213-1207857703.vi Download File:post-11213-1207857694.vi Download File:post-11213-1207857685.vi Download File:post-11213-1207857677.vi --- LAVAG is great ! LAVAG people are great ! Quote Link to comment
MikaelH Posted April 11, 2008 Report Share Posted April 11, 2008 Hi I downloaded the trunk from SVN, and that worked great :-) I've attached a VI with some things to consider. Download File:post-941-1207866659.vi Cheers, Mikael Quote Link to comment
scls19fr Posted April 12, 2008 Author Report Share Posted April 12, 2008 Thanks for your reply. I see that you put the VISA Write inside the event struct... Is it really a good idea ? since I hear that the code inside an event struct must be minimal... (because it can freeze the GUI) About the data reiceveid... there is no terminaison characters. String is send by the ECU byte after byte... not as a string so I need to make a little hack (reading only one byte) in order to synchronize data received with 252 253 (first two bytes) Here is the protocol http://www.espiell.com/fadprot.pdf for received data (coming from the ECU) And the protocol for sending key pressed 2 first bytes (222 et 223), adress (112 for commands), value, checksum (adress+value) Menu up 222,223,112,67,179 Menu down 222,223,112,68,180 Data up 222,223,112,65,177 Data down 222,223,112,66,178 Orko (an other LAVA member) said me to use queues CITATION That is when queues are useful. Enqueuing an item in an event strucure is very fast, and another loop can dequeue the item and take all the time it needs to complete the task (producer/consumer). Did you ever use them ? Best regards Sebastien Quote Link to comment
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.