Go Down

### Topic: Programming help - static lookup table (Read 2652 times)previous topic - next topic

#### jason07

##### Sep 14, 2012, 08:46 pm
I'm new to programming so any help is very much appreciated.
I have a 0-5v input, consisting of 60 x 0.083v steps.
I need  to monitor this input voltage and, referencing a static lookup table, vary an output voltage.
Basicly converting a linear input to a logorithmic curve output that i can alter by editing the lookup table.

Any code examples would be very helpful. Thanks

#### marthamcnall37

#1
##### Sep 14, 2012, 08:51 pm
There are video tutorials in Youtube. You can check there how to use and arrange codes that you are looking for. You just have to make sure that you choose the best tutorial to make things faster and easier.

#### jason07

#2
##### Sep 14, 2012, 09:04 pm
Thanks, can you recommend one? There are so many it is confusing.

#### AWOL

#3
##### Sep 14, 2012, 09:50 pm
Unless there's any interpolation, it is a simple array access, isn't it?
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#4
##### Sep 14, 2012, 09:59 pmLast Edit: Sep 14, 2012, 10:01 pm by CrossRoads Reason: 1
Isn't is just this?
Code: [Select]
`analogWrite(60byteArray[x]);with60byteArray[0] ={number_from_0_to_255};60byteArray[1] ={number_from_0_to_255};60byteArray[2] ={number_from_0_to_255};::60byteArray[58] ={number_from_0_to_255};60byteArray[59] ={number_from_0_to_255};`
and map your 0-59 into 0-255 along whatever curve you want to use.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### jason07

#5
##### Sep 14, 2012, 10:05 pm
CrossRoads, Many thanks although I'm still confused. Would you be willing to work with on this with me? I noticed you do design-build; I have some funds available and really need the help.

#6
##### Sep 14, 2012, 10:25 pm
Sure.
With
analogRead(analogPin) you get a reading back between 0 and 1023, with each increase representing a 4.88mV change
With 83mV steps,  that works out to a step change about every 17 steps
On the output side, you need to define the curve you want

0-16 will be step 1                       excpected
Start        end         step  PWM    output voltage
0   16   0      4           = 4/255 * 5 = 0.083
17   33   1      9          0.167
34   50   2      13        0.250
51   67   3      17        0.333
68   84   4      21        0.417
85   101   5      26        0.500
:
:
969   985   57      247     4.833
986   1002   58      251     4.917
1003   1019   59      255     5.000
and change 1019 goto 1023 for the end
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### jason07

#7
##### Sep 14, 2012, 10:36 pm
OK, I may be getting it. I'll work with this over the weekend. Will get back to you after. Many thanks

Go Up