Jump to content

Need a MCP command


frumpy
 Share

Recommended Posts

Hi guys,

I'm doing some interfacing with buttons, LEDs and switches. I'm almost done programming

a MCP testbed. Unfortunately these ones:

ixeg/733/autopilot/HDG_bug_inc_90
ixeg/733/autopilot/HDG_bug_dec_90

change the heading by 90°, but I need a command for 1° steps.

Also there is no command for the altitude knob! I can use the default X-Plane ones, but thats 10' increments, not hundreds.

Besides that, everything seems to work.

Could you please add those commands? :)

 

Thanks,

 

Olli

 

p.s. Sending the command 10 times will take care of the 10' steps^^ But still no help for the heading

Edited by frumpy
Link to comment
Share on other sites

Hmm it's fairly fast for me, do you really need sub-millisecond responses for heading data?

Or do you mean on your hardware side?

If so  it might be possible to create a plugin that exposes a custom command and handles the dataref reads/writes.

Edited by mfor
Link to comment
Share on other sites

Well, the IXEG runs at about 35fps, I assume this is also the frequency the datarefs are updated.

I am using Air Manager v3 as a plugin, I am not too familar with programming. Also due to my

encoder setup, I can only use every second signal. Here is the code:

hdg_counter = 0 -- init
function hdg_dial_change(hdg_direction)
	print(tostring(hdg_direction))
	hdg_counter = hdg_counter + 1
	if hdg_counter == 2 then hdg_counter = 0 -- use every second click
	else
	if hdg_direction == 1 then 
			new_hdg=hdg_act+1
			xpl_dataref_write("sim/cockpit/autopilot/heading_mag", "FLOAT", new_hdg)
	elseif hdg_direction == -1 then 
			new_hdg=hdg_act-1
			xpl_dataref_write("sim/cockpit/autopilot/heading_mag", "FLOAT", new_hdg)
		end
	end
end



hw_dial_add("ARDUINO_MEGA2560_A_D37", "ARDUINO_MEGA2560_A_D36", hdg_dial_change) -- thats the encoder

function hdg_dtaref(heading)
hdg_act=heading
end
xpl_dataref_subscribe("sim/cockpit/autopilot/heading_mag","FLOAT",hdg_dtaref) -- subscribe to the dataref, save as global variable every time it's changed

I made a video while toying around with it, the Course knob uses a command, the Heading knob the change of dataref:

 

Edited by frumpy
  • Upvote 2
Link to comment
Share on other sites

Edit: Misread what you were saying.

From the video it seems like the dataref might not be updated every frame (since then you should be able to move it about 35 (or 25/2) degres per second. In that case try Ben's dataref to see if that is faster.

If not what you can do is use some sort of local desired value which you can modify quickly, i.e. don't read the set heading (only at program start or when idle) and just do the calculation on a locally stored value that you then write to the dataref. 

Edited by mfor
Link to comment
Share on other sites

No, the encoder sends twice the signals that I need, thats why I use only every

second signal. This way one click equals one degree in heading change.

 

The thing is really that the HDG_bug_inc_90 command from the first post should only

move by one degree, not 90 - then it would work like the course knob as you see on the video.

 

I'll check Ben's recommendation tonight, however I think I would stil be bound to the

time delay due to reading&writing the dataref.

 

Olli

Link to comment
Share on other sites

5 minutes ago, frumpy said:

No, the encoder sends twice the signals that I need, thats why I use only every

second signal. This way one click equals one degree in heading change.

 

The thing is really that the HDG_bug_inc_90 command from the first post should only

move by one degree, not 90 - then it would work like the course knob as you see on the video.

 

I'll check Ben's recommendation tonight, however I think I would stil be bound to the

time delay due to reading&writing the dataref.

 

Olli

I've added;

ixeg/733/autopilot/HDG_bug_inc_1

and

ixeg/733/autopilot/HDG_bug_dec_1

 

Functionality as requested.

Can't comment as to when it will be available for download but it's in the code...

 

Thanks for your support.. :)

  • Upvote 3
Link to comment
Share on other sites

See my edited post. 

I kind of assumed since you can write the datarefs fairly quickly, they would be updated every frame, but apparently that is not the case.

A local variable however should be able to solve the problem of reading the previous (old) value and incrementing it, that is assuming that the function is actually called every (other) time you turn the knob. 

Edit: You can (and should) add acceleration to that variable as well, or wait until you get your hands on the updated version :D

Edited by mfor
Link to comment
Share on other sites

Join the conversation

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

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...