Graphing Slider Value


Scabby

Recommended Posts

Hi there,

I am a novice programmer, so please bear with me.

I need a manual override feature where, if a sensor fail, or for process fine-tuning, I can set the sensor value on a slider. I've manage to do this, switching between sensor channel (real input) and slider using a toggle switch. I divert either value to a V channel and then graph the V channel. It all works fine if the slider is on the same page (Page_0) as the graph, but as soon as I move the slider to another page, the graph is not updated when using the slider. It only updates when switching back and forth between pages. What must I do to sync the data between two pages so that the graph on one page continuously see the slider's value.

By the way the graph also did not want to draw the V channel if the value continuously stays the same (as set on the slider), so i had to add a X = X + 0.000000000001 in the loop that checks the slider - this make minute changes to the value without influencing my value and gives me a nice straight line on the graph. Any other suggestions of how to overcome this problem?

Thx

Jo

Link to comment
Share on other sites

You should have the slider change a global variable, then use a sequence that loops and updates the channel with whatever the global variable contains every so often (say every second). Something like

global sliderpos = 0
while(1)
   V.mychan = sliderpos
   delay(1)
endwhile

The slider would edit sliderpos.

I personally would use a Test D to A channel instead of a V channel.

Link to comment
Share on other sites

Thank you for your reply.

First I tried the global variable and the code you gave - I adapted to fit in my if loop (where I first check whether the sensing is in Auto or Manual mode. It still gave me exactly the same result. The slider is on a different page from the graph and it doesn't seem to send the data to the graph unless I page hence and forth between the two pages in question. When I view he graph page when using the slider, the graph just don't "run". When paging back to the slider and immediately back to the graph, the graph "catches up" but stops again. When slider on same page, it runs perfectly though.

I then pursued the D to A test channel suggestion and after a bit of fiddling, I manage to get it going perfectly using this code:

Global pHSlider = 0
While (1)
   If (V.VpHMan < 1)
	  pHs = pH
   else
	  pHs = pHSlider
   endif
 Delay(1)
endwhile

Where:

pHSlider = Slider component

V.VpHMan = toggle switch sets this channel - Auto/Manual 0/1

pHs = D to A test channel

pH = A to D sensing channel

I use pHs to graph.

Doing it this way also mean I do not have to trick it adding the 0.0000001 value every time I need to update the graph.

Thanks!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.