03-08-2014 12:05 PM
Hello
Got a question that is simple for the experienced people here I guess. But don't know where to start..... Here is what I want to try to do:
I have got a lot of inputs, to keep the question simple I have only drawn a few of them but eventually there will be tens of inputs. For now I will only use the front panel and no real IO box (hardware), just to see if I can make a State machine that can handle this "problem" in a organized / proper way.
What I want is to do is read a sensor, for example sensor B1 and multiply it with the multiplication factor (column Process input) and show the result on the front panel.
There will be different types of sensors, some need multiplication, others sensors need just a constant be added to the input before the result is shown in the Result column etc.Of every sensor there will be a lot, so just wiring them all in one place will create chaos, and I don't like chaos (only dr chaos in South park is fun but I would not have him in my labview code either).
Can anyone tell me how to approach this "problem" ?
Thank you for the advice!!
03-08-2014 12:40 PM - edited 03-08-2014 12:41 PM
Well, this does not really sound like a state machine, a simple polling loop is probably sufficient.
Use an array of booleans for the selector and for the status LEDs. Use a 1D array for the inputs, then multiply it with a 1D array of equal size containing all multipliers (element is 1 if not needed), and add another array for the offset to be added (element is 0 if not needed). The result will be an array of scaled outputs.
If you need more inputs, all you need is resize the arrays.
Repeat the loop at the desired sampling rate.
03-09-2014 07:30 AM
Hello altenbach,
thank you for your reply,
I think the question might not have been completely clear. I can devide the question in different parts I think. I will give it a try lets see
(1)There Will be a lot of sensors and a lot of different type of sensors. There will be sensors that behave:
(A)as a switch Called them Type A in the picture
(B)as a voltage source For example mV per degree celcius
and then there are more
(C)sensors that behave as a current source
(D)and a other type of sensor
.....
.....
ow noooo there are more
....
....
and even more
....
(K)sensors that have got a voltage output but measure something else as B for example a distance.
Of every type of sensor there will be more than 1 sensors. So there could be 10 sensors of type A 8 of type B 15 of type C etc. It would also be nice to ad or remove a sensor after a while.
The sensors need to have a usefull name. Like "Temperature in chamber A". I want to be able to use this name everywhere in the code. So I if I need to process the "Temperature in chamber A" I want to have a human readable name. (type def?).
I think I need to have a other name to indentiefie what kind of sensor it is: temperature, distance etc. This would make it easier to make a subfunction or SM deciding how to handle this information.
So I think the question should be how can I make a big highway of data comming out of the front pannel in one wire, If I have wire's A till K the code will become unreadable. I was thinking of some kind a arry of strucs?
I tried to keep the qestion as simple as possible at first but maybe it made it too unclear I think the question might sugest it will stay a simple program but it will not, it is just a first step.
The first step I want to try is to just multiply a voltage with a number (just to test the functioning of the supper-highway of data).
If I know that that works I will try this superhighway of data in a State machine then the value will to be prosseced in different ways.
After that I hope to have the Hardware IO It is a NON FPGA frame with a few cards in it from NI, cabable of measuring digital IO analog IO etc analog output etc. So at that point the frontpannel will be party replaced for the HArdware IO. As I want to test the software in different stages of development I first wanted to start simple so I could test the written software in different stages of development.
So can anyone tell me how to get this supperhighway of data out of the fron pannel?
I hope the question is a clear, if not just ask.
Thank you for the help so far!!
03-09-2014 01:36 PM
You can make an array of Cluster, with the cluster containing the needed info for the sensors, such as:
Name:string
Type:enum
Scaling:double
Offset:double
/Y