06-23-2016 10:45 PM
How to build, program decrease and increase output program,
This the rules,
1. with input 1 - 15
2. when input 0-5 the output program is increase linear(indicator show 0 to 5)
3. when input 6-10 the output program is reduce linear (indicator show 5 to 0)
3. when input 11-15 the output program is increase linear(indicator show 0 to 5)
This my program, when i change theknob value from 0-5 it increase,
but when i change the knob value from 6 to 10 its not decrease, why it happen??
Can u fix my program/ can u change with other diagram,
And i hope you know what im think :),
And im waiting ur help
thank,
stewkidz
06-24-2016 12:20 AM - edited 06-24-2016 12:26 AM
Its not that tough..!!
Please use 'In range' operation for remaining range values.
06-24-2016 01:21 AM - edited 06-24-2016 01:31 AM
Hi Stew,
let's play some pseudocode:
FOR i:=0 to 14 %% loop over your index range x := i mod 5 %% get the remainder of the integer division
y := i \ 5 %% get the integer result of an integer division (see Quotient&Remainder function!)
y := y AND 1 %% check for even/uneven IF y == 0 THEN z := x %% ramp up ELSE z := 4-x %% ramp down ENDIF
Output(z) NEXT
1. with input 1 - 15
2. when input 0-5 the output program is increase linear(indicator show 0 to 5)
3. when input 6-10 the output program is reduce linear (indicator show 5 to 0)
4. when input 11-15 the output program is increase linear(indicator show 0 to 5)
There are many problems in your description:
- in step 1 you define an input range of 1-15, but in step 2 you start with an input of 0…
- in step 3 you define a range of 5 values (let's count: 6, 7, 8, 9, 10), but an output range of 6 values (let's count again: 5, 4, 3, 2, 1, 0). How do you want to map those two ranges?
- in step 4 you even used a wrong step number, I corrected this for clarity…
- in step 4 you got the same problem of different ranges: 5 input values for 6 output values…
That's why my pseudocode will only step from input 0 to 14 and produces outputs in the range of 0…4!
A really good advice:
Before starting to code you should draw a sketch (aka algorithm) on a sheet of paper. That's the most critical part in the whole process of creating a program!