Menu

A/D in smaller steps

Help
Moto Geek
2017-11-28
2017-11-29
  • Moto Geek

    Moto Geek - 2017-11-28

    I need to chop down the values coming from the A/D (8 bit) into a certain amount of steps, in this case, creating the values 0 - 30 in 10 steps from the A/D's 0 - 255. Is this a good method or would you go about it a different way?

    #define TempVal (readAD(AN3)/25) * 3
    ADVal = TempVal
    
     
  • stan cartwright

    stan cartwright - 2017-11-29

    You could try

    #define TempVal (readAD(AN3)/25)
    ADVal = TempVal+TempVal+TempVal
    

    Which is faster? than * 3

     
  • Anobium

    Anobium - 2017-11-29

    The new select case using range?
    A lookup table of 255 numbers 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2 etc.

     
  • stan cartwright

    stan cartwright - 2017-11-29

    joe. why? :) speed? multiples of 2 can be done with rotate/shift. odd numbers and the math is more work to process.
    new project?

     
  • stan cartwright

    stan cartwright - 2017-11-29

    Anobium. In gcb, tables work faster than I thought they would. I was surprised. I thought arrays would be needed.
    I haven't used "old" select case yet. I thought there would be an overhead but guess it's all optimised.
    quote The new select case using range?
    ps looking back at forum stuff about tables created at compile time. My lack of flash mem knowledge ie program code. lots of it and tables are in program flash memeory area so 32K flash mem allows one big table as best way to access parts in gcb and you can still write a big program.
    What I'm trying to say is "where are tables explained more in gcb than in help" cos I use them a lot now.
    Again I could have used case to use individual tables but the overhead, when a pointer works ok.
    fast is better?

     

    Last edit: stan cartwright 2017-11-29
    • Anobium

      Anobium - 2017-11-29

      @Stan. Read the Help... Select Case...

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.