Forum Rule: Always post complete source code & details to reproduce any issue!

Search:

Type: Posts; User: frankzappa

Page 1 of 3 1 2 3

Search: Search took 0.00 seconds.

  1. Since we are discussing map functions: is there a...

    Since we are discussing map functions: is there a way to map a variable non linearly? For instance if a variable goes from 0-1023 make it 0-1023 but a logarithmic response.
  2. Ah, yes that is cleaner than what I did, thanks 😊

    Ah, yes that is cleaner than what I did, thanks 😊
  3. Also I had to limit the output to between 0 and...

    Also I had to limit the output to between 0 and 44. The map function went over and under the range.
  4. Yes I used your method but with floats and added...

    Yes I used your method but with floats and added 0.5 before converting to int. This works as it should. It rounds it to the correct value.
  5. Here is the solution, this produces accurate...

    Here is the solution, this produces accurate results:



    void setup()
    {



    }
  6. Both the suggestions produced the same result. It...

    Both the suggestions produced the same result. It discards the value. However clearly this is the way to go. I can use floats in stead and then make a function that rounds the result to the closest...
  7. Was not expecting replies this fast. Hmm......

    Was not expecting replies this fast.

    Hmm... that may work. I will try. Thanks.
    Will have to see how fast it is, I don't know what's inside the map function.



    Thanks for the suggestion. This...
  8. Function to find index in 2D array based on sensor values

    Hello!

    I need to write a program that can find the right indexes in a 2D array based off of sensor values and have no clue how to best solve this in an effecient way.

    Basically I have two...
  9. Thanks for the examples. Well right now I'm...

    Thanks for the examples.

    Well right now I'm only using the data to see what's happening and that my code is doing what it should. I'm only 30% done with the program. Later when the program is...
  10. Basically what I need to send is comma separated...

    Basically what I need to send is comma separated int and float values. Maybe I could just send it as a string, not sure if the program will accept it.
  11. Aha I understand. So the program stops execution...

    Aha I understand. So the program stops execution until there is room in the queue?

    It is strange because I'm getting delays of about 8-14 micros to write 15 lines. If that was the case then the...
  12. Ok, so I'm back with more stupid questions about...

    Ok, so I'm back with more stupid questions about speed.

    I have working code done in defragsters suggested way. I have 8 sensors connected with code executing between each sensor pair. It seems...
  13. Thanks 🙏 Just needed to be sure

    Thanks 🙏 Just needed to be sure
  14. Thanks, the pins are valid on the teensy 4 which...

    Thanks, the pins are valid on the teensy 4 which Iím using and he did specify that.

    Iím getting some strange values ocassionally and itís because of my code but wanted to make sure it wasnít...
  15. Hello! I'm trying to do calculations while...

    Hello!

    I'm trying to do calculations while waiting for conversions to finish.
    Is it guaranteed that ADC0 will read sensor A0 and sensor A2? And
    ADC1 will always read A1 and A3 in this code? If...
  16. Thanks, I think this is very clear now. So if...

    Thanks, I think this is very clear now.

    So if we have 4 bits and want to convert an unsigned value of 1111 which is 15 to a signed 4 bit value, then that would convert into -7. However as long as...
  17. That is true, maybe not that great for the forum....

    That is true, maybe not that great for the forum.

    I don't seem to have problems but maybe it only shows in a certain situation that I'm not anticipating.

    Is there any situation where a 0 will...
  18. In stead of making more noob threads I'll just...

    In stead of making more noob threads I'll just ask here:

    I've run into a little trouble with unsigned integers. As I understand you can't mix unsigned and signed together.

    For example: If I...
  19. That is very convenient indeed, I haven't read...

    That is very convenient indeed, I haven't read about classes yet. I've mostly read about C so far because it was a bit simpler to learn but i will get there eventually because I've noticed they are...
  20. Ah, much appreciated. Thanks :)

    Ah, much appreciated. Thanks :)
  21. How would I actually read it? uint32_t...

    How would I actually read it?



    uint32_t g_cycleCounter = ARM_DWT_CYCCNT;

    void setup() {
    }
    void loop(){
    uint32_ t start = g_cycleCounter;
  22. I will check. I usually use elapsed micros to...

    I will check. I usually use elapsed micros to check these things. I assumed it was pretty instantaneous until you said it above.

    I didn't get around to using the cycle counter. I will check the...
  23. That's great. How much CPU time are we talking? ...

    That's great. How much CPU time are we talking?

    I would only need to set a timer to 0 when a rising value passes zero and then check the elapsed time when it goes back down below zero. So the...
  24. How many elapsedMicros can you use on the teensy 4?

    I'm new at programming, I'm still half way through a book on C programming and I'm learning so bare with me.

    Is there a limit on how many timers you can run simultaneously with the teensy 4?
    ...
  25. Yeah as I said I used the fastest settings for...

    Yeah as I said I used the fastest settings for conversion and sampling. I can use medium and see if it goes away. My guess is that the capacitor inside the A/D doesnít discharge in time for some...
  26. Well itís an AC signal, the first peak is a...

    Well itís an AC signal, the first peak is a negative half wave sinusoidal signal that lasts up to 2ms but it vibrates up/down for maybe 50milliseconds after the first peak before calming down...
  27. Thanks 😊 🙏

    Thanks 😊 🙏
  28. @defragster Iím measuring a half wave that is...

    @defragster
    Iím measuring a half wave that is about 0.5 - 2ms in lenght so not very fast signals. Signals above say 1000 Hz are just noise in this application.

    Averaging is good in this case.
    ...
  29. Yeah. I figure if you have say ten sensor...

    Yeah. I figure if you have say ten sensor readings. They have a value of 10 and 11 every other reading. If you average them out they will still probably show 10 and 11 but the real value is 10,5. If...
  30. Yeah I've thought about that too. I've thought...

    Yeah I've thought about that too. I've thought about using 10bit readings, multiply them by say 4 and then do the averages. That should get more resolution (I think) because sometimes a voltage is...
  31. Your idea for the unrolled loop is genius. Iím...

    Your idea for the unrolled loop is genius.

    Iím getting great results with 10 bits and 8 averages although itís possible 12 bits with 4 averages may be even better. There is also the possibility to...
  32. Actually itís a non issue. With defragsters...

    Actually itís a non issue. With defragsters unrolled loop and placing all code only while waiting for the ADCís I can use 8 averages and still get 30 reads per sensor per millisecond which is...
  33. So connect one ADC to a voltage reference and...

    So connect one ADC to a voltage reference and read the signal on the other?

    I have read a bit more about the circuit part of things, I have a few more things to try. I think the noise can be...
  34. Let me try again: It's simpler then I thought....

    Let me try again:

    It's simpler then I thought.

    You start reading both adc's. Then there is time to do some work on previous sensor readings.

    Then there is a while loop which serves the...
  35. Oh wait, the while loop is just to wait for the...

    Oh wait, the while loop is just to wait for the conversion to finish right?

    That must be it.
  36. Hey defragster, could you help me break down this...

    Hey defragster, could you help me break down this code. What exactly is happening in detail when it comes to the unrolled part? I'm going to explain what I think is happening and you can tell me if...
  37. In comparison, here is how a normal peak looks...

    In comparison, here is how a normal peak looks like:

    https://www.dropbox.com/s/cxdrivhhv88k5ez/max%20peak.heic?dl=0
  38. Here is with 10 analog pins read (only showing...

    Here is with 10 analog pins read (only showing one):

    https://www.dropbox.com/s/31s9ngnt7o...sors.heic?dl=0

    Again, this is the worst case scenario. Could probably get twice the resolution by...
  39. That was 10 bits average of 2. However this was...

    That was 10 bits average of 2. However this was only two sensors (one shown) so it will be 5 times less measurements.
  40. Here is the worst case scenario that I want to...

    Here is the worst case scenario that I want to track. This is a very weakly struck drum:

    https://www.dropbox.com/s/il5tuzlr0k2wvvc/peak.heic?dl=0

    The lower pic is the first peak zoomed in.

    I...
  41. I'm using a center point of value 500 for the...

    I'm using a center point of value 500 for the signal. I'm catching the negative part of the signal and inverting it. This is the way the best edrums are triggered and I assumed it would have some...
  42. 12 bit looked the same but maybe it would improve...

    12 bit looked the same but maybe it would improve when divided by 4. The 10 bit with two averages seems to be good enough. The problem is not when you have a strong signal, it is when you play very...
  43. That is just with everything connected and at...

    That is just with everything connected and at rest.

    Only way for it to not jump up and down 4-5 values is to use averaging of 2. Conversion speed/sampling speed doesn't seem to affect it for the...
  44. Nevermind, I was doing 1023 - sensorValue to give...

    Nevermind, I was doing 1023 - sensorValue to give me an inverted signal, didn't work with a 12 bit value because it's a bigger number.
  45. Oh I had the capacitor placed in the wrong spot....

    Oh I had the capacitor placed in the wrong spot. Averaging of 2 works pretty good.

    https://www.dropbox.com/s/o0ky6lxppnmqnsp/averaging%202.heic?dl=0
  46. Here is 10 bit with an averaging of 4, it's...

    Here is 10 bit with an averaging of 4, it's actually worse.

    https://www.dropbox.com/s/94j9ur2l0mjlngn/filter2.heic?dl=0
  47. Well I've tried some low pass RC filters and it's...

    Well I've tried some low pass RC filters and it's still not that great but slightly improved.

    Strange thing is when I use averaging of 2 I get worse results with the RC filters.

    Maybe my...
  48. I was thinking that as well. I will try all...

    I was thinking that as well. I will try all possibilities and keep what works best. I also want to keep it reasonably simple.
  49. Thanks will try :)

    Thanks will try :)
  50. Not sure what you mean. Are you talking about a...

    Not sure what you mean. Are you talking about a bypass capacitor like this:

    https://components101.com/sites/default/files/inline-images/Bypass-Capacitor.png

    I was thinking a decoupling...
Results 1 to 50 of 120
Page 1 of 3 1 2 3