Go Down

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

jason07

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

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

Thanks, can you recommend one? There are so many it is confusing.

AWOL

Unless there's any interpolation, it is a simple array access, isn't it?
"Pete, it's a fool 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.

CrossRoads

#4
Sep 14, 2012, 09:59 pm Last Edit: Sep 14, 2012, 10:01 pm by CrossRoads Reason: 1
Isn't is just this?
Code: [Select]

analogWrite(60byteArray[x]);

with
60byteArray[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

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.

CrossRoads

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

OK, I may be getting it. I'll work with this over the weekend. Will get back to you after. Many thanks

Go Up