Jump to content

Sending string using a serial com when clicking on a button


Recommended Posts

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 !

Link to comment

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

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.